|
@@ -2503,17 +2503,16 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float&
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
// std::lower_bound but without the bullshit
|
|
|
-static ImGuiStoragePair* LowerBound(ImVector<ImGuiStoragePair>& data, ImGuiID key)
|
|
|
+ImGuiStoragePair* ImLowerBound(ImGuiStoragePair* in_begin, ImGuiStoragePair* in_end, ImGuiID key)
|
|
|
{
|
|
|
- ImGuiStoragePair* first = data.Data;
|
|
|
- ImGuiStoragePair* last = data.Data + data.Size;
|
|
|
- for (size_t count = (size_t)(last - first); count > 0; )
|
|
|
+ ImGuiStoragePair* in_p = in_begin;
|
|
|
+ for (size_t count = (size_t)(in_end - in_p); count > 0; )
|
|
|
{
|
|
|
size_t count2 = count >> 1;
|
|
|
- ImGuiStoragePair* mid = first + count2;
|
|
|
+ ImGuiStoragePair* mid = in_p + count2;
|
|
|
if (mid->key < key)
|
|
|
{
|
|
|
- first = ++mid;
|
|
|
+ in_p = ++mid;
|
|
|
count -= count2 + 1;
|
|
|
}
|
|
|
else
|
|
@@ -2521,7 +2520,7 @@ static ImGuiStoragePair* LowerBound(ImVector<ImGuiStoragePair>& data, ImGuiID ke
|
|
|
count = count2;
|
|
|
}
|
|
|
}
|
|
|
- return first;
|
|
|
+ return in_p;
|
|
|
}
|
|
|
|
|
|
// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
|
|
@@ -2542,7 +2541,7 @@ void ImGuiStorage::BuildSortByKey()
|
|
|
|
|
|
int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(const_cast<ImVector<ImGuiStoragePair>&>(Data), key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(const_cast<ImGuiStoragePair*>(Data.Data), const_cast<ImGuiStoragePair*>(Data.Data + Data.Size), key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
return default_val;
|
|
|
return it->val_i;
|
|
@@ -2555,7 +2554,7 @@ bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const
|
|
|
|
|
|
float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(const_cast<ImVector<ImGuiStoragePair>&>(Data), key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(const_cast<ImGuiStoragePair*>(Data.Data), const_cast<ImGuiStoragePair*>(Data.Data + Data.Size), key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
return default_val;
|
|
|
return it->val_f;
|
|
@@ -2563,7 +2562,7 @@ float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const
|
|
|
|
|
|
void* ImGuiStorage::GetVoidPtr(ImGuiID key) const
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(const_cast<ImVector<ImGuiStoragePair>&>(Data), key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(const_cast<ImGuiStoragePair*>(Data.Data), const_cast<ImGuiStoragePair*>(Data.Data + Data.Size), key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
return NULL;
|
|
|
return it->val_p;
|
|
@@ -2572,7 +2571,7 @@ void* ImGuiStorage::GetVoidPtr(ImGuiID key) const
|
|
|
// References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
|
|
|
int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val)
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(Data, key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
it = Data.insert(it, ImGuiStoragePair(key, default_val));
|
|
|
return &it->val_i;
|
|
@@ -2585,7 +2584,7 @@ bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val)
|
|
|
|
|
|
float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(Data, key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
it = Data.insert(it, ImGuiStoragePair(key, default_val));
|
|
|
return &it->val_f;
|
|
@@ -2593,7 +2592,7 @@ float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
|
|
|
|
|
|
void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(Data, key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
it = Data.insert(it, ImGuiStoragePair(key, default_val));
|
|
|
return &it->val_p;
|
|
@@ -2602,7 +2601,7 @@ void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
|
|
|
// FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame)
|
|
|
void ImGuiStorage::SetInt(ImGuiID key, int val)
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(Data, key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
Data.insert(it, ImGuiStoragePair(key, val));
|
|
|
else
|
|
@@ -2616,7 +2615,7 @@ void ImGuiStorage::SetBool(ImGuiID key, bool val)
|
|
|
|
|
|
void ImGuiStorage::SetFloat(ImGuiID key, float val)
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(Data, key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
Data.insert(it, ImGuiStoragePair(key, val));
|
|
|
else
|
|
@@ -2625,7 +2624,7 @@ void ImGuiStorage::SetFloat(ImGuiID key, float val)
|
|
|
|
|
|
void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val)
|
|
|
{
|
|
|
- ImGuiStoragePair* it = LowerBound(Data, key);
|
|
|
+ ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
|
|
if (it == Data.end() || it->key != key)
|
|
|
Data.insert(it, ImGuiStoragePair(key, val));
|
|
|
else
|
|
@@ -11238,8 +11237,8 @@ void ImGui::CloseCurrentPopup()
|
|
|
window->DC.NavHideHighlightOneFrame = true;
|
|
|
}
|
|
|
|
|
|
-// Attention! BeginPopup() adds default flags which BeginPopupEx()!
|
|
|
-bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
|
|
+// Attention! BeginPopup() adds default flags when calling BeginPopupEx()!
|
|
|
+bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_window_flags)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
if (!IsPopupOpen(id, ImGuiPopupFlags_None))
|
|
@@ -11249,13 +11248,12 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
|
|
}
|
|
|
|
|
|
char name[20];
|
|
|
- if (flags & ImGuiWindowFlags_ChildMenu)
|
|
|
+ if (extra_window_flags & ImGuiWindowFlags_ChildMenu)
|
|
|
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginMenuDepth); // Recycle windows based on depth
|
|
|
else
|
|
|
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
|
|
|
|
|
- flags |= ImGuiWindowFlags_Popup;
|
|
|
- bool is_open = Begin(name, NULL, flags);
|
|
|
+ bool is_open = Begin(name, NULL, extra_window_flags | ImGuiWindowFlags_Popup);
|
|
|
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
|
|
|
EndPopup();
|
|
|
|