From 74a1854db9a21d83f1c91681eb295ee05129a91f Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 17 Jul 2024 15:56:45 +0200 Subject: [PATCH] Nav, Demo: comments. --- imgui.cpp | 5 ++++- imgui_demo.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 605fae215..0f64254f2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1096,7 +1096,7 @@ CODE #endif // Debug options -#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL +#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Hold CTRL to display for all candidates. CTRL+Arrow to change last direction. #define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window // When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch. @@ -11716,6 +11716,9 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result) if (dbx != 0.0f || dby != 0.0f) { // For non-overlapping boxes, use distance between boxes + // FIXME-NAV: Quadrant may be incorrect because of (1) dbx bias and (2) curr.Max.y bias applied by NavBiasScoringRect() where typically curr.Max.y==curr.Min.y + // One typical case where this happens, with style.WindowMenuButtonPosition == ImGuiDir_Right, pressing Left to navigate from Close to Collapse tends to fail. + // Also see #6344. Calling ImGetDirQuadrantFromDelta() with unbiased values may be good but side-effects are plenty. dax = dbx; day = dby; dist_axial = dist_box; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 8f16e6c31..dd253454f 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -7793,6 +7793,7 @@ static ExampleTreeNode* ExampleTree_CreateNode(const char* name, const ImGuiID u return node; } +// Create example tree data static ExampleTreeNode* ExampleTree_CreateDemoTree() { static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" }; @@ -7826,6 +7827,7 @@ static ExampleTreeNode* ExampleTree_CreateDemoTree() // Some of the interactions are a bit lack-luster: // - We would want the table scrolling window to use NavFlattened. // - We would want pressing validating or leaving the filter to somehow restore focus. +// - We may want more advanced filtering (child nodes) and clipper support: both will need extra work. //----------------------------------------------------------------------------- struct ExampleAppPropertyEditor @@ -7835,13 +7837,12 @@ struct ExampleAppPropertyEditor void Draw(ExampleTreeNode* root_node) { ImGui::SetNextItemWidth(-FLT_MIN); - ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_F); + ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_F, ImGuiInputFlags_Tooltip); ImGui::PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true); if (ImGui::InputTextWithHint("##Filter", "incl,-excl", Filter.InputBuf, IM_ARRAYSIZE(Filter.InputBuf), ImGuiInputTextFlags_EscapeClearsAll)) Filter.Build(); ImGui::PopItemFlag(); - //ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 2)); ImGuiTableFlags table_flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg; if (ImGui::BeginTable("##split", 2, table_flags)) { @@ -7850,13 +7851,11 @@ struct ExampleAppPropertyEditor //ImGui::TableSetupScrollFreeze(0, 1); //ImGui::TableHeadersRow(); - // Filter root node for (ExampleTreeNode* node : root_node->Childs) - if (Filter.PassFilter(node->Name)) + if (Filter.PassFilter(node->Name)) // Filter root node DrawTreeNode(node); ImGui::EndTable(); } - //ImGui::PopStyleVar(); } void DrawTreeNode(ExampleTreeNode* node)