1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 15:50:25 +01:00

BeginChild(const char*) applies stack id to provided label (#894, #713)

This commit is contained in:
ocornut 2016-11-06 15:12:45 +01:00
parent 43e6c46c8d
commit ddf08ec2e8

View File

@ -150,6 +150,7 @@
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
- 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
- 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
@ -3581,12 +3582,12 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button)
return BeginPopup(str_id);
}
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
{
ImGuiWindow* window = GetCurrentWindow();
ImGuiWindow* window = ImGui::GetCurrentWindow();
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow;
const ImVec2 content_avail = GetContentRegionAvail();
const ImVec2 content_avail = ImGui::GetContentRegionAvail();
ImVec2 size = ImFloor(size_arg);
if (size.x <= 0.0f)
{
@ -3605,22 +3606,28 @@ bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border,
flags |= extra_flags;
char title[256];
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s", window->Name, str_id);
if (name)
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s.%08X", window->Name, name, id);
else
ImFormatString(title, IM_ARRAYSIZE(title), "%s.%08X", window->Name, id);
bool ret = ImGui::Begin(title, NULL, size, -1.0f, flags);
if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
ImGui::GetCurrentWindow()->Flags &= ~ImGuiWindowFlags_ShowBorders;
return ret;
}
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size, bool border, ImGuiWindowFlags extra_flags)
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
{
char str_id[32];
ImFormatString(str_id, IM_ARRAYSIZE(str_id), "child_%08x", id);
bool ret = ImGui::BeginChild(str_id, size, border, extra_flags);
return ret;
ImGuiWindow* window = GetCurrentWindow();
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
}
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
{
return BeginChildEx(NULL, id, size_arg, border, extra_flags);
}
void ImGui::EndChild()