Skip to content

Commit d6d00b4

Browse files
committed
Moved BeginChild() above BeginChildEx() as it is more readable.
Misc shallow tidying up. Should be a no-op.
1 parent 99913b5 commit d6d00b4

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

imgui.cpp

+18-25
Original file line numberDiff line numberDiff line change
@@ -2479,11 +2479,9 @@ void ImGuiStorage::SetInt(ImGuiID key, int val)
24792479
{
24802480
ImGuiStoragePair* it = LowerBound(Data, key);
24812481
if (it == Data.end() || it->key != key)
2482-
{
24832482
Data.insert(it, ImGuiStoragePair(key, val));
2484-
return;
2485-
}
2486-
it->val_i = val;
2483+
else
2484+
it->val_i = val;
24872485
}
24882486

24892487
void ImGuiStorage::SetBool(ImGuiID key, bool val)
@@ -2495,22 +2493,18 @@ void ImGuiStorage::SetFloat(ImGuiID key, float val)
24952493
{
24962494
ImGuiStoragePair* it = LowerBound(Data, key);
24972495
if (it == Data.end() || it->key != key)
2498-
{
24992496
Data.insert(it, ImGuiStoragePair(key, val));
2500-
return;
2501-
}
2502-
it->val_f = val;
2497+
else
2498+
it->val_f = val;
25032499
}
25042500

25052501
void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val)
25062502
{
25072503
ImGuiStoragePair* it = LowerBound(Data, key);
25082504
if (it == Data.end() || it->key != key)
2509-
{
25102505
Data.insert(it, ImGuiStoragePair(key, val));
2511-
return;
2512-
}
2513-
it->val_p = val;
2506+
else
2507+
it->val_p = val;
25142508
}
25152509

25162510
void ImGuiStorage::SetAllInt(int v)
@@ -5420,11 +5414,22 @@ ImVec2 ImGui::GetItemRectSize()
54205414
return g.LastItemData.Rect.GetSize();
54215415
}
54225416

5417+
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
5418+
{
5419+
ImGuiWindow* window = GetCurrentWindow();
5420+
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
5421+
}
5422+
5423+
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
5424+
{
5425+
IM_ASSERT(id != 0);
5426+
return BeginChildEx(NULL, id, size_arg, border, extra_flags);
5427+
}
5428+
54235429
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
54245430
{
54255431
ImGuiContext& g = *GImGui;
54265432
ImGuiWindow* parent_window = g.CurrentWindow;
5427-
54285433
flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow;
54295434
flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
54305435

@@ -5473,18 +5478,6 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
54735478
return ret;
54745479
}
54755480

5476-
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
5477-
{
5478-
ImGuiWindow* window = GetCurrentWindow();
5479-
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
5480-
}
5481-
5482-
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
5483-
{
5484-
IM_ASSERT(id != 0);
5485-
return BeginChildEx(NULL, id, size_arg, border, extra_flags);
5486-
}
5487-
54885481
void ImGui::EndChild()
54895482
{
54905483
ImGuiContext& g = *GImGui;

imgui.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -2346,9 +2346,9 @@ struct ImGuiStorage
23462346
{
23472347
ImGuiID key;
23482348
union { int val_i; float val_f; void* val_p; };
2349-
ImGuiStoragePair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
2350-
ImGuiStoragePair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
2351-
ImGuiStoragePair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
2349+
ImGuiStoragePair(ImGuiID _key, int _val) { key = _key; val_i = _val; }
2350+
ImGuiStoragePair(ImGuiID _key, float _val) { key = _key; val_f = _val; }
2351+
ImGuiStoragePair(ImGuiID _key, void* _val) { key = _key; val_p = _val; }
23522352
};
23532353

23542354
ImVector<ImGuiStoragePair> Data;
@@ -2375,11 +2375,10 @@ struct ImGuiStorage
23752375
IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f);
23762376
IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL);
23772377

2378-
// Use on your own storage if you know only integer are being stored (open/close all tree nodes)
2379-
IMGUI_API void SetAllInt(int val);
2380-
2381-
// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
2378+
// Advanced: for quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
23822379
IMGUI_API void BuildSortByKey();
2380+
// Obsolete: use on your own storage if you know only integer are being stored (open/close all tree nodes)
2381+
IMGUI_API void SetAllInt(int val);
23832382
};
23842383

23852384
// Helper: Manually clip large list of items.

0 commit comments

Comments
 (0)