mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
Internals: Renaming + added ImStrSkipBlank() from docking branch.
(cherry picked from commit a573943fa0ce323ffb4080e57f5e8fe1bc777c36)
This commit is contained in:
parent
09b2310237
commit
28f1d60de1
37
imgui.cpp
37
imgui.cpp
@ -847,9 +847,9 @@ static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted
|
||||
static ImRect GetViewportRect();
|
||||
|
||||
// Settings
|
||||
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
||||
static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
|
||||
static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
|
||||
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
||||
static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
|
||||
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
|
||||
|
||||
// Platform Dependents default implementation for IO functions
|
||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data);
|
||||
@ -1242,6 +1242,13 @@ void ImStrTrimBlanks(char* buf)
|
||||
buf[p - p_start] = 0; // Zero terminate
|
||||
}
|
||||
|
||||
const char* ImStrSkipBlank(const char* str)
|
||||
{
|
||||
while (str[0] == ' ' || str[0] == '\t')
|
||||
str++;
|
||||
return str;
|
||||
}
|
||||
|
||||
// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size).
|
||||
// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm.
|
||||
// B) When buf==NULL vsnprintf() will return the output size.
|
||||
@ -3744,13 +3751,15 @@ void ImGui::Initialize(ImGuiContext* context)
|
||||
IM_ASSERT(!g.Initialized && !g.SettingsLoaded);
|
||||
|
||||
// Add .ini handle for ImGuiWindow type
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Window";
|
||||
ini_handler.TypeHash = ImHashStr("Window");
|
||||
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
||||
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
||||
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
||||
g.SettingsHandlers.push_back(ini_handler);
|
||||
{
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Window";
|
||||
ini_handler.TypeHash = ImHashStr("Window");
|
||||
ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen;
|
||||
ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine;
|
||||
ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll;
|
||||
g.SettingsHandlers.push_back(ini_handler);
|
||||
}
|
||||
|
||||
g.Initialized = true;
|
||||
}
|
||||
@ -9342,7 +9351,7 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
|
||||
return g.SettingsIniData.c_str();
|
||||
}
|
||||
|
||||
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||
{
|
||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
|
||||
if (!settings)
|
||||
@ -9350,7 +9359,7 @@ static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*
|
||||
return (void*)settings;
|
||||
}
|
||||
|
||||
static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line)
|
||||
static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line)
|
||||
{
|
||||
ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
|
||||
int x, y;
|
||||
@ -9360,7 +9369,7 @@ static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*,
|
||||
else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0);
|
||||
}
|
||||
|
||||
static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
|
||||
static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
|
||||
{
|
||||
// Gather data from windows that were active during this session
|
||||
// (if a window wasn't opened in this session we preserve its settings)
|
||||
@ -9393,7 +9402,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
||||
buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
|
||||
buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
|
||||
buf->appendf("Collapsed=%d\n", settings->Collapsed);
|
||||
buf->appendf("\n");
|
||||
buf->append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ struct ImGuiTabBar; // Storage for a tab bar
|
||||
struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
|
||||
struct ImGuiWindow; // Storage for one window
|
||||
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
|
||||
struct ImGuiWindowSettings; // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
|
||||
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
|
||||
template<typename T> struct ImPool; // Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID
|
||||
|
||||
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
||||
@ -206,6 +206,7 @@ IMGUI_API const char* ImStreolRange(const char* str, const char* str_end);
|
||||
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||
IMGUI_API void ImStrTrimBlanks(char* str);
|
||||
IMGUI_API const char* ImStrSkipBlank(const char* str);
|
||||
IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API const char* ImParseFormatFindStart(const char* format);
|
||||
|
Loading…
Reference in New Issue
Block a user