mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Internals: ImHashStr() default parameter.
This commit is contained in:
parent
5078fa208b
commit
59f012d656
16
imgui.cpp
16
imgui.cpp
@ -2535,7 +2535,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|||||||
: DrawListInst(&context->DrawListSharedData)
|
: DrawListInst(&context->DrawListSharedData)
|
||||||
{
|
{
|
||||||
Name = ImStrdup(name);
|
Name = ImStrdup(name);
|
||||||
ID = ImHashStr(name, 0);
|
ID = ImHashStr(name);
|
||||||
IDStack.push_back(ID);
|
IDStack.push_back(ID);
|
||||||
Flags = ImGuiWindowFlags_None;
|
Flags = ImGuiWindowFlags_None;
|
||||||
Pos = ImVec2(0.0f, 0.0f);
|
Pos = ImVec2(0.0f, 0.0f);
|
||||||
@ -3629,7 +3629,7 @@ void ImGui::Initialize(ImGuiContext* context)
|
|||||||
// Add .ini handle for ImGuiWindow type
|
// Add .ini handle for ImGuiWindow type
|
||||||
ImGuiSettingsHandler ini_handler;
|
ImGuiSettingsHandler ini_handler;
|
||||||
ini_handler.TypeName = "Window";
|
ini_handler.TypeName = "Window";
|
||||||
ini_handler.TypeHash = ImHashStr("Window", 0);
|
ini_handler.TypeHash = ImHashStr("Window");
|
||||||
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
||||||
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
||||||
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
||||||
@ -4562,7 +4562,7 @@ ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
|
|||||||
|
|
||||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||||
{
|
{
|
||||||
ImGuiID id = ImHashStr(name, 0);
|
ImGuiID id = ImHashStr(name);
|
||||||
return FindWindowByID(id);
|
return FindWindowByID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8769,7 +8769,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
window = NULL;
|
window = NULL;
|
||||||
source_id = ImHashStr("#SourceExtern", 0);
|
source_id = ImHashStr("#SourceExtern");
|
||||||
source_drag_active = true;
|
source_drag_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9210,7 +9210,7 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
|
|||||||
g.SettingsWindows.push_back(ImGuiWindowSettings());
|
g.SettingsWindows.push_back(ImGuiWindowSettings());
|
||||||
ImGuiWindowSettings* settings = &g.SettingsWindows.back();
|
ImGuiWindowSettings* settings = &g.SettingsWindows.back();
|
||||||
settings->Name = ImStrdup(name);
|
settings->Name = ImStrdup(name);
|
||||||
settings->ID = ImHashStr(name, 0);
|
settings->ID = ImHashStr(name);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9225,7 +9225,7 @@ ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
|
|||||||
|
|
||||||
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
||||||
{
|
{
|
||||||
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name, 0)))
|
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name)))
|
||||||
return settings;
|
return settings;
|
||||||
return CreateNewWindowSettings(name);
|
return CreateNewWindowSettings(name);
|
||||||
}
|
}
|
||||||
@ -9243,7 +9243,7 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
|||||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiID type_hash = ImHashStr(type_name, 0);
|
const ImGuiID type_hash = ImHashStr(type_name);
|
||||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||||
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
|
||||||
return &g.SettingsHandlers[handler_n];
|
return &g.SettingsHandlers[handler_n];
|
||||||
@ -9347,7 +9347,7 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
|
|||||||
|
|
||||||
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||||
{
|
{
|
||||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name, 0));
|
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
|
||||||
if (!settings)
|
if (!settings)
|
||||||
settings = ImGui::CreateNewWindowSettings(name);
|
settings = ImGui::CreateNewWindowSettings(name);
|
||||||
return (void*)settings;
|
return (void*)settings;
|
||||||
|
@ -153,7 +153,7 @@ IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, cons
|
|||||||
|
|
||||||
// Helpers: Misc
|
// Helpers: Misc
|
||||||
IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
|
IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
|
||||||
IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size, ImU32 seed = 0);
|
IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0);
|
||||||
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
||||||
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
||||||
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
||||||
@ -630,7 +630,7 @@ struct ImGuiWindowSettings
|
|||||||
struct ImGuiSettingsHandler
|
struct ImGuiSettingsHandler
|
||||||
{
|
{
|
||||||
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
||||||
ImGuiID TypeHash; // == ImHashStr(TypeName, 0, 0)
|
ImGuiID TypeHash; // == ImHashStr(TypeName)
|
||||||
void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
|
void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
|
||||||
void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
|
void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
|
||||||
void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
|
void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
|
||||||
|
@ -6468,7 +6468,7 @@ static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label)
|
|||||||
{
|
{
|
||||||
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
|
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
|
||||||
{
|
{
|
||||||
ImGuiID id = ImHashStr(label, 0);
|
ImGuiID id = ImHashStr(label);
|
||||||
KeepAliveID(id);
|
KeepAliveID(id);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user