Internals: Move some Nav functions and members around (no functional change) + Misc comments
diff --git a/docs/README.md b/docs/README.md
index 97b7812..2bad5ca 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -114,19 +114,19 @@
Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page):
- Languages: C, C#/.Net, ChaiScript, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
-- Frameworks: Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/GameMakerStudio2, Irrlicht, Ogre, OpenFrameworks, OpenSceneGraph/OSG, ORX, px_render, LÖVE+Lua, Magnum, NanoRT, Qt, QtDirect3D, SFML, Software Rasterizers, Unreal Engine 4...
+- Frameworks: AGS/Adventure Game Studio, Amethyst, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, Irrlicht, Ogre, OpenFrameworks, OSG/OpenSceneGraph, ORX, px_render, LÖVE+Lua, Magnum, NanoRT, Qt, QtDirect3D, SFML, Software Rasterizers, Unreal Engine 4...
- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages.
Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
### Upcoming Changes
-Some of the goals for 2019-2020 are:
+Some of the goals for 2020 are:
- Finish work on docking, tabs. (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
- Finish work on multiple viewports / multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback)
- Finish work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787))
+- Finish work on new Tables API (to replace Columns). (see [#2957](https://github.com/ocornut/imgui/issues/2957))
- Add an automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435))
-- Make Columns better. They are currently pretty terrible! New Tables API coming Q4 2019!
- Make the examples look better, improve styles, improve font support, make the examples hi-DPI and multi-DPI aware.
### Gallery
diff --git a/examples/README.txt b/examples/README.txt
index a2655da..da05b05 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -106,7 +106,7 @@
imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl back-ends)
imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org
imgui_impl_win32.cpp ; Win32 native API (Windows)
- imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2019)
+ imgui_impl_glut.cpp ; GLUT/FreeGLUT (absolutely not recommended in 2020!)
List of Renderer Bindings in this repository:
diff --git a/examples/example_glut_opengl2/main.cpp b/examples/example_glut_opengl2/main.cpp
index 34c26db..03db3fc 100644
--- a/examples/example_glut_opengl2/main.cpp
+++ b/examples/example_glut_opengl2/main.cpp
@@ -2,7 +2,7 @@
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+// !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!!
// !!! Nowadays, prefer using GLFW or SDL instead!
#include "imgui.h"
diff --git a/examples/imgui_impl_glut.cpp b/examples/imgui_impl_glut.cpp
index 56d8c55..fe519d9 100644
--- a/examples/imgui_impl_glut.cpp
+++ b/examples/imgui_impl_glut.cpp
@@ -2,7 +2,7 @@
// This needs to be used along with a Renderer (e.g. OpenGL2)
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+// !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!!
// !!! Nowadays, prefer using GLFW or SDL instead!
// Issues:
diff --git a/examples/imgui_impl_glut.h b/examples/imgui_impl_glut.h
index 506c386..0c56120 100644
--- a/examples/imgui_impl_glut.h
+++ b/examples/imgui_impl_glut.h
@@ -2,7 +2,7 @@
// This needs to be used along with a Renderer (e.g. OpenGL2)
// !!! GLUT/FreeGLUT IS OBSOLETE SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!!
-// !!! If someone or something is teaching you GLUT in 2019, you are being abused. Please show some resistance. !!!
+// !!! If someone or something is teaching you GLUT in 2020, you are being abused. Please show some resistance. !!!
// !!! Nowadays, prefer using GLFW or SDL instead!
// Issues:
diff --git a/imgui.cpp b/imgui.cpp
index 6ef20da..bb94bdd 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -2754,27 +2754,6 @@
window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0;
}
-// FIXME-NAV: Refactor those functions into a single, more explicit one.
-void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(g.NavWindow);
- IM_ASSERT(nav_layer == 0 || nav_layer == 1);
- g.NavId = id;
- g.NavFocusScopeId = focus_scope_id;
- g.NavWindow->NavLastIds[nav_layer] = id;
-}
-
-void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
-{
- ImGuiContext& g = *GImGui;
- SetNavID(id, nav_layer, focus_scope_id);
- g.NavWindow->NavRectRel[nav_layer] = rect_rel;
- g.NavMousePosDirty = true;
- g.NavDisableHighlight = false;
- g.NavDisableMouseHover = true;
-}
-
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
@@ -2807,31 +2786,6 @@
g.ActiveIdUsingKeyInputMask = 0x00;
}
-// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
-void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
-{
- ImGuiContext& g = *GImGui;
- IM_ASSERT(id != 0);
-
- // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
- // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
- const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
- if (g.NavWindow != window)
- g.NavInitRequest = false;
- g.NavWindow = window;
- g.NavId = id;
- g.NavLayer = nav_layer;
- g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
- window->NavLastIds[nav_layer] = id;
- if (window->DC.LastItemId == id)
- window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
-
- if (g.ActiveIdSource == ImGuiInputSource_Nav)
- g.NavDisableMouseHover = true;
- else
- g.NavDisableHighlight = true;
-}
-
void ImGui::ClearActiveID()
{
SetActiveID(0, NULL);
@@ -2879,18 +2833,18 @@
// An active popup disable hovering on other windows (apart from its own children)
// FIXME-OPT: This could be cached/stored within the window.
ImGuiContext& g = *GImGui;
- if (g.NavWindow)
- if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
- if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
- {
- // For the purpose of those flags we differentiate "standard popup" from "modal popup"
- // NB: The order of those two tests is important because Modal windows are also Popups.
- if (focused_root_window->Flags & ImGuiWindowFlags_Modal)
- return false;
- if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
- return false;
- }
-
+ if (!g.NavWindow)
+ return false;
+ if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
+ if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
+ {
+ // For the purpose of those flags we differentiate "standard popup" from "modal popup"
+ // NB: The order of those two tests is important because Modal windows are also Popups.
+ if (focused_root_window->Flags & ImGuiWindowFlags_Modal)
+ return false;
+ if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
+ return false;
+ }
return true;
}
@@ -7860,6 +7814,52 @@
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
//-----------------------------------------------------------------------------
+// FIXME-NAV: The existance of SetNavID vs SetNavIDWithRectRel vs SetFocusID is incredibly messy and confusing,
+// and needs some explanation or serious refactoring.
+void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(g.NavWindow);
+ IM_ASSERT(nav_layer == 0 || nav_layer == 1);
+ g.NavId = id;
+ g.NavFocusScopeId = focus_scope_id;
+ g.NavWindow->NavLastIds[nav_layer] = id;
+}
+
+void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
+{
+ ImGuiContext& g = *GImGui;
+ SetNavID(id, nav_layer, focus_scope_id);
+ g.NavWindow->NavRectRel[nav_layer] = rect_rel;
+ g.NavMousePosDirty = true;
+ g.NavDisableHighlight = false;
+ g.NavDisableMouseHover = true;
+}
+
+void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
+{
+ ImGuiContext& g = *GImGui;
+ IM_ASSERT(id != 0);
+
+ // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
+ // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
+ const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
+ if (g.NavWindow != window)
+ g.NavInitRequest = false;
+ g.NavWindow = window;
+ g.NavId = id;
+ g.NavLayer = nav_layer;
+ g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
+ window->NavLastIds[nav_layer] = id;
+ if (window->DC.LastItemId == id)
+ window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
+
+ if (g.ActiveIdSource == ImGuiInputSource_Nav)
+ g.NavDisableMouseHover = true;
+ else
+ g.NavDisableHighlight = true;
+}
+
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
{
if (ImFabs(dx) > ImFabs(dy))
diff --git a/imgui.h b/imgui.h
index 1245ab1..3246816 100644
--- a/imgui.h
+++ b/imgui.h
@@ -595,7 +595,7 @@
// - You can also use SameLine(pos_x) to mimic simplified columns.
// - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!)
// - There is a maximum of 64 columns.
- // - By end of the 2019 we will expose a new 'Table' api which will replace columns.
+ // - Currently working on new 'Tables' api which will replace columns (see GitHub #2957)
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
IMGUI_API int GetColumnIndex(); // get current column index
diff --git a/imgui_internal.h b/imgui_internal.h
index 80453c9..e9c39d8 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1046,17 +1046,10 @@
ImGuiID NavJustTabbedId; // Just tabbed to this id.
ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest).
ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest).
-
ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
ImRect NavScoringRectScreen; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
int NavScoringCount; // Metrics for debugging
- ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed top-most.
- ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
- ImGuiWindow* NavWindowingList;
- float NavWindowingTimer;
- float NavWindowingHighlightAlpha;
- bool NavWindowingToggleLayer;
ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid
@@ -1078,6 +1071,14 @@
ImGuiNavMoveResult NavMoveResultLocalVisibleSet; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
ImGuiNavMoveResult NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
+ // Navigation: Windowing (CTRL+TAB, holding Menu button + directional pads to move/resize)
+ ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed top-most.
+ ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
+ ImGuiWindow* NavWindowingList;
+ float NavWindowingTimer;
+ float NavWindowingHighlightAlpha;
+ bool NavWindowingToggleLayer;
+
// Legacy Focus/Tabbing system (older than Nav, active even if Nav is disabled, misnamed. FIXME-NAV: This needs a redesign!)
ImGuiWindow* FocusRequestCurrWindow; //
ImGuiWindow* FocusRequestNextWindow; //
@@ -1221,9 +1222,6 @@
NavInputSource = ImGuiInputSource_None;
NavScoringRectScreen = ImRect();
NavScoringCount = 0;
- NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
- NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
- NavWindowingToggleLayer = false;
NavLayer = ImGuiNavLayer_Main;
NavIdTabCounter = INT_MAX;
NavIdIsAlive = false;
@@ -1240,6 +1238,10 @@
NavMoveRequestForward = ImGuiNavForward_None;
NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
+ NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
+ NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
+ NavWindowingToggleLayer = false;
+
FocusRequestCurrWindow = FocusRequestNextWindow = NULL;
FocusRequestCurrCounterRegular = FocusRequestCurrCounterTabStop = INT_MAX;
FocusRequestNextCounterRegular = FocusRequestNextCounterTabStop = INT_MAX;