Updated ImGui.
This commit is contained in:
parent
3a0233ed50
commit
3944eed099
119
3rdparty/dear-imgui/imgui.cpp
vendored
119
3rdparty/dear-imgui/imgui.cpp
vendored
@ -397,7 +397,10 @@ 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.
|
||||
|
||||
- 2023/03/14 (1.89.4) - commented out redirecting enums/functions names that were marked obsolete two years ago:
|
||||
|
||||
- 2023/05/15 (1.86.6) - clipper: commented out obsolete redirection constructor 'ImGuiListClipper(int items_count, float items_height = -1.0f)' that was marked obsolete in 1.79. Use default constructor + clipper.Begin().
|
||||
- 2023/05/15 (1.89.6) - clipper: renamed ImGuiListClipper::ForceDisplayRangeByIndices() to ImGuiListClipper::IncludeRangeByIndices().
|
||||
- 2023/03/14 (1.89.4) - commented out redirecting enums/functions names that were marked obsolete two years ago:
|
||||
- ImGuiSliderFlags_ClampOnInput -> use ImGuiSliderFlags_AlwaysClamp
|
||||
- ImGuiInputTextFlags_AlwaysInsertMode -> use ImGuiInputTextFlags_AlwaysOverwrite
|
||||
- ImDrawList::AddBezierCurve() -> use ImDrawList::AddBezierCubic()
|
||||
@ -1542,7 +1545,7 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
||||
// Filter duplicate
|
||||
const ImGuiInputEvent* latest_event = FindLatestInputEvent(&g, ImGuiInputEventType_Focus);
|
||||
const bool latest_focused = latest_event ? latest_event->AppFocused.Focused : !g.IO.AppFocusLost;
|
||||
if (latest_focused == focused)
|
||||
if (latest_focused == focused || (ConfigDebugIgnoreFocusLoss && !focused))
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
@ -2805,13 +2808,13 @@ void ImGuiListClipper::End()
|
||||
ItemsCount = -1;
|
||||
}
|
||||
|
||||
void ImGuiListClipper::ForceDisplayRangeByIndices(int item_min, int item_max)
|
||||
void ImGuiListClipper::IncludeRangeByIndices(int item_begin, int item_end)
|
||||
{
|
||||
ImGuiListClipperData* data = (ImGuiListClipperData*)TempData;
|
||||
IM_ASSERT(DisplayStart < 0); // Only allowed after Begin() and if there has not been a specified range yet.
|
||||
IM_ASSERT(item_min <= item_max);
|
||||
if (item_min < item_max)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(item_min, item_max));
|
||||
IM_ASSERT(item_begin <= item_end);
|
||||
if (item_begin < item_end)
|
||||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(item_begin, item_end));
|
||||
}
|
||||
|
||||
static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
@ -3690,6 +3693,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* ctx, const char* name) : DrawListInst(NUL
|
||||
DrawList = &DrawListInst;
|
||||
DrawList->_Data = &Ctx->DrawListSharedData;
|
||||
DrawList->_OwnerName = Name;
|
||||
NavPreferredScoringPosRel[0] = NavPreferredScoringPosRel[1] = ImVec2(FLT_MAX, FLT_MAX);
|
||||
}
|
||||
|
||||
ImGuiWindow::~ImGuiWindow()
|
||||
@ -9199,6 +9203,11 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name);
|
||||
PopStyleVar();
|
||||
}
|
||||
while (g.FontStack.Size > stack_sizes->SizeOfFontStack) //-V1044
|
||||
{
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing PopFont() in '%s'", window->Name);
|
||||
PopFont();
|
||||
}
|
||||
while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack + 1) //-V1044
|
||||
{
|
||||
if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name);
|
||||
@ -10622,6 +10631,12 @@ void ImGui::SetNavWindow(ImGuiWindow* window)
|
||||
NavUpdateAnyRequestFlag();
|
||||
}
|
||||
|
||||
void ImGui::NavClearPreferredPosForAxis(ImGuiAxis axis)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer][axis] = FLT_MAX;
|
||||
}
|
||||
|
||||
void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -10632,6 +10647,10 @@ void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id
|
||||
g.NavFocusScopeId = focus_scope_id;
|
||||
g.NavWindow->NavLastIds[nav_layer] = id;
|
||||
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
||||
|
||||
// Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
}
|
||||
|
||||
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
||||
@ -10656,9 +10675,13 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
||||
g.NavDisableMouseHover = true;
|
||||
else
|
||||
g.NavDisableHighlight = true;
|
||||
|
||||
// Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
}
|
||||
|
||||
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
|
||||
static ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
|
||||
{
|
||||
if (ImFabs(dx) > ImFabs(dy))
|
||||
return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
|
||||
@ -10748,16 +10771,22 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
||||
draw_list->AddText(cand.Min, IM_COL32(255, 255, 255, 255), buf);
|
||||
}
|
||||
}
|
||||
if (IsMouseHoveringRect(cand.Min, cand.Max))
|
||||
const bool debug_hovering = IsMouseHoveringRect(cand.Min, cand.Max);
|
||||
const bool debug_tty = (g.IO.KeyCtrl && IsKeyPressed(ImGuiKey_Space));
|
||||
if (debug_hovering || debug_tty)
|
||||
{
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf),
|
||||
"d-box (%7.3f,%7.3f) -> %7.3f\nd-center (%7.3f,%7.3f) -> %7.3f\nd-axial (%7.3f,%7.3f) -> %7.3f\nnav %c, quadrant %c",
|
||||
dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
|
||||
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||
draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
|
||||
draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
|
||||
draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40,0,0,200));
|
||||
draw_list->AddText(cand.Max, ~0U, buf);
|
||||
dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "-WENS"[move_dir+1], "-WENS"[quadrant+1]);
|
||||
if (debug_hovering)
|
||||
{
|
||||
ImDrawList* draw_list = GetForegroundDrawList(window);
|
||||
draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255, 200, 0, 100));
|
||||
draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255, 255, 0, 200));
|
||||
draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40, 0, 0, 200));
|
||||
draw_list->AddText(cand.Max, ~0U, buf);
|
||||
}
|
||||
if (debug_tty) { IMGUI_DEBUG_LOG_NAV("id 0x%08X\n%s\n", g.LastItemData.ID, buf); }
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -11025,7 +11054,8 @@ void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wra
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT((wrap_flags & ImGuiNavMoveFlags_WrapMask_ ) != 0 && (wrap_flags & ~ImGuiNavMoveFlags_WrapMask_) == 0); // Call with _WrapX, _WrapY, _LoopX, _LoopY
|
||||
|
||||
// In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it, NavEndFrame() will do the same test
|
||||
// In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it:
|
||||
// as NavEndFrame() will do the same test. It will end up calling NavUpdateCreateWrappingRequest().
|
||||
if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == ImGuiNavLayer_Main)
|
||||
g.NavMoveFlags = (g.NavMoveFlags & ~ImGuiNavMoveFlags_WrapMask_) | wrap_flags;
|
||||
}
|
||||
@ -11324,11 +11354,11 @@ static void ImGui::NavUpdate()
|
||||
// [DEBUG]
|
||||
g.NavScoringDebugCount = 0;
|
||||
#if IMGUI_DEBUG_NAV_RECTS
|
||||
if (g.NavWindow)
|
||||
if (ImGuiWindow* debug_window = g.NavWindow)
|
||||
{
|
||||
ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
|
||||
if (1) { for (int layer = 0; layer < 2; layer++) { ImRect r = WindowRectRelToAbs(g.NavWindow, g.NavWindow->NavRectRel[layer]); draw_list->AddRect(r.Min, r.Max, IM_COL32(255,200,0,255)); } } // [DEBUG]
|
||||
if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
ImDrawList* draw_list = GetForegroundDrawList(debug_window);
|
||||
int layer = g.NavLayer; /* for (int layer = 0; layer < 2; layer++)*/ { ImRect r = WindowRectRelToAbs(debug_window, debug_window->NavRectRel[layer]); draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 200, 0, 255)); }
|
||||
//if (1) { ImU32 col = (!debug_window->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -11349,6 +11379,31 @@ void ImGui::NavInitRequestApplyResult()
|
||||
NavRestoreHighlightAfterMove();
|
||||
}
|
||||
|
||||
// Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position
|
||||
static void NavBiasScoringRect(ImRect& r, ImVec2& preferred_pos_rel, ImGuiDir move_dir, ImGuiNavMoveFlags move_flags)
|
||||
{
|
||||
// Bias initial rect
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImVec2 rel_to_abs_offset = g.NavWindow->DC.CursorStartPos;
|
||||
|
||||
// Initialize bias on departure if we don't have any. So mouse-click + arrow will record bias.
|
||||
// - We default to L/U bias, so moving down from a large source item into several columns will land on left-most column.
|
||||
// - But each successful move sets new bias on one axis, only cleared when using mouse.
|
||||
if ((move_flags & ImGuiNavMoveFlags_Forwarded) == 0)
|
||||
{
|
||||
if (preferred_pos_rel.x == FLT_MAX)
|
||||
preferred_pos_rel.x = ImMin(r.Min.x + 1.0f, r.Max.x) - rel_to_abs_offset.x;
|
||||
if (preferred_pos_rel.y == FLT_MAX)
|
||||
preferred_pos_rel.y = r.GetCenter().y - rel_to_abs_offset.y;
|
||||
}
|
||||
|
||||
// Apply general bias on the other axis
|
||||
if ((move_dir == ImGuiDir_Up || move_dir == ImGuiDir_Down) && preferred_pos_rel.x != FLT_MAX)
|
||||
r.Min.x = r.Max.x = preferred_pos_rel.x + rel_to_abs_offset.x;
|
||||
else if ((move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) && preferred_pos_rel.y != FLT_MAX)
|
||||
r.Min.y = r.Max.y = preferred_pos_rel.y + rel_to_abs_offset.y;
|
||||
}
|
||||
|
||||
void ImGui::NavUpdateCreateMoveRequest()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -11455,8 +11510,8 @@ void ImGui::NavUpdateCreateMoveRequest()
|
||||
ImRect nav_rect_rel = !window->NavRectRel[g.NavLayer].IsInverted() ? window->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0);
|
||||
scoring_rect = WindowRectRelToAbs(window, nav_rect_rel);
|
||||
scoring_rect.TranslateY(scoring_rect_offset_y);
|
||||
scoring_rect.Min.x = ImMin(scoring_rect.Min.x + 1.0f, scoring_rect.Max.x);
|
||||
scoring_rect.Max.x = scoring_rect.Min.x;
|
||||
if (g.NavMoveSubmitted)
|
||||
NavBiasScoringRect(scoring_rect, window->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer], g.NavMoveDir, g.NavMoveFlags);
|
||||
IM_ASSERT(!scoring_rect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allow us to remove extraneous ImFabs() calls in NavScoreItem().
|
||||
//GetForegroundDrawList()->AddRect(scoring_rect.Min, scoring_rect.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
||||
//if (!g.NavScoringNoClipRect.IsInverted()) { GetForegroundDrawList()->AddRect(g.NavScoringNoClipRect.Min, g.NavScoringNoClipRect.Max, IM_COL32(255, 200, 0, 255)); } // [DEBUG]
|
||||
@ -11510,12 +11565,14 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
result = &g.NavTabbingResultFirst;
|
||||
|
||||
// In a situation when there are no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
|
||||
const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
if (result == NULL)
|
||||
{
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight;
|
||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0)
|
||||
NavRestoreHighlightAfterMove();
|
||||
NavClearPreferredPosForAxis(axis); // On a failed move, clear preferred pos for this axis.
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveSubmitted but not led to a result!\n");
|
||||
return;
|
||||
}
|
||||
@ -11560,10 +11617,19 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||
}
|
||||
|
||||
// Focus
|
||||
// Apply new NavID/Focus
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name);
|
||||
ImVec2 preferred_scoring_pos_rel = g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer];
|
||||
SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
||||
|
||||
// Restore last preferred position for current axis
|
||||
// (storing in RootWindowForNav-> as the info is desirable at the beginning of a Move Request. In theory all storage should use RootWindowForNav..)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) == 0)
|
||||
{
|
||||
preferred_scoring_pos_rel[axis] = result->RectRel.GetCenter()[axis];
|
||||
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
||||
}
|
||||
|
||||
// Tabbing: Activates Inputable or Focus non-Inputable
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable))
|
||||
{
|
||||
@ -11733,7 +11799,9 @@ static void ImGui::NavUpdateCreateWrappingRequest()
|
||||
bool do_forward = false;
|
||||
ImRect bb_rel = window->NavRectRel[g.NavLayer];
|
||||
ImGuiDir clip_dir = g.NavMoveDir;
|
||||
|
||||
const ImGuiNavMoveFlags move_flags = g.NavMoveFlags;
|
||||
//const ImGuiAxis move_axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
|
||||
{
|
||||
bb_rel.Min.x = bb_rel.Max.x = window->ContentSize.x + window->WindowPadding.x;
|
||||
@ -11777,6 +11845,8 @@ static void ImGui::NavUpdateCreateWrappingRequest()
|
||||
if (!do_forward)
|
||||
return;
|
||||
window->NavRectRel[g.NavLayer] = bb_rel;
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
NavMoveRequestForward(g.NavMoveDir, clip_dir, move_flags, g.NavMoveScrollFlags);
|
||||
}
|
||||
|
||||
@ -13340,7 +13410,7 @@ void ImGui::DebugRenderKeyboardPreview(ImDrawList* draw_list)
|
||||
void ImGui::DebugTextEncoding(const char* str)
|
||||
{
|
||||
Text("Text: \"%s\"", str);
|
||||
if (!BeginTable("list", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit))
|
||||
if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
|
||||
return;
|
||||
TableSetupColumn("Offset");
|
||||
TableSetupColumn("UTF-8");
|
||||
@ -14287,6 +14357,9 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label)
|
||||
BulletText("NavLastIds[%d]: 0x%08X at +(%.1f,%.1f)(%.1f,%.1f)", layer, window->NavLastIds[layer], r.Min.x, r.Min.y, r.Max.x, r.Max.y);
|
||||
DebugLocateItemOnHover(window->NavLastIds[layer]);
|
||||
}
|
||||
const ImVec2* pr = window->NavPreferredScoringPosRel;
|
||||
for (int layer = 0; layer < ImGuiNavLayer_COUNT; layer++)
|
||||
BulletText("NavPreferredScoringPosRel[%d] = {%.1f,%.1f)", layer, (pr[layer].x == FLT_MAX ? -99999.0f : pr[layer].x), (pr[layer].y == FLT_MAX ? -99999.0f : pr[layer].y)); // Display as 99999.0f so it looks neater.
|
||||
BulletText("NavLayersActiveMask: %X, NavLastChildNavWindow: %s", window->DC.NavLayersActiveMask, window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
|
||||
if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); }
|
||||
if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); }
|
||||
|
29
3rdparty/dear-imgui/imgui.h
vendored
29
3rdparty/dear-imgui/imgui.h
vendored
@ -21,9 +21,9 @@
|
||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
||||
#define IMGUI_VERSION "1.89.6 WIP"
|
||||
#define IMGUI_VERSION_NUM 18954
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.89.6 WIP"
|
||||
#define IMGUI_VERSION_NUM 18957
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
@ -1952,11 +1952,15 @@ struct ImGuiIO
|
||||
|
||||
// Debug options
|
||||
// - tools to test correct Begin/End and BeginChild/EndChild behaviors.
|
||||
// - presently Begn()/End() and BeginChild()EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
|
||||
// - presently Begin()/End() and BeginChild()/EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
|
||||
// this is inconsistent with other BeginXXX functions and create confusion for many users.
|
||||
// - we expect to update the API eventually. In the meanwhile we provided tools to facilitate checking user-code behavior.
|
||||
bool ConfigDebugBeginReturnValueOnce; // = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
|
||||
bool ConfigDebugBeginReturnValueLoop; // = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
|
||||
// - we expect to update the API eventually. In the meanwhile we provide tools to facilitate checking user-code behavior.
|
||||
bool ConfigDebugBeginReturnValueOnce;// = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
|
||||
bool ConfigDebugBeginReturnValueLoop;// = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
|
||||
// - option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
|
||||
// - backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
|
||||
// - consider using e.g. Win32's IsDebuggerPresent() as an additional filter (or see ImOsIsDebuggerPresent() in imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version).
|
||||
bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys() in input processing.
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Platform Functions
|
||||
@ -2340,11 +2344,13 @@ struct ImGuiListClipper
|
||||
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
|
||||
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
||||
|
||||
// Call ForceDisplayRangeByIndices() before first call to Step() if you need a range of items to be displayed regardless of visibility.
|
||||
IMGUI_API void ForceDisplayRangeByIndices(int item_min, int item_max); // item_max is exclusive e.g. use (42, 42+1) to make item 42 always visible BUT due to alignment/padding of certain items it is likely that an extra item may be included on either end of the display range.
|
||||
// Call IncludeRangeByIndices() *BEFORE* first call to Step() if you need a range of items to not be clipped, regardless of their visibility.
|
||||
// (Due to alignment / padding of certain items it is possible that an extra item may be included on either end of the display range).
|
||||
IMGUI_API void IncludeRangeByIndices(int item_begin, int item_end); // item_end is exclusive e.g. use (42, 42+1) to make item 42 never clipped.
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
|
||||
inline void ForceDisplayRangeByIndices(int item_begin, int item_end) { IncludeRangeByIndices(item_begin, item_end); } // [renamed in 1.89.6]
|
||||
//inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -2828,7 +2834,8 @@ struct ImFontAtlas
|
||||
//-------------------------------------------
|
||||
|
||||
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
|
||||
// NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
|
||||
// NB: Make sure that your string are UTF-8 and NOT in your local code page.
|
||||
// Read https://github.com/ocornut/imgui/blob/master/docs/FONTS.md/#about-utf-8-encoding for details.
|
||||
// NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data.
|
||||
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
|
||||
IMGUI_API const ImWchar* GetGlyphRangesGreek(); // Default + Greek and Coptic
|
||||
|
14
3rdparty/dear-imgui/imgui_demo.cpp
vendored
14
3rdparty/dear-imgui/imgui_demo.cpp
vendored
@ -398,23 +398,21 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
IMGUI_DEMO_MARKER("Help");
|
||||
if (ImGui::CollapsingHeader("Help"))
|
||||
{
|
||||
ImGui::Text("ABOUT THIS DEMO:");
|
||||
ImGui::SeparatorText("ABOUT THIS DEMO:");
|
||||
ImGui::BulletText("Sections below are demonstrating many aspects of the library.");
|
||||
ImGui::BulletText("The \"Examples\" menu above leads to more demo contents.");
|
||||
ImGui::BulletText("The \"Tools\" menu above gives access to: About Box, Style Editor,\n"
|
||||
"and Metrics/Debugger (general purpose Dear ImGui debugging tool).");
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("PROGRAMMER GUIDE:");
|
||||
ImGui::SeparatorText("PROGRAMMER GUIDE:");
|
||||
ImGui::BulletText("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
|
||||
ImGui::BulletText("See comments in imgui.cpp.");
|
||||
ImGui::BulletText("See example applications in the examples/ folder.");
|
||||
ImGui::BulletText("Read the FAQ at http://www.dearimgui.com/faq/");
|
||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
|
||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("USER GUIDE:");
|
||||
ImGui::SeparatorText("USER GUIDE:");
|
||||
ImGui::ShowUserGuide();
|
||||
}
|
||||
|
||||
@ -471,6 +469,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::SameLine(); HelpMarker("First calls to Begin()/BeginChild() will return false.\n\nTHIS OPTION IS DISABLED because it needs to be set at application boot-time to make sense. Showing the disabled option is a way to make this feature easier to discover");
|
||||
ImGui::Checkbox("io.ConfigDebugBeginReturnValueLoop", &io.ConfigDebugBeginReturnValueLoop);
|
||||
ImGui::SameLine(); HelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.");
|
||||
ImGui::Checkbox("io.ConfigDebugIgnoreFocusLoss", &io.ConfigDebugIgnoreFocusLoss);
|
||||
ImGui::SameLine(); HelpMarker("Option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.");
|
||||
|
||||
ImGui::TreePop();
|
||||
ImGui::Spacing();
|
||||
@ -631,7 +631,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::Text("Tooltips:");
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::SmallButton("Button");
|
||||
ImGui::SmallButton("Basic");
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("I am a tooltip");
|
||||
|
||||
@ -744,7 +744,7 @@ static void ShowDemoWindowWidgets()
|
||||
static int elem = Element_Fire;
|
||||
const char* elems_names[Element_COUNT] = { "Fire", "Earth", "Air", "Water" };
|
||||
const char* elem_name = (elem >= 0 && elem < Element_COUNT) ? elems_names[elem] : "Unknown";
|
||||
ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name);
|
||||
ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name); // Use ImGuiSliderFlags_NoInput flag to disable CTRL+Click here.
|
||||
ImGui::SameLine(); HelpMarker("Using the format string parameter to display a name instead of the underlying integer.");
|
||||
}
|
||||
|
||||
|
15
3rdparty/dear-imgui/imgui_internal.h
vendored
15
3rdparty/dear-imgui/imgui_internal.h
vendored
@ -479,7 +479,6 @@ IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, c
|
||||
IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||||
IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
|
||||
inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
|
||||
IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy);
|
||||
|
||||
// Helper: ImVec1 (1D vector)
|
||||
// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
|
||||
@ -904,7 +903,7 @@ enum ImGuiSeparatorFlags_
|
||||
ImGuiSeparatorFlags_None = 0,
|
||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1,
|
||||
ImGuiSeparatorFlags_SpanAllColumns = 1 << 2,
|
||||
ImGuiSeparatorFlags_SpanAllColumns = 1 << 2, // Make separator cover all columns of a legacy Columns() set.
|
||||
};
|
||||
|
||||
// Flags for FocusWindow(). This is not called ImGuiFocusFlags to avoid confusion with public-facing ImGuiFocusedFlags.
|
||||
@ -1405,6 +1404,7 @@ enum ImGuiInputFlags_
|
||||
// [SECTION] Clipper support
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Note that Max is exclusive, so perhaps should be using a Begin/End convention.
|
||||
struct ImGuiListClipperRange
|
||||
{
|
||||
int Min;
|
||||
@ -2366,6 +2366,7 @@ struct IMGUI_API ImGuiWindow
|
||||
ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
|
||||
ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
|
||||
ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space
|
||||
ImVec2 NavPreferredScoringPosRel[ImGuiNavLayer_COUNT]; // Preferred X/Y position updated when moving on a given axis, reset to FLT_MAX.
|
||||
ImGuiID NavRootFocusScopeId; // Focus Scope ID at the time of Begin()
|
||||
|
||||
int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy
|
||||
@ -2478,7 +2479,7 @@ struct IMGUI_API ImGuiTabBar
|
||||
typedef ImS16 ImGuiTableColumnIdx;
|
||||
typedef ImU16 ImGuiTableDrawChannelIdx;
|
||||
|
||||
// [Internal] sizeof() ~ 104
|
||||
// [Internal] sizeof() ~ 112
|
||||
// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api.
|
||||
// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping.
|
||||
// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped".
|
||||
@ -2524,7 +2525,7 @@ struct ImGuiTableColumn
|
||||
ImU8 SortDirection : 2; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
|
||||
ImU8 SortDirectionsAvailCount : 2; // Number of available sort directions (0 to 3)
|
||||
ImU8 SortDirectionsAvailMask : 4; // Mask of available sort directions (1-bit each)
|
||||
ImU8 SortDirectionsAvailList; // Ordered of available sort directions (2-bits each)
|
||||
ImU8 SortDirectionsAvailList; // Ordered list of available sort directions (2-bits each, total 8-bits)
|
||||
|
||||
ImGuiTableColumn()
|
||||
{
|
||||
@ -2559,6 +2560,7 @@ struct ImGuiTableInstanceData
|
||||
};
|
||||
|
||||
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
|
||||
// sizeof() ~ 580 bytes + heap allocs described in TableBeginInitMemory()
|
||||
struct IMGUI_API ImGuiTable
|
||||
{
|
||||
ImGuiID ID;
|
||||
@ -2674,6 +2676,7 @@ struct IMGUI_API ImGuiTable
|
||||
// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
|
||||
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
|
||||
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
|
||||
// sizeof() ~ 112 bytes.
|
||||
struct IMGUI_API ImGuiTableTempData
|
||||
{
|
||||
int TableIndex; // Index in g.Tables.Buf[] pool
|
||||
@ -2761,6 +2764,7 @@ namespace ImGui
|
||||
IMGUI_API void SetWindowHiddendAndSkipItemsForCurrentFrame(ImGuiWindow* window);
|
||||
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
||||
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
||||
inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
|
||||
|
||||
// Windows: Display Order and Focus Order
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags = 0);
|
||||
@ -2908,6 +2912,7 @@ namespace ImGui
|
||||
IMGUI_API void NavMoveRequestCancel();
|
||||
IMGUI_API void NavMoveRequestApplyResult();
|
||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||
IMGUI_API void NavClearPreferredPosForAxis(ImGuiAxis axis);
|
||||
IMGUI_API void NavUpdateCurrentWindowIsScrollPushableX();
|
||||
IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
|
||||
IMGUI_API void SetNavWindow(ImGuiWindow* window);
|
||||
@ -3125,7 +3130,7 @@ namespace ImGui
|
||||
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags);
|
||||
IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags, float thickness);
|
||||
IMGUI_API void SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_width);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value);
|
||||
|
90
3rdparty/dear-imgui/imgui_tables.cpp
vendored
90
3rdparty/dear-imgui/imgui_tables.cpp
vendored
@ -80,20 +80,20 @@ Index of this file:
|
||||
// - outer_size.x <= 0.0f -> Right-align from window/work-rect right-most edge. With -FLT_MIN or 0.0f will align exactly on right-most edge.
|
||||
// - outer_size.x > 0.0f -> Set Fixed width.
|
||||
// Y with ScrollX/ScrollY disabled: we output table directly in current window
|
||||
// - outer_size.y < 0.0f -> Bottom-align (but will auto extend, unless _NoHostExtendY is set). Not meaningful is parent window can vertically scroll.
|
||||
// - outer_size.y < 0.0f -> Bottom-align (but will auto extend, unless _NoHostExtendY is set). Not meaningful if parent window can vertically scroll.
|
||||
// - outer_size.y = 0.0f -> No minimum height (but will auto extend, unless _NoHostExtendY is set)
|
||||
// - outer_size.y > 0.0f -> Set Minimum height (but will auto extend, unless _NoHostExtenY is set)
|
||||
// Y with ScrollX/ScrollY enabled: using a child window for scrolling
|
||||
// - outer_size.y < 0.0f -> Bottom-align. Not meaningful is parent window can vertically scroll.
|
||||
// - outer_size.y < 0.0f -> Bottom-align. Not meaningful if parent window can vertically scroll.
|
||||
// - outer_size.y = 0.0f -> Bottom-align, consistent with BeginChild(). Not recommended unless table is last item in parent window.
|
||||
// - outer_size.y > 0.0f -> Set Exact height. Recommended when using Scrolling on any axis.
|
||||
//-----------------------------------------------------------------------------
|
||||
// Outer size is also affected by the NoHostExtendX/NoHostExtendY flags.
|
||||
// Important to that note how the two flags have slightly different behaviors!
|
||||
// Important to note how the two flags have slightly different behaviors!
|
||||
// - ImGuiTableFlags_NoHostExtendX -> Make outer width auto-fit to columns (overriding outer_size.x value). Only available when ScrollX/ScrollY are disabled and Stretch columns are not used.
|
||||
// - ImGuiTableFlags_NoHostExtendY -> Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY is disabled. Data below the limit will be clipped and not visible.
|
||||
// In theory ImGuiTableFlags_NoHostExtendY could be the default and any non-scrolling tables with outer_size.y != 0.0f would use exact height.
|
||||
// This would be consistent but perhaps less useful and more confusing (as vertically clipped items are not easily noticeable)
|
||||
// This would be consistent but perhaps less useful and more confusing (as vertically clipped items are not useful and not easily noticeable).
|
||||
//-----------------------------------------------------------------------------
|
||||
// About 'inner_width':
|
||||
// With ScrollX disabled:
|
||||
@ -112,15 +112,16 @@ Index of this file:
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// COLUMNS SIZING POLICIES
|
||||
// (Reference: ImGuiTableFlags_SizingXXX flags and ImGuiTableColumnFlags_WidthXXX flags)
|
||||
//-----------------------------------------------------------------------------
|
||||
// About overriding column sizing policy and width/weight with TableSetupColumn():
|
||||
// We use a default parameter of 'init_width_or_weight == -1'.
|
||||
// We use a default parameter of -1 for 'init_width'/'init_weight'.
|
||||
// - with ImGuiTableColumnFlags_WidthFixed, init_width <= 0 (default) --> width is automatic
|
||||
// - with ImGuiTableColumnFlags_WidthFixed, init_width > 0 (explicit) --> width is custom
|
||||
// - with ImGuiTableColumnFlags_WidthStretch, init_weight <= 0 (default) --> weight is 1.0f
|
||||
// - with ImGuiTableColumnFlags_WidthStretch, init_weight > 0 (explicit) --> weight is custom
|
||||
// Widths are specified _without_ CellPadding. If you specify a width of 100.0f, the column will be cover (100.0f + Padding * 2.0f)
|
||||
// and you can fit a 100.0f wide item in it without clipping and with full padding.
|
||||
// and you can fit a 100.0f wide item in it without clipping and with padding honored.
|
||||
//-----------------------------------------------------------------------------
|
||||
// About default sizing policy (if you don't specify a ImGuiTableColumnFlags_WidthXXXX flag)
|
||||
// - with Table policy ImGuiTableFlags_SizingFixedFit --> default Column policy is ImGuiTableColumnFlags_WidthFixed, default Width is equal to contents width
|
||||
@ -134,10 +135,10 @@ Index of this file:
|
||||
// - using mixed policies with ScrollX does not make much sense, as using Stretch columns with ScrollX does not make much sense in the first place!
|
||||
// that is, unless 'inner_width' is passed to BeginTable() to explicitly provide a total width to layout columns in.
|
||||
// - when using ImGuiTableFlags_SizingFixedSame with mixed columns, only the Fixed/Auto columns will match their widths to the width of the maximum contents.
|
||||
// - when using ImGuiTableFlags_SizingStretchSame with mixed columns, only the Stretch columns will match their weight/widths.
|
||||
// - when using ImGuiTableFlags_SizingStretchSame with mixed columns, only the Stretch columns will match their weights/widths.
|
||||
//-----------------------------------------------------------------------------
|
||||
// About using column width:
|
||||
// If a column is manual resizable or has a width specified with TableSetupColumn():
|
||||
// If a column is manually resizable or has a width specified with TableSetupColumn():
|
||||
// - you may use GetContentRegionAvail().x to query the width available in a given column.
|
||||
// - right-side alignment features such as SetNextItemWidth(-x) or PushItemWidth(-x) will rely on this width.
|
||||
// If the column is not resizable and has no width specified with TableSetupColumn():
|
||||
@ -151,7 +152,7 @@ Index of this file:
|
||||
// TABLES CLIPPING/CULLING
|
||||
//-----------------------------------------------------------------------------
|
||||
// About clipping/culling of Rows in Tables:
|
||||
// - For large numbers of rows, it is recommended you use ImGuiListClipper to only submit visible rows.
|
||||
// - For large numbers of rows, it is recommended you use ImGuiListClipper to submit only visible rows.
|
||||
// ImGuiListClipper is reliant on the fact that rows are of equal height.
|
||||
// See 'Demo->Tables->Vertical Scrolling' or 'Demo->Tables->Advanced' for a demo of using the clipper.
|
||||
// - Note that auto-resizing columns don't play well with using the clipper.
|
||||
@ -168,7 +169,7 @@ Index of this file:
|
||||
// - Case C: column is hidden explicitly by the user (e.g. via the context menu, or _DefaultHide column flag, etc.).
|
||||
//
|
||||
// [A] [B] [C]
|
||||
// TableNextColumn(): true false false -> [userland] when TableNextColumn() / TableSetColumnIndex() return false, user can skip submitting items but only if the column doesn't contribute to row height.
|
||||
// TableNextColumn(): true false false -> [userland] when TableNextColumn() / TableSetColumnIndex() returns false, user can skip submitting items but only if the column doesn't contribute to row height.
|
||||
// SkipItems: false false true -> [internal] when SkipItems is true, most widgets will early out if submitted, resulting is no layout output.
|
||||
// ClipRect: normal zero-width zero-width -> [internal] when ClipRect is zero, ItemAdd() will return false and most widgets will early out mid-way.
|
||||
// ImDrawList output: normal dummy dummy -> [internal] when using the dummy channel, ImDrawList submissions (if any) will be wasted (because cliprect is zero-width anyway).
|
||||
@ -319,7 +320,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
if (flags & ImGuiTableFlags_ScrollX)
|
||||
IM_ASSERT(inner_width >= 0.0f);
|
||||
|
||||
// If an outer size is specified ahead we will be able to early out when not visible. Exact clipping rules may evolve.
|
||||
// If an outer size is specified ahead we will be able to early out when not visible. Exact clipping criteria may evolve.
|
||||
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
|
||||
const ImVec2 avail_size = GetContentRegionAvail();
|
||||
ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f);
|
||||
@ -366,7 +367,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
IM_ASSERT(table->ColumnsCount == columns_count && "BeginTable(): Cannot change columns count mid-frame while preserving same ID");
|
||||
if (table->InstanceDataExtra.Size < instance_no)
|
||||
table->InstanceDataExtra.push_back(ImGuiTableInstanceData());
|
||||
instance_id = GetIDWithSeed(instance_no, GetIDWithSeed("##Instances", NULL, id)); // Push "##Instance" followed by (int)instance_no in ID stack.
|
||||
instance_id = GetIDWithSeed(instance_no, GetIDWithSeed("##Instances", NULL, id)); // Push "##Instances" followed by (int)instance_no in ID stack.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -477,7 +478,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
table->IsUnfrozenRows = true;
|
||||
table->DeclColumnsCount = 0;
|
||||
|
||||
// Using opaque colors facilitate overlapping elements of the grid
|
||||
// Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders()
|
||||
table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong);
|
||||
table->BorderColorLight = GetColorU32(ImGuiCol_TableBorderLight);
|
||||
|
||||
@ -491,7 +492,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
if ((table_last_flags & ImGuiTableFlags_Reorderable) && (flags & ImGuiTableFlags_Reorderable) == 0)
|
||||
table->IsResetDisplayOrderRequest = true;
|
||||
|
||||
// Mark as used
|
||||
// Mark as used to avoid GC
|
||||
if (table_idx >= g.TablesLastTimeActive.Size)
|
||||
g.TablesLastTimeActive.resize(table_idx + 1, -1.0f);
|
||||
g.TablesLastTimeActive[table_idx] = (float)g.Time;
|
||||
@ -584,13 +585,13 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
}
|
||||
|
||||
// For reference, the average total _allocation count_ for a table is:
|
||||
// + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables)
|
||||
// + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables[])
|
||||
// + 1 (for table->RawData allocated below)
|
||||
// + 1 (for table->ColumnsNames, if names are used)
|
||||
// Shared allocations per number of nested tables
|
||||
// Shared allocations for the maximum number of simultaneously nested tables (generally a very small number)
|
||||
// + 1 (for table->Splitter._Channels)
|
||||
// + 2 * active_channels_count (for ImDrawCmd and ImDrawIdx buffers inside channels)
|
||||
// Where active_channels_count is variable but often == columns_count or columns_count + 1, see TableSetupDrawChannels() for details.
|
||||
// Where active_channels_count is variable but often == columns_count or == columns_count + 1, see TableSetupDrawChannels() for details.
|
||||
// Unused channels don't perform their +2 allocations.
|
||||
void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count)
|
||||
{
|
||||
@ -617,7 +618,7 @@ void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count)
|
||||
void ImGui::TableBeginApplyRequests(ImGuiTable* table)
|
||||
{
|
||||
// Handle resizing request
|
||||
// (We process this at the first TableBegin of the frame)
|
||||
// (We process this in the TableBegin() of the first instance of each table)
|
||||
// FIXME-TABLE: Contains columns if our work area doesn't allow for scrolling?
|
||||
if (table->InstanceCurrent == 0)
|
||||
{
|
||||
@ -662,8 +663,7 @@ void ImGui::TableBeginApplyRequests(ImGuiTable* table)
|
||||
table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder -= (ImGuiTableColumnIdx)reorder_dir;
|
||||
IM_ASSERT(dst_column->DisplayOrder == dst_order - reorder_dir);
|
||||
|
||||
// Display order is stored in both columns->IndexDisplayOrder and table->DisplayOrder[],
|
||||
// rebuild the later from the former.
|
||||
// Display order is stored in both columns->IndexDisplayOrder and table->DisplayOrder[]. Rebuild later from the former.
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n;
|
||||
table->ReorderColumnDir = 0;
|
||||
@ -737,8 +737,8 @@ static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, I
|
||||
}
|
||||
}
|
||||
|
||||
// Layout columns for the frame. This is in essence the followup to BeginTable().
|
||||
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first.
|
||||
// Layout columns for the frame. This is in essence the followup to BeginTable() and this is our largest function.
|
||||
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() and other TableSetupXXXXX() functions to be called first.
|
||||
// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns.
|
||||
// Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution for _WidthAuto columns?
|
||||
void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
@ -859,8 +859,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
table->IsSettingsDirty = true;
|
||||
|
||||
// [Part 3] Fix column flags and record a few extra information.
|
||||
float sum_width_requests = 0.0f; // Sum of all width for fixed and auto-resize columns, excluding width contributed by Stretch columns but including spacing/padding.
|
||||
float stretch_sum_weights = 0.0f; // Sum of all weights for stretch columns.
|
||||
float sum_width_requests = 0.0f; // Sum of all width for fixed and auto-resize columns, excluding width contributed by Stretch columns but including spacing/padding.
|
||||
float stretch_sum_weights = 0.0f; // Sum of all weights for stretch columns.
|
||||
table->LeftMostStretchedColumn = table->RightMostStretchedColumn = -1;
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
@ -1145,7 +1145,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
// [Part 12] Sanitize and build sort specs before we have a change to use them for display.
|
||||
// [Part 12] Sanitize and build sort specs before we have a chance to use them for display.
|
||||
// This path will only be exercised when sort specs are modified before header rows (e.g. init or visibility change)
|
||||
if (table->IsSortSpecsDirty && (table->Flags & ImGuiTableFlags_Sortable))
|
||||
TableSortSpecsBuild(table);
|
||||
@ -1166,9 +1166,9 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||
}
|
||||
|
||||
// Process hit-testing on resizing borders. Actual size change will be applied in EndTable()
|
||||
// - Set table->HoveredColumnBorder with a short delay/timer to reduce feedback noise
|
||||
// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize widgets
|
||||
// overlapping the same area.
|
||||
// - Set table->HoveredColumnBorder with a short delay/timer to reduce visual feedback noise.
|
||||
// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize
|
||||
// widgets overlapping the same area.
|
||||
void ImGui::TableUpdateBorders(ImGuiTable* table)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -1643,7 +1643,7 @@ ImGuiID ImGui::TableGetColumnResizeID(ImGuiTable* table, int column_n, int insta
|
||||
return instance_id + 1 + column_n; // FIXME: #6140: still not ideal
|
||||
}
|
||||
|
||||
// Return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||
// Return -1 when table is not hovered. return columns_count if hovering the unused space at the right of the right-most visible column.
|
||||
int ImGui::TableGetHoveredColumn()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -1980,6 +1980,7 @@ bool ImGui::TableNextColumn()
|
||||
// FIXME-TABLE FIXME-OPT: Could probably shortcut some things for non-active or clipped columns.
|
||||
void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
ImGuiWindow* window = table->InnerWindow;
|
||||
table->CurrentColumn = column_n;
|
||||
@ -2004,7 +2005,6 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
||||
window->SkipItems = column->IsSkipItems;
|
||||
if (column->IsSkipItems)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.LastItemData.ID = 0;
|
||||
g.LastItemData.StatusFlags = 0;
|
||||
}
|
||||
@ -2023,7 +2023,6 @@ void ImGui::TableBeginCell(ImGuiTable* table, int column_n)
|
||||
}
|
||||
|
||||
// Logging
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.LogEnabled && !column->IsSkipItems)
|
||||
{
|
||||
LogRenderedText(&window->DC.CursorPos, "|");
|
||||
@ -2143,7 +2142,7 @@ void ImGui::TableSetColumnWidth(int column_n, float width)
|
||||
// - All stretch: easy.
|
||||
// - One or more fixed + one stretch: easy.
|
||||
// - One or more fixed + more than one stretch: tricky.
|
||||
// Qt when manual resize is enabled only support a single _trailing_ stretch column.
|
||||
// Qt when manual resize is enabled only supports a single _trailing_ stretch column, we support more cases here.
|
||||
|
||||
// When forwarding resize from Wn| to Fn+1| we need to be considerate of the _NoResize flag on Fn+1.
|
||||
// FIXME-TABLE: Find a way to rewrite all of this so interactions feel more consistent for the user.
|
||||
@ -2226,7 +2225,7 @@ void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table)
|
||||
{
|
||||
IM_ASSERT(table->LeftMostStretchedColumn != -1 && table->RightMostStretchedColumn != -1);
|
||||
|
||||
// Measure existing quantity
|
||||
// Measure existing quantities
|
||||
float visible_weight = 0.0f;
|
||||
float visible_width = 0.0f;
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
@ -2501,11 +2500,9 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table)
|
||||
merge_clip_rect.Max.x = ImMax(merge_clip_rect.Max.x, host_rect.Max.x);
|
||||
if ((merge_group_n & 2) != 0 && (table->Flags & ImGuiTableFlags_NoHostExtendY) == 0)
|
||||
merge_clip_rect.Max.y = ImMax(merge_clip_rect.Max.y, host_rect.Max.y);
|
||||
#if 0
|
||||
GetOverlayDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 0, 0, 200), 0.0f, 0, 1.0f);
|
||||
GetOverlayDrawList()->AddLine(merge_group->ClipRect.Min, merge_clip_rect.Min, IM_COL32(255, 100, 0, 200));
|
||||
GetOverlayDrawList()->AddLine(merge_group->ClipRect.Max, merge_clip_rect.Max, IM_COL32(255, 100, 0, 200));
|
||||
#endif
|
||||
//GetForegroundDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 0, 0, 200), 0.0f, 0, 1.0f); // [DEBUG]
|
||||
//GetForegroundDrawList()->AddLine(merge_group->ClipRect.Min, merge_clip_rect.Min, IM_COL32(255, 100, 0, 200));
|
||||
//GetForegroundDrawList()->AddLine(merge_group->ClipRect.Max, merge_clip_rect.Max, IM_COL32(255, 100, 0, 200));
|
||||
remaining_count -= merge_group->ChannelsCount;
|
||||
for (int n = 0; n < (size_for_masks_bitarrays_one >> 2); n++)
|
||||
remaining_mask[n] &= ~merge_group->ChannelsMask[n];
|
||||
@ -2669,7 +2666,6 @@ ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
|
||||
TableUpdateLayout(table);
|
||||
|
||||
TableSortSpecsBuild(table);
|
||||
|
||||
return &table->SortSpecs;
|
||||
}
|
||||
|
||||
@ -2788,7 +2784,7 @@ void ImGui::TableSortSpecsSanitize(ImGuiTable* table)
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback default sort order (if no column had the ImGuiTableColumnFlags_DefaultSort flag)
|
||||
// Fallback default sort order (if no column with the ImGuiTableColumnFlags_DefaultSort flag)
|
||||
if (sort_order_count == 0 && !(table->Flags & ImGuiTableFlags_SortTristate))
|
||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||
{
|
||||
@ -3479,12 +3475,12 @@ static void TableSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandle
|
||||
if (!save_column)
|
||||
continue;
|
||||
buf->appendf("Column %-2d", column_n);
|
||||
if (column->UserID != 0) buf->appendf(" UserID=%08X", column->UserID);
|
||||
if (save_size && column->IsStretch) buf->appendf(" Weight=%.4f", column->WidthOrWeight);
|
||||
if (save_size && !column->IsStretch) buf->appendf(" Width=%d", (int)column->WidthOrWeight);
|
||||
if (save_visible) buf->appendf(" Visible=%d", column->IsEnabled);
|
||||
if (save_order) buf->appendf(" Order=%d", column->DisplayOrder);
|
||||
if (save_sort && column->SortOrder != -1) buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^');
|
||||
if (column->UserID != 0) { buf->appendf(" UserID=%08X", column->UserID); }
|
||||
if (save_size && column->IsStretch) { buf->appendf(" Weight=%.4f", column->WidthOrWeight); }
|
||||
if (save_size && !column->IsStretch) { buf->appendf(" Width=%d", (int)column->WidthOrWeight); }
|
||||
if (save_visible) { buf->appendf(" Visible=%d", column->IsEnabled); }
|
||||
if (save_order) { buf->appendf(" Order=%d", column->DisplayOrder); }
|
||||
if (save_sort && column->SortOrder != -1) { buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^'); }
|
||||
buf->append("\n");
|
||||
}
|
||||
buf->append("\n");
|
||||
@ -3532,7 +3528,7 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table)
|
||||
IM_ASSERT(table->MemoryCompacted == false);
|
||||
table->SortSpecs.Specs = NULL;
|
||||
table->SortSpecsMulti.clear();
|
||||
table->IsSortSpecsDirty = true; // FIXME: shouldn't have to leak into user performing a sort
|
||||
table->IsSortSpecsDirty = true; // FIXME: In theory shouldn't have to leak into user performing a sort on resume.
|
||||
table->ColumnsNames.clear();
|
||||
table->MemoryCompacted = true;
|
||||
for (int n = 0; n < table->ColumnsCount; n++)
|
||||
|
38
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
38
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
@ -1392,8 +1392,9 @@ void ImGui::AlignTextToFramePadding()
|
||||
}
|
||||
|
||||
// Horizontal/vertical separating line
|
||||
// FIXME: Surprisingly, this seemingly simple widget is adjacent to MANY different legacy/tricky layout issues.
|
||||
void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
||||
// FIXME: Surprisingly, this seemingly trivial widget is a victim of many different legacy/tricky layout issues.
|
||||
// Note how thickness == 1.0f is handled specifically as not moving CursorPos by 'thickness', but other values are.
|
||||
void ImGui::SeparatorEx(ImGuiSeparatorFlags flags, float thickness)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
@ -1401,8 +1402,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected
|
||||
IM_ASSERT(thickness > 0.0f);
|
||||
|
||||
const float thickness = 1.0f; // Cannot use g.Style.SeparatorTextSize yet for various reasons.
|
||||
if (flags & ImGuiSeparatorFlags_Vertical)
|
||||
{
|
||||
// Vertical separator, for menu bars (use current line height).
|
||||
@ -1436,6 +1437,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
||||
x2 = table->Columns[table->CurrentColumn].MaxX;
|
||||
}
|
||||
|
||||
// Before Tables API happened, we relied on Separator() to span all columns of a Columns() set.
|
||||
// We currently don't need to provide the same feature for tables because tables naturally have border features.
|
||||
ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
|
||||
if (columns)
|
||||
PushColumnsBackground();
|
||||
@ -1445,8 +1448,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
||||
const float thickness_for_layout = (thickness == 1.0f) ? 0.0f : thickness; // FIXME: See 1.70/1.71 Separator() change: makes legacy 1-px separator not affect layout yet. Should change.
|
||||
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness));
|
||||
ItemSize(ImVec2(0.0f, thickness_for_layout));
|
||||
const bool item_visible = ItemAdd(bb, 0);
|
||||
if (item_visible)
|
||||
|
||||
if (ItemAdd(bb, 0))
|
||||
{
|
||||
// Draw
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator));
|
||||
@ -1469,10 +1472,11 @@ void ImGui::Separator()
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
// Those flags should eventually be overridable by the user
|
||||
// Those flags should eventually be configurable by the user
|
||||
// FIXME: We cannot g.Style.SeparatorTextBorderSize for thickness as it relates to SeparatorText() which is a decorated separator, not defaulting to 1.0f.
|
||||
ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
|
||||
flags |= ImGuiSeparatorFlags_SpanAllColumns; // NB: this only applies to legacy Columns() api as they relied on Separator() a lot.
|
||||
SeparatorEx(flags);
|
||||
SeparatorEx(flags, 1.0f);
|
||||
}
|
||||
|
||||
void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w)
|
||||
@ -1532,8 +1536,8 @@ void ImGui::SeparatorText(const char* label)
|
||||
return;
|
||||
|
||||
// The SeparatorText() vs SeparatorTextEx() distinction is designed to be considerate that we may want:
|
||||
// - allow headers to be draggable items (would require a stable ID + a noticeable highlight)
|
||||
// - this high-level entry point to allow formatting? (may require ID separate from formatted string)
|
||||
// - allow separator-text to be draggable items (would require a stable ID + a noticeable highlight)
|
||||
// - this high-level entry point to allow formatting? (which in turns may require ID separate from formatted string)
|
||||
// - because of this we probably can't turn 'const char* label' into 'const char* fmt, ...'
|
||||
// Otherwise, we can decide that users wanting to drag this would layout a dedicated drag-item,
|
||||
// and then we can turn this into a format function.
|
||||
@ -2090,7 +2094,8 @@ bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void
|
||||
memcpy(&data_backup, p_data, type_info->Size);
|
||||
|
||||
// Sanitize format
|
||||
// For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
|
||||
// - For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
|
||||
// - In theory could treat empty format as using default, but this would only cover rare/bizarre case of using InputScalar() + integer + format string without %.
|
||||
char format_sanitized[32];
|
||||
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
||||
format = type_info->ScanFmt;
|
||||
@ -3288,7 +3293,7 @@ const char* ImParseFormatFindEnd(const char* fmt)
|
||||
}
|
||||
|
||||
// Extract the format out of a format string with leading or trailing decorations
|
||||
// fmt = "blah blah" -> return fmt
|
||||
// fmt = "blah blah" -> return ""
|
||||
// fmt = "%.3f" -> return fmt
|
||||
// fmt = "hello %.3f" -> return fmt + 6
|
||||
// fmt = "%.3f hello" -> return buf written with "%.3f"
|
||||
@ -3296,7 +3301,7 @@ const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_
|
||||
{
|
||||
const char* fmt_start = ImParseFormatFindStart(fmt);
|
||||
if (fmt_start[0] != '%')
|
||||
return fmt;
|
||||
return "";
|
||||
const char* fmt_end = ImParseFormatFindEnd(fmt_start);
|
||||
if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data.
|
||||
return fmt_start;
|
||||
@ -3414,9 +3419,14 @@ static inline ImGuiInputTextFlags InputScalar_DefaultCharsFilter(ImGuiDataType d
|
||||
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
||||
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
|
||||
{
|
||||
// FIXME: May need to clarify display behavior if format doesn't contain %.
|
||||
// "%d" -> "%d" / "There are %d items" -> "%d" / "items" -> "%d" (fallback). Also see #6405
|
||||
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
|
||||
char fmt_buf[32];
|
||||
char data_buf[32];
|
||||
format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf));
|
||||
if (format[0] == 0)
|
||||
format = type_info->PrintFmt;
|
||||
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
|
||||
ImStrTrimBlanks(data_buf);
|
||||
|
||||
@ -3427,7 +3437,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||
{
|
||||
// Backup old value
|
||||
size_t data_type_size = DataTypeGetInfo(data_type)->Size;
|
||||
size_t data_type_size = type_info->Size;
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, data_type_size);
|
||||
|
||||
@ -6228,11 +6238,13 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open)
|
||||
{
|
||||
toggled = true;
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavMoveRequestCancel();
|
||||
}
|
||||
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority?
|
||||
{
|
||||
toggled = true;
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
NavMoveRequestCancel();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user