forked from Green-Sky/tomato
update imgui again, this time back on tag v1.91.0
This commit is contained in:
219
external/imgui/imgui/imgui.cpp
vendored
219
external/imgui/imgui/imgui.cpp
vendored
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// dear imgui, v1.91.0
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@@ -430,6 +430,16 @@ CODE
|
||||
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2024/07/25 (1.91.0) - obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). (see #7838 on GitHub for more info)
|
||||
you should never need those functions. you can do everything with GetCursorScreenPos() and GetContentRegionAvail() in a more simple way.
|
||||
- instead of: GetWindowContentRegionMax().x - GetCursorPos().x
|
||||
- you can use: GetContentRegionAvail().x
|
||||
- instead of: GetWindowContentRegionMax().x + GetWindowPos().x
|
||||
- you can use: GetCursorScreenPos().x + GetContentRegionAvail().x // when called from left edge of window
|
||||
- instead of: GetContentRegionMax()
|
||||
- you can use: GetContentRegionAvail() + GetCursorScreenPos() - GetWindowPos() // right edge in local coordinates
|
||||
- instead of: GetWindowContentRegionMax().x - GetWindowContentRegionMin().x
|
||||
- you can use: GetContentRegionAvail() // when called from left edge of window
|
||||
- 2024/07/15 (1.91.0) - renamed ImGuiSelectableFlags_DontClosePopups to ImGuiSelectableFlags_NoAutoClosePopups. (#1379, #1468, #2200, #4936, #5216, #7302, #7573)
|
||||
(internals: also renamed ImGuiItemFlags_SelectableDontClosePopup into ImGuiItemFlags_AutoClosePopups with inverted behaviors)
|
||||
- 2024/07/15 (1.91.0) - obsoleted PushButtonRepeat()/PopButtonRepeat() in favor of using new PushItemFlag(ImGuiItemFlags_ButtonRepeat, ...)/PopItemFlag().
|
||||
@@ -1269,12 +1279,13 @@ ImGuiStyle::ImGuiStyle()
|
||||
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
||||
TabMinWidthForCloseButton = 0.0f; // Minimum width for close button to appear on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
||||
TabBarBorderSize = 1.0f; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
||||
TabBarOverlineSize = 2.0f; // Thickness of tab-bar overline, which highlights the selected tab-bar.
|
||||
TableAngledHeadersAngle = 35.0f * (IM_PI / 180.0f); // Angle of angled headers (supported values range from -50 degrees to +50 degrees).
|
||||
TableAngledHeadersTextAlign = ImVec2(0.5f,0.0f);// Alignment of angled headers within the cell
|
||||
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
|
||||
SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||
SeparatorTextBorderSize = 3.0f; // Thickkness of border in SeparatorText()
|
||||
SeparatorTextBorderSize = 3.0f; // Thickness of border in SeparatorText()
|
||||
SeparatorTextAlign = ImVec2(0.0f,0.5f);// Alignment of text within the separator. Defaults to (0.0f, 0.5f) (left aligned, center).
|
||||
SeparatorTextPadding = ImVec2(20.0f,3.f);// Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
|
||||
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||
@@ -1321,6 +1332,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
||||
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor);
|
||||
TabRounding = ImTrunc(TabRounding * scale_factor);
|
||||
TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImTrunc(TabMinWidthForCloseButton * scale_factor) : FLT_MAX;
|
||||
TabBarOverlineSize = ImTrunc(TabBarOverlineSize * scale_factor);
|
||||
SeparatorTextPadding = ImTrunc(SeparatorTextPadding * scale_factor);
|
||||
DisplayWindowPadding = ImTrunc(DisplayWindowPadding * scale_factor);
|
||||
DisplaySafeAreaPadding = ImTrunc(DisplaySafeAreaPadding * scale_factor);
|
||||
@@ -1366,6 +1378,7 @@ ImGuiIO::ImGuiIO()
|
||||
#else
|
||||
ConfigMacOSXBehaviors = false;
|
||||
#endif
|
||||
ConfigNavSwapGamepadButtons = false;
|
||||
ConfigInputTrickleEventQueue = true;
|
||||
ConfigInputTextCursorBlink = true;
|
||||
ConfigInputTextEnterKeepActive = false;
|
||||
@@ -2558,6 +2571,7 @@ ImGuiStoragePair* ImLowerBound(ImGuiStoragePair* in_begin, ImGuiStoragePair* in_
|
||||
return in_p;
|
||||
}
|
||||
|
||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
static int IMGUI_CDECL PairComparerByID(const void* lhs, const void* rhs)
|
||||
{
|
||||
// We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
|
||||
@@ -2575,7 +2589,7 @@ void ImGuiStorage::BuildSortByKey()
|
||||
int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(const_cast<ImGuiStoragePair*>(Data.Data), const_cast<ImGuiStoragePair*>(Data.Data + Data.Size), key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
return default_val;
|
||||
return it->val_i;
|
||||
}
|
||||
@@ -2588,7 +2602,7 @@ bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const
|
||||
float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(const_cast<ImGuiStoragePair*>(Data.Data), const_cast<ImGuiStoragePair*>(Data.Data + Data.Size), key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
return default_val;
|
||||
return it->val_f;
|
||||
}
|
||||
@@ -2596,7 +2610,7 @@ float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const
|
||||
void* ImGuiStorage::GetVoidPtr(ImGuiID key) const
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(const_cast<ImGuiStoragePair*>(Data.Data), const_cast<ImGuiStoragePair*>(Data.Data + Data.Size), key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
return NULL;
|
||||
return it->val_p;
|
||||
}
|
||||
@@ -2605,7 +2619,7 @@ void* ImGuiStorage::GetVoidPtr(ImGuiID key) const
|
||||
int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val)
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
it = Data.insert(it, ImGuiStoragePair(key, default_val));
|
||||
return &it->val_i;
|
||||
}
|
||||
@@ -2618,7 +2632,7 @@ bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val)
|
||||
float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
it = Data.insert(it, ImGuiStoragePair(key, default_val));
|
||||
return &it->val_f;
|
||||
}
|
||||
@@ -2626,7 +2640,7 @@ float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
|
||||
void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
it = Data.insert(it, ImGuiStoragePair(key, default_val));
|
||||
return &it->val_p;
|
||||
}
|
||||
@@ -2635,7 +2649,7 @@ void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
|
||||
void ImGuiStorage::SetInt(ImGuiID key, int val)
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
Data.insert(it, ImGuiStoragePair(key, val));
|
||||
else
|
||||
it->val_i = val;
|
||||
@@ -2649,7 +2663,7 @@ void ImGuiStorage::SetBool(ImGuiID key, bool val)
|
||||
void ImGuiStorage::SetFloat(ImGuiID key, float val)
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
Data.insert(it, ImGuiStoragePair(key, val));
|
||||
else
|
||||
it->val_f = val;
|
||||
@@ -2658,7 +2672,7 @@ void ImGuiStorage::SetFloat(ImGuiID key, float val)
|
||||
void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val)
|
||||
{
|
||||
ImGuiStoragePair* it = ImLowerBound(Data.Data, Data.Data + Data.Size, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
if (it == Data.Data + Data.Size || it->key != key)
|
||||
Data.insert(it, ImGuiStoragePair(key, val));
|
||||
else
|
||||
it->val_p = val;
|
||||
@@ -2669,6 +2683,7 @@ void ImGuiStorage::SetAllInt(int v)
|
||||
for (int i = 0; i < Data.Size; i++)
|
||||
Data[i].val_i = v;
|
||||
}
|
||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImGuiTextFilter
|
||||
@@ -2736,15 +2751,15 @@ void ImGuiTextFilter::Build()
|
||||
|
||||
bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
||||
{
|
||||
if (Filters.empty())
|
||||
if (Filters.Size == 0)
|
||||
return true;
|
||||
|
||||
if (text == NULL)
|
||||
text = "";
|
||||
text = text_end = "";
|
||||
|
||||
for (const ImGuiTextRange& f : Filters)
|
||||
{
|
||||
if (f.empty())
|
||||
if (f.b == f.e)
|
||||
continue;
|
||||
if (f.b[0] == '-')
|
||||
{
|
||||
@@ -3047,7 +3062,8 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
bool affected_by_floating_point_precision = ImIsFloatAboveGuaranteedIntegerPrecision(clipper->StartPosY) || ImIsFloatAboveGuaranteedIntegerPrecision(window->DC.CursorPos.y);
|
||||
if (affected_by_floating_point_precision)
|
||||
clipper->ItemsHeight = window->DC.PrevLineSize.y + g.Style.ItemSpacing.y; // FIXME: Technically wouldn't allow multi-line entries.
|
||||
|
||||
if (clipper->ItemsHeight == 0.0f && clipper->ItemsCount == INT_MAX) // Accept that no item have been submitted if in indeterminate mode.
|
||||
return false;
|
||||
IM_ASSERT(clipper->ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!");
|
||||
calc_clipping = true; // If item height had to be calculated, calculate clipping afterwards.
|
||||
}
|
||||
@@ -3079,9 +3095,27 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(nav_rect_abs.Min.y, nav_rect_abs.Max.y, 0, 0));
|
||||
|
||||
// Add visible range
|
||||
float min_y = window->ClipRect.Min.y;
|
||||
float max_y = window->ClipRect.Max.y;
|
||||
|
||||
// Add box selection range
|
||||
ImGuiBoxSelectState* bs = &g.BoxSelectState;
|
||||
if (bs->IsActive && bs->Window == window)
|
||||
{
|
||||
// FIXME: Selectable() use of half-ItemSpacing isn't consistent in matter of layout, as ItemAdd(bb) stray above ItemSize()'s CursorPos.
|
||||
// RangeSelect's BoxSelect relies on comparing overlap of previous and current rectangle and is sensitive to that.
|
||||
// As a workaround we currently half ItemSpacing worth on each side.
|
||||
min_y -= g.Style.ItemSpacing.y;
|
||||
max_y += g.Style.ItemSpacing.y;
|
||||
|
||||
// Box-select on 2D area requires different clipping.
|
||||
if (bs->UnclipMode)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(bs->UnclipRect.Min.y, bs->UnclipRect.Max.y, 0, 0));
|
||||
}
|
||||
|
||||
const int off_min = (is_nav_request && g.NavMoveClipDir == ImGuiDir_Up) ? -1 : 0;
|
||||
const int off_max = (is_nav_request && g.NavMoveClipDir == ImGuiDir_Down) ? 1 : 0;
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(window->ClipRect.Min.y, window->ClipRect.Max.y, off_min, off_max));
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromPositions(min_y, max_y, off_min, off_max));
|
||||
}
|
||||
|
||||
// Convert position ranges to item index ranges
|
||||
@@ -3254,6 +3288,7 @@ static const ImGuiDataVarInfo GStyleVarInfo[] =
|
||||
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
|
||||
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarOverlineSize) }, // ImGuiStyleVar_TabBarOverlineSize
|
||||
{ ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersAngle)}, // ImGuiStyleVar_TableAngledHeadersAngle
|
||||
{ ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersTextAlign)},// ImGuiStyleVar_TableAngledHeadersTextAlign
|
||||
{ ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
||||
@@ -3818,6 +3853,9 @@ void ImGui::Shutdown()
|
||||
g.TablesTempData.clear_destruct();
|
||||
g.DrawChannelsTempMergeBuffer.clear();
|
||||
|
||||
g.MultiSelectStorage.Clear();
|
||||
g.MultiSelectTempData.clear_destruct();
|
||||
|
||||
g.ClipboardHandlerData.clear();
|
||||
g.MenusIdSubmittedThisFrame.clear();
|
||||
g.InputTextState.ClearFreeMemory();
|
||||
@@ -3928,6 +3966,8 @@ void ImGui::GcCompactTransientMiscBuffers()
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.ItemFlagsStack.clear();
|
||||
g.GroupStack.clear();
|
||||
g.MultiSelectTempDataStacked = 0;
|
||||
g.MultiSelectTempData.clear_destruct();
|
||||
TableGcCompactSettings();
|
||||
}
|
||||
|
||||
@@ -4012,9 +4052,6 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
// (Please note that this is WIP and not all keys/inputs are thoroughly declared by all widgets yet)
|
||||
g.ActiveIdUsingNavDirMask = 0x00;
|
||||
g.ActiveIdUsingAllKeyboardKeys = false;
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
g.ActiveIdUsingNavInputMask = 0x00;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::ClearActiveID()
|
||||
@@ -4052,7 +4089,7 @@ void ImGui::MarkItemEdited(ImGuiID id)
|
||||
|
||||
// We accept a MarkItemEdited() on drag and drop targets (see https://github.com/ocornut/imgui/issues/1875#issuecomment-978243343)
|
||||
// We accept 'ActiveIdPreviousFrame == id' for InputText() returning an edit after it has been taken ActiveId away (#4714)
|
||||
IM_ASSERT(g.DragDropActive || g.ActiveId == id || g.ActiveId == 0 || g.ActiveIdPreviousFrame == id);
|
||||
IM_ASSERT(g.DragDropActive || g.ActiveId == id || g.ActiveId == 0 || g.ActiveIdPreviousFrame == id || (g.CurrentMultiSelect != NULL && g.BoxSelectState.IsActive));
|
||||
|
||||
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited;
|
||||
@@ -4778,25 +4815,8 @@ void ImGui::NewFrame()
|
||||
{
|
||||
g.ActiveIdUsingNavDirMask = 0x00;
|
||||
g.ActiveIdUsingAllKeyboardKeys = false;
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
g.ActiveIdUsingNavInputMask = 0x00;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
if (g.ActiveId == 0)
|
||||
g.ActiveIdUsingNavInputMask = 0;
|
||||
else if (g.ActiveIdUsingNavInputMask != 0)
|
||||
{
|
||||
// If your custom widget code used: { g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel); }
|
||||
// Since IMGUI_VERSION_NUM >= 18804 it should be: { SetKeyOwner(ImGuiKey_Escape, g.ActiveId); SetKeyOwner(ImGuiKey_NavGamepadCancel, g.ActiveId); }
|
||||
if (g.ActiveIdUsingNavInputMask & (1 << ImGuiNavInput_Cancel))
|
||||
SetKeyOwner(ImGuiKey_Escape, g.ActiveId);
|
||||
if (g.ActiveIdUsingNavInputMask & ~(1 << ImGuiNavInput_Cancel))
|
||||
IM_ASSERT(0); // Other values unsupported
|
||||
}
|
||||
#endif
|
||||
|
||||
// Record when we have been stationary as this state is preserved while over same item.
|
||||
// FIXME: The way this is expressed means user cannot alter HoverStationaryDelay during the frame to use varying values.
|
||||
// To allow this we should store HoverItemMaxStationaryTime+ID and perform the >= check in IsItemHovered() function.
|
||||
@@ -5446,9 +5466,15 @@ bool ImGui::IsItemToggledOpen()
|
||||
return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledOpen) ? true : false;
|
||||
}
|
||||
|
||||
// Call after a Selectable() or TreeNode() involved in multi-selection.
|
||||
// Useful if you need the per-item information before reaching EndMultiSelect(), e.g. for rendering purpose.
|
||||
// This is only meant to be called inside a BeginMultiSelect()/EndMultiSelect() block.
|
||||
// (Outside of multi-select, it would be misleading/ambiguous to report this signal, as widgets
|
||||
// return e.g. a pressed event and user code is in charge of altering selection in ways we cannot predict.)
|
||||
bool ImGui::IsItemToggledSelection()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.CurrentMultiSelect != NULL); // Can only be used inside a BeginMultiSelect()/EndMultiSelect()
|
||||
return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false;
|
||||
}
|
||||
|
||||
@@ -5508,7 +5534,8 @@ void ImGui::SetItemAllowOverlap()
|
||||
}
|
||||
#endif
|
||||
|
||||
// FIXME: It might be undesirable that this will likely disable KeyOwner-aware shortcuts systems. Consider a more fine-tuned version for the two users of this function.
|
||||
// This is a shortcut for not taking ownership of 100+ keys, frequently used by drag operations.
|
||||
// FIXME: It might be undesirable that this will likely disable KeyOwner-aware shortcuts systems. Consider a more fine-tuned version if needed?
|
||||
void ImGui::SetActiveIdUsingAllKeyboardKeys()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@@ -8217,6 +8244,7 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
||||
|
||||
// This is one of the very rare legacy case where we use ImGuiWindow methods,
|
||||
// it should ideally be flattened at some point but it's been used a lots by widgets.
|
||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
@@ -8356,6 +8384,13 @@ ImGuiID ImGui::GetID(const void* ptr_id)
|
||||
return window->GetID(ptr_id);
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(int int_id)
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->GetID(int_id);
|
||||
}
|
||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] INPUTS
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -9773,6 +9808,11 @@ void ImGui::SetItemKeyOwner(ImGuiKey key, ImGuiInputFlags flags)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::SetItemKeyOwner(ImGuiKey key)
|
||||
{
|
||||
SetItemKeyOwner(key, ImGuiInputFlags_None);
|
||||
}
|
||||
|
||||
// This is the only public API until we expose owner_id versions of the API as replacements.
|
||||
bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord)
|
||||
{
|
||||
@@ -10060,6 +10100,11 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name);
|
||||
EndTabBar();
|
||||
}
|
||||
while (g.CurrentMultiSelect != NULL && g.CurrentMultiSelect->Storage->Window == window)
|
||||
{
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing EndMultiSelect() in '%s'", window->Name);
|
||||
EndMultiSelect();
|
||||
}
|
||||
while (window->DC.TreeDepth > 0)
|
||||
{
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name);
|
||||
@@ -10283,9 +10328,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
// - GetFrameHeight()
|
||||
// - GetFrameHeightWithSpacing()
|
||||
// - GetContentRegionMax()
|
||||
// - GetContentRegionMaxAbs() [Internal]
|
||||
// - GetContentRegionAvail(),
|
||||
// - GetWindowContentRegionMin(), GetWindowContentRegionMax()
|
||||
// - BeginGroup()
|
||||
// - EndGroup()
|
||||
// Also see in imgui_widgets: tab bars, and in imgui_tables: tables, columns.
|
||||
@@ -10501,8 +10544,8 @@ float ImGui::CalcItemWidth()
|
||||
w = window->DC.ItemWidth;
|
||||
if (w < 0.0f)
|
||||
{
|
||||
float region_max_x = GetContentRegionMaxAbs().x;
|
||||
w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w);
|
||||
float region_avail_x = GetContentRegionAvail().x;
|
||||
w = ImMax(1.0f, region_avail_x + w);
|
||||
}
|
||||
w = IM_TRUNC(w);
|
||||
return w;
|
||||
@@ -10514,22 +10557,19 @@ float ImGui::CalcItemWidth()
|
||||
// The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable)
|
||||
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
ImVec2 region_max;
|
||||
ImVec2 avail;
|
||||
if (size.x < 0.0f || size.y < 0.0f)
|
||||
region_max = GetContentRegionMaxAbs();
|
||||
avail = GetContentRegionAvail();
|
||||
|
||||
if (size.x == 0.0f)
|
||||
size.x = default_w;
|
||||
else if (size.x < 0.0f)
|
||||
size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x);
|
||||
size.x = ImMax(4.0f, avail.x + size.x); // <-- size.x is negative here so we are subtracting
|
||||
|
||||
if (size.y == 0.0f)
|
||||
size.y = default_h;
|
||||
else if (size.y < 0.0f)
|
||||
size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y);
|
||||
size.y = ImMax(4.0f, avail.y + size.y); // <-- size.y is negative here so we are subtracting
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -10558,33 +10598,23 @@ float ImGui::GetFrameHeightWithSpacing()
|
||||
return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
|
||||
}
|
||||
|
||||
// FIXME: All the Contents Region function are messy or misleading. WE WILL AIM TO OBSOLETE ALL OF THEM WITH A NEW "WORK RECT" API. Thanks for your patience!
|
||||
|
||||
// FIXME: This is in window space (not screen space!).
|
||||
ImVec2 ImGui::GetContentRegionMax()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
|
||||
return mx - window->Pos;
|
||||
}
|
||||
|
||||
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
|
||||
ImVec2 ImGui::GetContentRegionMaxAbs()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
|
||||
return mx;
|
||||
}
|
||||
|
||||
ImVec2 ImGui::GetContentRegionAvail()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return GetContentRegionMaxAbs() - window->DC.CursorPos;
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = (window->DC.CurrentColumns || g.CurrentTable) ? window->WorkRect.Max : window->ContentRegionRect.Max;
|
||||
return mx - window->DC.CursorPos;
|
||||
}
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
// You should never need those functions. Always use GetCursorScreenPos() and GetContentRegionAvail()!
|
||||
// They are bizarre local-coordinates which don't play well with scrolling.
|
||||
ImVec2 ImGui::GetContentRegionMax()
|
||||
{
|
||||
return GetContentRegionAvail() + GetCursorScreenPos() - GetWindowPos();
|
||||
}
|
||||
|
||||
// In window space (not screen space!)
|
||||
ImVec2 ImGui::GetWindowContentRegionMin()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
@@ -10596,6 +10626,7 @@ ImVec2 ImGui::GetWindowContentRegionMax()
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->ContentRegionRect.Max - window->Pos;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
|
||||
// Groups are currently a mishmash of functionalities which should perhaps be clarified and separated.
|
||||
@@ -10641,11 +10672,11 @@ void ImGui::EndGroup()
|
||||
if (window->DC.IsSetPos)
|
||||
ErrorCheckUsingSetCursorPosToExtendParentBoundaries();
|
||||
|
||||
ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));
|
||||
|
||||
// Include LastItemData.Rect.Max as a workaround for e.g. EndTable() undershooting with CursorMaxPos report. (#7543)
|
||||
ImRect group_bb(group_data.BackupCursorPos, ImMax(ImMax(window->DC.CursorMaxPos, g.LastItemData.Rect.Max), group_data.BackupCursorPos));
|
||||
window->DC.CursorPos = group_data.BackupCursorPos;
|
||||
window->DC.CursorPosPrevLine = group_data.BackupCursorPosPrevLine;
|
||||
window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
|
||||
window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, group_bb.Max);
|
||||
window->DC.Indent = group_data.BackupIndent;
|
||||
window->DC.GroupOffset = group_data.BackupGroupOffset;
|
||||
window->DC.CurrLineSize = group_data.BackupCurrLineSize;
|
||||
@@ -10660,7 +10691,7 @@ void ImGui::EndGroup()
|
||||
return;
|
||||
}
|
||||
|
||||
window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
|
||||
window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
|
||||
ItemSize(group_bb.GetSize());
|
||||
ItemAdd(group_bb, 0, NULL, ImGuiItemFlags_NoTabStop);
|
||||
|
||||
@@ -12003,6 +12034,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindow != NULL);
|
||||
//IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestSubmit: dir %c, window \"%s\"\n", "-WENS"[move_dir + 1], g.NavWindow->Name);
|
||||
|
||||
if (move_flags & ImGuiNavMoveFlags_IsTabbing)
|
||||
move_flags |= ImGuiNavMoveFlags_AllowCurrentNavId;
|
||||
@@ -12251,6 +12283,7 @@ static void ImGui::NavUpdate()
|
||||
|
||||
// Process navigation init request (select first/default focus)
|
||||
g.NavJustMovedToId = 0;
|
||||
g.NavJustMovedToFocusScopeId = g.NavJustMovedFromFocusScopeId = 0;
|
||||
if (g.NavInitResult.ID != 0)
|
||||
NavInitRequestApplyResult();
|
||||
g.NavInitRequest = false;
|
||||
@@ -12403,6 +12436,7 @@ void ImGui::NavInitRequestApplyResult()
|
||||
ImGuiNavItemData* result = &g.NavInitResult;
|
||||
if (g.NavId != result->ID)
|
||||
{
|
||||
g.NavJustMovedFromFocusScopeId = g.NavFocusScopeId;
|
||||
g.NavJustMovedToId = result->ID;
|
||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = 0;
|
||||
@@ -12661,6 +12695,7 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
// PageUp/PageDown however sets always set NavJustMovedTo (vs Home/End which doesn't) mimicking Windows behavior.
|
||||
if ((g.NavId != result->ID || (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)) && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||
{
|
||||
g.NavJustMovedFromFocusScopeId = g.NavFocusScopeId;
|
||||
g.NavJustMovedToId = result->ID;
|
||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||
@@ -13419,7 +13454,7 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
|
||||
|
||||
IM_ASSERT(g.DragDropWithinTarget == false && g.DragDropWithinSource == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
|
||||
g.DragDropTargetRect = bb;
|
||||
g.DragDropTargetClipRect = window->ClipRect; // May want to be overriden by user depending on use case?
|
||||
g.DragDropTargetClipRect = window->ClipRect; // May want to be overridden by user depending on use case?
|
||||
g.DragDropTargetId = id;
|
||||
g.DragDropWithinTarget = true;
|
||||
return true;
|
||||
@@ -14957,6 +14992,17 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
TreePop();
|
||||
}
|
||||
|
||||
// Details for MultiSelect
|
||||
if (TreeNode("MultiSelect", "MultiSelect (%d)", g.MultiSelectStorage.GetAliveCount()))
|
||||
{
|
||||
ImGuiBoxSelectState* bs = &g.BoxSelectState;
|
||||
BulletText("BoxSelect ID=0x%08X, Starting = %d, Active %d", bs->ID, bs->IsStarting, bs->IsActive);
|
||||
for (int n = 0; n < g.MultiSelectStorage.GetMapSize(); n++)
|
||||
if (ImGuiMultiSelectState* state = g.MultiSelectStorage.TryGetMapData(n))
|
||||
DebugNodeMultiSelectState(state);
|
||||
TreePop();
|
||||
}
|
||||
|
||||
// Details for Docking
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
if (TreeNode("Docking"))
|
||||
@@ -15025,7 +15071,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
for (int n = buf_size - 1; n >= 0; n--)
|
||||
{
|
||||
ImGuiDebugAllocEntry* entry = &info->LastEntriesBuf[(info->LastEntriesIdx - n + buf_size) % buf_size];
|
||||
BulletText("Frame %06d: %+3d ( %2d malloc, %2d free )%s", entry->FrameCount, entry->AllocCount - entry->FreeCount, entry->AllocCount, entry->FreeCount, (n == 0) ? " (most recent)" : "");
|
||||
BulletText("Frame %06d: %+3d ( %2d alloc, %2d free )", entry->FrameCount, entry->AllocCount - entry->FreeCount, entry->AllocCount, entry->FreeCount);
|
||||
if (n == 0)
|
||||
{
|
||||
SameLine();
|
||||
Text("<- %d frames ago", g.FrameCount - entry->FrameCount);
|
||||
}
|
||||
}
|
||||
TreePop();
|
||||
}
|
||||
@@ -15651,6 +15702,12 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
|
||||
(flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
|
||||
(flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
|
||||
(flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
|
||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||
BulletText("ChildFlags: 0x%08X (%s%s%s%s..)", window->ChildFlags,
|
||||
(window->ChildFlags & ImGuiChildFlags_Border) ? "Border " : "",
|
||||
(window->ChildFlags & ImGuiChildFlags_ResizeX) ? "ResizeX " : "",
|
||||
(window->ChildFlags & ImGuiChildFlags_ResizeY) ? "ResizeY " : "",
|
||||
(window->ChildFlags & ImGuiChildFlags_NavFlattened) ? "NavFlattened " : "");
|
||||
BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y, window->ScrollbarX ? "X" : "", window->ScrollbarY ? "Y" : "");
|
||||
BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
|
||||
BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems);
|
||||
@@ -15761,7 +15818,7 @@ static void SameLineOrWrap(const ImVec2& size)
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 pos(window->DC.CursorPosPrevLine.x + g.Style.ItemSpacing.x, window->DC.CursorPosPrevLine.y);
|
||||
if (window->ClipRect.Contains(ImRect(pos, pos + size)))
|
||||
if (window->WorkRect.Contains(ImRect(pos, pos + size)))
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
@@ -15799,7 +15856,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||
ShowDebugLogFlag("IO", ImGuiDebugLogFlags_EventIO);
|
||||
ShowDebugLogFlag("Nav", ImGuiDebugLogFlags_EventNav);
|
||||
ShowDebugLogFlag("Popup", ImGuiDebugLogFlags_EventPopup);
|
||||
//ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
|
||||
ShowDebugLogFlag("Selection", ImGuiDebugLogFlags_EventSelection);
|
||||
ShowDebugLogFlag("InputRouting", ImGuiDebugLogFlags_EventInputRouting);
|
||||
|
||||
if (SmallButton("Clear"))
|
||||
@@ -15855,7 +15912,7 @@ void ImGui::DebugTextUnformattedWithLocateItem(const char* line_begin, const cha
|
||||
for (const char* p = line_begin; p <= line_end - 10; p++)
|
||||
{
|
||||
ImGuiID id = 0;
|
||||
if (p[0] != '0' || (p[1] != 'x' && p[1] != 'X') || sscanf(p + 2, "%X", &id) != 1)
|
||||
if (p[0] != '0' || (p[1] != 'x' && p[1] != 'X') || sscanf(p + 2, "%X", &id) != 1 || ImCharIsXdigitA(p[10]))
|
||||
continue;
|
||||
ImVec2 p0 = CalcTextSize(line_begin, p);
|
||||
ImVec2 p1 = CalcTextSize(p, p + 10);
|
||||
|
||||
Reference in New Issue
Block a user