From b1a762cfa32d9599158cf0e04028fda34fe472d2 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 5 Aug 2022 21:19:12 +0200 Subject: [PATCH] Obsoleted using SetCursorPos()/SetCursorScreenPos() to extend parent window/cell boundaries. (#5548) This incorrect pattern has been mentioned or suggested in: #4510, #3355, #1760, #1490, #4152, #150 --- imgui.cpp | 5985 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 3415 insertions(+), 2570 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f90557907650..6e2550a7a025 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -854,12 +854,12 @@ CODE #include "imgui_internal.h" // System includes -#include // toupper -#include // vsnprintf, sscanf, printf +#include // toupper +#include // vsnprintf, sscanf, printf #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t +#include // intptr_t #else -#include // intptr_t +#include // intptr_t #endif // [Windows] On non-Visual Studio compilers, we default to IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS unless explicitly enabled @@ -879,7 +879,7 @@ CODE #define NOMINMAX #endif #ifndef __MINGW32__ -#include // _wfopen, OpenClipboard +#include // _wfopen, OpenClipboard #else #include #endif @@ -896,145 +896,145 @@ CODE // Visual Studio warnings #ifdef _MSC_VER -#pragma warning (disable: 4127) // condition expression is constant -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later -#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types +#pragma warning(disable : 4127) // condition expression is constant +#pragma warning(disable : 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen +#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later +#pragma warning(disable : 5054) // operator '|': deprecated between enumerations of different types #endif -#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). -#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6). -#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). +#pragma warning(disable : 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). +#pragma warning(disable : 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6). +#pragma warning(disable : 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). #endif // Clang/GCC warnings with -Weverything #if defined(__clang__) #if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! +#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! #endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. -#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. -#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. -#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. -#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is. -#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness -#pragma clang diagnostic ignored "-Wformat-pedantic" // warning: format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic. -#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning: cast to 'void *' from smaller integer type 'int' -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 -#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision +#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' +#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. +#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. +#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. +#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. +#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is. +#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness +#pragma clang diagnostic ignored "-Wformat-pedantic" // warning: format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic. +#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning: cast to 'void *' from smaller integer type 'int' +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 +#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. +#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision #elif defined(__GNUC__) // We disable -Wpragmas because GCC doesn't provide an has_warning equivalent and some forks/patches may not following the warning/version association. -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used -#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size -#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*' -#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function -#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value -#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked -#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead +#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind +#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size +#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*' +#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function +#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value +#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked +#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false +#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead #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_RECTS 0 // Display the reference navigation rectangle for each window -#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower) +#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_RECTS 0 // Display the reference navigation rectangle for each window +#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower) // 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. -static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in -static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear +static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in +static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear // Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend) -static const float WINDOWS_HOVER_PADDING = 4.0f; // Extend outside window for hovering/resizing (maxxed with TouchPadding) and inside windows for borders. Affect FindHoveredWindow(). -static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time. -static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved. +static const float WINDOWS_HOVER_PADDING = 4.0f; // Extend outside window for hovering/resizing (maxxed with TouchPadding) and inside windows for borders. Affect FindHoveredWindow(). +static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time. +static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved. // Docking -static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport. -static const float DOCKING_SPLITTER_SIZE = 2.0f; +static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport. +static const float DOCKING_SPLITTER_SIZE = 2.0f; //------------------------------------------------------------------------- // [SECTION] FORWARD DECLARATIONS //------------------------------------------------------------------------- -static void SetCurrentWindow(ImGuiWindow* window); -static void FindHoveredWindow(); -static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags); -static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window); +static void SetCurrentWindow(ImGuiWindow *window); +static void FindHoveredWindow(); +static ImGuiWindow *CreateNewWindow(const char *name, ImGuiWindowFlags flags); +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow *window); -static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list); -static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window); +static void AddDrawListToDrawData(ImVector *out_list, ImDrawList *draw_list); +static void AddWindowToSortBuffer(ImVector *out_sorted_windows, ImGuiWindow *window); // Settings -static void WindowSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*); -static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name); -static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line); -static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*); -static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf); +static void WindowSettingsHandler_ClearAll(ImGuiContext *, ImGuiSettingsHandler *); +static void *WindowSettingsHandler_ReadOpen(ImGuiContext *, ImGuiSettingsHandler *, const char *name); +static void WindowSettingsHandler_ReadLine(ImGuiContext *, ImGuiSettingsHandler *, void *entry, const char *line); +static void WindowSettingsHandler_ApplyAll(ImGuiContext *, ImGuiSettingsHandler *); +static void WindowSettingsHandler_WriteAll(ImGuiContext *, ImGuiSettingsHandler *, ImGuiTextBuffer *buf); // Platform Dependents default implementation for IO functions -static const char* GetClipboardTextFn_DefaultImpl(void* user_data); -static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text); -static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data); +static const char *GetClipboardTextFn_DefaultImpl(void *user_data); +static void SetClipboardTextFn_DefaultImpl(void *user_data, const char *text); +static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport *viewport, ImGuiPlatformImeData *data); namespace ImGui { -// Navigation -static void NavUpdate(); -static void NavUpdateWindowing(); -static void NavUpdateWindowingOverlay(); -static void NavUpdateCancelRequest(); -static void NavUpdateCreateMoveRequest(); -static void NavUpdateCreateTabbingRequest(); -static float NavUpdatePageUpPageDown(); -static inline void NavUpdateAnyRequestFlag(); -static void NavUpdateCreateWrappingRequest(); -static void NavEndFrame(); -static bool NavScoreItem(ImGuiNavItemData* result); -static void NavApplyItemToResult(ImGuiNavItemData* result); -static void NavProcessItem(); -static void NavProcessItemForTabbingRequest(ImGuiID id); -static ImVec2 NavCalcPreferredRefPos(); -static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window); -static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window); -static void NavRestoreLayer(ImGuiNavLayer layer); -static void NavRestoreHighlightAfterMove(); -static int FindWindowFocusIndex(ImGuiWindow* window); - -// Error Checking and Debug Tools -static void ErrorCheckNewFrameSanityChecks(); -static void ErrorCheckEndFrameSanityChecks(); -static void UpdateDebugToolItemPicker(); -static void UpdateDebugToolStackQueries(); - -// Misc -static void UpdateSettings(); -static void UpdateKeyboardInputs(); -static void UpdateMouseInputs(); -static void UpdateMouseWheel(); -static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect); -static void RenderWindowOuterBorders(ImGuiWindow* window); -static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size); -static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open); -static void RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 col); -static void RenderDimmedBackgrounds(); -static ImGuiWindow* FindBlockingModal(ImGuiWindow* window); - -// Viewports -const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter. -static ImGuiViewportP* AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& platform_pos, const ImVec2& size, ImGuiViewportFlags flags); -static void DestroyViewport(ImGuiViewportP* viewport); -static void UpdateViewportsNewFrame(); -static void UpdateViewportsEndFrame(); -static void WindowSelectViewport(ImGuiWindow* window); -static void WindowSyncOwnedViewport(ImGuiWindow* window, ImGuiWindow* parent_window_in_stack); -static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport); -static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window); -static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window); -static int FindPlatformMonitorForPos(const ImVec2& pos); -static int FindPlatformMonitorForRect(const ImRect& r); -static void UpdateViewportPlatformMonitor(ImGuiViewportP* viewport); + // Navigation + static void NavUpdate(); + static void NavUpdateWindowing(); + static void NavUpdateWindowingOverlay(); + static void NavUpdateCancelRequest(); + static void NavUpdateCreateMoveRequest(); + static void NavUpdateCreateTabbingRequest(); + static float NavUpdatePageUpPageDown(); + static inline void NavUpdateAnyRequestFlag(); + static void NavUpdateCreateWrappingRequest(); + static void NavEndFrame(); + static bool NavScoreItem(ImGuiNavItemData *result); + static void NavApplyItemToResult(ImGuiNavItemData *result); + static void NavProcessItem(); + static void NavProcessItemForTabbingRequest(ImGuiID id); + static ImVec2 NavCalcPreferredRefPos(); + static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow *nav_window); + static ImGuiWindow *NavRestoreLastChildNavWindow(ImGuiWindow *window); + static void NavRestoreLayer(ImGuiNavLayer layer); + static void NavRestoreHighlightAfterMove(); + static int FindWindowFocusIndex(ImGuiWindow *window); + + // Error Checking and Debug Tools + static void ErrorCheckNewFrameSanityChecks(); + static void ErrorCheckEndFrameSanityChecks(); + static void UpdateDebugToolItemPicker(); + static void UpdateDebugToolStackQueries(); + + // Misc + static void UpdateSettings(); + static void UpdateKeyboardInputs(); + static void UpdateMouseInputs(); + static void UpdateMouseWheel(); + static bool UpdateWindowManualResize(ImGuiWindow *window, const ImVec2 &size_auto_fit, int *border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect &visibility_rect); + static void RenderWindowOuterBorders(ImGuiWindow *window); + static void RenderWindowDecorations(ImGuiWindow *window, const ImRect &title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size); + static void RenderWindowTitleBarContents(ImGuiWindow *window, const ImRect &title_bar_rect, const char *name, bool *p_open); + static void RenderDimmedBackgroundBehindWindow(ImGuiWindow *window, ImU32 col); + static void RenderDimmedBackgrounds(); + static ImGuiWindow *FindBlockingModal(ImGuiWindow *window); + + // Viewports + const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter. + static ImGuiViewportP *AddUpdateViewport(ImGuiWindow *window, ImGuiID id, const ImVec2 &platform_pos, const ImVec2 &size, ImGuiViewportFlags flags); + static void DestroyViewport(ImGuiViewportP *viewport); + static void UpdateViewportsNewFrame(); + static void UpdateViewportsEndFrame(); + static void WindowSelectViewport(ImGuiWindow *window); + static void WindowSyncOwnedViewport(ImGuiWindow *window, ImGuiWindow *parent_window_in_stack); + static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow *window, ImGuiViewportP *host_viewport); + static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow *window); + static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow *window); + static int FindPlatformMonitorForPos(const ImVec2 &pos); + static int FindPlatformMonitorForRect(const ImRect &r); + static void UpdateViewportPlatformMonitor(ImGuiViewportP *viewport); } @@ -1063,22 +1063,41 @@ static void UpdateViewportPlatformMonitor(ImGuiViewportP* viewport); // - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from a different namespace. // - DLL users: read comments above. #ifndef GImGui -ImGuiContext* GImGui = NULL; +ImGuiContext *GImGui = NULL; #endif // Memory Allocator functions. Use SetAllocatorFunctions() to change them. // - You probably don't want to modify that mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction. // - DLL users: read comments above. #ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS -static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); } -static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); } +static void *MallocWrapper(size_t size, void *user_data) +{ + IM_UNUSED(user_data); + return malloc(size); +} +static void FreeWrapper(void *ptr, void *user_data) +{ + IM_UNUSED(user_data); + free(ptr); +} #else -static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; } -static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); } +static void *MallocWrapper(size_t size, void *user_data) +{ + IM_UNUSED(user_data); + IM_UNUSED(size); + IM_ASSERT(0); + return NULL; +} +static void FreeWrapper(void *ptr, void *user_data) +{ + IM_UNUSED(user_data); + IM_UNUSED(ptr); + IM_ASSERT(0); +} #endif -static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper; -static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper; -static void* GImAllocatorUserData = NULL; +static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper; +static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper; +static void *GImAllocatorUserData = NULL; //----------------------------------------------------------------------------- // [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) @@ -1086,46 +1105,46 @@ static void* GImAllocatorUserData = NULL; ImGuiStyle::ImGuiStyle() { - Alpha = 1.0f; // Global alpha applies to everything in Dear ImGui. - DisabledAlpha = 0.60f; // Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha. - WindowPadding = ImVec2(8,8); // Padding within a window - WindowRounding = 0.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended. - WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. - WindowMinSize = ImVec2(32,32); // Minimum window size - WindowTitleAlign = ImVec2(0.0f,0.5f);// Alignment for title bar text - WindowMenuButtonPosition= ImGuiDir_Left; // Position of the collapsing/docking button in the title bar (left/right). Defaults to ImGuiDir_Left. - ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows - ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. - PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows - PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. - FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets) - FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets). - FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. - ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines - ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) - CellPadding = ImVec2(4,2); // Padding within a table cell - TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! - IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). - ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). - ScrollbarSize = 14.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar - ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar - GrabMinSize = 12.0f; // Minimum width/height of a grab box for slider/scrollbar - GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. - LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. - TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. - TabBorderSize = 0.0f; // Thickness of border around tabs. - TabMinWidthForCloseButton = 0.0f; // Minimum width for close button to appears 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. - 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. - 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. - DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. - MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. - AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. - AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). - AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.). - CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. - CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. + Alpha = 1.0f; // Global alpha applies to everything in Dear ImGui. + DisabledAlpha = 0.60f; // Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha. + WindowPadding = ImVec2(8, 8); // Padding within a window + WindowRounding = 0.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended. + WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. + WindowMinSize = ImVec2(32, 32); // Minimum window size + WindowTitleAlign = ImVec2(0.0f, 0.5f); // Alignment for title bar text + WindowMenuButtonPosition = ImGuiDir_Left; // Position of the collapsing/docking button in the title bar (left/right). Defaults to ImGuiDir_Left. + ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows + ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. + PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows + PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. + FramePadding = ImVec2(4, 3); // Padding within a framed rectangle (used by most widgets) + FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets). + FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. + ItemSpacing = ImVec2(8, 4); // Horizontal and vertical spacing between widgets/lines + ItemInnerSpacing = ImVec2(4, 4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) + CellPadding = ImVec2(4, 2); // Padding within a table cell + TouchExtraPadding = ImVec2(0, 0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! + IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). + ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). + ScrollbarSize = 14.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar + ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar + GrabMinSize = 12.0f; // Minimum width/height of a grab box for slider/scrollbar + GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. + LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. + TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. + TabBorderSize = 0.0f; // Thickness of border around tabs. + TabMinWidthForCloseButton = 0.0f; // Minimum width for close button to appears 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. + 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. + 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. + DisplaySafeAreaPadding = ImVec2(3, 3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. + MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. + AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. + AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). + AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.). + CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. + CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. // Default theme ImGui::StyleColorsDark(this); @@ -1207,7 +1226,7 @@ ImGuiIO::ImGuiIO() // Miscellaneous options MouseDrawCursor = false; #ifdef __APPLE__ - ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag + ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag #else ConfigMacOSXBehaviors = false; #endif @@ -1222,7 +1241,7 @@ ImGuiIO::ImGuiIO() // Platform Functions BackendPlatformName = BackendRendererName = NULL; BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL; - GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations + GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; ClipboardUserData = NULL; SetPlatformImeDataFn = SetPlatformImeDataFn_DefaultImpl; @@ -1231,8 +1250,12 @@ ImGuiIO::ImGuiIO() MousePos = ImVec2(-FLT_MAX, -FLT_MAX); MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); MouseDragThreshold = 6.0f; - for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; - for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; } + for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) + MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; + for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) + { + KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; + } AppAcceptingEvents = true; BackendUsingLegacyKeyArrays = (ImS8)-1; BackendUsingLegacyNavInputArray = true; // assume using legacy array until proven wrong @@ -1244,7 +1267,7 @@ ImGuiIO::ImGuiIO() // FIXME: Should in theory be called "AddCharacterEvent()" to be consistent with new API void ImGuiIO::AddInputCharacter(unsigned int c) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); if (c == 0 || !AppAcceptingEvents) return; @@ -1292,7 +1315,7 @@ void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c) AddInputCharacter((unsigned)cp); } -void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) +void ImGuiIO::AddInputCharactersUTF8(const char *utf8_chars) { if (!AppAcceptingEvents) return; @@ -1317,8 +1340,8 @@ void ImGuiIO::ClearInputKeys() #endif for (int n = 0; n < IM_ARRAYSIZE(KeysData); n++) { - KeysData[n].Down = false; - KeysData[n].DownDuration = -1.0f; + KeysData[n].Down = false; + KeysData[n].DownDuration = -1.0f; KeysData[n].DownDurationPrev = -1.0f; } KeyCtrl = KeyShift = KeyAlt = KeySuper = false; @@ -1331,12 +1354,12 @@ void ImGuiIO::ClearInputKeys() // - float analog_value: 0.0f..1.0f void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value) { - //if (e->Down) { IMGUI_DEBUG_LOG_IO("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); } + // if (e->Down) { IMGUI_DEBUG_LOG_IO("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); } if (key == ImGuiKey_None || !AppAcceptingEvents) return; - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); - IM_ASSERT(ImGui::IsNamedKey(key)); // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API. + IM_ASSERT(ImGui::IsNamedKey(key)); // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API. IM_ASSERT(!ImGui::IsAliasKey(key)); // Backend cannot submit ImGuiKey_MouseXXX values they are automatically inferred from AddMouseXXX() events. // Verify that backend isn't mixing up using new io.AddKeyEvent() api and old io.KeysDown[] + io.KeyMap[] data. @@ -1351,7 +1374,7 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value) BackendUsingLegacyNavInputArray = false; // Partial filter of duplicates (not strictly needed, but makes data neater in particular for key mods and gamepad values which are most commonly spmamed) - ImGuiKeyData* key_data = ImGui::GetKeyData(key); + ImGuiKeyData *key_data = ImGui::GetKeyData(key); if (key_data->Down == down && key_data->AnalogValue == analog_value) { bool found = false; @@ -1386,10 +1409,10 @@ void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native { if (key == ImGuiKey_None) return; - IM_ASSERT(ImGui::IsNamedKey(key)); // >= 512 + IM_ASSERT(ImGui::IsNamedKey(key)); // >= 512 IM_ASSERT(native_legacy_index == -1 || ImGui::IsLegacyKey(native_legacy_index)); // >= 0 && <= 511 - IM_UNUSED(native_keycode); // Yet unused - IM_UNUSED(native_scancode); // Yet unused + IM_UNUSED(native_keycode); // Yet unused + IM_UNUSED(native_scancode); // Yet unused // Build native->imgui map so old user code can still call key functions with native 0..511 values. #ifndef IMGUI_DISABLE_OBSOLETE_KEYIO @@ -1413,7 +1436,7 @@ void ImGuiIO::SetAppAcceptingEvents(bool accepting_events) // Queue a mouse move event void ImGuiIO::AddMousePosEvent(float x, float y) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); if (!AppAcceptingEvents) return; @@ -1428,7 +1451,7 @@ void ImGuiIO::AddMousePosEvent(float x, float y) void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT); if (!AppAcceptingEvents) @@ -1445,7 +1468,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down) // Queue a mouse wheel event (most mouse/API will only have a Y component) void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); if ((wheel_x == 0.0f && wheel_y == 0.0f) || !AppAcceptingEvents) return; @@ -1460,7 +1483,7 @@ void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y) void ImGuiIO::AddMouseViewportEvent(ImGuiID viewport_id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); IM_ASSERT(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport); @@ -1473,7 +1496,7 @@ void ImGuiIO::AddMouseViewportEvent(ImGuiID viewport_id) void ImGuiIO::AddFocusEvent(bool focused) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(&g.IO == this && "Can only add events to current context."); ImGuiInputEvent e; @@ -1486,7 +1509,7 @@ void ImGuiIO::AddFocusEvent(bool focused) // [SECTION] MISC HELPERS/UTILITIES (Geometry functions) //----------------------------------------------------------------------------- -ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments) +ImVec2 ImBezierCubicClosestPoint(const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, const ImVec2 &p4, const ImVec2 &p, int num_segments) { IM_ASSERT(num_segments > 0); // Use ImBezierCubicClosestPointCasteljau() ImVec2 p_last = p1; @@ -1509,7 +1532,7 @@ ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec } // Closely mimics PathBezierToCasteljau() in imgui_draw.cpp -static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) +static void ImBezierCubicClosestPointCasteljauStep(const ImVec2 &p, ImVec2 &p_closest, ImVec2 &p_last, float &p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) { float dx = x4 - x1; float dy = y4 - y1; @@ -1531,12 +1554,12 @@ static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_cl } else if (level < 10) { - float x12 = (x1 + x2)*0.5f, y12 = (y1 + y2)*0.5f; - float x23 = (x2 + x3)*0.5f, y23 = (y2 + y3)*0.5f; - float x34 = (x3 + x4)*0.5f, y34 = (y3 + y4)*0.5f; - float x123 = (x12 + x23)*0.5f, y123 = (y12 + y23)*0.5f; - float x234 = (x23 + x34)*0.5f, y234 = (y23 + y34)*0.5f; - float x1234 = (x123 + x234)*0.5f, y1234 = (y123 + y234)*0.5f; + float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; + float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; + float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f; + float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; + float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f; + float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f; ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); } @@ -1544,7 +1567,7 @@ static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_cl // tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol // Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically. -ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol) +ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, const ImVec2 &p4, const ImVec2 &p, float tess_tol) { IM_ASSERT(tess_tol > 0.0f); ImVec2 p_last = p1; @@ -1554,7 +1577,7 @@ ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, co return p_closest; } -ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) +ImVec2 ImLineClosestPoint(const ImVec2 &a, const ImVec2 &b, const ImVec2 &p) { ImVec2 ap = p - a; ImVec2 ab_dir = b - a; @@ -1567,7 +1590,7 @@ ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) return a + ab_dir * dot / ab_len_sqr; } -bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) +bool ImTriangleContainsPoint(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, const ImVec2 &p) { bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f; bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f; @@ -1575,7 +1598,7 @@ bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, return ((b1 == b2) && (b2 == b3)); } -void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w) +void ImTriangleBarycentricCoords(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, const ImVec2 &p, float &out_u, float &out_v, float &out_w) { ImVec2 v0 = b - a; ImVec2 v1 = c - a; @@ -1586,7 +1609,7 @@ void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& out_u = 1.0f - out_v - out_w; } -ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) +ImVec2 ImTriangleClosestPoint(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, const ImVec2 &p) { ImVec2 proj_ab = ImLineClosestPoint(a, b, p); ImVec2 proj_bc = ImLineClosestPoint(b, c, p); @@ -1607,21 +1630,30 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, //----------------------------------------------------------------------------- // Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more. -int ImStricmp(const char* str1, const char* str2) +int ImStricmp(const char *str1, const char *str2) { int d; - while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } + while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) + { + str1++; + str2++; + } return d; } -int ImStrnicmp(const char* str1, const char* str2, size_t count) +int ImStrnicmp(const char *str1, const char *str2, size_t count) { int d = 0; - while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } + while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) + { + str1++; + str2++; + count--; + } return d; } -void ImStrncpy(char* dst, const char* src, size_t count) +void ImStrncpy(char *dst, const char *src, size_t count) { if (count < 1) return; @@ -1630,56 +1662,57 @@ void ImStrncpy(char* dst, const char* src, size_t count) dst[count - 1] = 0; } -char* ImStrdup(const char* str) +char *ImStrdup(const char *str) { size_t len = strlen(str); - void* buf = IM_ALLOC(len + 1); - return (char*)memcpy(buf, (const void*)str, len + 1); + void *buf = IM_ALLOC(len + 1); + return (char *)memcpy(buf, (const void *)str, len + 1); } -char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src) +char *ImStrdupcpy(char *dst, size_t *p_dst_size, const char *src) { size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1; size_t src_size = strlen(src) + 1; if (dst_buf_size < src_size) { IM_FREE(dst); - dst = (char*)IM_ALLOC(src_size); + dst = (char *)IM_ALLOC(src_size); if (p_dst_size) *p_dst_size = src_size; } - return (char*)memcpy(dst, (const void*)src, src_size); + return (char *)memcpy(dst, (const void *)src, src_size); } -const char* ImStrchrRange(const char* str, const char* str_end, char c) +const char *ImStrchrRange(const char *str, const char *str_end, char c) { - const char* p = (const char*)memchr(str, (int)c, str_end - str); + const char *p = (const char *)memchr(str, (int)c, str_end - str); return p; } -int ImStrlenW(const ImWchar* str) +int ImStrlenW(const ImWchar *str) { - //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bit + // return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bit int n = 0; - while (*str++) n++; + while (*str++) + n++; return n; } // Find end-of-line. Return pointer will point to either first \n, either str_end. -const char* ImStreolRange(const char* str, const char* str_end) +const char *ImStreolRange(const char *str, const char *str_end) { - const char* p = (const char*)memchr(str, '\n', str_end - str); + const char *p = (const char *)memchr(str, '\n', str_end - str); return p ? p : str_end; } -const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line +const ImWchar *ImStrbolW(const ImWchar *buf_mid_line, const ImWchar *buf_begin) // find beginning-of-line { while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n') buf_mid_line--; return buf_mid_line; } -const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) +const char *ImStristr(const char *haystack, const char *haystack_end, const char *needle, const char *needle_end) { if (!needle_end) needle_end = needle + strlen(needle); @@ -1689,8 +1722,8 @@ const char* ImStristr(const char* haystack, const char* haystack_end, const char { if (toupper(*haystack) == un0) { - const char* b = needle + 1; - for (const char* a = haystack + 1; b < needle_end; a++, b++) + const char *b = needle + 1; + for (const char *a = haystack + 1; b < needle_end; a++, b++) if (toupper(*a) != toupper(*b)) break; if (b == needle_end) @@ -1702,22 +1735,22 @@ const char* ImStristr(const char* haystack, const char* haystack_end, const char } // Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible. -void ImStrTrimBlanks(char* buf) +void ImStrTrimBlanks(char *buf) { - char* p = buf; - while (p[0] == ' ' || p[0] == '\t') // Leading blanks + char *p = buf; + while (p[0] == ' ' || p[0] == '\t') // Leading blanks p++; - char* p_start = p; - while (*p != 0) // Find end of string + char *p_start = p; + while (*p != 0) // Find end of string p++; - while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks + while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks p--; - if (p_start != buf) // Copy memory if we had leading blanks + if (p_start != buf) // Copy memory if we had leading blanks memmove(buf, p_start, p - p_start); - buf[p - p_start] = 0; // Zero terminate + buf[p - p_start] = 0; // Zero terminate } -const char* ImStrSkipBlank(const char* str) +const char *ImStrSkipBlank(const char *str) { while (str[0] == ' ' || str[0] == '\t') str++; @@ -1746,7 +1779,7 @@ const char* ImStrSkipBlank(const char* str) #define vsnprintf _vsnprintf #endif -int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) +int ImFormatString(char *buf, size_t buf_size, const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -1764,7 +1797,7 @@ int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) return w; } -int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) +int ImFormatStringV(char *buf, size_t buf_size, const char *fmt, va_list args) { #ifdef IMGUI_USE_STB_SPRINTF int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); @@ -1780,56 +1813,302 @@ int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) } #endif // #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS -void ImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end, const char* fmt, ...) +void ImFormatStringToTempBuffer(const char **out_buf, const char **out_buf_end, const char *fmt, ...) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; va_list args; va_start(args, fmt); int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); *out_buf = g.TempBuffer.Data; - if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; } + if (out_buf_end) + { + *out_buf_end = g.TempBuffer.Data + buf_len; + } va_end(args); } -void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args) +void ImFormatStringToTempBufferV(const char **out_buf, const char **out_buf_end, const char *fmt, va_list args) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args); *out_buf = g.TempBuffer.Data; - if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; } + if (out_buf_end) + { + *out_buf_end = g.TempBuffer.Data + buf_len; + } } // CRC32 needs a 1KB lookup table (not cache friendly) // Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily: // - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe. static const ImU32 GCrc32LookupTable[256] = -{ - 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91, - 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5, - 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59, - 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D, - 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01, - 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65, - 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9, - 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD, - 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1, - 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5, - 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79, - 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D, - 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21, - 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45, - 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9, - 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D, + { + 0x00000000, + 0x77073096, + 0xEE0E612C, + 0x990951BA, + 0x076DC419, + 0x706AF48F, + 0xE963A535, + 0x9E6495A3, + 0x0EDB8832, + 0x79DCB8A4, + 0xE0D5E91E, + 0x97D2D988, + 0x09B64C2B, + 0x7EB17CBD, + 0xE7B82D07, + 0x90BF1D91, + 0x1DB71064, + 0x6AB020F2, + 0xF3B97148, + 0x84BE41DE, + 0x1ADAD47D, + 0x6DDDE4EB, + 0xF4D4B551, + 0x83D385C7, + 0x136C9856, + 0x646BA8C0, + 0xFD62F97A, + 0x8A65C9EC, + 0x14015C4F, + 0x63066CD9, + 0xFA0F3D63, + 0x8D080DF5, + 0x3B6E20C8, + 0x4C69105E, + 0xD56041E4, + 0xA2677172, + 0x3C03E4D1, + 0x4B04D447, + 0xD20D85FD, + 0xA50AB56B, + 0x35B5A8FA, + 0x42B2986C, + 0xDBBBC9D6, + 0xACBCF940, + 0x32D86CE3, + 0x45DF5C75, + 0xDCD60DCF, + 0xABD13D59, + 0x26D930AC, + 0x51DE003A, + 0xC8D75180, + 0xBFD06116, + 0x21B4F4B5, + 0x56B3C423, + 0xCFBA9599, + 0xB8BDA50F, + 0x2802B89E, + 0x5F058808, + 0xC60CD9B2, + 0xB10BE924, + 0x2F6F7C87, + 0x58684C11, + 0xC1611DAB, + 0xB6662D3D, + 0x76DC4190, + 0x01DB7106, + 0x98D220BC, + 0xEFD5102A, + 0x71B18589, + 0x06B6B51F, + 0x9FBFE4A5, + 0xE8B8D433, + 0x7807C9A2, + 0x0F00F934, + 0x9609A88E, + 0xE10E9818, + 0x7F6A0DBB, + 0x086D3D2D, + 0x91646C97, + 0xE6635C01, + 0x6B6B51F4, + 0x1C6C6162, + 0x856530D8, + 0xF262004E, + 0x6C0695ED, + 0x1B01A57B, + 0x8208F4C1, + 0xF50FC457, + 0x65B0D9C6, + 0x12B7E950, + 0x8BBEB8EA, + 0xFCB9887C, + 0x62DD1DDF, + 0x15DA2D49, + 0x8CD37CF3, + 0xFBD44C65, + 0x4DB26158, + 0x3AB551CE, + 0xA3BC0074, + 0xD4BB30E2, + 0x4ADFA541, + 0x3DD895D7, + 0xA4D1C46D, + 0xD3D6F4FB, + 0x4369E96A, + 0x346ED9FC, + 0xAD678846, + 0xDA60B8D0, + 0x44042D73, + 0x33031DE5, + 0xAA0A4C5F, + 0xDD0D7CC9, + 0x5005713C, + 0x270241AA, + 0xBE0B1010, + 0xC90C2086, + 0x5768B525, + 0x206F85B3, + 0xB966D409, + 0xCE61E49F, + 0x5EDEF90E, + 0x29D9C998, + 0xB0D09822, + 0xC7D7A8B4, + 0x59B33D17, + 0x2EB40D81, + 0xB7BD5C3B, + 0xC0BA6CAD, + 0xEDB88320, + 0x9ABFB3B6, + 0x03B6E20C, + 0x74B1D29A, + 0xEAD54739, + 0x9DD277AF, + 0x04DB2615, + 0x73DC1683, + 0xE3630B12, + 0x94643B84, + 0x0D6D6A3E, + 0x7A6A5AA8, + 0xE40ECF0B, + 0x9309FF9D, + 0x0A00AE27, + 0x7D079EB1, + 0xF00F9344, + 0x8708A3D2, + 0x1E01F268, + 0x6906C2FE, + 0xF762575D, + 0x806567CB, + 0x196C3671, + 0x6E6B06E7, + 0xFED41B76, + 0x89D32BE0, + 0x10DA7A5A, + 0x67DD4ACC, + 0xF9B9DF6F, + 0x8EBEEFF9, + 0x17B7BE43, + 0x60B08ED5, + 0xD6D6A3E8, + 0xA1D1937E, + 0x38D8C2C4, + 0x4FDFF252, + 0xD1BB67F1, + 0xA6BC5767, + 0x3FB506DD, + 0x48B2364B, + 0xD80D2BDA, + 0xAF0A1B4C, + 0x36034AF6, + 0x41047A60, + 0xDF60EFC3, + 0xA867DF55, + 0x316E8EEF, + 0x4669BE79, + 0xCB61B38C, + 0xBC66831A, + 0x256FD2A0, + 0x5268E236, + 0xCC0C7795, + 0xBB0B4703, + 0x220216B9, + 0x5505262F, + 0xC5BA3BBE, + 0xB2BD0B28, + 0x2BB45A92, + 0x5CB36A04, + 0xC2D7FFA7, + 0xB5D0CF31, + 0x2CD99E8B, + 0x5BDEAE1D, + 0x9B64C2B0, + 0xEC63F226, + 0x756AA39C, + 0x026D930A, + 0x9C0906A9, + 0xEB0E363F, + 0x72076785, + 0x05005713, + 0x95BF4A82, + 0xE2B87A14, + 0x7BB12BAE, + 0x0CB61B38, + 0x92D28E9B, + 0xE5D5BE0D, + 0x7CDCEFB7, + 0x0BDBDF21, + 0x86D3D2D4, + 0xF1D4E242, + 0x68DDB3F8, + 0x1FDA836E, + 0x81BE16CD, + 0xF6B9265B, + 0x6FB077E1, + 0x18B74777, + 0x88085AE6, + 0xFF0F6A70, + 0x66063BCA, + 0x11010B5C, + 0x8F659EFF, + 0xF862AE69, + 0x616BFFD3, + 0x166CCF45, + 0xA00AE278, + 0xD70DD2EE, + 0x4E048354, + 0x3903B3C2, + 0xA7672661, + 0xD06016F7, + 0x4969474D, + 0x3E6E77DB, + 0xAED16A4A, + 0xD9D65ADC, + 0x40DF0B66, + 0x37D83BF0, + 0xA9BCAE53, + 0xDEBB9EC5, + 0x47B2CF7F, + 0x30B5FFE9, + 0xBDBDF21C, + 0xCABAC28A, + 0x53B39330, + 0x24B4A3A6, + 0xBAD03605, + 0xCDD70693, + 0x54DE5729, + 0x23D967BF, + 0xB3667A2E, + 0xC4614AB8, + 0x5D681B02, + 0x2A6F2B94, + 0xB40BBE37, + 0xC30C8EA1, + 0x5A05DF1B, + 0x2D02EF8D, }; // Known size hash // It is ok to call ImHashData on a string with known length but the ### operator won't be supported. // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. -ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed) +ImGuiID ImHashData(const void *data_p, size_t data_size, ImU32 seed) { ImU32 crc = ~seed; - const unsigned char* data = (const unsigned char*)data_p; - const ImU32* crc32_lut = GCrc32LookupTable; + const unsigned char *data = (const unsigned char *)data_p; + const ImU32 *crc32_lut = GCrc32LookupTable; while (data_size-- != 0) crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++]; return ~crc; @@ -1841,12 +2120,12 @@ ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed) // - If we reach ### in the string we discard the hash so far and reset to the seed. // - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build) // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. -ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed) +ImGuiID ImHashStr(const char *data_p, size_t data_size, ImU32 seed) { seed = ~seed; ImU32 crc = seed; - const unsigned char* data = (const unsigned char*)data_p; - const ImU32* crc32_lut = GCrc32LookupTable; + const unsigned char *data = (const unsigned char *)data_p; + const ImU32 *crc32_lut = GCrc32LookupTable; if (data_size != 0) { while (data_size-- != 0) @@ -1876,7 +2155,7 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed) // Default file functions #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS -ImFileHandle ImFileOpen(const char* filename, const char* mode) +ImFileHandle ImFileOpen(const char *filename, const char *mode) { #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__) // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. @@ -1885,25 +2164,29 @@ ImFileHandle ImFileOpen(const char* filename, const char* mode) const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); ImVector buf; buf.resize(filename_wsize + mode_wsize); - ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize); - ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize); - return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]); + ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t *)&buf[0], filename_wsize); + ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t *)&buf[filename_wsize], mode_wsize); + return ::_wfopen((const wchar_t *)&buf[0], (const wchar_t *)&buf[filename_wsize]); #else return fopen(filename, mode); #endif } // We should in theory be using fseeko()/ftello() with off_t and _fseeki64()/_ftelli64() with __int64, waiting for the PR that does that in a very portable pre-C++11 zero-warnings way. -bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } -ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; } -ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); } -ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); } +bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } +ImU64 ImFileGetSize(ImFileHandle f) +{ + long off = 0, sz = 0; + return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; +} +ImU64 ImFileRead(void *data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); } +ImU64 ImFileWrite(const void *data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); } #endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Helper: Load file content into memory // Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree() // This can't really be used with "rt" because fseek size won't match read size. -void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size, int padding_bytes) +void *ImFileLoadToMemory(const char *filename, const char *mode, size_t *out_file_size, int padding_bytes) { IM_ASSERT(filename && mode); if (out_file_size) @@ -1920,7 +2203,7 @@ void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_f return NULL; } - void* file_data = IM_ALLOC(file_size + padding_bytes); + void *file_data = IM_ALLOC(file_size + padding_bytes); if (file_data == NULL) { ImFileClose(f); @@ -1933,7 +2216,7 @@ void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_f return NULL; } if (padding_bytes > 0) - memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes); + memset((void *)(((char *)file_data) + file_size), 0, (size_t)padding_bytes); ImFileClose(f); if (out_file_size) @@ -1949,14 +2232,14 @@ void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_f // Convert UTF-8 to 32-bit character, process single character input. // A nearly-branchless UTF-8 decoder, based on work of Christopher Wellons (https://github.com/skeeto/branchless-utf8). // We handle UTF-8 decoding error by skipping forward. -int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) -{ - static const char lengths[32] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0 }; - static const int masks[] = { 0x00, 0x7f, 0x1f, 0x0f, 0x07 }; - static const uint32_t mins[] = { 0x400000, 0, 0x80, 0x800, 0x10000 }; - static const int shiftc[] = { 0, 18, 12, 6, 0 }; - static const int shifte[] = { 0, 6, 4, 2, 0 }; - int len = lengths[*(const unsigned char*)in_text >> 3]; +int ImTextCharFromUtf8(unsigned int *out_char, const char *in_text, const char *in_text_end) +{ + static const char lengths[32] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0}; + static const int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07}; + static const uint32_t mins[] = {0x400000, 0, 0x80, 0x800, 0x10000}; + static const int shiftc[] = {0, 18, 12, 6, 0}; + static const int shifte[] = {0, 6, 4, 2, 0}; + int len = lengths[*(const unsigned char *)in_text >> 3]; int wanted = len + !len; if (in_text_end == NULL) @@ -1971,20 +2254,20 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* s[3] = in_text + 3 < in_text_end ? in_text[3] : 0; // Assume a four-byte character and load four bytes. Unused bits are shifted out. - *out_char = (uint32_t)(s[0] & masks[len]) << 18; + *out_char = (uint32_t)(s[0] & masks[len]) << 18; *out_char |= (uint32_t)(s[1] & 0x3f) << 12; - *out_char |= (uint32_t)(s[2] & 0x3f) << 6; - *out_char |= (uint32_t)(s[3] & 0x3f) << 0; + *out_char |= (uint32_t)(s[2] & 0x3f) << 6; + *out_char |= (uint32_t)(s[3] & 0x3f) << 0; *out_char >>= shiftc[len]; // Accumulate the various error conditions. int e = 0; - e = (*out_char < mins[len]) << 6; // non-canonical encoding - e |= ((*out_char >> 11) == 0x1b) << 7; // surrogate half? - e |= (*out_char > IM_UNICODE_CODEPOINT_MAX) << 8; // out of range? + e = (*out_char < mins[len]) << 6; // non-canonical encoding + e |= ((*out_char >> 11) == 0x1b) << 7; // surrogate half? + e |= (*out_char > IM_UNICODE_CODEPOINT_MAX) << 8; // out of range? e |= (s[1] & 0xc0) >> 2; e |= (s[2] & 0xc0) >> 4; - e |= (s[3] ) >> 6; + e |= (s[3]) >> 6; e ^= 0x2a; // top two bits of each tail byte correct? e >>= shifte[len]; @@ -2001,10 +2284,10 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* return wanted; } -int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) +int ImTextStrFromUtf8(ImWchar *buf, int buf_size, const char *in_text, const char *in_text_end, const char **in_text_remaining) { - ImWchar* buf_out = buf; - ImWchar* buf_end = buf + buf_size; + ImWchar *buf_out = buf; + ImWchar *buf_end = buf + buf_size; while (buf_out < buf_end - 1 && (!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c; @@ -2019,7 +2302,7 @@ int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const cha return (int)(buf_out - buf); } -int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) +int ImTextCountCharsFromUtf8(const char *in_text, const char *in_text_end) { int char_count = 0; while ((!in_text_end || in_text < in_text_end) && *in_text) @@ -2034,7 +2317,7 @@ int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) } // Based on stb_to_utf8() from github.com/nothings/stb/ -static inline int ImTextCharToUtf8_inline(char* buf, int buf_size, unsigned int c) +static inline int ImTextCharToUtf8_inline(char *buf, int buf_size, unsigned int c) { if (c < 0x80) { @@ -2043,33 +2326,36 @@ static inline int ImTextCharToUtf8_inline(char* buf, int buf_size, unsigned int } if (c < 0x800) { - if (buf_size < 2) return 0; + if (buf_size < 2) + return 0; buf[0] = (char)(0xc0 + (c >> 6)); buf[1] = (char)(0x80 + (c & 0x3f)); return 2; } if (c < 0x10000) { - if (buf_size < 3) return 0; + if (buf_size < 3) + return 0; buf[0] = (char)(0xe0 + (c >> 12)); buf[1] = (char)(0x80 + ((c >> 6) & 0x3f)); - buf[2] = (char)(0x80 + ((c ) & 0x3f)); + buf[2] = (char)(0x80 + ((c)&0x3f)); return 3; } if (c <= 0x10FFFF) { - if (buf_size < 4) return 0; + if (buf_size < 4) + return 0; buf[0] = (char)(0xf0 + (c >> 18)); buf[1] = (char)(0x80 + ((c >> 12) & 0x3f)); buf[2] = (char)(0x80 + ((c >> 6) & 0x3f)); - buf[3] = (char)(0x80 + ((c ) & 0x3f)); + buf[3] = (char)(0x80 + ((c)&0x3f)); return 4; } // Invalid code point, the max unicode is 0x10FFFF return 0; } -const char* ImTextCharToUtf8(char out_buf[5], unsigned int c) +const char *ImTextCharToUtf8(char out_buf[5], unsigned int c) { int count = ImTextCharToUtf8_inline(out_buf, 5, c); out_buf[count] = 0; @@ -2077,7 +2363,7 @@ const char* ImTextCharToUtf8(char out_buf[5], unsigned int c) } // Not optimal but we very rarely use this function. -int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end) +int ImTextCountUtf8BytesFromChar(const char *in_text, const char *in_text_end) { unsigned int unused = 0; return ImTextCharFromUtf8(&unused, in_text, in_text_end); @@ -2085,17 +2371,21 @@ int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end) static inline int ImTextCountUtf8BytesFromChar(unsigned int c) { - if (c < 0x80) return 1; - if (c < 0x800) return 2; - if (c < 0x10000) return 3; - if (c <= 0x10FFFF) return 4; + if (c < 0x80) + return 1; + if (c < 0x800) + return 2; + if (c < 0x10000) + return 3; + if (c <= 0x10FFFF) + return 4; return 3; } -int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end) +int ImTextStrToUtf8(char *out_buf, int out_buf_size, const ImWchar *in_text, const ImWchar *in_text_end) { - char* buf_p = out_buf; - const char* buf_end = out_buf + out_buf_size; + char *buf_p = out_buf; + const char *buf_end = out_buf + out_buf_size; while (buf_p < buf_end - 1 && (!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c = (unsigned int)(*in_text++); @@ -2108,7 +2398,7 @@ int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, con return (int)(buf_p - out_buf); } -int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) +int ImTextCountUtf8BytesFromStr(const ImWchar *in_text, const ImWchar *in_text_end) { int bytes_count = 0; while ((!in_text_end || in_text < in_text_end) && *in_text) @@ -2146,10 +2436,10 @@ ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in) ((in >> IM_COL32_A_SHIFT) & 0xFF) * s); } -ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in) +ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4 &in) { ImU32 out; - out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT; + out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT; out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT; out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT; out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT; @@ -2158,7 +2448,7 @@ ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in) // Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592 // Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv -void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v) +void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float &out_h, float &out_s, float &out_v) { float K = 0.f; if (g < b) @@ -2180,7 +2470,7 @@ void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& // Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593 // also http://en.wikipedia.org/wiki/HSL_and_HSV -void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b) +void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float &out_r, float &out_g, float &out_b) { if (s == 0.0f) { @@ -2190,7 +2480,7 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& } h = ImFmod(h, 1.0f) / (60.0f / 360.0f); - int i = (int)h; + int i = (int)h; float f = h - (float)i; float p = v * (1.0f - s); float q = v * (1.0f - s * f); @@ -2198,12 +2488,37 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& switch (i) { - case 0: out_r = v; out_g = t; out_b = p; break; - case 1: out_r = q; out_g = v; out_b = p; break; - case 2: out_r = p; out_g = v; out_b = t; break; - case 3: out_r = p; out_g = q; out_b = v; break; - case 4: out_r = t; out_g = p; out_b = v; break; - case 5: default: out_r = v; out_g = p; out_b = q; break; + case 0: + out_r = v; + out_g = t; + out_b = p; + break; + case 1: + out_r = q; + out_g = v; + out_b = p; + break; + case 2: + out_r = p; + out_g = v; + out_b = t; + break; + case 3: + out_r = p; + out_g = q; + out_b = v; + break; + case 4: + out_r = t; + out_g = p; + out_b = v; + break; + case 5: + default: + out_r = v; + out_g = p; + out_b = q; + break; } } @@ -2213,15 +2528,15 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& //----------------------------------------------------------------------------- // std::lower_bound but without the bullshit -static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector& data, ImGuiID key) +static ImGuiStorage::ImGuiStoragePair *LowerBound(ImVector &data, ImGuiID key) { - ImGuiStorage::ImGuiStoragePair* first = data.Data; - ImGuiStorage::ImGuiStoragePair* last = data.Data + data.Size; + ImGuiStorage::ImGuiStoragePair *first = data.Data; + ImGuiStorage::ImGuiStoragePair *last = data.Data + data.Size; size_t count = (size_t)(last - first); while (count > 0) { size_t count2 = count >> 1; - ImGuiStorage::ImGuiStoragePair* mid = first + count2; + ImGuiStorage::ImGuiStoragePair *mid = first + count2; if (mid->key < key) { first = ++mid; @@ -2240,11 +2555,13 @@ void ImGuiStorage::BuildSortByKey() { struct StaticFunc { - static int IMGUI_CDECL PairComparerByID(const void* lhs, const void* rhs) + 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. - if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; - if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; + if (((const ImGuiStoragePair *)lhs)->key > ((const ImGuiStoragePair *)rhs)->key) + return +1; + if (((const ImGuiStoragePair *)lhs)->key < ((const ImGuiStoragePair *)rhs)->key) + return -1; return 0; } }; @@ -2253,7 +2570,7 @@ void ImGuiStorage::BuildSortByKey() int ImGuiStorage::GetInt(ImGuiID key, int default_val) const { - ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); + ImGuiStoragePair *it = LowerBound(const_cast &>(Data), key); if (it == Data.end() || it->key != key) return default_val; return it->val_i; @@ -2266,45 +2583,45 @@ bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const { - ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); + ImGuiStoragePair *it = LowerBound(const_cast &>(Data), key); if (it == Data.end() || it->key != key) return default_val; return it->val_f; } -void* ImGuiStorage::GetVoidPtr(ImGuiID key) const +void *ImGuiStorage::GetVoidPtr(ImGuiID key) const { - ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); + ImGuiStoragePair *it = LowerBound(const_cast &>(Data), key); if (it == Data.end() || it->key != key) return NULL; return it->val_p; } // References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. -int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) +int *ImGuiStorage::GetIntRef(ImGuiID key, int default_val) { - ImGuiStoragePair* it = LowerBound(Data, key); + ImGuiStoragePair *it = LowerBound(Data, key); if (it == Data.end() || it->key != key) it = Data.insert(it, ImGuiStoragePair(key, default_val)); return &it->val_i; } -bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) +bool *ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) { - return (bool*)GetIntRef(key, default_val ? 1 : 0); + return (bool *)GetIntRef(key, default_val ? 1 : 0); } -float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) +float *ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) { - ImGuiStoragePair* it = LowerBound(Data, key); + ImGuiStoragePair *it = LowerBound(Data, key); if (it == Data.end() || it->key != key) it = Data.insert(it, ImGuiStoragePair(key, default_val)); return &it->val_f; } -void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) +void **ImGuiStorage::GetVoidPtrRef(ImGuiID key, void *default_val) { - ImGuiStoragePair* it = LowerBound(Data, key); + ImGuiStoragePair *it = LowerBound(Data, key); if (it == Data.end() || it->key != key) it = Data.insert(it, ImGuiStoragePair(key, default_val)); return &it->val_p; @@ -2313,7 +2630,7 @@ void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) // FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame) void ImGuiStorage::SetInt(ImGuiID key, int val) { - ImGuiStoragePair* it = LowerBound(Data, key); + ImGuiStoragePair *it = LowerBound(Data, key); if (it == Data.end() || it->key != key) { Data.insert(it, ImGuiStoragePair(key, val)); @@ -2329,7 +2646,7 @@ void ImGuiStorage::SetBool(ImGuiID key, bool val) void ImGuiStorage::SetFloat(ImGuiID key, float val) { - ImGuiStoragePair* it = LowerBound(Data, key); + ImGuiStoragePair *it = LowerBound(Data, key); if (it == Data.end() || it->key != key) { Data.insert(it, ImGuiStoragePair(key, val)); @@ -2338,9 +2655,9 @@ void ImGuiStorage::SetFloat(ImGuiID key, float val) it->val_f = val; } -void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) +void ImGuiStorage::SetVoidPtr(ImGuiID key, void *val) { - ImGuiStoragePair* it = LowerBound(Data, key); + ImGuiStoragePair *it = LowerBound(Data, key); if (it == Data.end() || it->key != key) { Data.insert(it, ImGuiStoragePair(key, val)); @@ -2360,7 +2677,7 @@ void ImGuiStorage::SetAllInt(int v) //----------------------------------------------------------------------------- // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" -ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) //-V1077 +ImGuiTextFilter::ImGuiTextFilter(const char *default_filter) //-V1077 { InputBuf[0] = 0; CountGrep = 0; @@ -2371,7 +2688,7 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) //-V1077 } } -bool ImGuiTextFilter::Draw(const char* label, float width) +bool ImGuiTextFilter::Draw(const char *label, float width) { if (width != 0.0f) ImGui::SetNextItemWidth(width); @@ -2381,11 +2698,11 @@ bool ImGuiTextFilter::Draw(const char* label, float width) return value_changed; } -void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector* out) const +void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector *out) const { out->resize(0); - const char* wb = b; - const char* we = wb; + const char *wb = b; + const char *we = wb; while (we < e) { if (*we == separator) @@ -2408,7 +2725,7 @@ void ImGuiTextFilter::Build() CountGrep = 0; for (int i = 0; i != Filters.Size; i++) { - ImGuiTextRange& f = Filters[i]; + ImGuiTextRange &f = Filters[i]; while (f.b < f.e && ImCharIsBlankA(f.b[0])) f.b++; while (f.e > f.b && ImCharIsBlankA(f.e[-1])) @@ -2420,7 +2737,7 @@ void ImGuiTextFilter::Build() } } -bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const +bool ImGuiTextFilter::PassFilter(const char *text, const char *text_end) const { if (Filters.empty()) return true; @@ -2430,7 +2747,7 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const for (int i = 0; i != Filters.Size; i++) { - const ImGuiTextRange& f = Filters[i]; + const ImGuiTextRange &f = Filters[i]; if (f.empty()) continue; if (f.b[0] == '-') @@ -2468,9 +2785,9 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const #endif #endif -char ImGuiTextBuffer::EmptyString[1] = { 0 }; +char ImGuiTextBuffer::EmptyString[1] = {0}; -void ImGuiTextBuffer::append(const char* str, const char* str_end) +void ImGuiTextBuffer::append(const char *str, const char *str_end) { int len = str_end ? (int)(str_end - str) : (int)strlen(str); @@ -2488,7 +2805,7 @@ void ImGuiTextBuffer::append(const char* str, const char* str_end) Buf[write_off - 1 + len] = 0; } -void ImGuiTextBuffer::appendf(const char* fmt, ...) +void ImGuiTextBuffer::appendf(const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -2497,12 +2814,12 @@ void ImGuiTextBuffer::appendf(const char* fmt, ...) } // Helper: Text buffer for logging/accumulating text -void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) +void ImGuiTextBuffer::appendfv(const char *fmt, va_list args) { va_list args_copy; va_copy(args_copy, args); - int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. + int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. if (len <= 0) { va_end(args_copy); @@ -2533,7 +2850,7 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) // The problem we have is that without a Begin/End scheme for rows using the clipper is ambiguous. static bool GetSkipItemForListClipping() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return (g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems); } @@ -2541,10 +2858,10 @@ static bool GetSkipItemForListClipping() // Legacy helper to calculate coarse clipping of large list of evenly sized items. // This legacy API is not ideal because it assume we will return a single contiguous rectangle. // Prefer using ImGuiListClipper which can returns non-contiguous ranges. -void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end) +void ImGui::CalcListClipping(int items_count, float items_height, int *out_items_display_start, int *out_items_display_end) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (g.LogEnabled) { // If logging is active, do not perform any clipping @@ -2585,7 +2902,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items } #endif -static void ImGuiListClipper_SortAndFuseRanges(ImVector& ranges, int offset = 0) +static void ImGuiListClipper_SortAndFuseRanges(ImVector &ranges, int offset = 0) { if (ranges.Size - offset <= 1) return; @@ -2614,31 +2931,31 @@ static void ImGuiListClipper_SeekCursorAndSetupPrevLine(float pos_y, float line_ // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. // The clipper should probably have a final step to display the last item in a regular manner, maybe with an opt-out flag for data sets which may have costly seek? - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; float off_y = pos_y - window->DC.CursorPos.y; window->DC.CursorPos.y = pos_y; window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y - g.Style.ItemSpacing.y); - window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. - window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. - if (ImGuiOldColumns* columns = window->DC.CurrentColumns) - columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly - if (ImGuiTable* table = g.CurrentTable) + window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. + window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. + if (ImGuiOldColumns *columns = window->DC.CurrentColumns) + columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly + if (ImGuiTable *table = g.CurrentTable) { if (table->IsInsideRow) ImGui::TableEndRow(table); table->RowPosY2 = window->DC.CursorPos.y; const int row_increase = (int)((off_y / line_height) + 0.5f); - //table->CurrentRow += row_increase; // Can't do without fixing TableEndRow() + // table->CurrentRow += row_increase; // Can't do without fixing TableEndRow() table->RowBgColorCounter += row_increase; } } -static void ImGuiListClipper_SeekCursorForItem(ImGuiListClipper* clipper, int item_n) +static void ImGuiListClipper_SeekCursorForItem(ImGuiListClipper *clipper, int item_n) { // StartPosY starts from ItemsFrozen hence the subtraction // Perform the add and multiply with double to allow seeking through larger ranges - ImGuiListClipperData* data = (ImGuiListClipperData*)clipper->TempData; + ImGuiListClipperData *data = (ImGuiListClipperData *)clipper->TempData; float pos_y = (float)((double)clipper->StartPosY + data->LossynessOffset + (double)(item_n - data->ItemsFrozen) * clipper->ItemsHeight); ImGuiListClipper_SeekCursorAndSetupPrevLine(pos_y, clipper->ItemsHeight); } @@ -2656,11 +2973,11 @@ ImGuiListClipper::~ImGuiListClipper() void ImGuiListClipper::Begin(int items_count, float items_height) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IMGUI_DEBUG_LOG_CLIPPER("Clipper: Begin(%d,%.2f) in '%s'\n", items_count, items_height, window->Name); - if (ImGuiTable* table = g.CurrentTable) + if (ImGuiTable *table = g.CurrentTable) if (table->IsInsideRow) ImGui::TableEndRow(table); @@ -2673,7 +2990,7 @@ void ImGuiListClipper::Begin(int items_count, float items_height) // Acquire temporary buffer if (++g.ClipperTempDataStacked > g.ClipperTempData.Size) g.ClipperTempData.resize(g.ClipperTempDataStacked, ImGuiListClipperData()); - ImGuiListClipperData* data = &g.ClipperTempData[g.ClipperTempDataStacked - 1]; + ImGuiListClipperData *data = &g.ClipperTempData[g.ClipperTempDataStacked - 1]; data->Reset(this); data->LossynessOffset = window->DC.CursorStartPosLossyness.y; TempData = data; @@ -2681,8 +2998,8 @@ void ImGuiListClipper::Begin(int items_count, float items_height) void ImGuiListClipper::End() { - ImGuiContext& g = *GImGui; - if (ImGuiListClipperData* data = (ImGuiListClipperData*)TempData) + ImGuiContext &g = *GImGui; + if (ImGuiListClipperData *data = (ImGuiListClipperData *)TempData) { // In theory here we should assert that we are already at the right position, but it seems saner to just seek at the end and not assert/crash the user. IMGUI_DEBUG_LOG_CLIPPER("Clipper: End() in '%s'\n", g.CurrentWindow->Name); @@ -2704,21 +3021,21 @@ void ImGuiListClipper::End() void ImGuiListClipper::ForceDisplayRangeByIndices(int item_min, int item_max) { - ImGuiListClipperData* data = (ImGuiListClipperData*)TempData; + 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)); } -static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) +static bool ImGuiListClipper_StepInternal(ImGuiListClipper *clipper) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiListClipperData* data = (ImGuiListClipperData*)clipper->TempData; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + ImGuiListClipperData *data = (ImGuiListClipperData *)clipper->TempData; IM_ASSERT(data != NULL && "Called ImGuiListClipper::Step() too many times, or before ImGuiListClipper::Begin() ?"); - ImGuiTable* table = g.CurrentTable; + ImGuiTable *table = g.CurrentTable; if (table && table->IsInsideRow) ImGui::TableEndRow(table); @@ -2751,7 +3068,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) data->StepNo = 1; return true; } - calc_clipping = true; // If on the first step with known item height, calculate clipping. + calc_clipping = true; // If on the first step with known item height, calculate clipping. } // Step 1: Let the clipper infer height from first range @@ -2767,7 +3084,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) clipper->ItemsHeight = window->DC.PrevLineSize.y + g.Style.ItemSpacing.y; // FIXME: Technically wouldn't allow multi-line entries. 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. + calc_clipping = true; // If item height had to be calculated, calculate clipping afterwards. } // Step 0 or 1: Calculate the actual ranges of visible elements. @@ -2836,7 +3153,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper) bool ImGuiListClipper::Step() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; bool need_items_height = (ItemsHeight <= 0.0f); bool ret = ImGuiListClipper_StepInternal(this); if (ret && (DisplayStart == DisplayEnd)) @@ -2858,7 +3175,7 @@ bool ImGuiListClipper::Step() // [SECTION] STYLING //----------------------------------------------------------------------------- -ImGuiStyle& ImGui::GetStyle() +ImGuiStyle &ImGui::GetStyle() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); return GImGui->Style; @@ -2866,29 +3183,29 @@ ImGuiStyle& ImGui::GetStyle() ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul) { - ImGuiStyle& style = GImGui->Style; + ImGuiStyle &style = GImGui->Style; ImVec4 c = style.Colors[idx]; c.w *= style.Alpha * alpha_mul; return ColorConvertFloat4ToU32(c); } -ImU32 ImGui::GetColorU32(const ImVec4& col) +ImU32 ImGui::GetColorU32(const ImVec4 &col) { - ImGuiStyle& style = GImGui->Style; + ImGuiStyle &style = GImGui->Style; ImVec4 c = col; c.w *= style.Alpha; return ColorConvertFloat4ToU32(c); } -const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx) +const ImVec4 &ImGui::GetStyleColorVec4(ImGuiCol idx) { - ImGuiStyle& style = GImGui->Style; + ImGuiStyle &style = GImGui->Style; return style.Colors[idx]; } ImU32 ImGui::GetColorU32(ImU32 col) { - ImGuiStyle& style = GImGui->Style; + ImGuiStyle &style = GImGui->Style; if (style.Alpha >= 1.0f) return col; ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT; @@ -2899,7 +3216,7 @@ ImU32 ImGui::GetColorU32(ImU32 col) // FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32 void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiColorMod backup; backup.Col = idx; backup.BackupValue = g.Style.Colors[idx]; @@ -2907,9 +3224,9 @@ void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) g.Style.Colors[idx] = ColorConvertU32ToFloat4(col); } -void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) +void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4 &col) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiColorMod backup; backup.Col = idx; backup.BackupValue = g.Style.Colors[idx]; @@ -2919,7 +3236,7 @@ void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) void ImGui::PopStyleColor(int count) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.ColorStack.Size < count) { IM_ASSERT_USER_ERROR(g.ColorStack.Size > count, "Calling PopStyleColor() too many times: stack underflow."); @@ -2927,7 +3244,7 @@ void ImGui::PopStyleColor(int count) } while (count > 0) { - ImGuiColorMod& backup = g.ColorStack.back(); + ImGuiColorMod &backup = g.ColorStack.back(); g.Style.Colors[backup.Col] = backup.BackupValue; g.ColorStack.pop_back(); count--; @@ -2936,47 +3253,46 @@ void ImGui::PopStyleColor(int count) struct ImGuiStyleVarInfo { - ImGuiDataType Type; - ImU32 Count; - ImU32 Offset; - void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); } + ImGuiDataType Type; + ImU32 Count; + ImU32 Offset; + void *GetVarPtr(ImGuiStyle *style) const { return (void *)((unsigned char *)style + Offset); } }; static const ImGuiCol GWindowDockStyleColors[ImGuiWindowDockStyleCol_COUNT] = -{ - ImGuiCol_Text, ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive -}; + { + ImGuiCol_Text, ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive}; static const ImGuiStyleVarInfo GStyleVarInfo[] = -{ - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, DisabledAlpha) }, // ImGuiStyleVar_DisabledAlpha - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign + { + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha)}, // ImGuiStyleVar_Alpha + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, DisabledAlpha)}, // ImGuiStyleVar_DisabledAlpha + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding)}, // ImGuiStyleVar_WindowPadding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding)}, // ImGuiStyleVar_WindowRounding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize)}, // ImGuiStyleVar_WindowBorderSize + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize)}, // ImGuiStyleVar_WindowMinSize + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign)}, // ImGuiStyleVar_WindowTitleAlign + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding)}, // ImGuiStyleVar_ChildRounding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize)}, // ImGuiStyleVar_ChildBorderSize + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding)}, // ImGuiStyleVar_PopupRounding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize)}, // ImGuiStyleVar_PopupBorderSize + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding)}, // ImGuiStyleVar_FramePadding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding)}, // ImGuiStyleVar_FrameRounding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize)}, // ImGuiStyleVar_FrameBorderSize + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing)}, // ImGuiStyleVar_ItemSpacing + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing)}, // ImGuiStyleVar_ItemInnerSpacing + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing)}, // ImGuiStyleVar_IndentSpacing + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, CellPadding)}, // ImGuiStyleVar_CellPadding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize)}, // ImGuiStyleVar_ScrollbarSize + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding)}, // ImGuiStyleVar_ScrollbarRounding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize)}, // ImGuiStyleVar_GrabMinSize + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding)}, // ImGuiStyleVar_GrabRounding + {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding)}, // ImGuiStyleVar_TabRounding + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign)}, // ImGuiStyleVar_ButtonTextAlign + {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign)}, // ImGuiStyleVar_SelectableTextAlign }; -static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) +static const ImGuiStyleVarInfo *GetStyleVarInfo(ImGuiStyleVar idx) { IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT); IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT); @@ -2985,11 +3301,11 @@ static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) { - const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); + const ImGuiStyleVarInfo *var_info = GetStyleVarInfo(idx); if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) { - ImGuiContext& g = *GImGui; - float* pvar = (float*)var_info->GetVarPtr(&g.Style); + ImGuiContext &g = *GImGui; + float *pvar = (float *)var_info->GetVarPtr(&g.Style); g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar)); *pvar = val; return; @@ -2997,13 +3313,13 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!"); } -void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) +void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2 &val) { - const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); + const ImGuiStyleVarInfo *var_info = GetStyleVarInfo(idx); if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) { - ImGuiContext& g = *GImGui; - ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); + ImGuiContext &g = *GImGui; + ImVec2 *pvar = (ImVec2 *)var_info->GetVarPtr(&g.Style); g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar)); *pvar = val; return; @@ -3013,7 +3329,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) void ImGui::PopStyleVar(int count) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.StyleVarStack.Size < count) { IM_ASSERT_USER_ERROR(g.StyleVarStack.Size > count, "Calling PopStyleVar() too many times: stack underflow."); @@ -3022,82 +3338,143 @@ void ImGui::PopStyleVar(int count) while (count > 0) { // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it. - ImGuiStyleMod& backup = g.StyleVarStack.back(); - const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx); - void* data = info->GetVarPtr(&g.Style); - if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; } - else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; } + ImGuiStyleMod &backup = g.StyleVarStack.back(); + const ImGuiStyleVarInfo *info = GetStyleVarInfo(backup.VarIdx); + void *data = info->GetVarPtr(&g.Style); + if (info->Type == ImGuiDataType_Float && info->Count == 1) + { + ((float *)data)[0] = backup.BackupFloat[0]; + } + else if (info->Type == ImGuiDataType_Float && info->Count == 2) + { + ((float *)data)[0] = backup.BackupFloat[0]; + ((float *)data)[1] = backup.BackupFloat[1]; + } g.StyleVarStack.pop_back(); count--; } } -const char* ImGui::GetStyleColorName(ImGuiCol idx) +const char *ImGui::GetStyleColorName(ImGuiCol idx) { // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1"; switch (idx) { - case ImGuiCol_Text: return "Text"; - case ImGuiCol_TextDisabled: return "TextDisabled"; - case ImGuiCol_WindowBg: return "WindowBg"; - case ImGuiCol_ChildBg: return "ChildBg"; - case ImGuiCol_PopupBg: return "PopupBg"; - case ImGuiCol_Border: return "Border"; - case ImGuiCol_BorderShadow: return "BorderShadow"; - case ImGuiCol_FrameBg: return "FrameBg"; - case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; - case ImGuiCol_FrameBgActive: return "FrameBgActive"; - case ImGuiCol_TitleBg: return "TitleBg"; - case ImGuiCol_TitleBgActive: return "TitleBgActive"; - case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed"; - case ImGuiCol_MenuBarBg: return "MenuBarBg"; - case ImGuiCol_ScrollbarBg: return "ScrollbarBg"; - case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab"; - case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered"; - case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive"; - case ImGuiCol_CheckMark: return "CheckMark"; - case ImGuiCol_SliderGrab: return "SliderGrab"; - case ImGuiCol_SliderGrabActive: return "SliderGrabActive"; - case ImGuiCol_Button: return "Button"; - case ImGuiCol_ButtonHovered: return "ButtonHovered"; - case ImGuiCol_ButtonActive: return "ButtonActive"; - case ImGuiCol_Header: return "Header"; - case ImGuiCol_HeaderHovered: return "HeaderHovered"; - case ImGuiCol_HeaderActive: return "HeaderActive"; - case ImGuiCol_Separator: return "Separator"; - case ImGuiCol_SeparatorHovered: return "SeparatorHovered"; - case ImGuiCol_SeparatorActive: return "SeparatorActive"; - case ImGuiCol_ResizeGrip: return "ResizeGrip"; - case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered"; - case ImGuiCol_ResizeGripActive: return "ResizeGripActive"; - case ImGuiCol_Tab: return "Tab"; - case ImGuiCol_TabHovered: return "TabHovered"; - case ImGuiCol_TabActive: return "TabActive"; - case ImGuiCol_TabUnfocused: return "TabUnfocused"; - case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive"; - case ImGuiCol_DockingPreview: return "DockingPreview"; - case ImGuiCol_DockingEmptyBg: return "DockingEmptyBg"; - case ImGuiCol_PlotLines: return "PlotLines"; - case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered"; - case ImGuiCol_PlotHistogram: return "PlotHistogram"; - case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered"; - case ImGuiCol_TableHeaderBg: return "TableHeaderBg"; - case ImGuiCol_TableBorderStrong: return "TableBorderStrong"; - case ImGuiCol_TableBorderLight: return "TableBorderLight"; - case ImGuiCol_TableRowBg: return "TableRowBg"; - case ImGuiCol_TableRowBgAlt: return "TableRowBgAlt"; - case ImGuiCol_TextSelectedBg: return "TextSelectedBg"; - case ImGuiCol_DragDropTarget: return "DragDropTarget"; - case ImGuiCol_NavHighlight: return "NavHighlight"; - case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight"; - case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg"; - case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg"; + case ImGuiCol_Text: + return "Text"; + case ImGuiCol_TextDisabled: + return "TextDisabled"; + case ImGuiCol_WindowBg: + return "WindowBg"; + case ImGuiCol_ChildBg: + return "ChildBg"; + case ImGuiCol_PopupBg: + return "PopupBg"; + case ImGuiCol_Border: + return "Border"; + case ImGuiCol_BorderShadow: + return "BorderShadow"; + case ImGuiCol_FrameBg: + return "FrameBg"; + case ImGuiCol_FrameBgHovered: + return "FrameBgHovered"; + case ImGuiCol_FrameBgActive: + return "FrameBgActive"; + case ImGuiCol_TitleBg: + return "TitleBg"; + case ImGuiCol_TitleBgActive: + return "TitleBgActive"; + case ImGuiCol_TitleBgCollapsed: + return "TitleBgCollapsed"; + case ImGuiCol_MenuBarBg: + return "MenuBarBg"; + case ImGuiCol_ScrollbarBg: + return "ScrollbarBg"; + case ImGuiCol_ScrollbarGrab: + return "ScrollbarGrab"; + case ImGuiCol_ScrollbarGrabHovered: + return "ScrollbarGrabHovered"; + case ImGuiCol_ScrollbarGrabActive: + return "ScrollbarGrabActive"; + case ImGuiCol_CheckMark: + return "CheckMark"; + case ImGuiCol_SliderGrab: + return "SliderGrab"; + case ImGuiCol_SliderGrabActive: + return "SliderGrabActive"; + case ImGuiCol_Button: + return "Button"; + case ImGuiCol_ButtonHovered: + return "ButtonHovered"; + case ImGuiCol_ButtonActive: + return "ButtonActive"; + case ImGuiCol_Header: + return "Header"; + case ImGuiCol_HeaderHovered: + return "HeaderHovered"; + case ImGuiCol_HeaderActive: + return "HeaderActive"; + case ImGuiCol_Separator: + return "Separator"; + case ImGuiCol_SeparatorHovered: + return "SeparatorHovered"; + case ImGuiCol_SeparatorActive: + return "SeparatorActive"; + case ImGuiCol_ResizeGrip: + return "ResizeGrip"; + case ImGuiCol_ResizeGripHovered: + return "ResizeGripHovered"; + case ImGuiCol_ResizeGripActive: + return "ResizeGripActive"; + case ImGuiCol_Tab: + return "Tab"; + case ImGuiCol_TabHovered: + return "TabHovered"; + case ImGuiCol_TabActive: + return "TabActive"; + case ImGuiCol_TabUnfocused: + return "TabUnfocused"; + case ImGuiCol_TabUnfocusedActive: + return "TabUnfocusedActive"; + case ImGuiCol_DockingPreview: + return "DockingPreview"; + case ImGuiCol_DockingEmptyBg: + return "DockingEmptyBg"; + case ImGuiCol_PlotLines: + return "PlotLines"; + case ImGuiCol_PlotLinesHovered: + return "PlotLinesHovered"; + case ImGuiCol_PlotHistogram: + return "PlotHistogram"; + case ImGuiCol_PlotHistogramHovered: + return "PlotHistogramHovered"; + case ImGuiCol_TableHeaderBg: + return "TableHeaderBg"; + case ImGuiCol_TableBorderStrong: + return "TableBorderStrong"; + case ImGuiCol_TableBorderLight: + return "TableBorderLight"; + case ImGuiCol_TableRowBg: + return "TableRowBg"; + case ImGuiCol_TableRowBgAlt: + return "TableRowBgAlt"; + case ImGuiCol_TextSelectedBg: + return "TextSelectedBg"; + case ImGuiCol_DragDropTarget: + return "DragDropTarget"; + case ImGuiCol_NavHighlight: + return "NavHighlight"; + case ImGuiCol_NavWindowingHighlight: + return "NavWindowingHighlight"; + case ImGuiCol_NavWindowingDimBg: + return "NavWindowingDimBg"; + case ImGuiCol_ModalWindowDimBg: + return "ModalWindowDimBg"; } IM_ASSERT(0); return "Unknown"; } - //----------------------------------------------------------------------------- // [SECTION] RENDER HELPERS // Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change, @@ -3105,11 +3482,11 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx) // Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: context. //----------------------------------------------------------------------------- -const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) +const char *ImGui::FindRenderedTextEnd(const char *text, const char *text_end) { - const char* text_display_end = text; + const char *text_display_end = text; if (!text_end) - text_end = (const char*)-1; + text_end = (const char *)-1; while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) text_display_end++; @@ -3118,13 +3495,13 @@ const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) // Internal ImGui functions to render text // RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText() -void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash) +void ImGui::RenderText(ImVec2 pos, const char *text, const char *text_end, bool hide_text_after_hash) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; // Hide anything after a '##' string - const char* text_display_end; + const char *text_display_end; if (hide_text_after_hash) { text_display_end = FindRenderedTextEnd(text, text_end); @@ -3144,10 +3521,10 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool } } -void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) +void ImGui::RenderTextWrapped(ImVec2 pos, const char *text, const char *text_end, float wrap_width) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (!text_end) text_end = text + strlen(text); // FIXME-OPT @@ -3162,21 +3539,23 @@ void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end // Default clip_rect uses (pos_min,pos_max) // Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges) -void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) +void ImGui::RenderTextClippedEx(ImDrawList *draw_list, const ImVec2 &pos_min, const ImVec2 &pos_max, const char *text, const char *text_display_end, const ImVec2 *text_size_if_known, const ImVec2 &align, const ImRect *clip_rect) { // Perform CPU side clipping for single clipped element to avoid using scissor state ImVec2 pos = pos_min; const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f); - const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min; - const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max; + const ImVec2 *clip_min = clip_rect ? &clip_rect->Min : &pos_min; + const ImVec2 *clip_max = clip_rect ? &clip_rect->Max : &pos_max; bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y); if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y); // Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment. - if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x); - if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); + if (align.x > 0.0f) + pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x); + if (align.y > 0.0f) + pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); // Render if (need_clipping) @@ -3190,36 +3569,35 @@ void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, co } } -void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) +void ImGui::RenderTextClipped(const ImVec2 &pos_min, const ImVec2 &pos_max, const char *text, const char *text_end, const ImVec2 *text_size_if_known, const ImVec2 &align, const ImRect *clip_rect) { // Hide anything after a '##' string - const char* text_display_end = FindRenderedTextEnd(text, text_end); + const char *text_display_end = FindRenderedTextEnd(text, text_end); const int text_len = (int)(text_display_end - text); if (text_len == 0) return; - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect); if (g.LogEnabled) LogRenderedText(&pos_min, text, text_display_end); } - // Another overly complex function until we reorganize everything into a nice all-in-one helper. // This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display. // This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. -void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known) +void ImGui::RenderTextEllipsis(ImDrawList *draw_list, const ImVec2 &pos_min, const ImVec2 &pos_max, float clip_max_x, float ellipsis_max_x, const char *text, const char *text_end_full, const ImVec2 *text_size_if_known) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (text_end_full == NULL) text_end_full = FindRenderedTextEnd(text); const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f); - //draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255)); - //draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255)); - //draw_list->AddLine(ImVec2(clip_max_x, pos_min.y), ImVec2(clip_max_x, pos_max.y), IM_COL32(255, 0, 0, 255)); - // FIXME: We could technically remove (last_glyph->AdvanceX - last_glyph->X1) from text_size.x here and save a few pixels. + // draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255)); + // draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255)); + // draw_list->AddLine(ImVec2(clip_max_x, pos_min.y), ImVec2(clip_max_x, pos_max.y), IM_COL32(255, 0, 0, 255)); + // FIXME: We could technically remove (last_glyph->AdvanceX - last_glyph->X1) from text_size.x here and save a few pixels. if (text_size.x > pos_max.x - pos_min.x) { // Hello wo... @@ -3227,9 +3605,9 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con // min max ellipsis_max // <-> this is generally some padding value - const ImFont* font = draw_list->_Data->Font; + const ImFont *font = draw_list->_Data->Font; const float font_size = draw_list->_Data->FontSize; - const char* text_end_ellipsis = NULL; + const char *text_end_ellipsis = NULL; ImWchar ellipsis_char = font->EllipsisChar; int ellipsis_char_count = 1; @@ -3238,10 +3616,10 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con ellipsis_char = font->DotChar; ellipsis_char_count = 3; } - const ImFontGlyph* glyph = font->FindGlyph(ellipsis_char); + const ImFontGlyph *glyph = font->FindGlyph(ellipsis_char); - float ellipsis_glyph_width = glyph->X1; // Width of the glyph with no padding on either side - float ellipsis_total_width = ellipsis_glyph_width; // Full width of entire ellipsis + float ellipsis_glyph_width = glyph->X1; // Width of the glyph with no padding on either side + float ellipsis_total_width = ellipsis_glyph_width; // Full width of entire ellipsis if (ellipsis_char_count > 1) { @@ -3289,8 +3667,8 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con // Render a rectangle shaped with optional rounding and borders void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding); const float border_size = g.Style.FrameBorderSize; if (border && border_size > 0.0f) @@ -3302,8 +3680,8 @@ void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; const float border_size = g.Style.FrameBorderSize; if (border_size > 0.0f) { @@ -3312,14 +3690,14 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) } } -void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags) +void ImGui::RenderNavHighlight(const ImRect &bb, ImGuiID id, ImGuiNavHighlightFlags flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (id != g.NavId) return; if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw)) return; - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow *window = g.CurrentWindow; if (window->DC.NavHideHighlightOneFrame) return; @@ -3346,38 +3724,37 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT); - ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas; + ImFontAtlas *font_atlas = g.DrawListSharedData.Font->ContainerAtlas; for (int n = 0; n < g.Viewports.Size; n++) { // We scale cursor with current viewport/monitor, however Windows 10 for its own hardware cursor seems to be using a different scale factor. ImVec2 offset, size, uv[4]; if (!font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2])) continue; - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; const ImVec2 pos = base_pos - offset; const float scale = base_scale * viewport->DpiScale; if (!viewport->GetMainRect().Overlaps(ImRect(pos, pos + ImVec2(size.x + 2, size.y + 2) * scale))) continue; - ImDrawList* draw_list = GetForegroundDrawList(viewport); + ImDrawList *draw_list = GetForegroundDrawList(viewport); ImTextureID tex_id = font_atlas->TexID; draw_list->PushTextureID(tex_id); draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow); draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow); - draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border); - draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill); + draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border); + draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill); draw_list->PopTextureID(); } } - //----------------------------------------------------------------------------- // [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) //----------------------------------------------------------------------------- // ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods -ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst(NULL) +ImGuiWindow::ImGuiWindow(ImGuiContext *context, const char *name) : DrawListInst(NULL) { memset(this, 0, sizeof(*this)); Name = ImStrdup(name); @@ -3403,7 +3780,8 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst DrawList = &DrawListInst; DrawList->_Data = &context->DrawListSharedData; DrawList->_OwnerName = Name; - IM_PLACEMENT_NEW(&WindowClass) ImGuiWindowClass(); + IM_PLACEMENT_NEW(&WindowClass) + ImGuiWindowClass(); } ImGuiWindow::~ImGuiWindow() @@ -3413,21 +3791,21 @@ ImGuiWindow::~ImGuiWindow() ColumnsStorage.clear_destruct(); } -ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) +ImGuiID ImGuiWindow::GetID(const char *str, const char *str_end) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.DebugHookIdInfo == id) ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); return id; } -ImGuiID ImGuiWindow::GetID(const void* ptr) +ImGuiID ImGuiWindow::GetID(const void *ptr) { ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); - ImGuiContext& g = *GImGui; + ImGuiID id = ImHashData(&ptr, sizeof(void *), seed); + ImGuiContext &g = *GImGui; if (g.DebugHookIdInfo == id) ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL); return id; @@ -3437,14 +3815,14 @@ ImGuiID ImGuiWindow::GetID(int n) { ImGuiID seed = IDStack.back(); ImGuiID id = ImHashData(&n, sizeof(n), seed); - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); + ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void *)(intptr_t)n, NULL); return id; } // This is only used in rare/specific situations to manufacture an ID out of nowhere. -ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) +ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect &r_abs) { ImGuiID seed = IDStack.back(); ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs); @@ -3452,9 +3830,9 @@ ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) return id; } -static void SetCurrentWindow(ImGuiWindow* window) +static void SetCurrentWindow(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.CurrentWindow = window; g.CurrentTable = window && window->DC.CurrentTableIdx != -1 ? g.Tables.GetByIndex(window->DC.CurrentTableIdx) : NULL; if (window) @@ -3463,7 +3841,7 @@ static void SetCurrentWindow(ImGuiWindow* window) void ImGui::GcCompactTransientMiscBuffers() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.ItemFlagsStack.clear(); g.GroupStack.clear(); TableGcCompactSettings(); @@ -3473,7 +3851,7 @@ void ImGui::GcCompactTransientMiscBuffers() // Not freed: // - ImGuiWindow, ImGuiWindowSettings, Name, StateStorage, ColumnsStorage (may hold useful data) // This should have no noticeable visual effect. When the window reappear however, expect new allocation/buffer growth/copy cost. -void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window) +void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow *window) { window->MemoryCompacted = true; window->MemoryDrawListIdxCapacity = window->DrawList->IdxBuffer.Capacity; @@ -3485,7 +3863,7 @@ void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window) window->DC.TextWrapPosStack.clear(); } -void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window) +void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow *window) { // We stored capacity of the ImDrawList buffer to reduce growth-caused allocation/copy when awakening. // The other buffers tends to amortize much faster. @@ -3495,9 +3873,9 @@ void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window) window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0; } -void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) +void ImGui::SetActiveID(ImGuiID id, ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // While most behaved code would make an effort to not steal active id during window move/drag operations, // we at least need to be resilient to it. Cancelling the move is rather aggressive and users of 'master' branch @@ -3550,7 +3928,7 @@ void ImGui::ClearActiveID() void ImGui::SetHoveredID(ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.HoveredId = id; g.HoveredIdAllowOverlap = false; g.HoveredIdUsingMouseWheel = false; @@ -3560,7 +3938,7 @@ void ImGui::SetHoveredID(ImGuiID id) ImGuiID ImGui::GetHoveredID() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; } @@ -3568,7 +3946,7 @@ ImGuiID ImGui::GetHoveredID() // Code not using ItemAdd() may need to call this manually otherwise ActiveId will be cleared. In IMGUI_VERSION_NUM < 18717 this was called by GetID(). void ImGui::KeepAliveID(ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.ActiveId == id) g.ActiveIdIsAlive = id; if (g.ActiveIdPreviousFrame == id) @@ -3579,22 +3957,22 @@ void ImGui::MarkItemEdited(ImGuiID id) { // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit(). // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data. - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive); IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out. - //IM_ASSERT(g.CurrentWindow->DC.LastItemId == id); + // IM_ASSERT(g.CurrentWindow->DC.LastItemId == id); g.ActiveIdHasBeenEditedThisFrame = true; g.ActiveIdHasBeenEditedBefore = true; g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited; } -static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags) +static inline bool IsWindowContentHoverable(ImGuiWindow *window, ImGuiHoveredFlags flags) { // 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; + ImGuiContext &g = *GImGui; if (g.NavWindow) - if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindowDockTree) + if (ImGuiWindow *focused_root_window = g.NavWindow->RootWindowDockTree) if (focused_root_window->WasActive && focused_root_window != window->RootWindowDockTree) { // For the purpose of those flags we differentiate "standard popup" from "modal popup" @@ -3618,8 +3996,8 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla // - this should work even for non-interactive items that have no ID, so we cannot use LastItemId bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride)) { if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) @@ -3633,7 +4011,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags; if (!(status_flags & ImGuiItemStatusFlags_HoveredRect)) return false; - IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_DockHierarchy)) == 0); // Flags not supported by this function + IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_DockHierarchy)) == 0); // Flags not supported by this function // Test if we are hovering the right window (our window could be behind another window) // [2021/03/02] Reworked / reverted the revert, finally. Note we want e.g. BeginGroup/ItemAdd/EndGroup to work as well. (#3851) @@ -3688,13 +4066,13 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) } // Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). -bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) +bool ImGui::ItemHoverable(const ImRect &bb, ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) return false; - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow *window = g.CurrentWindow; if (g.HoveredWindow != window) return false; if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) @@ -3742,10 +4120,10 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) return true; } -bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id) +bool ImGui::IsClippedEx(const ImRect &bb, ImGuiID id) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (!bb.Overlaps(window->ClipRect)) if (id == 0 || (id != g.ActiveId && id != g.NavId)) if (!g.LogEnabled) @@ -3755,29 +4133,29 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id) // This is also inlined in ItemAdd() // Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect! -void ImGui::SetLastItemData(ImGuiID item_id, ImGuiItemFlags in_flags, ImGuiItemStatusFlags item_flags, const ImRect& item_rect) +void ImGui::SetLastItemData(ImGuiID item_id, ImGuiItemFlags in_flags, ImGuiItemStatusFlags item_flags, const ImRect &item_rect) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.LastItemData.ID = item_id; g.LastItemData.InFlags = in_flags; g.LastItemData.StatusFlags = item_flags; g.LastItemData.Rect = item_rect; } -float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) +float ImGui::CalcWrapWidthForPos(const ImVec2 &pos, float wrap_pos_x) { if (wrap_pos_x < 0.0f) return 0.0f; - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (wrap_pos_x == 0.0f) { // We could decide to setup a default wrapping max point for auto-resizing windows, // or have auto-wrap (with unspecified wrapping pos) behave as a ContentSize extending function? - //if (window->Hidden && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) + // if (window->Hidden && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) // wrap_pos_x = ImMax(window->WorkRect.Min.x + g.FontSize * 10.0f, window->WorkRect.Max.x); - //else + // else wrap_pos_x = window->WorkRect.Max.x; } else if (wrap_pos_x > 0.0f) @@ -3789,48 +4167,48 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) } // IM_ALLOC() == ImGui::MemAlloc() -void* ImGui::MemAlloc(size_t size) +void *ImGui::MemAlloc(size_t size) { - if (ImGuiContext* ctx = GImGui) + if (ImGuiContext *ctx = GImGui) ctx->IO.MetricsActiveAllocations++; return (*GImAllocatorAllocFunc)(size, GImAllocatorUserData); } // IM_FREE() == ImGui::MemFree() -void ImGui::MemFree(void* ptr) +void ImGui::MemFree(void *ptr) { if (ptr) - if (ImGuiContext* ctx = GImGui) + if (ImGuiContext *ctx = GImGui) ctx->IO.MetricsActiveAllocations--; return (*GImAllocatorFreeFunc)(ptr, GImAllocatorUserData); } -const char* ImGui::GetClipboardText() +const char *ImGui::GetClipboardText() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : ""; } -void ImGui::SetClipboardText(const char* text) +void ImGui::SetClipboardText(const char *text) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.IO.SetClipboardTextFn) g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text); } -const char* ImGui::GetVersion() +const char *ImGui::GetVersion() { return IMGUI_VERSION; } // Internal state access - if you want to share Dear ImGui state between modules (e.g. DLL) or allocate it yourself // Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module -ImGuiContext* ImGui::GetCurrentContext() +ImGuiContext *ImGui::GetCurrentContext() { return GImGui; } -void ImGui::SetCurrentContext(ImGuiContext* ctx) +void ImGui::SetCurrentContext(ImGuiContext *ctx) { #ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this. @@ -3839,7 +4217,7 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx) #endif } -void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data) +void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void *user_data) { GImAllocatorAllocFunc = alloc_func; GImAllocatorFreeFunc = free_func; @@ -3847,17 +4225,17 @@ void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc } // This is provided to facilitate copying allocators from one static/DLL boundary to another (e.g. retrieve default allocator of your executable address space) -void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func, ImGuiMemFreeFunc* p_free_func, void** p_user_data) +void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc *p_alloc_func, ImGuiMemFreeFunc *p_free_func, void **p_user_data) { *p_alloc_func = GImAllocatorAllocFunc; *p_free_func = GImAllocatorFreeFunc; *p_user_data = GImAllocatorUserData; } -ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas) +ImGuiContext *ImGui::CreateContext(ImFontAtlas *shared_font_atlas) { - ImGuiContext* prev_ctx = GetCurrentContext(); - ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas); + ImGuiContext *prev_ctx = GetCurrentContext(); + ImGuiContext *ctx = IM_NEW(ImGuiContext)(shared_font_atlas); SetCurrentContext(ctx); Initialize(); if (prev_ctx != NULL) @@ -3865,9 +4243,9 @@ ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas) return ctx; } -void ImGui::DestroyContext(ImGuiContext* ctx) +void ImGui::DestroyContext(ImGuiContext *ctx) { - ImGuiContext* prev_ctx = GetCurrentContext(); + ImGuiContext *prev_ctx = GetCurrentContext(); if (ctx == NULL) //-V1051 ctx = prev_ctx; SetCurrentContext(ctx); @@ -3877,9 +4255,9 @@ void ImGui::DestroyContext(ImGuiContext* ctx) } // No specific ordering/dependency support, will see as needed -ImGuiID ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook) +ImGuiID ImGui::AddContextHook(ImGuiContext *ctx, const ImGuiContextHook *hook) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; IM_ASSERT(hook->Callback != NULL && hook->HookId == 0 && hook->Type != ImGuiContextHookType_PendingRemoval_); g.Hooks.push_back(*hook); g.Hooks.back().HookId = ++g.HookIdNext; @@ -3887,9 +4265,9 @@ ImGuiID ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook) } // Deferred removal, avoiding issue with changing vector while iterating it -void ImGui::RemoveContextHook(ImGuiContext* ctx, ImGuiID hook_id) +void ImGui::RemoveContextHook(ImGuiContext *ctx, ImGuiID hook_id) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; IM_ASSERT(hook_id != 0); for (int n = 0; n < g.Hooks.Size; n++) if (g.Hooks[n].HookId == hook_id) @@ -3898,31 +4276,31 @@ void ImGui::RemoveContextHook(ImGuiContext* ctx, ImGuiID hook_id) // Call context hooks (used by e.g. test engine) // We assume a small number of hooks so all stored in same array -void ImGui::CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType hook_type) +void ImGui::CallContextHooks(ImGuiContext *ctx, ImGuiContextHookType hook_type) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; for (int n = 0; n < g.Hooks.Size; n++) if (g.Hooks[n].Type == hook_type) g.Hooks[n].Callback(&g, &g.Hooks[n]); } -ImGuiIO& ImGui::GetIO() +ImGuiIO &ImGui::GetIO() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); return GImGui->IO; } -ImGuiPlatformIO& ImGui::GetPlatformIO() +ImGuiPlatformIO &ImGui::GetPlatformIO() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?"); return GImGui->PlatformIO; } // Pass this to your backend rendering function! Valid after Render() and until the next call to NewFrame() -ImDrawData* ImGui::GetDrawData() +ImDrawData *ImGui::GetDrawData() { - ImGuiContext& g = *GImGui; - ImGuiViewportP* viewport = g.Viewports[0]; + ImGuiContext &g = *GImGui; + ImGuiViewportP *viewport = g.Viewports[0]; return viewport->DrawDataP.Valid ? &viewport->DrawDataP : NULL; } @@ -3936,12 +4314,12 @@ int ImGui::GetFrameCount() return GImGui->FrameCount; } -static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist_no, const char* drawlist_name) +static ImDrawList *GetViewportDrawList(ImGuiViewportP *viewport, size_t drawlist_no, const char *drawlist_name) { // Create the draw list on demand, because they are not frequently used for all viewports - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(drawlist_no < IM_ARRAYSIZE(viewport->DrawLists)); - ImDrawList* draw_list = viewport->DrawLists[drawlist_no]; + ImDrawList *draw_list = viewport->DrawLists[drawlist_no]; if (draw_list == NULL) { draw_list = IM_NEW(ImDrawList)(&g.DrawListSharedData); @@ -3960,39 +4338,39 @@ static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist return draw_list; } -ImDrawList* ImGui::GetBackgroundDrawList(ImGuiViewport* viewport) +ImDrawList *ImGui::GetBackgroundDrawList(ImGuiViewport *viewport) { - return GetViewportDrawList((ImGuiViewportP*)viewport, 0, "##Background"); + return GetViewportDrawList((ImGuiViewportP *)viewport, 0, "##Background"); } -ImDrawList* ImGui::GetBackgroundDrawList() +ImDrawList *ImGui::GetBackgroundDrawList() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return GetBackgroundDrawList(g.CurrentWindow->Viewport); } -ImDrawList* ImGui::GetForegroundDrawList(ImGuiViewport* viewport) +ImDrawList *ImGui::GetForegroundDrawList(ImGuiViewport *viewport) { - return GetViewportDrawList((ImGuiViewportP*)viewport, 1, "##Foreground"); + return GetViewportDrawList((ImGuiViewportP *)viewport, 1, "##Foreground"); } -ImDrawList* ImGui::GetForegroundDrawList() +ImDrawList *ImGui::GetForegroundDrawList() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return GetForegroundDrawList(g.CurrentWindow->Viewport); } -ImDrawListSharedData* ImGui::GetDrawListSharedData() +ImDrawListSharedData *ImGui::GetDrawListSharedData() { return &GImGui->DrawListSharedData; } -void ImGui::StartMouseMovingWindow(ImGuiWindow* window) +void ImGui::StartMouseMovingWindow(ImGuiWindow *window) { // Set ActiveId even if the _NoMove flag is set. Without it, dragging away from a window with _NoMove would activate hover on other windows. // We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward. // This is because we want ActiveId to be set even when the window is not permitted to move. - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; FocusWindow(window); SetActiveID(window->MoveId, window); g.NavDisableHighlight = true; @@ -4003,7 +4381,7 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window) bool can_move_window = true; if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindowDockTree->Flags & ImGuiWindowFlags_NoMove)) can_move_window = false; - if (ImGuiDockNode* node = window->DockNodeAsHost) + if (ImGuiDockNode *node = window->DockNodeAsHost) if (node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove)) can_move_window = false; if (can_move_window) @@ -4013,17 +4391,17 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window) // We use 'undock_floating_node == false' when dragging from title bar to allow moving groups of floating nodes without undocking them. // - undock_floating_node == true: when dragging from a floating node within a hierarchy, always undock the node. // - undock_floating_node == false: when dragging from a floating node within a hierarchy, move root window. -void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* node, bool undock_floating_node) +void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow *window, ImGuiDockNode *node, bool undock_floating_node) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; bool can_undock_node = false; if (node != NULL && node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove) == 0) { // Can undock if: // - part of a floating node hierarchy with more than one visible node (if only one is visible, we'll just move the whole hierarchy) // - part of a dockspace node hierarchy (trivia: undocking from a fixed/central node will create a new node and copy windows) - ImGuiDockNode* root_node = DockNodeGetRootNode(node); - if (root_node->OnlyNodeWithWindows != node || root_node->CentralNode != NULL) // -V1051 PVS-Studio thinks node should be root_node and is wrong about that. + ImGuiDockNode *root_node = DockNodeGetRootNode(node); + if (root_node->OnlyNodeWithWindows != node || root_node->CentralNode != NULL) // -V1051 PVS-Studio thinks node should be root_node and is wrong about that. if (undock_floating_node || root_node->IsDockSpace()) can_undock_node = true; } @@ -4043,14 +4421,14 @@ void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* nod // but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other. void ImGui::UpdateMouseMovingWindowNewFrame() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.MovingWindow != NULL) { // We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window). // We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency. KeepAliveID(g.ActiveId); IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindowDockTree); - ImGuiWindow* moving_window = g.MovingWindow->RootWindowDockTree; + ImGuiWindow *moving_window = g.MovingWindow->RootWindowDockTree; // When a window stop being submitted while being dragged, it may will its viewport until next Begin() const bool window_disappared = ((!moving_window->WasActive && !moving_window->Active) || moving_window->Viewport == NULL); @@ -4105,7 +4483,7 @@ void ImGui::UpdateMouseMovingWindowNewFrame() // Handle left-click and right-click focus. void ImGui::UpdateMouseMovingWindowEndFrame() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.ActiveId != 0 || g.HoveredId != 0) return; @@ -4119,7 +4497,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame() { // Handle the edge case of a popup being closed while clicking in its empty space. // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more. - ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; + ImGuiWindow *root_window = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel); if (root_window != NULL && !is_closed_popup) @@ -4150,7 +4528,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame() { // Find the top-most window between HoveredWindow and the top-most Modal Window. // This is where we can trim the popup stack. - ImGuiWindow* modal = GetTopMostPopupModal(); + ImGuiWindow *modal = GetTopMostPopupModal(); bool hovered_window_above_modal = g.HoveredWindow && (modal == NULL || IsWindowAbove(g.HoveredWindow, modal)); ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true); } @@ -4158,7 +4536,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame() // This is called during NewFrame()->UpdateViewportsNewFrame() only. // Need to keep in sync with SetWindowPos() -static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta) +static void TranslateWindow(ImGuiWindow *window, const ImVec2 &delta) { window->Pos += delta; window->ClipRect.Translate(delta); @@ -4170,7 +4548,7 @@ static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta) window->DC.IdealMaxPos += delta; } -static void ScaleWindow(ImGuiWindow* window, float scale) +static void ScaleWindow(ImGuiWindow *window, float scale) { ImVec2 origin = window->Viewport->Pos; window->Pos = ImFloor((window->Pos - origin) * scale + origin); @@ -4179,7 +4557,7 @@ static void ScaleWindow(ImGuiWindow* window, float scale) window->ContentSize = ImFloor(window->ContentSize * scale); } -static bool IsWindowActiveAndVisible(ImGuiWindow* window) +static bool IsWindowActiveAndVisible(ImGuiWindow *window) { return (window->Active) && (!window->Hidden); } @@ -4187,15 +4565,15 @@ static bool IsWindowActiveAndVisible(ImGuiWindow* window) static void UpdateAliasKey(ImGuiKey key, bool v, float analog_value) { IM_ASSERT(ImGui::IsAliasKey(key)); - ImGuiKeyData* key_data = ImGui::GetKeyData(key); + ImGuiKeyData *key_data = ImGui::GetKeyData(key); key_data->Down = v; key_data->AnalogValue = analog_value; } static void ImGui::UpdateKeyboardInputs() { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; // Import legacy keys or verify they are not used #ifndef IMGUI_DISABLE_OBSOLETE_KEYIO @@ -4243,8 +4621,18 @@ static void ImGui::UpdateKeyboardInputs() const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; if (io.BackendUsingLegacyNavInputArray && nav_gamepad_active) { - #define MAP_LEGACY_NAV_INPUT_TO_KEY1(_KEY, _NAV1) do { io.KeysData[_KEY].Down = (io.NavInputs[_NAV1] > 0.0f); io.KeysData[_KEY].AnalogValue = io.NavInputs[_NAV1]; } while (0) - #define MAP_LEGACY_NAV_INPUT_TO_KEY2(_KEY, _NAV1, _NAV2) do { io.KeysData[_KEY].Down = (io.NavInputs[_NAV1] > 0.0f) || (io.NavInputs[_NAV2] > 0.0f); io.KeysData[_KEY].AnalogValue = ImMax(io.NavInputs[_NAV1], io.NavInputs[_NAV2]); } while (0) +#define MAP_LEGACY_NAV_INPUT_TO_KEY1(_KEY, _NAV1) \ + do \ + { \ + io.KeysData[_KEY].Down = (io.NavInputs[_NAV1] > 0.0f); \ + io.KeysData[_KEY].AnalogValue = io.NavInputs[_NAV1]; \ + } while (0) +#define MAP_LEGACY_NAV_INPUT_TO_KEY2(_KEY, _NAV1, _NAV2) \ + do \ + { \ + io.KeysData[_KEY].Down = (io.NavInputs[_NAV1] > 0.0f) || (io.NavInputs[_NAV2] > 0.0f); \ + io.KeysData[_KEY].AnalogValue = ImMax(io.NavInputs[_NAV1], io.NavInputs[_NAV2]); \ + } while (0) MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadFaceDown, ImGuiNavInput_Activate); MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadFaceRight, ImGuiNavInput_Cancel); MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadFaceLeft, ImGuiNavInput_Menu); @@ -4259,7 +4647,7 @@ static void ImGui::UpdateKeyboardInputs() MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadLStickRight, ImGuiNavInput_LStickRight); MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadLStickUp, ImGuiNavInput_LStickUp); MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadLStickDown, ImGuiNavInput_LStickDown); - #undef NAV_MAP_KEY +#undef NAV_MAP_KEY } #endif @@ -4283,7 +4671,7 @@ static void ImGui::UpdateKeyboardInputs() // Update keys for (int i = 0; i < IM_ARRAYSIZE(io.KeysData); i++) { - ImGuiKeyData* key_data = &io.KeysData[i]; + ImGuiKeyData *key_data = &io.KeysData[i]; key_data->DownDurationPrev = key_data->DownDuration; key_data->DownDuration = key_data->Down ? (key_data->DownDuration < 0.0f ? 0.0f : key_data->DownDuration + io.DeltaTime) : -1.0f; } @@ -4291,8 +4679,8 @@ static void ImGui::UpdateKeyboardInputs() static void ImGui::UpdateMouseInputs() { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; // Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well) if (IsMousePosValid(&io.MousePos)) @@ -4353,9 +4741,9 @@ static void ImGui::UpdateMouseInputs() } } -static void StartLockWheelingWindow(ImGuiWindow* window) +static void StartLockWheelingWindow(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.WheelingWindow == window) return; g.WheelingWindow = window; @@ -4365,7 +4753,7 @@ static void StartLockWheelingWindow(ImGuiWindow* window) void ImGui::UpdateMouseWheel() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Reset the locked window if we move the mouse or after the timer elapses if (g.WheelingWindow != NULL) @@ -4389,7 +4777,7 @@ void ImGui::UpdateMouseWheel() if (wheel_x == 0.0f && wheel_y == 0.0f) return; - ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow; + ImGuiWindow *window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow; if (!window || window->Collapsed) return; @@ -4457,8 +4845,8 @@ void ImGui::UpdateMouseWheel() // The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app) void ImGui::UpdateHoveredWindowAndCaptureFlags() { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; g.WindowsHoverPadding = ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_HOVER_PADDING, WINDOWS_HOVER_PADDING)); // Find the window hovered by mouse: @@ -4470,7 +4858,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags() IM_ASSERT(g.HoveredWindow == NULL || g.HoveredWindow == g.MovingWindow || g.HoveredWindow->Viewport == g.MouseViewport); // Modal windows prevents mouse from hovering behind them. - ImGuiWindow* modal_window = GetTopMostPopupModal(); + ImGuiWindow *modal_window = GetTopMostPopupModal(); if (modal_window && g.HoveredWindow && !IsWindowWithinBeginStackOf(g.HoveredWindow->RootWindow, modal_window)) // FIXME-MERGE: RootWindowDockTree ? clear_hovered_windows = true; @@ -4535,19 +4923,31 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags() // [Internal] Do not use directly (can read io.KeyMods instead) ImGuiModFlags ImGui::GetMergedModFlags() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiModFlags key_mods = ImGuiModFlags_None; - if (g.IO.KeyCtrl) { key_mods |= ImGuiModFlags_Ctrl; } - if (g.IO.KeyShift) { key_mods |= ImGuiModFlags_Shift; } - if (g.IO.KeyAlt) { key_mods |= ImGuiModFlags_Alt; } - if (g.IO.KeySuper) { key_mods |= ImGuiModFlags_Super; } + if (g.IO.KeyCtrl) + { + key_mods |= ImGuiModFlags_Ctrl; + } + if (g.IO.KeyShift) + { + key_mods |= ImGuiModFlags_Shift; + } + if (g.IO.KeyAlt) + { + key_mods |= ImGuiModFlags_Alt; + } + if (g.IO.KeySuper) + { + key_mods |= ImGuiModFlags_Super; + } return key_mods; } void ImGui::NewFrame() { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Remove pending delete hooks before frame start. // This deferred removal avoid issues of removal while iterating the hook vector @@ -4605,7 +5005,7 @@ void ImGui::NewFrame() // Mark rendering data as invalid to prevent user who may have a handle on it to use it. for (int n = 0; n < g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; viewport->DrawData = NULL; viewport->DrawDataP.Clear(); } @@ -4676,7 +5076,7 @@ void ImGui::NewFrame() g.HoverDelayIdPreviousFrame = g.HoverDelayId; if (g.HoverDelayId != 0) { - //if (g.IO.MouseDelta.x == 0.0f && g.IO.MouseDelta.y == 0.0f) // Need design/flags + // if (g.IO.MouseDelta.x == 0.0f && g.IO.MouseDelta.y == 0.0f) // Need design/flags g.HoverDelayTimer += g.IO.DeltaTime; g.HoverDelayClearTimer = 0.0f; g.HoverDelayId = 0; @@ -4686,7 +5086,7 @@ void ImGui::NewFrame() // This gives a little bit of leeway before clearing the hover timer, allowing mouse to cross gaps g.HoverDelayClearTimer += g.IO.DeltaTime; if (g.HoverDelayClearTimer >= ImMax(0.20f, g.IO.DeltaTime * 2.0f)) // ~6 frames at 30 Hz + allow for low framerate - g.HoverDelayTimer = g.HoverDelayClearTimer = 0.0f; // May want a decaying timer, in which case need to clamp at max first, based on max of caller last requested timer. + g.HoverDelayTimer = g.HoverDelayClearTimer = 0.0f; // May want a decaying timer, in which case need to clamp at max first, based on max of caller last requested timer. } // Drag and drop @@ -4698,7 +5098,7 @@ void ImGui::NewFrame() g.DragDropHoldJustPressedId = 0; // Close popups on focus lost (currently wip/opt-in) - //if (g.IO.AppFocusLost) + // if (g.IO.AppFocusLost) // ClosePopupsExceptModals(); // Process input queue (trickle as many events as possible) @@ -4708,10 +5108,10 @@ void ImGui::NewFrame() // Update keyboard input state UpdateKeyboardInputs(); - //IM_ASSERT(g.IO.KeyCtrl == IsKeyDown(ImGuiKey_LeftCtrl) || IsKeyDown(ImGuiKey_RightCtrl)); - //IM_ASSERT(g.IO.KeyShift == IsKeyDown(ImGuiKey_LeftShift) || IsKeyDown(ImGuiKey_RightShift)); - //IM_ASSERT(g.IO.KeyAlt == IsKeyDown(ImGuiKey_LeftAlt) || IsKeyDown(ImGuiKey_RightAlt)); - //IM_ASSERT(g.IO.KeySuper == IsKeyDown(ImGuiKey_LeftSuper) || IsKeyDown(ImGuiKey_RightSuper)); + // IM_ASSERT(g.IO.KeyCtrl == IsKeyDown(ImGuiKey_LeftCtrl) || IsKeyDown(ImGuiKey_RightCtrl)); + // IM_ASSERT(g.IO.KeyShift == IsKeyDown(ImGuiKey_LeftShift) || IsKeyDown(ImGuiKey_RightShift)); + // IM_ASSERT(g.IO.KeyAlt == IsKeyDown(ImGuiKey_LeftAlt) || IsKeyDown(ImGuiKey_RightAlt)); + // IM_ASSERT(g.IO.KeySuper == IsKeyDown(ImGuiKey_LeftSuper) || IsKeyDown(ImGuiKey_RightSuper)); // Update gamepad/keyboard navigation NavUpdate(); @@ -4751,7 +5151,7 @@ void ImGui::NewFrame() const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer; for (int i = 0; i != g.Windows.Size; i++) { - ImGuiWindow* window = g.Windows[i]; + ImGuiWindow *window = g.Windows[i]; window->WasActive = window->Active; window->BeginCount = 0; window->Active = false; @@ -4805,7 +5205,7 @@ void ImGui::NewFrame() void ImGui::Initialize() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(!g.Initialized && !g.SettingsLoaded); // Add .ini handle for ImGuiWindow type @@ -4825,7 +5225,7 @@ void ImGui::Initialize() TableSettingsAddSettingsHandler(); // Create default viewport - ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)(); + ImGuiViewportP *viewport = IM_NEW(ImGuiViewportP)(); viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID; viewport->Idx = 0; viewport->PlatformWindowCreated = true; @@ -4846,7 +5246,7 @@ void ImGui::Initialize() void ImGui::Shutdown() { // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.IO.Fonts && g.FontAtlasOwnedByContext) { g.IO.Fonts->Locked = false; @@ -4922,10 +5322,10 @@ void ImGui::Shutdown() } // FIXME: Add a more explicit sort order in the window structure. -static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs) +static int IMGUI_CDECL ChildWindowComparer(const void *lhs, const void *rhs) { - const ImGuiWindow* const a = *(const ImGuiWindow* const *)lhs; - const ImGuiWindow* const b = *(const ImGuiWindow* const *)rhs; + const ImGuiWindow *const a = *(const ImGuiWindow *const *)lhs; + const ImGuiWindow *const b = *(const ImGuiWindow *const *)rhs; if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup)) return d; if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip)) @@ -4933,23 +5333,23 @@ static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs) return (a->BeginOrderWithinParent - b->BeginOrderWithinParent); } -static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window) +static void AddWindowToSortBuffer(ImVector *out_sorted_windows, ImGuiWindow *window) { out_sorted_windows->push_back(window); if (window->Active) { int count = window->DC.ChildWindows.Size; - ImQsort(window->DC.ChildWindows.Data, (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer); + ImQsort(window->DC.ChildWindows.Data, (size_t)count, sizeof(ImGuiWindow *), ChildWindowComparer); for (int i = 0; i < count; i++) { - ImGuiWindow* child = window->DC.ChildWindows[i]; + ImGuiWindow *child = window->DC.ChildWindows[i]; if (child->Active) AddWindowToSortBuffer(out_sorted_windows, child); } } } -static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list) +static void AddDrawListToDrawData(ImVector *out_list, ImDrawList *draw_list) { if (draw_list->CmdBuffer.Size == 0) return; @@ -4984,29 +5384,29 @@ static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* d out_list->push_back(draw_list); } -static void AddWindowToDrawData(ImGuiWindow* window, int layer) +static void AddWindowToDrawData(ImGuiWindow *window, int layer) { - ImGuiContext& g = *GImGui; - ImGuiViewportP* viewport = window->Viewport; + ImGuiContext &g = *GImGui; + ImGuiViewportP *viewport = window->Viewport; g.IO.MetricsRenderWindows++; if (window->Flags & ImGuiWindowFlags_DockNodeHost) window->DrawList->ChannelsMerge(); AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[layer], window->DrawList); for (int i = 0; i < window->DC.ChildWindows.Size; i++) { - ImGuiWindow* child = window->DC.ChildWindows[i]; + ImGuiWindow *child = window->DC.ChildWindows[i]; if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active AddWindowToDrawData(child, layer); } } -static inline int GetWindowDisplayLayer(ImGuiWindow* window) +static inline int GetWindowDisplayLayer(ImGuiWindow *window) { return (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0; } // Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu) -static inline void AddRootWindowToDrawData(ImGuiWindow* window) +static inline void AddRootWindowToDrawData(ImGuiWindow *window) { AddWindowToDrawData(window, GetWindowDisplayLayer(window)); } @@ -5020,16 +5420,16 @@ void ImDrawDataBuilder::FlattenIntoSingleLayer() Layers[0].resize(size); for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++) { - ImVector& layer = Layers[layer_n]; + ImVector &layer = Layers[layer_n]; if (layer.empty()) continue; - memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*)); + memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList *)); n += layer.Size; layer.resize(0); } } -static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector* draw_lists) +static void SetupViewportDrawData(ImGuiViewportP *viewport, ImVector *draw_lists) { // When minimized, we report draw_data->DisplaySize as zero to be consistent with non-viewport mode, // and to allow applications/backends to easily skip rendering. @@ -5038,8 +5438,8 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVectorFlags & ImGuiViewportFlags_Minimized) != 0; - ImGuiIO& io = ImGui::GetIO(); - ImDrawData* draw_data = &viewport->DrawDataP; + ImGuiIO &io = ImGui::GetIO(); + ImDrawData *draw_data = &viewport->DrawDataP; viewport->DrawData = draw_data; // Make publicly accessible draw_data->Valid = true; draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL; @@ -5051,7 +5451,7 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVectorOwnerViewport = viewport; for (int n = 0; n < draw_lists->Size; n++) { - ImDrawList* draw_list = draw_lists->Data[n]; + ImDrawList *draw_list = draw_lists->Data[n]; draw_list->_PopUnusedDrawCmd(); draw_data->TotalVtxCount += draw_list->VtxBuffer.Size; draw_data->TotalIdxCount += draw_list->IdxBuffer.Size; @@ -5064,21 +5464,21 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVectorDrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); window->ClipRect = window->DrawList->_ClipRectStack.back(); } void ImGui::PopClipRect() { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DrawList->PopClipRect(); window->ClipRect = window->DrawList->_ClipRectStack.back(); } -static ImGuiWindow* FindFrontMostVisibleChildWindow(ImGuiWindow* window) +static ImGuiWindow *FindFrontMostVisibleChildWindow(ImGuiWindow *window) { for (int n = window->DC.ChildWindows.Size - 1; n >= 0; n--) if (IsWindowActiveAndVisible(window->DC.ChildWindows[n])) @@ -5086,12 +5486,12 @@ static ImGuiWindow* FindFrontMostVisibleChildWindow(ImGuiWindow* window) return window; } -static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 col) +static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow *window, ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; - ImGuiViewportP* viewport = window->Viewport; + ImGuiViewportP *viewport = window->Viewport; ImRect viewport_rect = viewport->GetMainRect(); // Draw behind window by moving the draw command at the FRONT of the draw list @@ -5099,7 +5499,7 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 // We've already called AddWindowToDrawData() which called DrawList->ChannelsMerge() on DockNodeHost windows, // and draw list have been trimmed already, hence the explicit recreation of a draw command if missing. // FIXME: This is creating complication, might be simpler if we could inject a drawlist in drawdata at a given position and not attempt to manipulate ImDrawCmd order. - ImDrawList* draw_list = window->RootWindowDockTree->DrawList; + ImDrawList *draw_list = window->RootWindowDockTree->DrawList; if (draw_list->CmdBuffer.Size == 0) draw_list->AddDrawCmd(); draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // Ensure ImDrawCmd are not merged @@ -5115,22 +5515,22 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 // Draw over sibling docking nodes in a same docking tree if (window->RootWindow->DockIsActive) { - ImDrawList* draw_list = FindFrontMostVisibleChildWindow(window->RootWindowDockTree)->DrawList; + ImDrawList *draw_list = FindFrontMostVisibleChildWindow(window->RootWindowDockTree)->DrawList; if (draw_list->CmdBuffer.Size == 0) draw_list->AddDrawCmd(); draw_list->PushClipRect(viewport_rect.Min, viewport_rect.Max, false); - RenderRectFilledWithHole(draw_list, window->RootWindowDockTree->Rect(), window->RootWindow->Rect(), col, 0.0f);// window->RootWindowDockTree->WindowRounding); + RenderRectFilledWithHole(draw_list, window->RootWindowDockTree->Rect(), window->RootWindow->Rect(), col, 0.0f); // window->RootWindowDockTree->WindowRounding); draw_list->PopClipRect(); } } -ImGuiWindow* ImGui::FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow* parent_window) +ImGuiWindow *ImGui::FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow *parent_window) { - ImGuiContext& g = *GImGui; - ImGuiWindow* bottom_most_visible_window = parent_window; + ImGuiContext &g = *GImGui; + ImGuiWindow *bottom_most_visible_window = parent_window; for (int i = FindWindowDisplayIndex(parent_window); i >= 0; i--) { - ImGuiWindow* window = g.Windows[i]; + ImGuiWindow *window = g.Windows[i]; if (window->Flags & ImGuiWindowFlags_ChildWindow) continue; if (!IsWindowWithinBeginStackOf(window, parent_window)) @@ -5143,8 +5543,8 @@ ImGuiWindow* ImGui::FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow* par static void ImGui::RenderDimmedBackgrounds() { - ImGuiContext& g = *GImGui; - ImGuiWindow* modal_window = GetTopMostAndVisiblePopupModal(); + ImGuiContext &g = *GImGui; + ImGuiWindow *modal_window = GetTopMostAndVisiblePopupModal(); if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f) return; const bool dim_bg_for_modal = (modal_window != NULL); @@ -5152,11 +5552,11 @@ static void ImGui::RenderDimmedBackgrounds() if (!dim_bg_for_modal && !dim_bg_for_window_list) return; - ImGuiViewport* viewports_already_dimmed[2] = { NULL, NULL }; + ImGuiViewport *viewports_already_dimmed[2] = {NULL, NULL}; if (dim_bg_for_modal) { // Draw dimming behind modal or a begin stack child, whichever comes first in draw order. - ImGuiWindow* dim_behind_window = FindBottomMostVisibleWindowWithinBeginStack(modal_window); + ImGuiWindow *dim_behind_window = FindBottomMostVisibleWindowWithinBeginStack(modal_window); RenderDimmedBackgroundBehindWindow(dim_behind_window, GetColorU32(ImGuiCol_ModalWindowDimBg, g.DimBgRatio)); viewports_already_dimmed[0] = modal_window->Viewport; } @@ -5170,8 +5570,8 @@ static void ImGui::RenderDimmedBackgrounds() viewports_already_dimmed[1] = g.NavWindowingListWindow ? g.NavWindowingListWindow->Viewport : NULL; // Draw border around CTRL+Tab target window - ImGuiWindow* window = g.NavWindowingTargetAnim; - ImGuiViewport* viewport = window->Viewport; + ImGuiWindow *window = g.NavWindowingTargetAnim; + ImGuiViewport *viewport = window->Viewport; float distance = g.FontSize; ImRect bb = window->Rect(); bb.Expand(distance); @@ -5187,12 +5587,12 @@ static void ImGui::RenderDimmedBackgrounds() // Draw dimming background on _other_ viewports than the ones our windows are in for (int viewport_n = 0; viewport_n < g.Viewports.Size; viewport_n++) { - ImGuiViewportP* viewport = g.Viewports[viewport_n]; + ImGuiViewportP *viewport = g.Viewports[viewport_n]; if (viewport == viewports_already_dimmed[0] || viewport == viewports_already_dimmed[1]) continue; if (modal_window && viewport->Window && IsWindowAbove(viewport->Window, modal_window)) continue; - ImDrawList* draw_list = GetForegroundDrawList(viewport); + ImDrawList *draw_list = GetForegroundDrawList(viewport); const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio); draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col); } @@ -5201,7 +5601,7 @@ static void ImGui::RenderDimmedBackgrounds() // This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal. void ImGui::EndFrame() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.Initialized); // Don't process EndFrame() multiple times. @@ -5216,7 +5616,7 @@ void ImGui::EndFrame() // Notify Platform/OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) if (g.IO.SetPlatformImeDataFn && memcmp(&g.PlatformImeData, &g.PlatformImeDataPrev, sizeof(ImGuiPlatformImeData)) != 0) { - ImGuiViewport* viewport = FindViewportByID(g.PlatformImeViewport); + ImGuiViewport *viewport = FindViewportByID(g.PlatformImeViewport); g.IO.SetPlatformImeDataFn(viewport ? viewport : GetMainViewport(), &g.PlatformImeData); } @@ -5267,8 +5667,8 @@ void ImGui::EndFrame() g.WindowsTempSortBuffer.reserve(g.Windows.Size); for (int i = 0; i != g.Windows.Size; i++) { - ImGuiWindow* window = g.Windows[i]; - if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it + ImGuiWindow *window = g.Windows[i]; + if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it continue; AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window); } @@ -5293,7 +5693,7 @@ void ImGui::EndFrame() // it is the role of the ImGui_ImplXXXX_RenderDrawData() function provided by the renderer backend) void ImGui::Render() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.Initialized); if (g.FrameCountEnded != g.FrameCount) @@ -5307,19 +5707,19 @@ void ImGui::Render() // Add background ImDrawList (for each active viewport) for (int n = 0; n != g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; viewport->DrawDataBuilder.Clear(); if (viewport->DrawLists[0] != NULL) AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport)); } // Add ImDrawList to render - ImGuiWindow* windows_to_render_top_most[2]; + ImGuiWindow *windows_to_render_top_most[2]; windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindowDockTree : NULL; windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL); for (int n = 0; n != g.Windows.Size; n++) { - ImGuiWindow* window = g.Windows[n]; + ImGuiWindow *window = g.Windows[n]; IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'" if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1]) AddRootWindowToDrawData(window); @@ -5340,7 +5740,7 @@ void ImGui::Render() g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0; for (int n = 0; n < g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; viewport->DrawDataBuilder.FlattenIntoSingleLayer(); // Add foreground ImDrawList (for each active viewport) @@ -5348,7 +5748,7 @@ void ImGui::Render() AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport)); SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]); - ImDrawData* draw_data = viewport->DrawData; + ImDrawData *draw_data = viewport->DrawData; g.IO.MetricsRenderVertices += draw_data->TotalVtxCount; g.IO.MetricsRenderIndices += draw_data->TotalIdxCount; } @@ -5358,17 +5758,17 @@ void ImGui::Render() // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. // CalcTextSize("") should return ImVec2(0.0f, g.FontSize) -ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) +ImVec2 ImGui::CalcTextSize(const char *text, const char *text_end, bool hide_text_after_double_hash, float wrap_width) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; - const char* text_display_end; + const char *text_display_end; if (hide_text_after_double_hash) - text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string + text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string else text_display_end = text_end; - ImFont* font = g.Font; + ImFont *font = g.Font; const float font_size = g.FontSize; if (text == text_display_end) return ImVec2(0.0f, font_size); @@ -5390,15 +5790,15 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex // called, aka before the next Begin(). Moving window isn't affected. static void FindHoveredWindow() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Special handling for the window being moved: Ignore the mouse viewport check (because it may reset/lose its viewport during the undocking frame) - ImGuiViewportP* moving_window_viewport = g.MovingWindow ? g.MovingWindow->Viewport : NULL; + ImGuiViewportP *moving_window_viewport = g.MovingWindow ? g.MovingWindow->Viewport : NULL; if (g.MovingWindow) g.MovingWindow->Viewport = g.MouseViewport; - ImGuiWindow* hovered_window = NULL; - ImGuiWindow* hovered_window_ignoring_moving_window = NULL; + ImGuiWindow *hovered_window = NULL; + ImGuiWindow *hovered_window_ignoring_moving_window = NULL; if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs)) hovered_window = g.MovingWindow; @@ -5406,7 +5806,7 @@ static void FindHoveredWindow() ImVec2 padding_for_resize = g.IO.ConfigWindowsResizeFromEdges ? g.WindowsHoverPadding : padding_regular; for (int i = g.Windows.Size - 1; i >= 0; i--) { - ImGuiWindow* window = g.Windows[i]; + ImGuiWindow *window = g.Windows[i]; IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer. if (!window->Active || window->Hidden) continue; @@ -5453,7 +5853,7 @@ static void FindHoveredWindow() bool ImGui::IsItemActive() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.ActiveId) return g.ActiveId == g.LastItemData.ID; return false; @@ -5461,7 +5861,7 @@ bool ImGui::IsItemActive() bool ImGui::IsItemActivated() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.ActiveId) if (g.ActiveId == g.LastItemData.ID && g.ActiveIdPreviousFrame != g.LastItemData.ID) return true; @@ -5470,7 +5870,7 @@ bool ImGui::IsItemActivated() bool ImGui::IsItemDeactivated() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDeactivated) return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Deactivated) != 0; return (g.ActiveIdPreviousFrame == g.LastItemData.ID && g.ActiveIdPreviousFrame != 0 && g.ActiveId != g.LastItemData.ID); @@ -5478,20 +5878,20 @@ bool ImGui::IsItemDeactivated() bool ImGui::IsItemDeactivatedAfterEdit() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEditedBefore || (g.ActiveId == 0 && g.ActiveIdHasBeenEditedBefore)); } // == GetItemID() == GetFocusID() bool ImGui::IsItemFocused() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.NavId != g.LastItemData.ID || g.NavId == 0) return false; // Special handling for the dummy item after Begin() which represent the title bar or tab. // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case. - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow *window = g.CurrentWindow; if (g.LastItemData.ID == window->ID && window->WriteAccessed) return false; @@ -5507,43 +5907,43 @@ bool ImGui::IsItemClicked(ImGuiMouseButton mouse_button) bool ImGui::IsItemToggledOpen() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledOpen) ? true : false; } bool ImGui::IsItemToggledSelection() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false; } bool ImGui::IsAnyItemHovered() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0; } bool ImGui::IsAnyItemActive() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.ActiveId != 0; } bool ImGui::IsAnyItemFocused() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.NavId != 0 && !g.NavDisableHighlight; } bool ImGui::IsItemVisible() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.CurrentWindow->ClipRect.Overlaps(g.LastItemData.Rect); } bool ImGui::IsItemEdited() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Edited) != 0; } @@ -5551,7 +5951,7 @@ bool ImGui::IsItemEdited() // FIXME: Although this is exposed, its interaction and ideal idiom with using ImGuiButtonFlags_AllowItemOverlap flag are extremely confusing, need rework. void ImGui::SetItemAllowOverlap() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiID id = g.LastItemData.ID; if (g.HoveredId == id) g.HoveredIdAllowOverlap = true; @@ -5561,7 +5961,7 @@ void ImGui::SetItemAllowOverlap() void ImGui::SetItemUsingMouseWheel() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiID id = g.LastItemData.ID; if (g.HoveredId == id) g.HoveredIdUsingMouseWheel = true; @@ -5575,7 +5975,7 @@ void ImGui::SetItemUsingMouseWheel() // FIXME: Technically this also prevents use of Gamepad D-Pad, may not be an issue. void ImGui::SetActiveIdUsingAllKeyboardKeys() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.ActiveId != 0); g.ActiveIdUsingNavDirMask = ~(ImU32)0; g.ActiveIdUsingKeyInputMask.SetBitRange(ImGuiKey_Keyboard_BEGIN, ImGuiKey_Keyboard_END); @@ -5588,29 +5988,29 @@ void ImGui::SetActiveIdUsingAllKeyboardKeys() ImVec2 ImGui::GetItemRectMin() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.LastItemData.Rect.Min; } ImVec2 ImGui::GetItemRectMax() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.LastItemData.Rect.Max; } ImVec2 ImGui::GetItemRectSize() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.LastItemData.Rect.GetSize(); } -bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) +bool ImGui::BeginChildEx(const char *name, ImGuiID id, const ImVec2 &size_arg, bool border, ImGuiWindowFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* parent_window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *parent_window = g.CurrentWindow; flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDocking; - flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag + flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag // Size const ImVec2 content_avail = GetContentRegionAvail(); @@ -5623,7 +6023,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b SetNextWindowSize(size); // Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value. - const char* temp_window_name; + const char *temp_window_name; if (name) ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s_%08X", parent_window->Name, name, id); else @@ -5635,7 +6035,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b bool ret = Begin(temp_window_name, NULL, flags); g.Style.ChildBorderSize = backup_border_size; - ImGuiWindow* child_window = g.CurrentWindow; + ImGuiWindow *child_window = g.CurrentWindow; child_window->ChildId = id; child_window->AutoFitChildAxises = (ImS8)auto_fit_axises; @@ -5655,13 +6055,13 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b return ret; } -bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +bool ImGui::BeginChild(const char *str_id, const ImVec2 &size_arg, bool border, ImGuiWindowFlags extra_flags) { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); } -bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +bool ImGui::BeginChild(ImGuiID id, const ImVec2 &size_arg, bool border, ImGuiWindowFlags extra_flags) { IM_ASSERT(id != 0); return BeginChildEx(NULL, id, size_arg, border, extra_flags); @@ -5669,11 +6069,11 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWin void ImGui::EndChild() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IM_ASSERT(g.WithinEndChild == false); - IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls + IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls g.WithinEndChild = true; if (window->BeginCount > 1) @@ -5689,7 +6089,7 @@ void ImGui::EndChild() sz.y = ImMax(4.0f, sz.y); End(); - ImGuiWindow* parent_window = g.CurrentWindow; + ImGuiWindow *parent_window = g.CurrentWindow; ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); ItemSize(sz); if ((window->DC.NavLayersActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened)) @@ -5714,10 +6114,10 @@ void ImGui::EndChild() } // Helper to create a child window / scrolling region that looks like a normal widget frame. -bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) +bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2 &size, ImGuiWindowFlags extra_flags) { - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; + ImGuiContext &g = *GImGui; + const ImGuiStyle &style = g.Style; PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); @@ -5733,29 +6133,29 @@ void ImGui::EndChildFrame() EndChild(); } -static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) +static void SetWindowConditionAllowFlags(ImGuiWindow *window, ImGuiCond flags, bool enabled) { - window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); - window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); + window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); + window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); - window->SetWindowDockAllowFlags = enabled ? (window->SetWindowDockAllowFlags | flags) : (window->SetWindowDockAllowFlags & ~flags); + window->SetWindowDockAllowFlags = enabled ? (window->SetWindowDockAllowFlags | flags) : (window->SetWindowDockAllowFlags & ~flags); } -ImGuiWindow* ImGui::FindWindowByID(ImGuiID id) +ImGuiWindow *ImGui::FindWindowByID(ImGuiID id) { - ImGuiContext& g = *GImGui; - return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id); + ImGuiContext &g = *GImGui; + return (ImGuiWindow *)g.WindowsById.GetVoidPtr(id); } -ImGuiWindow* ImGui::FindWindowByName(const char* name) +ImGuiWindow *ImGui::FindWindowByName(const char *name) { ImGuiID id = ImHashStr(name); return FindWindowByID(id); } -static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settings) +static void ApplyWindowSettings(ImGuiWindow *window, ImGuiWindowSettings *settings) { - const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); + const ImGuiViewport *main_viewport = ImGui::GetMainViewport(); window->ViewportPos = main_viewport->Pos; if (settings->ViewportId) { @@ -5770,9 +6170,9 @@ static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settin window->DockOrder = settings->DockOrder; } -static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created, ImGuiWindowFlags new_flags) +static void UpdateWindowInFocusOrderList(ImGuiWindow *window, bool just_created, ImGuiWindowFlags new_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const bool new_is_explicit_child = (new_flags & ImGuiWindowFlags_ChildWindow) != 0; const bool child_flag_changed = new_is_explicit_child != window->IsExplicitChild; if ((just_created || child_flag_changed) && !new_is_explicit_child) @@ -5792,24 +6192,24 @@ static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created, window->IsExplicitChild = new_is_explicit_child; } -static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags) +static ImGuiWindow *CreateNewWindow(const char *name, ImGuiWindowFlags flags) { - ImGuiContext& g = *GImGui; - //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); + ImGuiContext &g = *GImGui; + // IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); // Create window the first time - ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); + ImGuiWindow *window = IM_NEW(ImGuiWindow)(&g, name); window->Flags = flags; g.WindowsById.SetVoidPtr(window->ID, window); // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. - const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); + const ImGuiViewport *main_viewport = ImGui::GetMainViewport(); window->Pos = main_viewport->Pos + ImVec2(60, 60); window->ViewportPos = main_viewport->Pos; // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. if (!(flags & ImGuiWindowFlags_NoSavedSettings)) - if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) + if (ImGuiWindowSettings *settings = ImGui::FindWindowSettings(window->ID)) { // Retrieve settings from .ini file window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); @@ -5840,19 +6240,19 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags) return window; } -static ImGuiWindow* GetWindowForTitleDisplay(ImGuiWindow* window) +static ImGuiWindow *GetWindowForTitleDisplay(ImGuiWindow *window) { return window->DockNodeAsHost ? window->DockNodeAsHost->VisibleWindow : window; } -static ImGuiWindow* GetWindowForTitleAndMenuHeight(ImGuiWindow* window) +static ImGuiWindow *GetWindowForTitleAndMenuHeight(ImGuiWindow *window) { return (window->DockNodeAsHost && window->DockNodeAsHost->VisibleWindow) ? window->DockNodeAsHost->VisibleWindow : window; } -static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired) +static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow *window, const ImVec2 &size_desired) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImVec2 new_size = size_desired; if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) { @@ -5877,7 +6277,7 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& s // Minimum size if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize))) { - ImGuiWindow* window_for_height = GetWindowForTitleAndMenuHeight(window); + ImGuiWindow *window_for_height = GetWindowForTitleAndMenuHeight(window); const float decoration_up_height = window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight(); new_size = ImMax(new_size, g.Style.WindowMinSize); new_size.y = ImMax(new_size.y, decoration_up_height + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows @@ -5885,7 +6285,7 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& s return new_size; } -static void CalcWindowContentSizes(ImGuiWindow* window, ImVec2* content_size_current, ImVec2* content_size_ideal) +static void CalcWindowContentSizes(ImGuiWindow *window, ImVec2 *content_size_current, ImVec2 *content_size_ideal) { bool preserve_old_content_sizes = false; if (window->Collapsed && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) @@ -5905,10 +6305,10 @@ static void CalcWindowContentSizes(ImGuiWindow* window, ImVec2* content_size_cur content_size_ideal->y = (window->ContentSizeExplicit.y != 0.0f) ? window->ContentSizeExplicit.y : IM_FLOOR(ImMax(window->DC.CursorMaxPos.y, window->DC.IdealMaxPos.y) - window->DC.CursorStartPos.y); } -static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_contents) +static ImVec2 CalcWindowAutoFitSize(ImGuiWindow *window, const ImVec2 &size_contents) { - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; + ImGuiContext &g = *GImGui; + ImGuiStyle &style = g.Style; const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); ImVec2 size_pad = window->WindowPadding * 2.0f; ImVec2 size_desired = size_contents + size_pad + ImVec2(0.0f, decoration_up_height); @@ -5938,7 +6338,7 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont // When the window cannot fit all contents (either because of constraints, either because screen is too small), // we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding. ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit); - bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - 0.0f < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar); + bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - 0.0f < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar); bool will_have_scrollbar_y = (size_auto_fit_after_constraint.y - size_pad.y - decoration_up_height < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysVerticalScrollbar); if (will_have_scrollbar_x) size_auto_fit.y += style.ScrollbarSize; @@ -5948,7 +6348,7 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont } } -ImVec2 ImGui::CalcWindowNextAutoFitSize(ImGuiWindow* window) +ImVec2 ImGui::CalcWindowNextAutoFitSize(ImGuiWindow *window) { ImVec2 size_contents_current; ImVec2 size_contents_ideal; @@ -5958,7 +6358,7 @@ ImVec2 ImGui::CalcWindowNextAutoFitSize(ImGuiWindow* window) return size_final; } -static ImGuiCol GetWindowBgColorIdx(ImGuiWindow* window) +static ImGuiCol GetWindowBgColorIdx(ImGuiWindow *window) { if (window->Flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) return ImGuiCol_PopupBg; @@ -5967,7 +6367,7 @@ static ImGuiCol GetWindowBgColorIdx(ImGuiWindow* window) return ImGuiCol_WindowBg; } -static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size) +static void CalcResizePosSizeFromAnyCorner(ImGuiWindow *window, const ImVec2 &corner_target, const ImVec2 &corner_norm, ImVec2 *out_pos, ImVec2 *out_size) { ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right @@ -5984,16 +6384,16 @@ static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& co // Data for resizing from corner struct ImGuiResizeGripDef { - ImVec2 CornerPosN; - ImVec2 InnerDir; - int AngleMin12, AngleMax12; + ImVec2 CornerPosN; + ImVec2 InnerDir; + int AngleMin12, AngleMax12; }; static const ImGuiResizeGripDef resize_grip_def[4] = -{ - { ImVec2(1, 1), ImVec2(-1, -1), 0, 3 }, // Lower-right - { ImVec2(0, 1), ImVec2(+1, -1), 3, 6 }, // Lower-left - { ImVec2(0, 0), ImVec2(+1, +1), 6, 9 }, // Upper-left (Unused) - { ImVec2(1, 0), ImVec2(-1, +1), 9, 12 } // Upper-right (Unused) + { + {ImVec2(1, 1), ImVec2(-1, -1), 0, 3}, // Lower-right + {ImVec2(0, 1), ImVec2(+1, -1), 3, 6}, // Lower-left + {ImVec2(0, 0), ImVec2(+1, +1), 6, 9}, // Upper-left (Unused) + {ImVec2(1, 0), ImVec2(-1, +1), 9, 12} // Upper-right (Unused) }; // Data for resizing from borders @@ -6001,31 +6401,43 @@ struct ImGuiResizeBorderDef { ImVec2 InnerDir; ImVec2 SegmentN1, SegmentN2; - float OuterAngle; + float OuterAngle; }; static const ImGuiResizeBorderDef resize_border_def[4] = -{ - { ImVec2(+1, 0), ImVec2(0, 1), ImVec2(0, 0), IM_PI * 1.00f }, // Left - { ImVec2(-1, 0), ImVec2(1, 0), ImVec2(1, 1), IM_PI * 0.00f }, // Right - { ImVec2(0, +1), ImVec2(0, 0), ImVec2(1, 0), IM_PI * 1.50f }, // Up - { ImVec2(0, -1), ImVec2(1, 1), ImVec2(0, 1), IM_PI * 0.50f } // Down + { + {ImVec2(+1, 0), ImVec2(0, 1), ImVec2(0, 0), IM_PI * 1.00f}, // Left + {ImVec2(-1, 0), ImVec2(1, 0), ImVec2(1, 1), IM_PI * 0.00f}, // Right + {ImVec2(0, +1), ImVec2(0, 0), ImVec2(1, 0), IM_PI * 1.50f}, // Up + {ImVec2(0, -1), ImVec2(1, 1), ImVec2(0, 1), IM_PI * 0.50f} // Down }; -static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness) +static ImRect GetResizeBorderRect(ImGuiWindow *window, int border_n, float perp_padding, float thickness) { ImRect rect = window->Rect(); if (thickness == 0.0f) rect.Max -= ImVec2(1, 1); - if (border_n == ImGuiDir_Left) { return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); } - if (border_n == ImGuiDir_Right) { return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding); } - if (border_n == ImGuiDir_Up) { return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness); } - if (border_n == ImGuiDir_Down) { return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness); } + if (border_n == ImGuiDir_Left) + { + return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); + } + if (border_n == ImGuiDir_Right) + { + return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding); + } + if (border_n == ImGuiDir_Up) + { + return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness); + } + if (border_n == ImGuiDir_Down) + { + return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness); + } IM_ASSERT(0); return ImRect(); } // 0..3: corners (Lower-right, Lower-left, Unused, Unused) -ImGuiID ImGui::GetWindowResizeCornerID(ImGuiWindow* window, int n) +ImGuiID ImGui::GetWindowResizeCornerID(ImGuiWindow *window, int n) { IM_ASSERT(n >= 0 && n < 4); ImGuiID id = window->DockIsActive ? window->DockNode->HostWindow->ID : window->ID; @@ -6035,7 +6447,7 @@ ImGuiID ImGui::GetWindowResizeCornerID(ImGuiWindow* window, int n) } // Borders (Left, Right, Up, Down) -ImGuiID ImGui::GetWindowResizeBorderID(ImGuiWindow* window, ImGuiDir dir) +ImGuiID ImGui::GetWindowResizeBorderID(ImGuiWindow *window, ImGuiDir dir) { IM_ASSERT(dir >= 0 && dir < 4); int n = (int)dir + 4; @@ -6047,9 +6459,9 @@ ImGuiID ImGui::GetWindowResizeBorderID(ImGuiWindow* window, ImGuiDir dir) // Handle resize for: Resize Grips, Borders, Gamepad // Return true when using auto-fit (double click on resize grip) -static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect) +static bool ImGui::UpdateWindowManualResize(ImGuiWindow *window, const ImVec2 &size_auto_fit, int *border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect &visibility_rect) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiWindowFlags flags = window->Flags; if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) @@ -6083,18 +6495,20 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s PushID("#RESIZE"); for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) { - const ImGuiResizeGripDef& def = resize_grip_def[resize_grip_n]; + const ImGuiResizeGripDef &def = resize_grip_def[resize_grip_n]; const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, def.CornerPosN); // Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window bool hovered, held; ImRect resize_rect(corner - def.InnerDir * grip_hover_outer_size, corner + def.InnerDir * grip_hover_inner_size); - if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x); - if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y); + if (resize_rect.Min.x > resize_rect.Max.x) + ImSwap(resize_rect.Min.x, resize_rect.Max.x); + if (resize_rect.Min.y > resize_rect.Max.y) + ImSwap(resize_rect.Min.y, resize_rect.Max.y); ImGuiID resize_grip_id = window->GetID(resize_grip_n); // == GetWindowResizeCornerID() KeepAliveID(resize_grip_id); ButtonBehavior(resize_rect, resize_grip_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); - //GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)); + // GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)); if (hovered || held) g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; @@ -6118,11 +6532,12 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s // Only lower-left grip is visible before hovering/activating if (resize_grip_n == 0 || held || hovered) - resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); + resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered + : ImGuiCol_ResizeGrip); } for (int border_n = 0; border_n < resize_border_count; border_n++) { - const ImGuiResizeBorderDef& def = resize_border_def[border_n]; + const ImGuiResizeBorderDef &def = resize_border_def[border_n]; const ImGuiAxis axis = (border_n == ImGuiDir_Left || border_n == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y; bool hovered, held; @@ -6130,7 +6545,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s ImGuiID border_id = window->GetID(border_n + 4); // == GetWindowResizeBorderID() KeepAliveID(border_id); ButtonBehavior(border_rect, border_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); - //GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)); + // GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)); if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held) { g.MouseCursor = (axis == ImGuiAxis_X) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS; @@ -6140,7 +6555,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s if (held) { ImVec2 clamp_min(border_n == ImGuiDir_Right ? visibility_rect.Min.x : -FLT_MAX, border_n == ImGuiDir_Down ? visibility_rect.Min.y : -FLT_MAX); - ImVec2 clamp_max(border_n == ImGuiDir_Left ? visibility_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? visibility_rect.Max.y : +FLT_MAX); + ImVec2 clamp_max(border_n == ImGuiDir_Left ? visibility_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? visibility_rect.Max.y : +FLT_MAX); ImVec2 border_target = window->Pos; border_target[axis] = g.IO.MousePos[axis] - g.ActiveIdClickOffset[axis] + WINDOWS_HOVER_PADDING; border_target = ImClamp(border_target, clamp_min, clamp_max); @@ -6197,18 +6612,18 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s return ret_auto_fit; } -static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& visibility_rect) +static inline void ClampWindowRect(ImGuiWindow *window, const ImRect &visibility_rect) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImVec2 size_for_clamping = window->Size; if (g.IO.ConfigWindowsMoveFromTitleBarOnly && (!(window->Flags & ImGuiWindowFlags_NoTitleBar) || window->DockNodeAsHost)) size_for_clamping.y = ImGui::GetFrameHeight(); // Not using window->TitleBarHeight() as DockNodeAsHost will report 0.0f here. window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max); } -static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) +static void ImGui::RenderWindowOuterBorders(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; float rounding = window->WindowRounding; float border_size = window->WindowBorderSize; if (border_size > 0.0f && !(window->Flags & ImGuiWindowFlags_NoBackground)) @@ -6217,7 +6632,7 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) int border_held = window->ResizeBorderHeld; if (border_held != -1) { - const ImGuiResizeBorderDef& def = resize_border_def[border_held]; + const ImGuiResizeBorderDef &def = resize_border_def[border_held]; ImRect border_r = GetResizeBorderRect(window, border_held, rounding, 0.0f); window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI * 0.25f, def.OuterAngle); window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI * 0.25f); @@ -6232,10 +6647,10 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) // Draw background and borders // Draw and handle scrollbars -void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size) +void ImGui::RenderWindowDecorations(ImGuiWindow *window, const ImRect &title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size) { - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; + ImGuiContext &g = *GImGui; + ImGuiStyle &style = g.Style; ImGuiWindowFlags flags = window->Flags; // Ensure that ScrollBar doesn't read last frame's SkipItems @@ -6262,7 +6677,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar { bool is_docking_transparent_payload = false; if (g.DragDropActive && (g.FrameCount - g.DragDropAcceptFrameCount) <= 1 && g.IO.ConfigDockingTransparentPayload) - if (g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && *(ImGuiWindow**)g.DragDropPayload.Data == window) + if (g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && *(ImGuiWindow **)g.DragDropPayload.Data == window) is_docking_transparent_payload = true; ImU32 bg_col = GetColorU32(GetWindowBgColorIdx(window)); @@ -6295,7 +6710,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar // Render, for docked windows and host windows we ensure bg goes before decorations if (window->DockIsActive) window->DockNode->LastBgColor = bg_col; - ImDrawList* bg_draw_list = window->DockIsActive ? window->DockNode->HostWindow->DrawList : window->DrawList; + ImDrawList *bg_draw_list = window->DockIsActive ? window->DockNode->HostWindow->DrawList : window->DrawList; if (window->DockIsActive || (flags & ImGuiWindowFlags_DockNodeHost)) bg_draw_list->ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG); bg_draw_list->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? 0 : ImDrawFlags_RoundCornersBottom); @@ -6318,14 +6733,14 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar if (flags & ImGuiWindowFlags_MenuBar) { ImRect menu_bar_rect = window->MenuBarRect(); - menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. + menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawFlags_RoundCornersTop); if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y) window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); } // Docking: Unhide tab bar (small triangle in the corner), drag from small triangle to quickly undock - ImGuiDockNode* node = window->DockNode; + ImGuiDockNode *node = window->DockNode; if (window->DockIsActive && node->IsHiddenTabBar() && !node->IsNoTabBar()) { float unhide_sz_draw = ImFloor(g.FontSize * 0.70f); @@ -6341,7 +6756,8 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar StartMouseMovingWindowOrNode(window, node, true); // FIXME-DOCK: Ideally we'd use ImGuiCol_TitleBgActive/ImGuiCol_TitleBg here, but neither is guaranteed to be visible enough at this sort of size.. - ImU32 col = GetColorU32(((held && hovered) || (node->IsFocused && !hovered)) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + ImU32 col = GetColorU32(((held && hovered) || (node->IsFocused && !hovered)) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered + : ImGuiCol_Button); window->DrawList->AddTriangleFilled(p, p + ImVec2(unhide_sz_draw, 0.0f), p + ImVec2(0.0f, unhide_sz_draw), col); } @@ -6356,7 +6772,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar { for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) { - const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; + const ImGuiResizeGripDef &grip = resize_grip_def[resize_grip_n]; const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size))); window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size))); @@ -6373,10 +6789,10 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar // Render title text, collapse button, close button // When inside a dock node, this is handled in DockNodeCalcTabBarLayout() instead. -void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open) +void ImGui::RenderWindowTitleBarContents(ImGuiWindow *window, const ImRect &title_bar_rect, const char *name, bool *p_open) { - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; + ImGuiContext &g = *GImGui; + ImGuiStyle &style = g.Style; ImGuiWindowFlags flags = window->Flags; const bool has_close_button = (p_open != NULL); @@ -6456,12 +6872,12 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl clip_r.Max.x = ImMin(clip_r.Max.x, marker_pos.x - (int)(marker_size_x * 0.5f)); } } - //if (g.IO.KeyShift) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] - //if (g.IO.KeyCtrl) window->DrawList->AddRect(clip_r.Min, clip_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] + // if (g.IO.KeyShift) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] + // if (g.IO.KeyCtrl) window->DrawList->AddRect(clip_r.Min, clip_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] RenderTextClipped(layout_r.Min, layout_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_r); } -void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window) +void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow *window, ImGuiWindowFlags flags, ImGuiWindow *parent_window) { window->ParentWindow = parent_window; window->RootWindow = window->RootWindowPopupTree = window->RootWindowDockTree = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window; @@ -6491,25 +6907,25 @@ void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags // - Window // .. returns Modal2 // - Window // .. returns Modal2 // - Modal2 // .. returns Modal2 -static ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window) +static ImGuiWindow *ImGui::FindBlockingModal(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.OpenPopupStack.Size <= 0) return NULL; // Find a modal that has common parent with specified window. Specified window should be positioned behind that modal. for (int i = g.OpenPopupStack.Size - 1; i >= 0; i--) { - ImGuiWindow* popup_window = g.OpenPopupStack.Data[i].Window; + ImGuiWindow *popup_window = g.OpenPopupStack.Data[i].Window; if (popup_window == NULL || !(popup_window->Flags & ImGuiWindowFlags_Modal)) continue; - if (!popup_window->Active && !popup_window->WasActive) // Check WasActive, because this code may run before popup renders on current frame, also check Active to handle newly created windows. + if (!popup_window->Active && !popup_window->WasActive) // Check WasActive, because this code may run before popup renders on current frame, also check Active to handle newly created windows. continue; - if (IsWindowWithinBeginStackOf(window, popup_window)) // Window is rendered over last modal, no render order change needed. + if (IsWindowWithinBeginStackOf(window, popup_window)) // Window is rendered over last modal, no render order change needed. break; - for (ImGuiWindow* parent = popup_window->ParentWindowInBeginStack->RootWindow; parent != NULL; parent = parent->ParentWindowInBeginStack->RootWindow) + for (ImGuiWindow *parent = popup_window->ParentWindowInBeginStack->RootWindow; parent != NULL; parent = parent->ParentWindowInBeginStack->RootWindow) if (IsWindowWithinBeginStackOf(window, parent)) - return popup_window; // Place window above its begin stack parent. + return popup_window; // Place window above its begin stack parent. } return NULL; } @@ -6521,16 +6937,16 @@ static ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window) // You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file. // - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned. // - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. -bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) +bool ImGui::Begin(const char *name, bool *p_open, ImGuiWindowFlags flags) { - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required - IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame() - IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet + ImGuiContext &g = *GImGui; + const ImGuiStyle &style = g.Style; + IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required + IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame() + IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet // Find or create - ImGuiWindow* window = FindWindowByName(name); + ImGuiWindow *window = FindWindowByName(name); const bool window_just_created = (window == NULL); if (window_just_created) window = CreateNewWindow(name, flags); @@ -6550,7 +6966,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on if (flags & ImGuiWindowFlags_Popup) { - ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; + ImGuiPopupData &popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed window_just_activated_by_user |= (window != popup_ref.Window); } @@ -6610,8 +7026,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) } // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack - ImGuiWindow* parent_window_in_stack = (window->DockIsActive && window->DockNode->HostWindow) ? window->DockNode->HostWindow : g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back().Window; - ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; + ImGuiWindow *parent_window_in_stack = (window->DockIsActive && window->DockNode->HostWindow) ? window->DockNode->HostWindow : g.CurrentWindowStack.empty() ? NULL + : g.CurrentWindowStack.back().Window; + ImGuiWindow *parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); // We allow window memory to be compacted so recreate the base stack when needed. @@ -6632,7 +7049,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (flags & ImGuiWindowFlags_Popup) { - ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; + ImGuiPopupData &popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; popup_ref.Window = window; popup_ref.ParentNavLayer = parent_window_in_stack->DC.NavLayerCurrent; g.BeginPopupStack.push_back(popup_ref); @@ -6725,7 +7142,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) bool window_title_visible_elsewhere = false; if ((window->Viewport && window->Viewport->Window == window) || (window->DockIsActive)) window_title_visible_elsewhere = true; - else if (g.NavWindowingListWindow != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB + else if (g.NavWindowingListWindow != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB window_title_visible_elsewhere = true; if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0) { @@ -6893,11 +7310,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (!window->Viewport->GetMainRect().Contains(window->Rect())) { // This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport) - //ImGuiViewport* old_viewport = window->Viewport; + // ImGuiViewport* old_viewport = window->Viewport; window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing); // FIXME-DPI - //IM_ASSERT(old_viewport->DpiScale == window->Viewport->DpiScale); // FIXME-DPI: Something went wrong + // IM_ASSERT(old_viewport->DpiScale == window->Viewport->DpiScale); // FIXME-DPI: Something went wrong SetCurrentViewport(window, window->Viewport); window->FontDpiScale = (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ? window->Viewport->DpiScale : 1.0f; SetCurrentWindow(window); @@ -6925,7 +7342,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) else if (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0) { // Lost windows (e.g. a monitor disconnected) will naturally moved to the fallback/dummy monitor aka the main viewport. - const ImGuiPlatformMonitor* monitor = GetViewportPlatformMonitor(window->Viewport); + const ImGuiPlatformMonitor *monitor = GetViewportPlatformMonitor(window->Viewport); visibility_rect.Min = monitor->WorkPos + visibility_padding; visibility_rect.Max = monitor->WorkPos + monitor->WorkSize - visibility_padding; ClampWindowRect(window, visibility_rect); @@ -6938,10 +7355,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (window->ViewportOwned || window->DockIsActive) window->WindowRounding = 0.0f; else - window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding; + window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding + : style.WindowRounding; // For windows with title bar or menu bar, we clamp to FrameHeight(FontSize + FramePadding.y * 2.0f) to completely hide artifacts. - //if ((window->Flags & ImGuiWindowFlags_MenuBar) || !(window->Flags & ImGuiWindowFlags_NoTitleBar)) + // if ((window->Flags & ImGuiWindowFlags_MenuBar) || !(window->Flags & ImGuiWindowFlags_NoTitleBar)) // window->WindowRounding = ImMin(window->WindowRounding, g.FontSize + style.FramePadding.y * 2.0f); // Apply window focus (new and reactivated windows are moved to front) @@ -6953,7 +7371,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) else if ((window->DockIsActive || (flags & ImGuiWindowFlags_ChildWindow) == 0) && !(flags & ImGuiWindowFlags_Tooltip)) want_focus = true; - ImGuiWindow* modal = GetTopMostPopupModal(); + ImGuiWindow *modal = GetTopMostPopupModal(); if (modal != NULL && !IsWindowWithinBeginStackOf(window, modal)) { // Avoid focusing a window that is created outside of active modal. This will prevent active modal from being closed. @@ -6963,7 +7381,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) want_focus = false; if (window == window->RootWindow) { - ImGuiWindow* blocking_modal = FindBlockingModal(window); + ImGuiWindow *blocking_modal = FindBlockingModal(window); IM_ASSERT(blocking_modal != NULL); BringWindowToDisplayBehind(window, blocking_modal); } @@ -7021,7 +7439,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f; float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x; float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.y : avail_size_from_last_frame.y; - //bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons? + // bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons? window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar)); window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((needed_size_from_last_frame.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); if (window->ScrollbarX && !window->ScrollbarY) @@ -7107,7 +7525,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) { // - We test overlap with the previous child window only (testing all would end up being O(log N) not a good investment here) // - We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping childs - ImGuiWindow* previous_child = parent_window->DC.ChildWindows.Size >= 2 ? parent_window->DC.ChildWindows[parent_window->DC.ChildWindows.Size - 2] : NULL; + ImGuiWindow *previous_child = parent_window->DC.ChildWindows.Size >= 2 ? parent_window->DC.ChildWindows[parent_window->DC.ChildWindows.Size - 2] : NULL; bool previous_child_overlapping = previous_child ? previous_child->Rect().Overlaps(window->Rect()) : false; bool parent_is_empty = parent_window->DrawList->VtxBuffer.Size > 0; if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_is_empty && !previous_child_overlapping) @@ -7117,7 +7535,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->DrawList = parent_window->DrawList; // Handle title bar, scrollbar, resize grips and resize borders - const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow; + const ImGuiWindow *window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow; const bool title_bar_is_highlight = want_focus || (window_to_highlight && (window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight || (window->DockNode && window->DockNode == window_to_highlight->DockNode))); RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, handle_borders_and_resize_grips, resize_grip_count, resize_grip_col, resize_grip_draw_size); @@ -7161,7 +7579,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // This is used by clipper to compensate and fix the most common use case of large scroll area. Easy and cheap, next best thing compared to switching everything to double or ImU64. double start_pos_highp_x = (double)window->Pos.x + window->WindowPadding.x - (double)window->Scroll.x + window->DC.ColumnsOffset.x; double start_pos_highp_y = (double)window->Pos.y + window->WindowPadding.y - (double)window->Scroll.y + decoration_up_height; - window->DC.CursorStartPos = ImVec2((float)start_pos_highp_x, (float)start_pos_highp_y); + window->DC.CursorStartPos = ImVec2((float)start_pos_highp_x, (float)start_pos_highp_y); window->DC.CursorStartPosLossyness = ImVec2((float)(start_pos_highp_x - window->DC.CursorStartPos.x), (float)(start_pos_highp_y - window->DC.CursorStartPos.y)); window->DC.CursorPos = window->DC.CursorStartPos; window->DC.CursorPosPrevLine = window->DC.CursorPos; @@ -7296,7 +7714,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) { // Child window can be out of sight and have "negative" clip windows. // Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar). - IM_ASSERT((flags& ImGuiWindowFlags_NoTitleBar) != 0 || (window->DockIsActive)); + IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0 || (window->DockIsActive)); if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) // FIXME: Doesn't make sense for ChildWindow?? { const bool nav_request = (flags & ImGuiWindowFlags_NavFlattened) && (g.NavAnyRequest && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav); @@ -7350,8 +7768,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) void ImGui::End() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; // Error checking: verify that user hasn't called End() too many times! if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow) @@ -7368,11 +7786,11 @@ void ImGui::End() // Close anything that is open if (window->DC.CurrentColumns) EndColumns(); - if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle + if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle PopClipRect(); // Stop logging - if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging + if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging LogFinish(); if (window->DC.IsSetPos) @@ -7380,7 +7798,7 @@ void ImGui::End() // Docking: report contents sizes to parent to allow for auto-resize if (window->DockNode && window->DockTabIsVisible) - if (ImGuiWindow* host_window = window->DockNode->HostWindow) // FIXME-DOCK + if (ImGuiWindow *host_window = window->DockNode->HostWindow) // FIXME-DOCK host_window->DC.CursorMaxPos = window->DC.CursorMaxPos + window->WindowPadding - host_window->WindowPadding; // Pop from window stack @@ -7396,9 +7814,9 @@ void ImGui::End() SetCurrentViewport(g.CurrentWindow, g.CurrentWindow->Viewport); } -void ImGui::BringWindowToFocusFront(ImGuiWindow* window) +void ImGui::BringWindowToFocusFront(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(window == window->RootWindow); const int cur_order = window->FocusOrder; @@ -7417,67 +7835,67 @@ void ImGui::BringWindowToFocusFront(ImGuiWindow* window) window->FocusOrder = (short)new_order; } -void ImGui::BringWindowToDisplayFront(ImGuiWindow* window) +void ImGui::BringWindowToDisplayFront(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; - ImGuiWindow* current_front_window = g.Windows.back(); + ImGuiContext &g = *GImGui; + ImGuiWindow *current_front_window = g.Windows.back(); if (current_front_window == window || current_front_window->RootWindowDockTree == window) // Cheap early out (could be better) return; for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the top-most window if (g.Windows[i] == window) { - memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*)); + memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow *)); g.Windows[g.Windows.Size - 1] = window; break; } } -void ImGui::BringWindowToDisplayBack(ImGuiWindow* window) +void ImGui::BringWindowToDisplayBack(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.Windows[0] == window) return; for (int i = 0; i < g.Windows.Size; i++) if (g.Windows[i] == window) { - memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*)); + memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow *)); g.Windows[0] = window; break; } } -void ImGui::BringWindowToDisplayBehind(ImGuiWindow* window, ImGuiWindow* behind_window) +void ImGui::BringWindowToDisplayBehind(ImGuiWindow *window, ImGuiWindow *behind_window) { IM_ASSERT(window != NULL && behind_window != NULL); - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; window = window->RootWindow; behind_window = behind_window->RootWindow; int pos_wnd = FindWindowDisplayIndex(window); int pos_beh = FindWindowDisplayIndex(behind_window); if (pos_wnd < pos_beh) { - size_t copy_bytes = (pos_beh - pos_wnd - 1) * sizeof(ImGuiWindow*); + size_t copy_bytes = (pos_beh - pos_wnd - 1) * sizeof(ImGuiWindow *); memmove(&g.Windows.Data[pos_wnd], &g.Windows.Data[pos_wnd + 1], copy_bytes); g.Windows[pos_beh - 1] = window; } else { - size_t copy_bytes = (pos_wnd - pos_beh) * sizeof(ImGuiWindow*); + size_t copy_bytes = (pos_wnd - pos_beh) * sizeof(ImGuiWindow *); memmove(&g.Windows.Data[pos_beh + 1], &g.Windows.Data[pos_beh], copy_bytes); g.Windows[pos_beh] = window; } } -int ImGui::FindWindowDisplayIndex(ImGuiWindow* window) +int ImGui::FindWindowDisplayIndex(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.Windows.index_from_ptr(g.Windows.find(window)); } // Moving window to front of display and set focus (which happens to be back of our sorted list) -void ImGui::FocusWindow(ImGuiWindow* window) +void ImGui::FocusWindow(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.NavWindow != window) { @@ -7495,9 +7913,9 @@ void ImGui::FocusWindow(ImGuiWindow* window) // Move the root window to the top of the pile IM_ASSERT(window == NULL || window->RootWindowDockTree != NULL); - ImGuiWindow* focus_front_window = window ? window->RootWindow : NULL; - ImGuiWindow* display_front_window = window ? window->RootWindowDockTree : NULL; - ImGuiDockNode* dock_node = window ? window->DockNode : NULL; + ImGuiWindow *focus_front_window = window ? window->RootWindow : NULL; + ImGuiWindow *display_front_window = window ? window->RootWindowDockTree : NULL; + ImGuiDockNode *dock_node = window ? window->DockNode : NULL; bool active_id_window_is_dock_node_host = (g.ActiveIdWindow && dock_node && dock_node->HostWindow == g.ActiveIdWindow); // Steal active widgets. Some of the cases it triggers includes: @@ -7523,9 +7941,9 @@ void ImGui::FocusWindow(ImGuiWindow* window) BringWindowToDisplayFront(display_front_window); } -void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window) +void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow *under_this_window, ImGuiWindow *ignore_window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; int start_idx = g.WindowsFocusOrder.Size - 1; if (under_this_window != NULL) { @@ -7541,7 +7959,7 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind for (int i = start_idx; i >= 0; i--) { // We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user. - ImGuiWindow* window = g.WindowsFocusOrder[i]; + ImGuiWindow *window = g.WindowsFocusOrder[i]; IM_ASSERT(window == window->RootWindow); if (window != ignore_window && window->WasActive) if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) @@ -7550,7 +7968,7 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind // If A and B are docked into window and B disappear, at the NewFrame() call site window->NavLastChildNavWindow will still point to B. // We might leverage the tab order implicitly stored in window->DockNodeAsHost->TabBar (essentially the 'most_recently_selected_tab' code in tab bar will do that but on next update) // to tell which is the "previous" window. Or we may leverage 'LastFrameFocused/LastFrameJustFocused' and have this function handle child window itself? - ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window); + ImGuiWindow *focus_window = NavRestoreLastChildNavWindow(window); FocusWindow(focus_window); return; } @@ -7559,25 +7977,25 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind } // Important: this alone doesn't alter current ImDrawList state. This is called by PushFont/PopFont only. -void ImGui::SetCurrentFont(ImFont* font) +void ImGui::SetCurrentFont(ImFont *font) { - ImGuiContext& g = *GImGui; - IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ? + ImGuiContext &g = *GImGui; + IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ? IM_ASSERT(font->Scale > 0.0f); g.Font = font; g.FontBaseSize = ImMax(1.0f, g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale); g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f; - ImFontAtlas* atlas = g.Font->ContainerAtlas; + ImFontAtlas *atlas = g.Font->ContainerAtlas; g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel; g.DrawListSharedData.TexUvLines = atlas->TexUvLines; g.DrawListSharedData.Font = g.Font; g.DrawListSharedData.FontSize = g.FontSize; } -void ImGui::PushFont(ImFont* font) +void ImGui::PushFont(ImFont *font) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!font) font = GetDefaultFont(); SetCurrentFont(font); @@ -7585,9 +8003,9 @@ void ImGui::PushFont(ImFont* font) g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID); } -void ImGui::PopFont() +void ImGui::PopFont() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.CurrentWindow->DrawList->PopTextureID(); g.FontStack.pop_back(); SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back()); @@ -7595,7 +8013,7 @@ void ImGui::PopFont() void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiItemFlags item_flags = g.CurrentItemFlags; IM_ASSERT(item_flags == g.ItemFlagsStack.back()); if (enabled) @@ -7608,7 +8026,7 @@ void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) void ImGui::PopItemFlag() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.ItemFlagsStack.Size > 1); // Too many calls to PopItemFlag() - we always leave a 0 at the bottom of the stack. g.ItemFlagsStack.pop_back(); g.CurrentItemFlags = g.ItemFlagsStack.back(); @@ -7622,7 +8040,7 @@ void ImGui::PopItemFlag() // - Optimized shortcuts instead of PushStyleVar() + PushItemFlag() void ImGui::BeginDisabled(bool disabled) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; if (!was_disabled && disabled) { @@ -7637,15 +8055,15 @@ void ImGui::BeginDisabled(bool disabled) void ImGui::EndDisabled() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.DisabledStackSize > 0); g.DisabledStackSize--; bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; - //PopItemFlag(); + // PopItemFlag(); g.ItemFlagsStack.pop_back(); g.CurrentItemFlags = g.ItemFlagsStack.back(); if (was_disabled && (g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0) - g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar(); + g.Style.Alpha = g.DisabledAlphaBackup; // PopStyleVar(); } // FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system. @@ -7671,36 +8089,36 @@ void ImGui::PopButtonRepeat() void ImGui::PushTextWrapPos(float wrap_pos_x) { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.TextWrapPosStack.push_back(window->DC.TextWrapPos); window->DC.TextWrapPos = wrap_pos_x; } void ImGui::PopTextWrapPos() { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.TextWrapPos = window->DC.TextWrapPosStack.back(); window->DC.TextWrapPosStack.pop_back(); } -static ImGuiWindow* GetCombinedRootWindow(ImGuiWindow* window, bool popup_hierarchy, bool dock_hierarchy) +static ImGuiWindow *GetCombinedRootWindow(ImGuiWindow *window, bool popup_hierarchy, bool dock_hierarchy) { - ImGuiWindow* last_window = NULL; + ImGuiWindow *last_window = NULL; while (last_window != window) { last_window = window; window = window->RootWindow; if (popup_hierarchy) window = window->RootWindowPopupTree; - if (dock_hierarchy) - window = window->RootWindowDockTree; - } + if (dock_hierarchy) + window = window->RootWindowDockTree; + } return window; } -bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy, bool dock_hierarchy) +bool ImGui::IsWindowChildOf(ImGuiWindow *window, ImGuiWindow *potential_parent, bool popup_hierarchy, bool dock_hierarchy) { - ImGuiWindow* window_root = GetCombinedRootWindow(window, popup_hierarchy, dock_hierarchy); + ImGuiWindow *window_root = GetCombinedRootWindow(window, popup_hierarchy, dock_hierarchy); if (window_root == potential_parent) return true; while (window != NULL) @@ -7714,7 +8132,7 @@ bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, return false; } -bool ImGui::IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent) +bool ImGui::IsWindowWithinBeginStackOf(ImGuiWindow *window, ImGuiWindow *potential_parent) { if (window->RootWindow == potential_parent) return true; @@ -7727,9 +8145,9 @@ bool ImGui::IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potenti return false; } -bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below) +bool ImGui::IsWindowAbove(ImGuiWindow *potential_above, ImGuiWindow *potential_below) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // It would be saner to ensure that display layer is always reflected in the g.Windows[] order, which would likely requires altering all manipulations of that array const int display_layer_delta = GetWindowDisplayLayer(potential_above) - GetWindowDisplayLayer(potential_below); @@ -7738,7 +8156,7 @@ bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_b for (int i = g.Windows.Size - 1; i >= 0; i--) { - ImGuiWindow* candidate_window = g.Windows[i]; + ImGuiWindow *candidate_window = g.Windows[i]; if (candidate_window == potential_above) return true; if (candidate_window == potential_below) @@ -7749,10 +8167,10 @@ bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_b bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) { - IM_ASSERT((flags & (ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled)) == 0); // Flags not supported by this function - ImGuiContext& g = *GImGui; - ImGuiWindow* ref_window = g.HoveredWindow; - ImGuiWindow* cur_window = g.CurrentWindow; + IM_ASSERT((flags & (ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled)) == 0); // Flags not supported by this function + ImGuiContext &g = *GImGui; + ImGuiWindow *ref_window = g.HoveredWindow; + ImGuiWindow *cur_window = g.CurrentWindow; if (ref_window == NULL) return false; @@ -7783,9 +8201,9 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* ref_window = g.NavWindow; - ImGuiWindow* cur_window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *ref_window = g.NavWindow; + ImGuiWindow *cur_window = g.CurrentWindow; if (ref_window == NULL) return false; @@ -7806,44 +8224,44 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) ImGuiID ImGui::GetWindowDockID() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.CurrentWindow->DockId; } bool ImGui::IsWindowDocked() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.CurrentWindow->DockIsActive; } // Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext) // Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmatically. // If you want a window to never be focused, you may use the e.g. NoInputs flag. -bool ImGui::IsWindowNavFocusable(ImGuiWindow* window) +bool ImGui::IsWindowNavFocusable(ImGuiWindow *window) { return window->WasActive && window == window->RootWindow && !(window->Flags & ImGuiWindowFlags_NoNavFocus); } float ImGui::GetWindowWidth() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->Size.x; } float ImGui::GetWindowHeight() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->Size.y; } ImVec2 ImGui::GetWindowPos() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; return window->Pos; } -void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) +void ImGui::SetWindowPos(ImGuiWindow *window, const ImVec2 &pos, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowPosAllowFlags & cond) == 0) @@ -7861,31 +8279,31 @@ void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) return; MarkIniSettingsDirty(window); // FIXME: share code with TranslateWindow(), need to confirm whether the 3 rect modified by TranslateWindow() are desirable here. - window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor - window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. + window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor + window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. window->DC.IdealMaxPos += offset; window->DC.CursorStartPos += offset; } -void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond) +void ImGui::SetWindowPos(const ImVec2 &pos, ImGuiCond cond) { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); SetWindowPos(window, pos, cond); } -void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond) +void ImGui::SetWindowPos(const char *name, const ImVec2 &pos, ImGuiCond cond) { - if (ImGuiWindow* window = FindWindowByName(name)) + if (ImGuiWindow *window = FindWindowByName(name)) SetWindowPos(window, pos, cond); } ImVec2 ImGui::GetWindowSize() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->Size; } -void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond) +void ImGui::SetWindowSize(ImGuiWindow *window, const ImVec2 &size, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) @@ -7910,18 +8328,18 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con MarkIniSettingsDirty(window); } -void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond) +void ImGui::SetWindowSize(const ImVec2 &size, ImGuiCond cond) { SetWindowSize(GImGui->CurrentWindow, size, cond); } -void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond) +void ImGui::SetWindowSize(const char *name, const ImVec2 &size, ImGuiCond cond) { - if (ImGuiWindow* window = FindWindowByName(name)) + if (ImGuiWindow *window = FindWindowByName(name)) SetWindowSize(window, size, cond); } -void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond) +void ImGui::SetWindowCollapsed(ImGuiWindow *window, bool collapsed, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) @@ -7932,9 +8350,9 @@ void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond co window->Collapsed = collapsed; } -void ImGui::SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size) +void ImGui::SetWindowHitTestHole(ImGuiWindow *window, const ImVec2 &pos, const ImVec2 &size) { - IM_ASSERT(window->HitTestHoleSize.x == 0); // We don't support multiple holes/hit test filters + IM_ASSERT(window->HitTestHoleSize.x == 0); // We don't support multiple holes/hit test filters window->HitTestHoleSize = ImVec2ih(size); window->HitTestHoleOffset = ImVec2ih(pos - window->Pos); } @@ -7946,19 +8364,19 @@ void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond) bool ImGui::IsWindowCollapsed() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->Collapsed; } bool ImGui::IsWindowAppearing() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->Appearing; } -void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond) +void ImGui::SetWindowCollapsed(const char *name, bool collapsed, ImGuiCond cond) { - if (ImGuiWindow* window = FindWindowByName(name)) + if (ImGuiWindow *window = FindWindowByName(name)) SetWindowCollapsed(window, collapsed, cond); } @@ -7967,11 +8385,11 @@ void ImGui::SetWindowFocus() FocusWindow(GImGui->CurrentWindow); } -void ImGui::SetWindowFocus(const char* name) +void ImGui::SetWindowFocus(const char *name) { if (name) { - if (ImGuiWindow* window = FindWindowByName(name)) + if (ImGuiWindow *window = FindWindowByName(name)) FocusWindow(window); } else @@ -7980,9 +8398,9 @@ void ImGui::SetWindowFocus(const char* name) } } -void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot) +void ImGui::SetNextWindowPos(const ImVec2 &pos, ImGuiCond cond, const ImVec2 &pivot) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasPos; g.NextWindowData.PosVal = pos; @@ -7991,18 +8409,18 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi g.NextWindowData.PosUndock = true; } -void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) +void ImGui::SetNextWindowSize(const ImVec2 &size, ImGuiCond cond) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSize; g.NextWindowData.SizeVal = size; g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always; } -void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data) +void ImGui::SetNextWindowSizeConstraints(const ImVec2 &size_min, const ImVec2 &size_max, ImGuiSizeCallback custom_callback, void *custom_callback_user_data) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max); g.NextWindowData.SizeCallback = custom_callback; @@ -8011,23 +8429,23 @@ void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& s // Content size = inner scrollable rectangle, padded with WindowPadding. // SetNextWindowContentSize(ImVec2(100,100) + ImGuiWindowFlags_AlwaysAutoResize will always allow submitting a 100x100 item. -void ImGui::SetNextWindowContentSize(const ImVec2& size) +void ImGui::SetNextWindowContentSize(const ImVec2 &size) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasContentSize; g.NextWindowData.ContentSizeVal = ImFloor(size); } -void ImGui::SetNextWindowScroll(const ImVec2& scroll) +void ImGui::SetNextWindowScroll(const ImVec2 &scroll) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasScroll; g.NextWindowData.ScrollVal = scroll; } void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasCollapsed; g.NextWindowData.CollapsedVal = collapsed; @@ -8036,60 +8454,60 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) void ImGui::SetNextWindowFocus() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus; } void ImGui::SetNextWindowBgAlpha(float alpha) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha; g.NextWindowData.BgAlphaVal = alpha; } void ImGui::SetNextWindowViewport(ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasViewport; g.NextWindowData.ViewportId = id; } void ImGui::SetNextWindowDockID(ImGuiID id, ImGuiCond cond) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasDock; g.NextWindowData.DockCond = cond ? cond : ImGuiCond_Always; g.NextWindowData.DockId = id; } -void ImGui::SetNextWindowClass(const ImGuiWindowClass* window_class) +void ImGui::SetNextWindowClass(const ImGuiWindowClass *window_class) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT((window_class->ViewportFlagsOverrideSet & window_class->ViewportFlagsOverrideClear) == 0); // Cannot set both set and clear for the same bit g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasWindowClass; g.NextWindowData.WindowClass = *window_class; } -ImDrawList* ImGui::GetWindowDrawList() +ImDrawList *ImGui::GetWindowDrawList() { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); return window->DrawList; } float ImGui::GetWindowDpiScale() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.CurrentDpiScale; } -ImGuiViewport* ImGui::GetWindowViewport() +ImGuiViewport *ImGui::GetWindowViewport() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.CurrentViewport != NULL && g.CurrentViewport == g.CurrentWindow->Viewport); return g.CurrentViewport; } -ImFont* ImGui::GetFont() +ImFont *ImGui::GetFont() { return GImGui->Font; } @@ -8107,31 +8525,31 @@ ImVec2 ImGui::GetFontTexUvWhitePixel() void ImGui::SetWindowFontScale(float scale) { IM_ASSERT(scale > 0.0f); - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); + ImGuiContext &g = *GImGui; + ImGuiWindow *window = GetCurrentWindow(); window->FontWindowScale = scale; g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); } void ImGui::ActivateItem(ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NavNextActivateId = id; g.NavNextActivateFlags = ImGuiActivateFlags_None; } void ImGui::PushFocusScope(ImGuiID id) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; g.FocusScopeStack.push_back(window->DC.NavFocusScopeIdCurrent); window->DC.NavFocusScopeIdCurrent = id; } void ImGui::PopFocusScope() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IM_ASSERT(g.FocusScopeStack.Size > 0); // Too many PopFocusScope() ? window->DC.NavFocusScopeIdCurrent = g.FocusScopeStack.back(); g.FocusScopeStack.pop_back(); @@ -8140,9 +8558,9 @@ void ImGui::PopFocusScope() // Note: this will likely be called ActivateItem() once we rework our Focus/Activation system! void ImGui::SetKeyboardFocusHere(int offset) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(offset >= -1); // -1 is allowed but not below + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + IM_ASSERT(offset >= -1); // -1 is allowed but not below IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name); // It makes sense in the vast majority of cases to never interrupt a drag and drop. @@ -8172,8 +8590,8 @@ void ImGui::SetKeyboardFocusHere(int offset) void ImGui::SetItemDefaultFocus() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (!window->Appearing) return; if (g.NavWindow != window->RootWindowForNav || (!g.NavInitRequest && g.NavInitResultId == 0) || g.NavLayer != window->DC.NavLayerCurrent) @@ -8189,46 +8607,46 @@ void ImGui::SetItemDefaultFocus() ScrollToRectEx(window, g.LastItemData.Rect, ImGuiScrollFlags_None); } -void ImGui::SetStateStorage(ImGuiStorage* tree) +void ImGui::SetStateStorage(ImGuiStorage *tree) { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; window->DC.StateStorage = tree ? tree : &window->StateStorage; } -ImGuiStorage* ImGui::GetStateStorage() +ImGuiStorage *ImGui::GetStateStorage() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->DC.StateStorage; } -void ImGui::PushID(const char* str_id) +void ImGui::PushID(const char *str_id) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImGuiID id = window->GetID(str_id); window->IDStack.push_back(id); } -void ImGui::PushID(const char* str_id_begin, const char* str_id_end) +void ImGui::PushID(const char *str_id_begin, const char *str_id_end) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImGuiID id = window->GetID(str_id_begin, str_id_end); window->IDStack.push_back(id); } -void ImGui::PushID(const void* ptr_id) +void ImGui::PushID(const void *ptr_id) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImGuiID id = window->GetID(ptr_id); window->IDStack.push_back(id); } void ImGui::PushID(int int_id) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImGuiID id = window->GetID(int_id); window->IDStack.push_back(id); } @@ -8236,8 +8654,8 @@ void ImGui::PushID(int int_id) // Push a given id value ignoring the ID stack as a seed. void ImGui::PushOverrideID(ImGuiID id) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (g.DebugHookIdInfo == id) DebugHookIdInfo(id, ImGuiDataType_ID, NULL, NULL); window->IDStack.push_back(id); @@ -8246,10 +8664,10 @@ void ImGui::PushOverrideID(ImGuiID id) // Helper to avoid a common series of PushOverrideID -> GetID() -> PopID() call // (note that when using this pattern, TestEngine's "Stack Tool" will tend to not display the intermediate stack level. // for that to work we would need to do PushOverrideID() -> ItemAdd() -> PopID() which would alter widget code a little more) -ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed) +ImGuiID ImGui::GetIDWithSeed(const char *str, const char *str_end, ImGuiID seed) { ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.DebugHookIdInfo == id) DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); return id; @@ -8257,42 +8675,41 @@ ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed) void ImGui::PopID() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; IM_ASSERT(window->IDStack.Size > 1); // Too many PopID(), or could be popping in a wrong/different window? window->IDStack.pop_back(); } -ImGuiID ImGui::GetID(const char* str_id) +ImGuiID ImGui::GetID(const char *str_id) { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->GetID(str_id); } -ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end) +ImGuiID ImGui::GetID(const char *str_id_begin, const char *str_id_end) { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->GetID(str_id_begin, str_id_end); } -ImGuiID ImGui::GetID(const void* ptr_id) +ImGuiID ImGui::GetID(const void *ptr_id) { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->GetID(ptr_id); } -bool ImGui::IsRectVisible(const ImVec2& size) +bool ImGui::IsRectVisible(const ImVec2 &size) { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); } -bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) +bool ImGui::IsRectVisible(const ImVec2 &rect_min, const ImVec2 &rect_max) { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); } - //----------------------------------------------------------------------------- // [SECTION] INPUTS //----------------------------------------------------------------------------- @@ -8300,9 +8717,9 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) // Test if mouse cursor is hovering given rectangle // NB- Rectangle is clipped by our current clip setting // NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) -bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) +bool ImGui::IsMouseHoveringRect(const ImVec2 &r_min, const ImVec2 &r_max, bool clip) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Clip ImRect rect_clipped(r_min, r_max); @@ -8318,9 +8735,9 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c return true; } -ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key) +ImGuiKeyData *ImGui::GetKeyData(ImGuiKey key) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; int index; #ifndef IMGUI_DISABLE_OBSOLETE_KEYIO IM_ASSERT(key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_NamedKey_END); @@ -8338,46 +8755,167 @@ ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key) #ifndef IMGUI_DISABLE_OBSOLETE_KEYIO int ImGui::GetKeyIndex(ImGuiKey key) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(IsNamedKey(key)); - const ImGuiKeyData* key_data = GetKeyData(key); + const ImGuiKeyData *key_data = GetKeyData(key); return (int)(key_data - g.IO.KeysData); } #endif // Those names a provided for debugging purpose and are not meant to be saved persistently not compared. -static const char* const GKeyNames[] = -{ - "Tab", "LeftArrow", "RightArrow", "UpArrow", "DownArrow", "PageUp", "PageDown", - "Home", "End", "Insert", "Delete", "Backspace", "Space", "Enter", "Escape", - "LeftCtrl", "LeftShift", "LeftAlt", "LeftSuper", "RightCtrl", "RightShift", "RightAlt", "RightSuper", "Menu", - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", - "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", - "Apostrophe", "Comma", "Minus", "Period", "Slash", "Semicolon", "Equal", "LeftBracket", - "Backslash", "RightBracket", "GraveAccent", "CapsLock", "ScrollLock", "NumLock", "PrintScreen", - "Pause", "Keypad0", "Keypad1", "Keypad2", "Keypad3", "Keypad4", "Keypad5", "Keypad6", - "Keypad7", "Keypad8", "Keypad9", "KeypadDecimal", "KeypadDivide", "KeypadMultiply", - "KeypadSubtract", "KeypadAdd", "KeypadEnter", "KeypadEqual", - "GamepadStart", "GamepadBack", - "GamepadFaceLeft", "GamepadFaceRight", "GamepadFaceUp", "GamepadFaceDown", - "GamepadDpadLeft", "GamepadDpadRight", "GamepadDpadUp", "GamepadDpadDown", - "GamepadL1", "GamepadR1", "GamepadL2", "GamepadR2", "GamepadL3", "GamepadR3", - "GamepadLStickLeft", "GamepadLStickRight", "GamepadLStickUp", "GamepadLStickDown", - "GamepadRStickLeft", "GamepadRStickRight", "GamepadRStickUp", "GamepadRStickDown", - "ModCtrl", "ModShift", "ModAlt", "ModSuper", - "MouseLeft", "MouseRight", "MouseMiddle", "MouseX1", "MouseX2", "MouseWheelX", "MouseWheelY", +static const char *const GKeyNames[] = + { + "Tab", + "LeftArrow", + "RightArrow", + "UpArrow", + "DownArrow", + "PageUp", + "PageDown", + "Home", + "End", + "Insert", + "Delete", + "Backspace", + "Space", + "Enter", + "Escape", + "LeftCtrl", + "LeftShift", + "LeftAlt", + "LeftSuper", + "RightCtrl", + "RightShift", + "RightAlt", + "RightSuper", + "Menu", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "F1", + "F2", + "F3", + "F4", + "F5", + "F6", + "F7", + "F8", + "F9", + "F10", + "F11", + "F12", + "Apostrophe", + "Comma", + "Minus", + "Period", + "Slash", + "Semicolon", + "Equal", + "LeftBracket", + "Backslash", + "RightBracket", + "GraveAccent", + "CapsLock", + "ScrollLock", + "NumLock", + "PrintScreen", + "Pause", + "Keypad0", + "Keypad1", + "Keypad2", + "Keypad3", + "Keypad4", + "Keypad5", + "Keypad6", + "Keypad7", + "Keypad8", + "Keypad9", + "KeypadDecimal", + "KeypadDivide", + "KeypadMultiply", + "KeypadSubtract", + "KeypadAdd", + "KeypadEnter", + "KeypadEqual", + "GamepadStart", + "GamepadBack", + "GamepadFaceLeft", + "GamepadFaceRight", + "GamepadFaceUp", + "GamepadFaceDown", + "GamepadDpadLeft", + "GamepadDpadRight", + "GamepadDpadUp", + "GamepadDpadDown", + "GamepadL1", + "GamepadR1", + "GamepadL2", + "GamepadR2", + "GamepadL3", + "GamepadR3", + "GamepadLStickLeft", + "GamepadLStickRight", + "GamepadLStickUp", + "GamepadLStickDown", + "GamepadRStickLeft", + "GamepadRStickRight", + "GamepadRStickUp", + "GamepadRStickDown", + "ModCtrl", + "ModShift", + "ModAlt", + "ModSuper", + "MouseLeft", + "MouseRight", + "MouseMiddle", + "MouseX1", + "MouseX2", + "MouseWheelX", + "MouseWheelY", }; IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames)); -const char* ImGui::GetKeyName(ImGuiKey key) +const char *ImGui::GetKeyName(ImGuiKey key) { #ifdef IMGUI_DISABLE_OBSOLETE_KEYIO IM_ASSERT((IsNamedKey(key) || key == ImGuiKey_None) && "Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code."); #else if (IsLegacyKey(key)) { - ImGuiIO& io = GetIO(); + ImGuiIO &io = GetIO(); if (io.KeyMap[key] == -1) return "N/A"; IM_ASSERT(IsNamedKey((ImGuiKey)io.KeyMap[key])); @@ -8392,16 +8930,16 @@ const char* ImGui::GetKeyName(ImGuiKey key) return GKeyNames[key - ImGuiKey_NamedKey_BEGIN]; } -void ImGui::GetKeyChordName(ImGuiModFlags mods, ImGuiKey key, char* out_buf, int out_buf_size) +void ImGui::GetKeyChordName(ImGuiModFlags mods, ImGuiKey key, char *out_buf, int out_buf_size) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT((mods & ~ImGuiModFlags_All) == 0 && "Passing invalid ImGuiModFlags value!"); // A frequent mistake is to pass ImGuiKey_ModXXX instead of ImGuiModFlags_XXX ImFormatString(out_buf, (size_t)out_buf_size, "%s%s%s%s%s", - (mods & ImGuiModFlags_Ctrl) ? "Ctrl+" : "", - (mods & ImGuiModFlags_Shift) ? "Shift+" : "", - (mods & ImGuiModFlags_Alt) ? "Alt+" : "", - (mods & ImGuiModFlags_Super) ? (g.IO.ConfigMacOSXBehaviors ? "Cmd+" : "Super+") : "", - GetKeyName(key)); + (mods & ImGuiModFlags_Ctrl) ? "Ctrl+" : "", + (mods & ImGuiModFlags_Shift) ? "Shift+" : "", + (mods & ImGuiModFlags_Alt) ? "Alt+" : "", + (mods & ImGuiModFlags_Super) ? (g.IO.ConfigMacOSXBehaviors ? "Cmd+" : "Super+") : "", + GetKeyName(key)); } // t0 = previous time (e.g.: g.Time - g.IO.DeltaTime) @@ -8422,14 +8960,24 @@ int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, flo return count; } -void ImGui::GetTypematicRepeatRate(ImGuiInputFlags flags, float* repeat_delay, float* repeat_rate) +void ImGui::GetTypematicRepeatRate(ImGuiInputFlags flags, float *repeat_delay, float *repeat_rate) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; switch (flags & ImGuiInputFlags_RepeatRateMask_) { - case ImGuiInputFlags_RepeatRateNavMove: *repeat_delay = g.IO.KeyRepeatDelay * 0.72f; *repeat_rate = g.IO.KeyRepeatRate * 0.80f; return; - case ImGuiInputFlags_RepeatRateNavTweak: *repeat_delay = g.IO.KeyRepeatDelay * 0.72f; *repeat_rate = g.IO.KeyRepeatRate * 0.30f; return; - case ImGuiInputFlags_RepeatRateDefault: default: *repeat_delay = g.IO.KeyRepeatDelay * 1.00f; *repeat_rate = g.IO.KeyRepeatRate * 1.00f; return; + case ImGuiInputFlags_RepeatRateNavMove: + *repeat_delay = g.IO.KeyRepeatDelay * 0.72f; + *repeat_rate = g.IO.KeyRepeatRate * 0.80f; + return; + case ImGuiInputFlags_RepeatRateNavTweak: + *repeat_delay = g.IO.KeyRepeatDelay * 0.72f; + *repeat_rate = g.IO.KeyRepeatRate * 0.30f; + return; + case ImGuiInputFlags_RepeatRateDefault: + default: + *repeat_delay = g.IO.KeyRepeatDelay * 1.00f; + *repeat_rate = g.IO.KeyRepeatRate * 1.00f; + return; } } @@ -8437,8 +8985,8 @@ void ImGui::GetTypematicRepeatRate(ImGuiInputFlags flags, float* repeat_delay, f // (most often returns 0 or 1. The result is generally only >1 when RepeatRate is smaller than DeltaTime, aka large DeltaTime or fast RepeatRate) int ImGui::GetKeyPressedAmount(ImGuiKey key, float repeat_delay, float repeat_rate) { - ImGuiContext& g = *GImGui; - const ImGuiKeyData* key_data = GetKeyData(key); + ImGuiContext &g = *GImGui; + const ImGuiKeyData *key_data = GetKeyData(key); if (!key_data->Down) // In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitate eating mechanism (until we finish work on input ownership) return 0; const float t = key_data->DownDuration; @@ -8457,7 +9005,7 @@ ImVec2 ImGui::GetKeyVector2d(ImGuiKey key_left, ImGuiKey key_right, ImGuiKey key // Consider transitioning from 'IsKeyDown(MY_ENGINE_KEY_A)' (<1.87) to IsKeyDown(ImGuiKey_A) (>= 1.87) bool ImGui::IsKeyDown(ImGuiKey key) { - const ImGuiKeyData* key_data = GetKeyData(key); + const ImGuiKeyData *key_data = GetKeyData(key); if (!key_data->Down) return false; return true; @@ -8472,7 +9020,7 @@ bool ImGui::IsKeyPressed(ImGuiKey key, bool repeat) // [Internal] 2022/07: Do not call this directly! It is a temporary entry point which we will soon replace with an overload for IsKeyPressed() when we introduce key ownership. bool ImGui::IsKeyPressedEx(ImGuiKey key, ImGuiInputFlags flags) { - const ImGuiKeyData* key_data = GetKeyData(key); + const ImGuiKeyData *key_data = GetKeyData(key); if (!key_data->Down) // In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitate eating mechanism (until we finish work on input ownership) return false; const float t = key_data->DownDuration; @@ -8494,7 +9042,7 @@ bool ImGui::IsKeyPressedEx(ImGuiKey key, ImGuiInputFlags flags) bool ImGui::IsKeyReleased(ImGuiKey key) { - const ImGuiKeyData* key_data = GetKeyData(key); + const ImGuiKeyData *key_data = GetKeyData(key); if (key_data->DownDurationPrev < 0.0f || key_data->Down) return false; return true; @@ -8502,14 +9050,14 @@ bool ImGui::IsKeyReleased(ImGuiKey key) bool ImGui::IsMouseDown(ImGuiMouseButton button) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseDown[button]; } bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (!g.IO.MouseDown[button]) // In theory this should already be encoded as (DownDuration < 0.0f), but testing this facilitate eating mechanism (until we finish work on input ownership) return false; @@ -8523,21 +9071,21 @@ bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat) bool ImGui::IsMouseReleased(ImGuiMouseButton button) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseReleased[button]; } bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseClickedCount[button] == 2; } int ImGui::GetMouseClickedCount(ImGuiMouseButton button) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseClickedCount[button]; } @@ -8546,7 +9094,7 @@ int ImGui::GetMouseClickedCount(ImGuiMouseButton button) // [Internal] This doesn't test if the button is pressed bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (lock_threshold < 0.0f) lock_threshold = g.IO.MouseDragThreshold; @@ -8555,7 +9103,7 @@ bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_thresho bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (!g.IO.MouseDown[button]) return false; @@ -8564,21 +9112,21 @@ bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold) ImVec2 ImGui::GetMousePos() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.IO.MousePos; } // NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed! ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.BeginPopupStack.Size > 0) return g.OpenPopupStack[g.BeginPopupStack.Size - 1].OpenMousePos; return g.IO.MousePos; } // We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position. -bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) +bool ImGui::IsMousePosValid(const ImVec2 *mouse_pos) { // The assert is only to silence a false-positive in XCode Static Analysis. // Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions). @@ -8591,7 +9139,7 @@ bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) // [WILL OBSOLETE] This was designed for backends, but prefer having backend maintain a mask of held mouse buttons, because upcoming input queue system will make this invalid. bool ImGui::IsAnyMouseDown() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++) if (g.IO.MouseDown[n]) return true; @@ -8603,7 +9151,7 @@ bool ImGui::IsAnyMouseDown() // NB: This is only valid if IsMousePosValid(). backends in theory should always keep mouse position valid when dragging even outside the client window. ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); if (lock_threshold < 0.0f) lock_threshold = g.IO.MouseDragThreshold; @@ -8616,7 +9164,7 @@ ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) void ImGui::ResetMouseDragDelta(ImGuiMouseButton button) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr g.IO.MouseClickedPos[button] = g.IO.MousePos; @@ -8624,44 +9172,68 @@ void ImGui::ResetMouseDragDelta(ImGuiMouseButton button) ImGuiMouseCursor ImGui::GetMouseCursor() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.MouseCursor; } void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.MouseCursor = cursor_type; } void ImGui::SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.WantCaptureKeyboardNextFrame = want_capture_keyboard ? 1 : 0; } void ImGui::SetNextFrameWantCaptureMouse(bool want_capture_mouse) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.WantCaptureMouseNextFrame = want_capture_mouse ? 1 : 0; } #ifndef IMGUI_DISABLE_DEBUG_TOOLS -static const char* GetInputSourceName(ImGuiInputSource source) +static const char *GetInputSourceName(ImGuiInputSource source) { - const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad", "Nav", "Clipboard" }; + const char *input_source_names[] = {"None", "Mouse", "Keyboard", "Gamepad", "Nav", "Clipboard"}; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT && source >= 0 && source < ImGuiInputSource_COUNT); return input_source_names[source]; } -static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e) +static void DebugPrintInputEvent(const char *prefix, const ImGuiInputEvent *e) { - ImGuiContext& g = *GImGui; - if (e->Type == ImGuiInputEventType_MousePos) { IMGUI_DEBUG_LOG_IO("%s: MousePos (%.1f, %.1f)\n", prefix, e->MousePos.PosX, e->MousePos.PosY); return; } - if (e->Type == ImGuiInputEventType_MouseButton) { IMGUI_DEBUG_LOG_IO("%s: MouseButton %d %s\n", prefix, e->MouseButton.Button, e->MouseButton.Down ? "Down" : "Up"); return; } - if (e->Type == ImGuiInputEventType_MouseWheel) { IMGUI_DEBUG_LOG_IO("%s: MouseWheel (%.1f, %.1f)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY); return; } - if (e->Type == ImGuiInputEventType_Key) { IMGUI_DEBUG_LOG_IO("%s: Key \"%s\" %s\n", prefix, ImGui::GetKeyName(e->Key.Key), e->Key.Down ? "Down" : "Up"); return; } - if (e->Type == ImGuiInputEventType_Text) { IMGUI_DEBUG_LOG_IO("%s: Text: %c (U+%08X)\n", prefix, e->Text.Char, e->Text.Char); return; } - if (e->Type == ImGuiInputEventType_Focus) { IMGUI_DEBUG_LOG_IO("%s: AppFocused %d\n", prefix, e->AppFocused.Focused); return; } + ImGuiContext &g = *GImGui; + if (e->Type == ImGuiInputEventType_MousePos) + { + IMGUI_DEBUG_LOG_IO("%s: MousePos (%.1f, %.1f)\n", prefix, e->MousePos.PosX, e->MousePos.PosY); + return; + } + if (e->Type == ImGuiInputEventType_MouseButton) + { + IMGUI_DEBUG_LOG_IO("%s: MouseButton %d %s\n", prefix, e->MouseButton.Button, e->MouseButton.Down ? "Down" : "Up"); + return; + } + if (e->Type == ImGuiInputEventType_MouseWheel) + { + IMGUI_DEBUG_LOG_IO("%s: MouseWheel (%.1f, %.1f)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY); + return; + } + if (e->Type == ImGuiInputEventType_Key) + { + IMGUI_DEBUG_LOG_IO("%s: Key \"%s\" %s\n", prefix, ImGui::GetKeyName(e->Key.Key), e->Key.Down ? "Down" : "Up"); + return; + } + if (e->Type == ImGuiInputEventType_Text) + { + IMGUI_DEBUG_LOG_IO("%s: Text: %c (U+%08X)\n", prefix, e->Text.Char, e->Text.Char); + return; + } + if (e->Type == ImGuiInputEventType_Focus) + { + IMGUI_DEBUG_LOG_IO("%s: AppFocused %d\n", prefix, e->AppFocused.Focused); + return; + } } #endif @@ -8671,8 +9243,8 @@ static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e) // - trickle_fast_inputs = true : process as many events as possible (successive down/up/down/up will be trickled over several frames so nothing is lost) (new feature in 1.87) void ImGui::UpdateInputEvents(bool trickle_fast_inputs) { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; // Only trickle chars<>key when working with InputText() // FIXME: InputText() could parse event trail? @@ -8680,13 +9252,13 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs) const bool trickle_interleaved_keys_and_text = (trickle_fast_inputs && g.WantTextInputNextFrame == 1); bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputted = false; - int mouse_button_changed = 0x00; + int mouse_button_changed = 0x00; ImBitArray key_changed_mask; int event_n = 0; for (; event_n < g.InputEventsQueue.Size; event_n++) { - ImGuiInputEvent* e = &g.InputEventsQueue[event_n]; + ImGuiInputEvent *e = &g.InputEventsQueue[event_n]; if (e->Type == ImGuiInputEventType_MousePos) { ImVec2 event_pos(e->MousePos.PosX, e->MousePos.PosY); @@ -8738,7 +9310,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs) ImGuiKey key = e->Key.Key; IM_ASSERT(key != ImGuiKey_None); const int keydata_index = (key - ImGuiKey_KeysData_OFFSET); - ImGuiKeyData* keydata = &io.KeysData[keydata_index]; + ImGuiKeyData *keydata = &io.KeysData[keydata_index]; e->IgnoredAsSame = (keydata->Down == e->Key.Down && keydata->AnalogValue == e->Key.AnalogValue); if (!e->IgnoredAsSame) { @@ -8752,10 +9324,22 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs) if (key == ImGuiKey_ModCtrl || key == ImGuiKey_ModShift || key == ImGuiKey_ModAlt || key == ImGuiKey_ModSuper) { - if (key == ImGuiKey_ModCtrl) { io.KeyCtrl = keydata->Down; } - if (key == ImGuiKey_ModShift) { io.KeyShift = keydata->Down; } - if (key == ImGuiKey_ModAlt) { io.KeyAlt = keydata->Down; } - if (key == ImGuiKey_ModSuper) { io.KeySuper = keydata->Down; } + if (key == ImGuiKey_ModCtrl) + { + io.KeyCtrl = keydata->Down; + } + if (key == ImGuiKey_ModShift) + { + io.KeyShift = keydata->Down; + } + if (key == ImGuiKey_ModAlt) + { + io.KeyAlt = keydata->Down; + } + if (key == ImGuiKey_ModSuper) + { + io.KeySuper = keydata->Down; + } io.KeyMods = GetMergedModFlags(); } @@ -8793,11 +9377,11 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs) } // Record trail (for domain-specific applications wanting to access a precise trail) - //if (event_n != 0) IMGUI_DEBUG_LOG_IO("Processed: %d / Remaining: %d\n", event_n, g.InputEventsQueue.Size - event_n); + // if (event_n != 0) IMGUI_DEBUG_LOG_IO("Processed: %d / Remaining: %d\n", event_n, g.InputEventsQueue.Size - event_n); for (int n = 0; n < event_n; n++) g.InputEventsTrail.push_back(g.InputEventsQueue[n]); - // [DEBUG] + // [DEBUG] #ifndef IMGUI_DISABLE_DEBUG_TOOLS if (event_n != 0 && (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO)) for (int n = 0; n < g.InputEventsQueue.Size; n++) @@ -8819,7 +9403,6 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs) } } - //----------------------------------------------------------------------------- // [SECTION] ERROR CHECKING //----------------------------------------------------------------------------- @@ -8832,16 +9415,44 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs) // The configuration settings mentioned in imconfig.h must be set for all compilation units involved with Dear ImGui, // which is way it is required you put them in your imconfig file (and not just before including imgui.h). // Otherwise it is possible that different compilation units would see different structure layout -bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) +bool ImGui::DebugCheckVersionAndDataLayout(const char *version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) { bool error = false; - if (strcmp(version, IMGUI_VERSION) != 0) { error = true; IM_ASSERT(strcmp(version, IMGUI_VERSION) == 0 && "Mismatched version string!"); } - if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); } - if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); } - if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); } - if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); } - if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); } - if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); } + if (strcmp(version, IMGUI_VERSION) != 0) + { + error = true; + IM_ASSERT(strcmp(version, IMGUI_VERSION) == 0 && "Mismatched version string!"); + } + if (sz_io != sizeof(ImGuiIO)) + { + error = true; + IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); + } + if (sz_style != sizeof(ImGuiStyle)) + { + error = true; + IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); + } + if (sz_vec2 != sizeof(ImVec2)) + { + error = true; + IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); + } + if (sz_vec4 != sizeof(ImVec4)) + { + error = true; + IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); + } + if (sz_vert != sizeof(ImDrawVert)) + { + error = true; + IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); + } + if (sz_idx != sizeof(ImDrawIdx)) + { + error = true; + IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); + } return !error; } @@ -8862,8 +9473,8 @@ bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, si // While this code is a little twisted, no-one would expect SetXXX(GetXXX()) to have a side-effect. Using vertical alignment patterns could trigger this issue. void ImGui::ErrorCheckUsingSetCursorPosToExtendParentBoundaries() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IM_ASSERT(window->DC.IsSetPos); window->DC.IsSetPos = false; #ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS @@ -8877,7 +9488,7 @@ void ImGui::ErrorCheckUsingSetCursorPosToExtendParentBoundaries() static void ImGui::ErrorCheckNewFrameSanityChecks() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Check user IM_ASSERT macro // (IF YOU GET A WARNING OR COMPILE ERROR HERE: it means your assert macro is incorrectly defined! @@ -8885,18 +9496,21 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() // This is a common C/C++ idiom to allow multiple statements macros to be used in control flow blocks.) // #define IM_ASSERT(EXPR) if (SomeCode(EXPR)) SomeMoreCode(); // Wrong! // #define IM_ASSERT(EXPR) do { if (SomeCode(EXPR)) SomeMoreCode(); } while (0) // Correct! - if (true) IM_ASSERT(1); else IM_ASSERT(0); + if (true) + IM_ASSERT(1); + else + IM_ASSERT(0); // Check user data // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) IM_ASSERT(g.Initialized); - IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); - IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); - IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); - IM_ASSERT(g.IO.Fonts->IsBuilt() && "Font Atlas not built! Make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()"); - IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); - IM_ASSERT(g.Style.CircleTessellationMaxError > 0.0f && "Invalid style setting!"); - IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting!"); // Allows us to avoid a few clamps in color computations + IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); + IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); + IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); + IM_ASSERT(g.IO.Fonts->IsBuilt() && "Font Atlas not built! Make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()"); + IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); + IM_ASSERT(g.Style.CircleTessellationMaxError > 0.0f && "Invalid style setting!"); + IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting!"); // Allows us to avoid a few clamps in color computations IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting."); IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right); IM_ASSERT(g.Style.ColorButtonPosition == ImGuiDir_Left || g.Style.ColorButtonPosition == ImGuiDir_Right); @@ -8925,10 +9539,10 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() if ((g.IO.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasViewports)) { IM_ASSERT((g.FrameCount == 0 || g.FrameCount == g.FrameCountPlatformEnded) && "Forgot to call UpdatePlatformWindows() in main loop after EndFrame()? Check examples/ applications for reference."); - IM_ASSERT(g.PlatformIO.Platform_CreateWindow != NULL && "Platform init didn't install handlers?"); + IM_ASSERT(g.PlatformIO.Platform_CreateWindow != NULL && "Platform init didn't install handlers?"); IM_ASSERT(g.PlatformIO.Platform_DestroyWindow != NULL && "Platform init didn't install handlers?"); - IM_ASSERT(g.PlatformIO.Platform_GetWindowPos != NULL && "Platform init didn't install handlers?"); - IM_ASSERT(g.PlatformIO.Platform_SetWindowPos != NULL && "Platform init didn't install handlers?"); + IM_ASSERT(g.PlatformIO.Platform_GetWindowPos != NULL && "Platform init didn't install handlers?"); + IM_ASSERT(g.PlatformIO.Platform_SetWindowPos != NULL && "Platform init didn't install handlers?"); IM_ASSERT(g.PlatformIO.Platform_GetWindowSize != NULL && "Platform init didn't install handlers?"); IM_ASSERT(g.PlatformIO.Platform_SetWindowSize != NULL && "Platform init didn't install handlers?"); IM_ASSERT(g.PlatformIO.Monitors.Size > 0 && "Platform init didn't setup Monitors list?"); @@ -8945,7 +9559,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() // Perform simple checks on platform monitor data + compute a total bounding box for quick early outs for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size; monitor_n++) { - ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[monitor_n]; + ImGuiPlatformMonitor &mon = g.PlatformIO.Monitors[monitor_n]; IM_UNUSED(mon); IM_ASSERT(mon.MainSize.x > 0.0f && mon.MainSize.y > 0.0f && "Monitor main bounds not setup properly."); IM_ASSERT(ImRect(mon.MainPos, mon.MainPos + mon.MainSize).Contains(ImRect(mon.WorkPos, mon.WorkPos + mon.WorkSize)) && "Monitor work bounds not setup properly. If you don't have work area information, just copy MainPos/MainSize into them."); @@ -8956,7 +9570,7 @@ static void ImGui::ErrorCheckNewFrameSanityChecks() static void ImGui::ErrorCheckEndFrameSanityChecks() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Verify that io.KeyXXX fields haven't been tampered with. Key mods should not be modified between NewFrame() and EndFrame() // One possible reason leading to this assert is that your backends update inputs _AFTER_ NewFrame(). @@ -8969,7 +9583,7 @@ static void ImGui::ErrorCheckEndFrameSanityChecks() IM_UNUSED(key_mods); // [EXPERIMENTAL] Recover from errors: You may call this yourself before EndFrame(). - //ErrorCheckEndFrameRecover(); + // ErrorCheckEndFrameRecover(); // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API). @@ -8995,14 +9609,14 @@ static void ImGui::ErrorCheckEndFrameSanityChecks() // This is generally flawed as we are not necessarily End/Popping things in the right order. // FIXME: Can't recover from inside BeginTabItem/EndTabItem yet. // FIXME: Can't recover from interleaved BeginTabBar/Begin -void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data) +void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void *user_data) { // PVS-Studio V1044 is "Loop break conditions do not depend on the number of iterations" - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; while (g.CurrentWindowStack.Size > 0) //-V1044 { ErrorCheckEndWindowRecover(log_callback, user_data); - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow *window = g.CurrentWindow; if (g.CurrentWindowStack.Size == 1) { IM_ASSERT(window->IsFallbackWindow); @@ -9010,73 +9624,85 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi } if (window->Flags & ImGuiWindowFlags_ChildWindow) { - if (log_callback) log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name); EndChild(); } else { - if (log_callback) log_callback(user_data, "Recovered from missing End() for '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing End() for '%s'", window->Name); End(); } } } // Must be called before End()/EndChild() -void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, void* user_data) +void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, void *user_data) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow)) { - if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name); EndTable(); } - ImGuiWindow* window = g.CurrentWindow; - ImGuiStackSizes* stack_sizes = &g.CurrentWindowStack.back().StackSizesOnBegin; + ImGuiWindow *window = g.CurrentWindow; + ImGuiStackSizes *stack_sizes = &g.CurrentWindowStack.back().StackSizesOnBegin; IM_ASSERT(window != NULL); while (g.CurrentTabBar != NULL) //-V1044 { - if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name); EndTabBar(); } while (window->DC.TreeDepth > 0) { - if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name); TreePop(); } while (g.GroupStack.Size > stack_sizes->SizeOfGroupStack) //-V1044 { - if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name); EndGroup(); } while (window->IDStack.Size > 1) { - if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name); PopID(); } while (g.DisabledStackSize > stack_sizes->SizeOfDisabledStack) //-V1044 { - if (log_callback) log_callback(user_data, "Recovered from missing EndDisabled() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing EndDisabled() in '%s'", window->Name); EndDisabled(); } while (g.ColorStack.Size > stack_sizes->SizeOfColorStack) { - if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col)); + if (log_callback) + log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col)); PopStyleColor(); } while (g.ItemFlagsStack.Size > stack_sizes->SizeOfItemFlagsStack) //-V1044 { - if (log_callback) log_callback(user_data, "Recovered from missing PopItemFlag() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing PopItemFlag() in '%s'", window->Name); PopItemFlag(); } while (g.StyleVarStack.Size > stack_sizes->SizeOfStyleVarStack) //-V1044 { - if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name); PopStyleVar(); } while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack) //-V1044 { - if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name); + if (log_callback) + log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name); PopFocusScope(); } } @@ -9084,8 +9710,8 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo // Save current stack sizes for later compare void ImGuiStackSizes::SetToCurrentState() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; SizeOfIDStack = (short)window->IDStack.Size; SizeOfColorStack = (short)g.ColorStack.Size; SizeOfStyleVarStack = (short)g.StyleVarStack.Size; @@ -9100,27 +9726,26 @@ void ImGuiStackSizes::SetToCurrentState() // Compare to detect usage errors void ImGuiStackSizes::CompareWithCurrentState() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IM_UNUSED(window); // Window stacks // NOT checking: DC.ItemWidth, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin) - IM_ASSERT(SizeOfIDStack == window->IDStack.Size && "PushID/PopID or TreeNode/TreePop Mismatch!"); + IM_ASSERT(SizeOfIDStack == window->IDStack.Size && "PushID/PopID or TreeNode/TreePop Mismatch!"); // Global stacks // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them. - IM_ASSERT(SizeOfGroupStack == g.GroupStack.Size && "BeginGroup/EndGroup Mismatch!"); - IM_ASSERT(SizeOfBeginPopupStack == g.BeginPopupStack.Size && "BeginPopup/EndPopup or BeginMenu/EndMenu Mismatch!"); - IM_ASSERT(SizeOfDisabledStack == g.DisabledStackSize && "BeginDisabled/EndDisabled Mismatch!"); - IM_ASSERT(SizeOfItemFlagsStack >= g.ItemFlagsStack.Size && "PushItemFlag/PopItemFlag Mismatch!"); - IM_ASSERT(SizeOfColorStack >= g.ColorStack.Size && "PushStyleColor/PopStyleColor Mismatch!"); - IM_ASSERT(SizeOfStyleVarStack >= g.StyleVarStack.Size && "PushStyleVar/PopStyleVar Mismatch!"); - IM_ASSERT(SizeOfFontStack >= g.FontStack.Size && "PushFont/PopFont Mismatch!"); - IM_ASSERT(SizeOfFocusScopeStack == g.FocusScopeStack.Size && "PushFocusScope/PopFocusScope Mismatch!"); + IM_ASSERT(SizeOfGroupStack == g.GroupStack.Size && "BeginGroup/EndGroup Mismatch!"); + IM_ASSERT(SizeOfBeginPopupStack == g.BeginPopupStack.Size && "BeginPopup/EndPopup or BeginMenu/EndMenu Mismatch!"); + IM_ASSERT(SizeOfDisabledStack == g.DisabledStackSize && "BeginDisabled/EndDisabled Mismatch!"); + IM_ASSERT(SizeOfItemFlagsStack >= g.ItemFlagsStack.Size && "PushItemFlag/PopItemFlag Mismatch!"); + IM_ASSERT(SizeOfColorStack >= g.ColorStack.Size && "PushStyleColor/PopStyleColor Mismatch!"); + IM_ASSERT(SizeOfStyleVarStack >= g.StyleVarStack.Size && "PushStyleVar/PopStyleVar Mismatch!"); + IM_ASSERT(SizeOfFontStack >= g.FontStack.Size && "PushFont/PopFont Mismatch!"); + IM_ASSERT(SizeOfFocusScopeStack == g.FocusScopeStack.Size && "PushFocusScope/PopFocusScope Mismatch!"); } - //----------------------------------------------------------------------------- // [SECTION] LAYOUT //----------------------------------------------------------------------------- @@ -9156,10 +9781,10 @@ void ImGuiStackSizes::CompareWithCurrentState() // Advance cursor given item size for layout. // Register minimum needed size so it can extend the bounding box used for auto-fit calculation. // See comments in ItemAdd() about how/why the size provided to ItemSize() vs ItemAdd() may often different. -void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) +void ImGui::ItemSize(const ImVec2 &size, float text_baseline_y) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (window->SkipItems) return; @@ -9169,17 +9794,17 @@ void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f; const float line_y1 = window->DC.IsSameLine ? window->DC.CursorPosPrevLine.y : window->DC.CursorPos.y; - const float line_height = ImMax(window->DC.CurrLineSize.y, /*ImMax(*/window->DC.CursorPos.y - line_y1/*, 0.0f)*/ + size.y + offset_to_match_baseline_y); + const float line_height = ImMax(window->DC.CurrLineSize.y, /*ImMax(*/ window->DC.CursorPos.y - line_y1 /*, 0.0f)*/ + size.y + offset_to_match_baseline_y); // Always align ourselves on pixel boundaries - //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG] + // if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG] window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x; window->DC.CursorPosPrevLine.y = line_y1; - window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line + window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line window->DC.CursorPos.y = IM_FLOOR(line_y1 + line_height + g.Style.ItemSpacing.y); // Next line window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x); window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y); - //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG] + // if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG] window->DC.PrevLineSize.y = line_height; window->DC.CurrLineSize.y = 0.0f; @@ -9195,10 +9820,10 @@ void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) // Declare item bounding box for clipping and interaction. // Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface // declare their minimum size requirement to ItemSize() and provide a larger region to ItemAdd() which is used drawing/interaction. -bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGuiItemFlags extra_flags) +bool ImGui::ItemAdd(const ImRect &bb, ImGuiID id, const ImRect *nav_bb_arg, ImGuiItemFlags extra_flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; // Set item data // (DisplayRect is left untouched, made valid when ImGuiItemStatusFlags_HasDisplayRect is set) @@ -9253,7 +9878,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu const bool is_clipped = IsClippedEx(bb, id); if (is_clipped) return false; - //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] + // if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them) if (IsMouseHoveringRect(bb.Min, bb.Max)) @@ -9268,8 +9893,8 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu // spacing_w >= 0 : enforce spacing amount void ImGui::SameLine(float offset_from_start_x, float spacing_w) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (window->SkipItems) return; @@ -9294,18 +9919,18 @@ void ImGui::SameLine(float offset_from_start_x, float spacing_w) ImVec2 ImGui::GetCursorScreenPos() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->DC.CursorPos; } // 2022/08/05: Setting cursor position also extend boundaries (via modifying CursorMaxPos) used to compute window size, group size etc. // I believe this was is a judicious choice but it's probably being relied upon (it has been the case since 1.31 and 1.50) // It would be sane if we requested user to use SetCursorPos() + Dummy(ImVec2(0,0)) to extend CursorMaxPos... -void ImGui::SetCursorScreenPos(const ImVec2& pos) +void ImGui::SetCursorScreenPos(const ImVec2 &pos) { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.CursorPos = pos; - //window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); + // window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); window->DC.IsSetPos = true; } @@ -9313,64 +9938,64 @@ void ImGui::SetCursorScreenPos(const ImVec2& pos) // Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'. ImVec2 ImGui::GetCursorPos() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->DC.CursorPos - window->Pos + window->Scroll; } float ImGui::GetCursorPosX() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x; } float ImGui::GetCursorPosY() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y; } -void ImGui::SetCursorPos(const ImVec2& local_pos) +void ImGui::SetCursorPos(const ImVec2 &local_pos) { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.CursorPos = window->Pos - window->Scroll + local_pos; - //window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); + // window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); window->DC.IsSetPos = true; } void ImGui::SetCursorPosX(float x) { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x; - //window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); + // window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); window->DC.IsSetPos = true; } void ImGui::SetCursorPosY(float y) { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y; - //window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); + // window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); window->DC.IsSetPos = true; } ImVec2 ImGui::GetCursorStartPos() { - ImGuiWindow* window = GetCurrentWindowRead(); + ImGuiWindow *window = GetCurrentWindowRead(); return window->DC.CursorStartPos - window->Pos; } void ImGui::Indent(float indent_w) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); + ImGuiContext &g = *GImGui; + ImGuiWindow *window = GetCurrentWindow(); window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; } void ImGui::Unindent(float indent_w) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); + ImGuiContext &g = *GImGui; + ImGuiWindow *window = GetCurrentWindow(); window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; } @@ -9378,7 +10003,7 @@ void ImGui::Unindent(float indent_w) // Affect large frame+labels widgets only. void ImGui::SetNextItemWidth(float item_width) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth; g.NextItemData.Width = item_width; } @@ -9386,8 +10011,8 @@ void ImGui::SetNextItemWidth(float item_width) // FIXME: Remove the == 0.0f behavior? void ImGui::PushItemWidth(float item_width) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width); g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; @@ -9395,10 +10020,10 @@ void ImGui::PushItemWidth(float item_width) void ImGui::PushMultiItemsWidths(int components, float w_full) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - const ImGuiStyle& style = g.Style; - const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + const ImGuiStyle &style = g.Style; + const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); const float w_item_last = ImMax(1.0f, IM_FLOOR(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components - 1))); window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width window->DC.ItemWidthStack.push_back(w_item_last); @@ -9410,7 +10035,7 @@ void ImGui::PushMultiItemsWidths(int components, float w_full) void ImGui::PopItemWidth() { - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); window->DC.ItemWidth = window->DC.ItemWidthStack.back(); window->DC.ItemWidthStack.pop_back(); } @@ -9419,8 +10044,8 @@ void ImGui::PopItemWidth() // The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags() float ImGui::CalcItemWidth() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; float w; if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth) w = g.NextItemData.Width; @@ -9441,8 +10066,8 @@ 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; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImVec2 region_max; if (size.x < 0.0f || size.y < 0.0f) @@ -9463,25 +10088,25 @@ ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h) float ImGui::GetTextLineHeight() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.FontSize; } float ImGui::GetTextLineHeightWithSpacing() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.FontSize + g.Style.ItemSpacing.y; } float ImGui::GetFrameHeight() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.FontSize + g.Style.FramePadding.y * 2.0f; } float ImGui::GetFrameHeightWithSpacing() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y; } @@ -9490,8 +10115,8 @@ float ImGui::GetFrameHeightWithSpacing() // FIXME: This is in window space (not screen space!). ImVec2 ImGui::GetContentRegionMax() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImVec2 mx = window->ContentRegionRect.Max - window->Pos; if (window->DC.CurrentColumns || g.CurrentTable) mx.x = window->WorkRect.Max.x - window->Pos.x; @@ -9501,8 +10126,8 @@ ImVec2 ImGui::GetContentRegionMax() // [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; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImVec2 mx = window->ContentRegionRect.Max; if (window->DC.CurrentColumns || g.CurrentTable) mx.x = window->WorkRect.Max.x; @@ -9511,20 +10136,20 @@ ImVec2 ImGui::GetContentRegionMaxAbs() ImVec2 ImGui::GetContentRegionAvail() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return GetContentRegionMaxAbs() - window->DC.CursorPos; } // In window space (not screen space!) ImVec2 ImGui::GetWindowContentRegionMin() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->ContentRegionRect.Min - window->Pos; } ImVec2 ImGui::GetWindowContentRegionMax() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->ContentRegionRect.Max - window->Pos; } @@ -9533,11 +10158,11 @@ ImVec2 ImGui::GetWindowContentRegionMax() // FIXME-OPT: Could we safely early out on ->SkipItems? void ImGui::BeginGroup() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; g.GroupStack.resize(g.GroupStack.Size + 1); - ImGuiGroupData& group_data = g.GroupStack.back(); + ImGuiGroupData &group_data = g.GroupStack.back(); group_data.WindowID = window->ID; group_data.BackupCursorPos = window->DC.CursorPos; group_data.BackupCursorMaxPos = window->DC.CursorMaxPos; @@ -9560,11 +10185,11 @@ void ImGui::BeginGroup() void ImGui::EndGroup() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IM_ASSERT(g.GroupStack.Size > 0); // Mismatched BeginGroup()/EndGroup() calls - ImGuiGroupData& group_data = g.GroupStack.back(); + ImGuiGroupData &group_data = g.GroupStack.back(); IM_ASSERT(group_data.WindowID == window->ID); // EndGroup() in wrong window? if (window->DC.IsSetPos) @@ -9587,7 +10212,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); @@ -9618,10 +10243,9 @@ void ImGui::EndGroup() g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Deactivated; g.GroupStack.pop_back(); - //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug] + // window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug] } - //----------------------------------------------------------------------------- // [SECTION] SCROLLING //----------------------------------------------------------------------------- @@ -9639,7 +10263,7 @@ static float CalcScrollEdgeSnap(float target, float snap_min, float snap_max, fl return target; } -static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow *window) { ImVec2 scroll = window->Scroll; if (window->ScrollTarget.x < FLT_MAX) @@ -9680,22 +10304,22 @@ static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) void ImGui::ScrollToItem(ImGuiScrollFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ScrollToRectEx(window, g.LastItemData.NavRect, flags); } -void ImGui::ScrollToRect(ImGuiWindow* window, const ImRect& item_rect, ImGuiScrollFlags flags) +void ImGui::ScrollToRect(ImGuiWindow *window, const ImRect &item_rect, ImGuiScrollFlags flags) { ScrollToRectEx(window, item_rect, flags); } // Scroll to keep newly navigated item fully into view -ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGuiScrollFlags flags) +ImVec2 ImGui::ScrollToRectEx(ImGuiWindow *window, const ImRect &item_rect, ImGuiScrollFlags flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)); - //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG] + // GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG] // Check that only one behavior is selected per axis IM_ASSERT((flags & ImGuiScrollFlags_MaskX_) == 0 || ImIsPowerOfTwo(flags & ImGuiScrollFlags_MaskX_)); @@ -9758,36 +10382,36 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui float ImGui::GetScrollX() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->Scroll.x; } float ImGui::GetScrollY() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->Scroll.y; } float ImGui::GetScrollMaxX() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->ScrollMax.x; } float ImGui::GetScrollMaxY() { - ImGuiWindow* window = GImGui->CurrentWindow; + ImGuiWindow *window = GImGui->CurrentWindow; return window->ScrollMax.y; } -void ImGui::SetScrollX(ImGuiWindow* window, float scroll_x) +void ImGui::SetScrollX(ImGuiWindow *window, float scroll_x) { window->ScrollTarget.x = scroll_x; window->ScrollTargetCenterRatio.x = 0.0f; window->ScrollTargetEdgeSnapDist.x = 0.0f; } -void ImGui::SetScrollY(ImGuiWindow* window, float scroll_y) +void ImGui::SetScrollY(ImGuiWindow *window, float scroll_y) { window->ScrollTarget.y = scroll_y; window->ScrollTargetCenterRatio.y = 0.0f; @@ -9796,13 +10420,13 @@ void ImGui::SetScrollY(ImGuiWindow* window, float scroll_y) void ImGui::SetScrollX(float scroll_x) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; SetScrollX(g.CurrentWindow, scroll_x); } void ImGui::SetScrollY(float scroll_y) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; SetScrollY(g.CurrentWindow, scroll_y); } @@ -9816,7 +10440,7 @@ void ImGui::SetScrollY(float scroll_y) // - SetScrollFromPosY(0.0f) == SetScrollY(0.0f + scroll.y) == has no effect! // - SetScrollFromPosY(-scroll.y) == SetScrollY(-scroll.y + scroll.y) == SetScrollY(0.0f) == reset scroll. Of course writing SetScrollY(0.0f) directly then makes more sense // We store a target position so centering and clamping can occur on the next frame when we are guaranteed to have a known window size -void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio) +void ImGui::SetScrollFromPosX(ImGuiWindow *window, float local_x, float center_x_ratio) { IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f); window->ScrollTarget.x = IM_FLOOR(local_x + window->Scroll.x); // Convert local position to scroll offset @@ -9824,7 +10448,7 @@ void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x window->ScrollTargetEdgeSnapDist.x = 0.0f; } -void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio) +void ImGui::SetScrollFromPosY(ImGuiWindow *window, float local_y, float center_y_ratio) { IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); // FIXME: Would be nice to have a more standardized access to our scrollable/client rect; @@ -9836,21 +10460,21 @@ void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio); } void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio); } // center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item. void ImGui::SetScrollHereX(float center_x_ratio) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; float spacing_x = ImMax(window->WindowPadding.x, g.Style.ItemSpacing.x); float target_pos_x = ImLerp(g.LastItemData.Rect.Min.x - spacing_x, g.LastItemData.Rect.Max.x + spacing_x, center_x_ratio); SetScrollFromPosX(window, target_pos_x - window->Pos.x, center_x_ratio); // Convert from absolute to local pos @@ -9862,8 +10486,8 @@ void ImGui::SetScrollHereX(float center_x_ratio) // center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. void ImGui::SetScrollHereY(float center_y_ratio) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; float spacing_y = ImMax(window->WindowPadding.y, g.Style.ItemSpacing.y); float target_pos_y = ImLerp(window->DC.CursorPosPrevLine.y - spacing_y, window->DC.CursorPosPrevLine.y + window->DC.PrevLineSize.y + spacing_y, center_y_ratio); SetScrollFromPosY(window, target_pos_y - window->Pos.y, center_y_ratio); // Convert from absolute to local pos @@ -9883,25 +10507,25 @@ void ImGui::BeginTooltip() void ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.DragDropWithinSource || g.DragDropWithinTarget) { // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor) // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor. // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do. - //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding; + // ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding; ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale); SetNextWindowPos(tooltip_pos); SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f); - //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :( + // PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :( tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip; } char window_name[16]; ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount); if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip) - if (ImGuiWindow* window = FindWindowByName(window_name)) + if (ImGuiWindow *window = FindWindowByName(window_name)) if (window->Active) { // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one. @@ -9915,18 +10539,18 @@ void ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags ext void ImGui::EndTooltip() { - IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls + IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls End(); } -void ImGui::SetTooltipV(const char* fmt, va_list args) +void ImGui::SetTooltipV(const char *fmt, va_list args) { BeginTooltipEx(ImGuiTooltipFlags_OverridePreviousTooltip, ImGuiWindowFlags_None); TextV(fmt, args); EndTooltip(); } -void ImGui::SetTooltip(const char* fmt, ...) +void ImGui::SetTooltip(const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -9941,7 +10565,7 @@ void ImGui::SetTooltip(const char* fmt, ...) // Supported flags: ImGuiPopupFlags_AnyPopupId, ImGuiPopupFlags_AnyPopupLevel bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (popup_flags & ImGuiPopupFlags_AnyPopupId) { // Return true if any popup is open at the current BeginPopup() level of the popup stack @@ -9970,38 +10594,38 @@ bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags) } } -bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags) +bool ImGui::IsPopupOpen(const char *str_id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetID(str_id); if ((popup_flags & ImGuiPopupFlags_AnyPopupLevel) && id != 0) IM_ASSERT(0 && "Cannot use IsPopupOpen() with a string id and ImGuiPopupFlags_AnyPopupLevel."); // But non-string version is legal and used internally return IsPopupOpen(id, popup_flags); } -ImGuiWindow* ImGui::GetTopMostPopupModal() +ImGuiWindow *ImGui::GetTopMostPopupModal() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int n = g.OpenPopupStack.Size - 1; n >= 0; n--) - if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window) + if (ImGuiWindow *popup = g.OpenPopupStack.Data[n].Window) if (popup->Flags & ImGuiWindowFlags_Modal) return popup; return NULL; } -ImGuiWindow* ImGui::GetTopMostAndVisiblePopupModal() +ImGuiWindow *ImGui::GetTopMostAndVisiblePopupModal() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int n = g.OpenPopupStack.Size - 1; n >= 0; n--) - if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window) + if (ImGuiWindow *popup = g.OpenPopupStack.Data[n].Window) if ((popup->Flags & ImGuiWindowFlags_Modal) && IsWindowActiveAndVisible(popup)) return popup; return NULL; } -void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags) +void ImGui::OpenPopup(const char *str_id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiID id = g.CurrentWindow->GetID(str_id); IMGUI_DEBUG_LOG_POPUP("[popup] OpenPopup(\"%s\" -> 0x%08X\n", str_id, id); OpenPopupEx(id, popup_flags); @@ -10018,8 +10642,8 @@ void ImGui::OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags) // One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* parent_window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *parent_window = g.CurrentWindow; const int current_stack_size = g.BeginPopupStack.Size; if (popup_flags & ImGuiPopupFlags_NoOpenOverExistingPopup) @@ -10029,7 +10653,7 @@ void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags) ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. popup_ref.PopupId = id; popup_ref.Window = NULL; - popup_ref.BackupNavWindow = g.NavWindow; // When popup closes focus may be restored to NavWindow (depend on window type). + popup_ref.BackupNavWindow = g.NavWindow; // When popup closes focus may be restored to NavWindow (depend on window type). popup_ref.OpenFrameCount = g.FrameCount; popup_ref.OpenParentId = parent_window->IDStack.back(); popup_ref.OpenPopupPos = NavCalcPreferredRefPos(); @@ -10058,16 +10682,16 @@ void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags) // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow(). // This is equivalent to what ClosePopupToLevel() does. - //if (g.OpenPopupStack[current_stack_size].PopupId == id) + // if (g.OpenPopupStack[current_stack_size].PopupId == id) // FocusWindow(parent_window); } } // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it. // This function closes any popups that are over 'ref_window'. -void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup) +void ImGui::ClosePopupsOverWindow(ImGuiWindow *ref_window, bool restore_focus_to_window_under_popup) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.OpenPopupStack.Size == 0) return; @@ -10078,7 +10702,7 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow) for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++) { - ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep]; + ImGuiPopupData &popup = g.OpenPopupStack[popup_count_to_keep]; if (!popup.Window) continue; IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); @@ -10092,8 +10716,8 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to // Window -> Popup1 -> Popup1_Child -> Popup2 -> Popup2_Child bool ref_window_is_descendent_of_popup = false; for (int n = popup_count_to_keep; n < g.OpenPopupStack.Size; n++) - if (ImGuiWindow* popup_window = g.OpenPopupStack[n].Window) - //if (popup_window->RootWindowDockTree == ref_window->RootWindowDockTree) // FIXME-MERGE + if (ImGuiWindow *popup_window = g.OpenPopupStack[n].Window) + // if (popup_window->RootWindowDockTree == ref_window->RootWindowDockTree) // FIXME-MERGE if (IsWindowWithinBeginStackOf(ref_window, popup_window)) { ref_window_is_descendent_of_popup = true; @@ -10112,12 +10736,12 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to void ImGui::ClosePopupsExceptModals() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; int popup_count_to_keep; for (popup_count_to_keep = g.OpenPopupStack.Size; popup_count_to_keep > 0; popup_count_to_keep--) { - ImGuiWindow* window = g.OpenPopupStack[popup_count_to_keep - 1].Window; + ImGuiWindow *window = g.OpenPopupStack[popup_count_to_keep - 1].Window; if (!window || window->Flags & ImGuiWindowFlags_Modal) break; } @@ -10127,18 +10751,18 @@ void ImGui::ClosePopupsExceptModals() void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IMGUI_DEBUG_LOG_POPUP("[popup] ClosePopupToLevel(%d), restore_focus_to_window_under_popup=%d\n", remaining, restore_focus_to_window_under_popup); IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size); // Trim open popup stack - ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window; - ImGuiWindow* popup_backup_nav_window = g.OpenPopupStack[remaining].BackupNavWindow; + ImGuiWindow *popup_window = g.OpenPopupStack[remaining].Window; + ImGuiWindow *popup_backup_nav_window = g.OpenPopupStack[remaining].BackupNavWindow; g.OpenPopupStack.resize(remaining); if (restore_focus_to_window_under_popup) { - ImGuiWindow* focus_window = (popup_window && popup_window->Flags & ImGuiWindowFlags_ChildMenu) ? popup_window->ParentWindow : popup_backup_nav_window; + ImGuiWindow *focus_window = (popup_window && popup_window->Flags & ImGuiWindowFlags_ChildMenu) ? popup_window->ParentWindow : popup_backup_nav_window; if (focus_window && !focus_window->WasActive && popup_window) { // Fallback @@ -10156,7 +10780,7 @@ void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_ // Close the popup we have begin-ed into. void ImGui::CloseCurrentPopup() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; int popup_idx = g.BeginPopupStack.Size - 1; if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId) return; @@ -10164,8 +10788,8 @@ void ImGui::CloseCurrentPopup() // Closing a menu closes its top-most parent popup (unless a modal) while (popup_idx > 0) { - ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window; - ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window; + ImGuiWindow *popup_window = g.OpenPopupStack[popup_idx].Window; + ImGuiWindow *parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window; bool close_parent = false; if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu)) if (parent_popup_window && !(parent_popup_window->Flags & ImGuiWindowFlags_MenuBar)) @@ -10180,14 +10804,14 @@ void ImGui::CloseCurrentPopup() // A common pattern is to close a popup when selecting a menu item/selectable that will open another window. // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window. // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic. - if (ImGuiWindow* window = g.NavWindow) + if (ImGuiWindow *window = g.NavWindow) window->DC.NavHideHighlightOneFrame = true; } // Attention! BeginPopup() adds default flags which BeginPopupEx()! bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!IsPopupOpen(id, ImGuiPopupFlags_None)) { g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values @@ -10208,9 +10832,9 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags) return is_open; } -bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags) +bool ImGui::BeginPopup(const char *str_id, ImGuiWindowFlags flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance { g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values @@ -10223,10 +10847,10 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags) // If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. // Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here. -bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) +bool ImGui::BeginPopupModal(const char *name, bool *p_open, ImGuiWindowFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; const ImGuiID id = window->GetID(name); if (!IsPopupOpen(id, ImGuiPopupFlags_None)) { @@ -10239,7 +10863,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window. if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0) { - const ImGuiViewport* viewport = window->WasActive ? window->Viewport : GetMainViewport(); // FIXME-VIEWPORT: What may be our reference viewport? + const ImGuiViewport *viewport = window->WasActive ? window->Viewport : GetMainViewport(); // FIXME-VIEWPORT: What may be our reference viewport? SetNextWindowPos(viewport->GetCenter(), ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f)); } @@ -10257,9 +10881,9 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla void ImGui::EndPopup() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls IM_ASSERT(g.BeginPopupStack.Size > 0); // Make all menus and popups wrap around for now, may need to expose that policy (e.g. focus scope could include wrap/loop policy flags used by new move requests) @@ -10276,15 +10900,15 @@ void ImGui::EndPopup() // Helper to open a popup if mouse button is released over the item // - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup() -void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags) +void ImGui::OpenPopupOnItemClick(const char *str_id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) { - ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! - IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) + ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) OpenPopupEx(id, popup_flags); } } @@ -10305,24 +10929,24 @@ void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags // OpenPopup(id); // return BeginPopup(id); // The main difference being that this is tweaked to avoid computing the ID twice. -bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags) +bool ImGui::BeginPopupContextItem(const char *str_id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (window->SkipItems) return false; - ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! - IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) + ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) OpenPopupEx(id, popup_flags); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); } -bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_flags) +bool ImGui::BeginPopupContextWindow(const char *str_id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (!str_id) str_id = "window_context"; ImGuiID id = window->GetID(str_id); @@ -10333,10 +10957,10 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_fl return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); } -bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flags) +bool ImGui::BeginPopupContextVoid(const char *str_id, ImGuiPopupFlags popup_flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (!str_id) str_id = "void_context"; ImGuiID id = window->GetID(str_id); @@ -10352,26 +10976,30 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flag // (r_outer is usually equivalent to the viewport rectangle minus padding, but when multi-viewports are enabled and monitor // information are available, it may represent the entire platform monitor from the frame of reference of the current viewport. // this allows us to have tooltips/popups displayed out of the parent viewport.) -ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy) +ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2 &ref_pos, const ImVec2 &size, ImGuiDir *last_dir, const ImRect &r_outer, const ImRect &r_avoid, ImGuiPopupPositionPolicy policy) { ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size); - //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); - //GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255)); + // GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); + // GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255)); // Combo Box policy (we want a connecting edge) if (policy == ImGuiPopupPositionPolicy_ComboBox) { - const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up }; + const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = {ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up}; for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) { const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; if (n != -1 && dir == *last_dir) // Already tried this direction? continue; ImVec2 pos; - if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default) - if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right - if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left - if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left + if (dir == ImGuiDir_Down) + pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default) + if (dir == ImGuiDir_Right) + pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right + if (dir == ImGuiDir_Left) + pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left + if (dir == ImGuiDir_Up) + pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left if (!r_outer.Contains(ImRect(pos, pos + size))) continue; *last_dir = dir; @@ -10383,7 +11011,7 @@ ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& s // (Always first try the direction we used on the last frame, if any) if (policy == ImGuiPopupPositionPolicy_Tooltip || policy == ImGuiPopupPositionPolicy_Default) { - const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left }; + const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = {ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left}; for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) { const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; @@ -10400,8 +11028,10 @@ ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& s continue; ImVec2 pos; - pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x; - pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y; + pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x + : base_pos_clamped.x; + pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y + : base_pos_clamped.y; // Clamp top-left corner of popup pos.x = ImMax(pos.x, r_outer.Min.x); @@ -10427,14 +11057,14 @@ ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& s } // Note that this is used for popups, which can overlap the non work-area of individual viewports. -ImRect ImGui::GetPopupAllowedExtentRect(ImGuiWindow* window) +ImRect ImGui::GetPopupAllowedExtentRect(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImRect r_screen; if (window->ViewportAllowPlatformMonitorExtend >= 0) { // Extent with be in the frame of reference of the given viewport (so Min is likely to be negative here) - const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[window->ViewportAllowPlatformMonitorExtend]; + const ImGuiPlatformMonitor &monitor = g.PlatformIO.Monitors[window->ViewportAllowPlatformMonitorExtend]; r_screen.Min = monitor.WorkPos; r_screen.Max = monitor.WorkPos + monitor.WorkSize; } @@ -10448,16 +11078,16 @@ ImRect ImGui::GetPopupAllowedExtentRect(ImGuiWindow* window) return r_screen; } -ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) +ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImRect r_outer = GetPopupAllowedExtentRect(window); if (window->Flags & ImGuiWindowFlags_ChildMenu) { // Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds. // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu. - ImGuiWindow* parent_window = window->ParentWindow; + ImGuiWindow *parent_window = window->ParentWindow; float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x). ImRect r_avoid; if (parent_window->DC.MenuBarAppending) @@ -10494,9 +11124,9 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) // In our terminology those should be interchangeable, yet right now this is super confusing. // Those two functions are merely a legacy artifact, so at minimum naming should be clarified. -void ImGui::SetNavWindow(ImGuiWindow* window) +void ImGui::SetNavWindow(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.NavWindow != window) { IMGUI_DEBUG_LOG_FOCUS("[focus] SetNavWindow(\"%s\")\n", window ? window->Name : ""); @@ -10506,9 +11136,9 @@ void ImGui::SetNavWindow(ImGuiWindow* window) NavUpdateAnyRequestFlag(); } -void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel) +void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect &rect_rel) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.NavWindow != NULL); IM_ASSERT(nav_layer == ImGuiNavLayer_Main || nav_layer == ImGuiNavLayer_Menu); g.NavId = id; @@ -10518,13 +11148,13 @@ void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id g.NavWindow->NavRectRel[nav_layer] = rect_rel; } -void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) +void ImGui::SetFocusID(ImGuiID id, ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(id != 0); if (g.NavWindow != window) - SetNavWindow(window); + SetNavWindow(window); // 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) @@ -10558,7 +11188,7 @@ static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float return 0.0f; } -static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect) +static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect &r, const ImRect &clip_rect) { if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) { @@ -10573,16 +11203,16 @@ static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect } // Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057 -static bool ImGui::NavScoreItem(ImGuiNavItemData* result) +static bool ImGui::NavScoreItem(ImGuiNavItemData *result) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; if (g.NavLayer != window->DC.NavLayerCurrent) return false; // FIXME: Those are not good variables names - ImRect cand = g.LastItemData.NavRect; // Current item nav rectangle - const ImRect curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width) + ImRect cand = g.LastItemData.NavRect; // Current item nav rectangle + const ImRect curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width) g.NavScoringDebugCount++; // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring @@ -10641,10 +11271,10 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result) if (IsMouseHoveringRect(cand.Min, cand.Max)) { ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\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,150)); + 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, 150)); draw_list->AddText(cand.Max, ~0U, buf); } else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate. @@ -10652,7 +11282,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result) if (quadrant == g.NavMoveDir) { ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center); - ImDrawList* draw_list = GetForegroundDrawList(window); + ImDrawList *draw_list = GetForegroundDrawList(window); draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200)); draw_list->AddText(cand.Min, IM_COL32(255, 255, 255, 255), buf); } @@ -10695,7 +11325,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result) // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too. // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward. // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option? - if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match + if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match if (g.NavLayer == ImGuiNavLayer_Menu && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) if ((move_dir == ImGuiDir_Left && dax < 0.0f) || (move_dir == ImGuiDir_Right && dax > 0.0f) || (move_dir == ImGuiDir_Up && day < 0.0f) || (move_dir == ImGuiDir_Down && day > 0.0f)) { @@ -10706,10 +11336,10 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result) return new_best; } -static void ImGui::NavApplyItemToResult(ImGuiNavItemData* result) +static void ImGui::NavApplyItemToResult(ImGuiNavItemData *result) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; result->Window = window; result->ID = g.LastItemData.ID; result->FocusScopeId = window->DC.NavFocusScopeIdCurrent; @@ -10721,8 +11351,8 @@ static void ImGui::NavApplyItemToResult(ImGuiNavItemData* result) // This is called after LastItemData is set. static void ImGui::NavProcessItem() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; const ImGuiID id = g.LastItemData.ID; const ImRect nav_bb = g.LastItemData.NavRect; const ImGuiItemFlags item_flags = g.LastItemData.InFlags; @@ -10757,7 +11387,7 @@ static void ImGui::NavProcessItem() } else if ((g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNav))) { - ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; + ImGuiNavItemData *result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; if (!is_tabbing) { if (NavScoreItem(result)) @@ -10781,7 +11411,7 @@ static void ImGui::NavProcessItem() g.NavLayer = window->DC.NavLayerCurrent; g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; g.NavIdIsAlive = true; - window->NavRectRel[window->DC.NavLayerCurrent] = WindowRectAbsToRel(window, nav_bb); // Store item bounding box (relative to window position) + window->NavRectRel[window->DC.NavLayerCurrent] = WindowRectAbsToRel(window, nav_bb); // Store item bounding box (relative to window position) } } @@ -10794,10 +11424,10 @@ static void ImGui::NavProcessItem() // - Case 5: tab backward wrap: store all results, on ref id if no result keep storing until last // FIXME-TABBING: Could be done as next-frame forwarded requested void ImGui::NavProcessItemForTabbingRequest(ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Always store in NavMoveResultLocal (unlike directional request which uses NavMoveResultOther on sibling/flattened windows) - ImGuiNavItemData* result = &g.NavMoveResultLocal; + ImGuiNavItemData *result = &g.NavMoveResultLocal; if (g.NavTabbingDir == +1) { // Tab Forward or SetKeyboardFocusHere() with >= 0 @@ -10834,14 +11464,14 @@ void ImGui::NavProcessItemForTabbingRequest(ImGuiID id) bool ImGui::NavMoveRequestButNoResultYet() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.NavMoveScoringItems && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0; } // FIXME: ScoringRect is not set void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.NavWindow != NULL); if (move_flags & ImGuiNavMoveFlags_Tabbing) @@ -10863,9 +11493,9 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM NavUpdateAnyRequestFlag(); } -void ImGui::NavMoveRequestResolveWithLastItem(ImGuiNavItemData* result) +void ImGui::NavMoveRequestResolveWithLastItem(ImGuiNavItemData *result) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NavMoveScoringItems = false; // Ensure request doesn't need more processing NavApplyItemToResult(result); NavUpdateAnyRequestFlag(); @@ -10873,7 +11503,7 @@ void ImGui::NavMoveRequestResolveWithLastItem(ImGuiNavItemData* result) void ImGui::NavMoveRequestCancel() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NavMoveSubmitted = g.NavMoveScoringItems = false; NavUpdateAnyRequestFlag(); } @@ -10881,7 +11511,7 @@ void ImGui::NavMoveRequestCancel() // Forward will reuse the move request again on the next frame (generally with modifications done to it) void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.NavMoveForwardToNextFrame == false); NavMoveRequestCancel(); g.NavMoveForwardToNextFrame = true; @@ -10893,9 +11523,9 @@ void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNav // Navigation wrap-around logic is delayed to the end of the frame because this operation is only valid after entire // popup is assembled and in case of appended popups it is not clear which EndPopup() call is final. -void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wrap_flags) +void ImGui::NavMoveRequestTryWrapping(ImGuiWindow *window, ImGuiNavMoveFlags wrap_flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(wrap_flags != 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 if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == ImGuiNavLayer_Main) @@ -10904,9 +11534,9 @@ void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wra // FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0). // This way we could find the last focused window among our children. It would be much less confusing this way? -static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window) +static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow *nav_window) { - ImGuiWindow* parent = nav_window; + ImGuiWindow *parent = nav_window; while (parent && parent->RootWindow != parent && (parent->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) parent = parent->ParentWindow; if (parent && parent != nav_window) @@ -10915,27 +11545,27 @@ static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window) // Restore the last focused child. // Call when we are expected to land on the Main Layer (0) after FocusWindow() -static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window) +static ImGuiWindow *ImGui::NavRestoreLastChildNavWindow(ImGuiWindow *window) { if (window->NavLastChildNavWindow && window->NavLastChildNavWindow->WasActive) return window->NavLastChildNavWindow; if (window->DockNodeAsHost && window->DockNodeAsHost->TabBar) - if (ImGuiTabItem* tab = TabBarFindMostRecentlySelectedTabForActiveWindow(window->DockNodeAsHost->TabBar)) + if (ImGuiTabItem *tab = TabBarFindMostRecentlySelectedTabForActiveWindow(window->DockNodeAsHost->TabBar)) return tab->Window; return window; } void ImGui::NavRestoreLayer(ImGuiNavLayer layer) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (layer == ImGuiNavLayer_Main) { - ImGuiWindow* prev_nav_window = g.NavWindow; - g.NavWindow = NavRestoreLastChildNavWindow(g.NavWindow); // FIXME-NAV: Should clear ongoing nav requests? + ImGuiWindow *prev_nav_window = g.NavWindow; + g.NavWindow = NavRestoreLastChildNavWindow(g.NavWindow); // FIXME-NAV: Should clear ongoing nav requests? if (prev_nav_window) IMGUI_DEBUG_LOG_FOCUS("[focus] NavRestoreLayer: from \"%s\" to SetNavWindow(\"%s\")\n", prev_nav_window->Name, g.NavWindow->Name); } - ImGuiWindow* window = g.NavWindow; + ImGuiWindow *window = g.NavWindow; if (window->NavLastIds[layer] != 0) { SetNavID(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]); @@ -10949,24 +11579,24 @@ void ImGui::NavRestoreLayer(ImGuiNavLayer layer) void ImGui::NavRestoreHighlightAfterMove() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NavDisableHighlight = false; g.NavDisableMouseHover = g.NavMousePosDirty = true; } static inline void ImGui::NavUpdateAnyRequestFlag() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.NavAnyRequest = g.NavMoveScoringItems || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL); if (g.NavAnyRequest) IM_ASSERT(g.NavWindow != NULL); } // This needs to be called before we submit any widget (aka in or before Begin) -void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit) +void ImGui::NavInitWindow(ImGuiWindow *window, bool force_reinit) { // FIXME: ChildWindow test here is wrong for docking - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(window == g.NavWindow); if (window->Flags & ImGuiWindowFlags_NoNavInputs) @@ -10997,8 +11627,8 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit) static ImVec2 ImGui::NavCalcPreferredRefPos() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.NavWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.NavWindow; if (g.NavDisableHighlight || !g.NavDisableMouseHover || !window) { // Mouse (we need a fallback in case the mouse becomes invalid after being used) @@ -11018,14 +11648,14 @@ static ImVec2 ImGui::NavCalcPreferredRefPos() rect_rel.Translate(window->Scroll - next_scroll); } ImVec2 pos = ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight())); - ImGuiViewport* viewport = window->Viewport; + ImGuiViewport *viewport = window->Viewport; return ImFloor(ImClamp(pos, viewport->Pos, viewport->Pos + viewport->Size)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta. } } float ImGui::GetNavTweakPressedAmount(ImGuiAxis axis) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; float repeat_delay, repeat_rate; GetTypematicRepeatRate(ImGuiInputFlags_RepeatRateNavTweak, &repeat_delay, &repeat_rate); @@ -11048,22 +11678,22 @@ float ImGui::GetNavTweakPressedAmount(ImGuiAxis axis) static void ImGui::NavUpdate() { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; io.WantSetMousePos = false; - //if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG_NAV("[nav] NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest); + // if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG_NAV("[nav] NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest); // Set input source based on which keys are last pressed (as some features differs when used with Gamepad vs Keyboard) // FIXME-NAV: Now that keys are separated maybe we can get rid of NavInputSource? const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; - const ImGuiKey nav_gamepad_keys_to_change_source[] = { ImGuiKey_GamepadFaceRight, ImGuiKey_GamepadFaceLeft, ImGuiKey_GamepadFaceUp, ImGuiKey_GamepadFaceDown, ImGuiKey_GamepadDpadRight, ImGuiKey_GamepadDpadLeft, ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadDpadDown }; + const ImGuiKey nav_gamepad_keys_to_change_source[] = {ImGuiKey_GamepadFaceRight, ImGuiKey_GamepadFaceLeft, ImGuiKey_GamepadFaceUp, ImGuiKey_GamepadFaceDown, ImGuiKey_GamepadDpadRight, ImGuiKey_GamepadDpadLeft, ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadDpadDown}; if (nav_gamepad_active) for (ImGuiKey key : nav_gamepad_keys_to_change_source) if (IsKeyDown(key)) g.NavInputSource = ImGuiInputSource_Gamepad; const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; - const ImGuiKey nav_keyboard_keys_to_change_source[] = { ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_RightArrow, ImGuiKey_LeftArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow }; + const ImGuiKey nav_keyboard_keys_to_change_source[] = {ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_RightArrow, ImGuiKey_LeftArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow}; if (nav_keyboard_active) for (ImGuiKey key : nav_keyboard_keys_to_change_source) if (IsKeyDown(key)) @@ -11159,7 +11789,7 @@ static void ImGui::NavUpdate() if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget) { // *Fallback* manual-scroll with Nav directional keys when window has no navigable item - ImGuiWindow* window = g.NavWindow; + ImGuiWindow *window = g.NavWindow; const float scroll_speed = IM_ROUND(window->CalcFontSize() * 100 * io.DeltaTime); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported. const ImGuiDir move_dir = g.NavMoveDir; if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavHasScroll && move_dir != ImGuiDir_None) @@ -11175,7 +11805,8 @@ static void ImGui::NavUpdate() if (nav_gamepad_active) { const ImVec2 scroll_dir = GetKeyVector2d(ImGuiKey_GamepadLStickLeft, ImGuiKey_GamepadLStickRight, ImGuiKey_GamepadLStickUp, ImGuiKey_GamepadLStickDown); - const float tweak_factor = IsKeyDown(ImGuiKey_NavGamepadTweakSlow) ? 1.0f / 10.0f : IsKeyDown(ImGuiKey_NavGamepadTweakFast) ? 10.0f : 1.0f; + const float tweak_factor = IsKeyDown(ImGuiKey_NavGamepadTweakSlow) ? 1.0f / 10.0f : IsKeyDown(ImGuiKey_NavGamepadTweakFast) ? 10.0f + : 1.0f; if (scroll_dir.x != 0.0f && window->ScrollbarX) SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed * tweak_factor)); if (scroll_dir.y != 0.0f) @@ -11196,7 +11827,7 @@ static void ImGui::NavUpdate() { io.MousePos = io.MousePosPrev = NavCalcPreferredRefPos(); io.WantSetMousePos = true; - //IMGUI_DEBUG_LOG_IO("SetMousePos: (%.1f,%.1f)\n", io.MousePos.x, io.MousePos.y); + // IMGUI_DEBUG_LOG_IO("SetMousePos: (%.1f,%.1f)\n", io.MousePos.x, io.MousePos.y); } // [DEBUG] @@ -11204,9 +11835,24 @@ static void ImGui::NavUpdate() #if IMGUI_DEBUG_NAV_RECTS if (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(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); + } } #endif } @@ -11214,7 +11860,7 @@ static void ImGui::NavUpdate() void ImGui::NavInitRequestApplyResult() { // In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void) - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.NavWindow) return; @@ -11229,9 +11875,9 @@ void ImGui::NavInitRequestApplyResult() void ImGui::NavUpdateCreateMoveRequest() { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - ImGuiWindow* window = g.NavWindow; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; + ImGuiWindow *window = g.NavWindow; const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; @@ -11252,10 +11898,22 @@ void ImGui::NavUpdateCreateMoveRequest() if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs)) { const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateNavMove; - if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadLeft, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_LeftArrow, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Left; } - if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadRight, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_RightArrow, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Right; } - if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadUp, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_UpArrow, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Up; } - if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadDown, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_DownArrow, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Down; } + if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadLeft, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_LeftArrow, repeat_mode)))) + { + g.NavMoveDir = ImGuiDir_Left; + } + if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadRight, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_RightArrow, repeat_mode)))) + { + g.NavMoveDir = ImGuiDir_Right; + } + if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadUp, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_UpArrow, repeat_mode)))) + { + g.NavMoveDir = ImGuiDir_Up; + } + if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && ((nav_gamepad_active && IsKeyPressedEx(ImGuiKey_GamepadDpadDown, repeat_mode)) || (nav_keyboard_active && IsKeyPressedEx(ImGuiKey_DownArrow, repeat_mode)))) + { + g.NavMoveDir = ImGuiDir_Down; + } } g.NavMoveClipDir = g.NavMoveDir; g.NavScoringNoClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX); @@ -11300,14 +11958,14 @@ void ImGui::NavUpdateCreateMoveRequest() // When using gamepad, we project the reference nav bounding box into window visible area. // This is to allow resuming navigation inside the visible area after doing a large amount of scrolling, since with gamepad every movements are relative // (can't focus a visible object like we can with the mouse). - if (g.NavMoveSubmitted && g.NavInputSource == ImGuiInputSource_Gamepad && g.NavLayer == ImGuiNavLayer_Main && window != NULL)// && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded)) + if (g.NavMoveSubmitted && g.NavInputSource == ImGuiInputSource_Gamepad && g.NavLayer == ImGuiNavLayer_Main && window != NULL) // && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded)) { bool clamp_x = (g.NavMoveFlags & (ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_WrapX)) == 0; bool clamp_y = (g.NavMoveFlags & (ImGuiNavMoveFlags_LoopY | ImGuiNavMoveFlags_WrapY)) == 0; ImRect inner_rect_rel = WindowRectAbsToRel(window, ImRect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1))); if ((clamp_x || clamp_y) && !inner_rect_rel.Contains(window->NavRectRel[g.NavLayer])) { - //IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: clamp NavRectRel for gamepad move\n"); + // IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: clamp NavRectRel for gamepad move\n"); float pad_x = ImMin(inner_rect_rel.GetWidth(), window->CalcFontSize() * 0.5f); float pad_y = ImMin(inner_rect_rel.GetHeight(), window->CalcFontSize() * 0.5f); // Terrible approximation for the intent of starting navigation from first fully visible item inner_rect_rel.Min.x = clamp_x ? (inner_rect_rel.Min.x + pad_x) : -FLT_MAX; @@ -11329,8 +11987,8 @@ void ImGui::NavUpdateCreateMoveRequest() scoring_rect.Min.x = ImMin(scoring_rect.Min.x + 1.0f, scoring_rect.Max.x); scoring_rect.Max.x = scoring_rect.Min.x; IM_ASSERT(!scoring_rect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows 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] + // 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] } g.NavScoringRect = scoring_rect; g.NavScoringNoClipRect.Add(scoring_rect); @@ -11338,8 +11996,8 @@ void ImGui::NavUpdateCreateMoveRequest() void ImGui::NavUpdateCreateTabbingRequest() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.NavWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.NavWindow; IM_ASSERT(g.NavMoveDir == ImGuiDir_None); if (window == NULL || g.NavWindowingTarget != NULL || (window->Flags & ImGuiWindowFlags_NoNavInputs)) return; @@ -11353,7 +12011,8 @@ void ImGui::NavUpdateCreateTabbingRequest() // Initially this was designed to use counters and modulo arithmetic, but that could not work with unsubmitted items (list clipper). Instead we use a strategy close to other move requests. // See NavProcessItemForTabbingRequest() for a description of the various forward/backward tabbing cases with and without wrapping. //// FIXME: We use (g.ActiveId == 0) but (g.NavDisableHighlight == false) might be righter once we can tab through anything - g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1; + g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 + : +1; ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY; ImGuiDir clip_dir = (g.NavTabbingDir < 0) ? ImGuiDir_Up : ImGuiDir_Down; NavMoveRequestSubmit(ImGuiDir_None, clip_dir, ImGuiNavMoveFlags_Tabbing, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable. @@ -11363,14 +12022,15 @@ void ImGui::NavUpdateCreateTabbingRequest() // Apply result from previous frame navigation directional move request. Always called from NavUpdate() void ImGui::NavMoveRequestApplyResult() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; #if IMGUI_DEBUG_NAV_SCORING if (g.NavMoveFlags & ImGuiNavMoveFlags_DebugNoResult) // [DEBUG] Scoring all items in NavWindow at all times return; #endif // Select which result to use - ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL; + ImGuiNavItemData *result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther + : NULL; // Tabbing forward wrap if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) @@ -11459,7 +12119,7 @@ void ImGui::NavMoveRequestApplyResult() // - either to move most/all of those tests to the epilogue/end functions of the scope they are dealing with (e.g. exit child window in EndChild()) or in EndFrame(), to allow an earlier intercept static void ImGui::NavUpdateCancelRequest() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; const bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; if (!(nav_keyboard_active && IsKeyPressed(ImGuiKey_Escape, false)) && !(nav_gamepad_active && IsKeyPressed(ImGuiKey_NavGamepadCancel, false))) @@ -11480,8 +12140,8 @@ static void ImGui::NavUpdateCancelRequest() else if (g.NavWindow && g.NavWindow != g.NavWindow->RootWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow) { // Exit child window - ImGuiWindow* child_window = g.NavWindow; - ImGuiWindow* parent_window = g.NavWindow->ParentWindow; + ImGuiWindow *child_window = g.NavWindow; + ImGuiWindow *parent_window = g.NavWindow->ParentWindow; IM_ASSERT(child_window->ChildId != 0); ImRect child_rect = child_window->Rect(); FocusWindow(parent_window); @@ -11508,8 +12168,8 @@ static void ImGui::NavUpdateCancelRequest() // FIXME-NAV: how to get Home/End to aim at the beginning/end of a 2D grid? static float ImGui::NavUpdatePageUpPageDown() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.NavWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.NavWindow; if ((window->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL) return 0.0f; @@ -11537,7 +12197,7 @@ static float ImGui::NavUpdatePageUpPageDown() } else { - ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer]; + ImRect &nav_rect_rel = window->NavRectRel[g.NavLayer]; const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight()); float nav_scoring_rect_offset_y = 0.0f; if (IsKeyPressed(ImGuiKey_PageUp, true)) @@ -11582,7 +12242,7 @@ static float ImGui::NavUpdatePageUpPageDown() static void ImGui::NavEndFrame() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // Show CTRL+TAB list window if (g.NavWindowingTarget != NULL) @@ -11598,8 +12258,8 @@ static void ImGui::NavEndFrame() static void ImGui::NavUpdateCreateWrappingRequest() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.NavWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.NavWindow; bool do_forward = false; ImRect bb_rel = window->NavRectRel[g.NavLayer]; @@ -11651,9 +12311,9 @@ static void ImGui::NavUpdateCreateWrappingRequest() NavMoveRequestForward(g.NavMoveDir, clip_dir, move_flags, g.NavMoveScrollFlags); } -static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) +static int ImGui::FindWindowFocusIndex(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_UNUSED(g); int order = window->FocusOrder; IM_ASSERT(window->RootWindow == window); // No child window (not testing _ChildWindow because of docking) @@ -11661,9 +12321,9 @@ static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) return order; } -static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) +static ImGuiWindow *FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir) if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i])) return g.WindowsFocusOrder[i]; @@ -11672,13 +12332,13 @@ static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // static void NavUpdateWindowingHighlightWindow(int focus_change_dir) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.NavWindowingTarget); if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal) return; const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget); - ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir); + ImGuiWindow *window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir); if (!window_target) window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir); if (window_target) // Don't reset windowing target if there's a single window in the list @@ -11694,13 +12354,13 @@ static void NavUpdateWindowingHighlightWindow(int focus_change_dir) // Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer) static void ImGui::NavUpdateWindowing() { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; - ImGuiWindow* apply_focus_window = NULL; + ImGuiWindow *apply_focus_window = NULL; bool apply_toggle_layer = false; - ImGuiWindow* modal_window = GetTopMostPopupModal(); + ImGuiWindow *modal_window = GetTopMostPopupModal(); bool allow_windowing = (modal_window == NULL); if (!allow_windowing) g.NavWindowingTarget = NULL; @@ -11719,7 +12379,7 @@ static void ImGui::NavUpdateWindowing() const bool start_windowing_with_gamepad = allow_windowing && nav_gamepad_active && !g.NavWindowingTarget && IsKeyPressed(ImGuiKey_NavGamepadMenu, false); const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && io.KeyCtrl && IsKeyPressed(ImGuiKey_Tab, false); // Note: enabled even without NavEnableKeyboard! if (start_windowing_with_gamepad || start_windowing_with_keyboard) - if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) + if (ImGuiWindow *window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) { g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; @@ -11808,7 +12468,7 @@ static void ImGui::NavUpdateWindowing() ImVec2 accum_floored = ImFloor(g.NavWindowingAccumDeltaPos); if (accum_floored.x != 0.0f || accum_floored.y != 0.0f) { - ImGuiWindow* moving_window = g.NavWindowingTarget->RootWindowDockTree; + ImGuiWindow *moving_window = g.NavWindowingTarget->RootWindowDockTree; SetWindowPos(moving_window, moving_window->Pos + accum_floored, ImGuiCond_Always); g.NavWindowingAccumDeltaPos -= accum_floored; } @@ -11818,7 +12478,7 @@ static void ImGui::NavUpdateWindowing() // Apply final focus if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow)) { - ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL; + ImGuiViewport *previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL; ClearActiveID(); NavRestoreHighlightAfterMove(); apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window); @@ -11850,15 +12510,12 @@ static void ImGui::NavUpdateWindowing() ClearActiveID(); // Move to parent menu if necessary - ImGuiWindow* new_nav_window = g.NavWindow; - while (new_nav_window->ParentWindow - && (new_nav_window->DC.NavLayersActiveMask & (1 << ImGuiNavLayer_Menu)) == 0 - && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 - && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) + ImGuiWindow *new_nav_window = g.NavWindow; + while (new_nav_window->ParentWindow && (new_nav_window->DC.NavLayersActiveMask & (1 << ImGuiNavLayer_Menu)) == 0 && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) new_nav_window = new_nav_window->ParentWindow; if (new_nav_window != g.NavWindow) { - ImGuiWindow* old_nav_window = g.NavWindow; + ImGuiWindow *old_nav_window = g.NavWindow; FocusWindow(new_nav_window); new_nav_window->NavLastChildNavWindow = old_nav_window; } @@ -11878,7 +12535,7 @@ static void ImGui::NavUpdateWindowing() } // Window has already passed the IsWindowNavFocusable() -static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) +static const char *GetFallbackWindowNameForWindowingList(ImGuiWindow *window) { if (window->Flags & ImGuiWindowFlags_Popup) return "(Popup)"; @@ -11892,7 +12549,7 @@ static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) // Overlay displayed when using CTRL+TAB. Called by EndFrame(). void ImGui::NavUpdateWindowingOverlay() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.NavWindowingTarget != NULL); if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY) @@ -11900,18 +12557,18 @@ void ImGui::NavUpdateWindowingOverlay() if (g.NavWindowingListWindow == NULL) g.NavWindowingListWindow = FindWindowByName("###NavWindowingList"); - const ImGuiViewport* viewport = /*g.NavWindow ? g.NavWindow->Viewport :*/ GetMainViewport(); + const ImGuiViewport *viewport = /*g.NavWindow ? g.NavWindow->Viewport :*/ GetMainViewport(); SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX)); SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f); Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings); for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--) { - ImGuiWindow* window = g.WindowsFocusOrder[n]; + ImGuiWindow *window = g.WindowsFocusOrder[n]; IM_ASSERT(window != NULL); // Fix static analyzers if (!IsWindowNavFocusable(window)) continue; - const char* label = window->Name; + const char *label = window->Name; if (label == FindRenderedTextEnd(label)) label = GetFallbackWindowNameForWindowingList(window); Selectable(label, g.NavWindowingTarget == window); @@ -11920,20 +12577,19 @@ void ImGui::NavUpdateWindowingOverlay() PopStyleVar(); } - //----------------------------------------------------------------------------- // [SECTION] DRAG AND DROP //----------------------------------------------------------------------------- bool ImGui::IsDragDropActive() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.DragDropActive; } void ImGui::ClearDragDrop() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.DragDropActive = false; g.DragDropPayload.Clear(); g.DragDropAcceptFlags = ImGuiDragDropFlags_None; @@ -11954,8 +12610,8 @@ void ImGui::ClearDragDrop() // - Currently always assume left mouse button. bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; // FIXME-DRAGDROP: While in the common-most "drag from non-zero active id" case we can tell the mouse button, // in both SourceExtern and id==0 cases we may requires something else (explicit flags or some heuristic). @@ -12031,7 +12687,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) { IM_ASSERT(source_id != 0); ClearDragDrop(); - ImGuiPayload& payload = g.DragDropPayload; + ImGuiPayload &payload = g.DragDropPayload; payload.SourceId = source_id; payload.SourceParentId = source_parent_id; g.DragDropActive = true; @@ -12050,7 +12706,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) BeginTooltip(); if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip)) { - ImGuiWindow* tooltip_window = g.CurrentWindow; + ImGuiWindow *tooltip_window = g.CurrentWindow; tooltip_window->Hidden = tooltip_window->SkipItems = true; tooltip_window->HiddenFramesCanSkipItems = 1; } @@ -12066,7 +12722,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) void ImGui::EndDragDropSource() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.DragDropActive); IM_ASSERT(g.DragDropWithinSource && "Not after a BeginDragDropSource()?"); @@ -12080,10 +12736,10 @@ void ImGui::EndDragDropSource() } // Use 'cond' to choose to submit payload on drag start or every frame -bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond) +bool ImGui::SetDragDropPayload(const char *type, const void *data, size_t data_size, ImGuiCond cond) { - ImGuiContext& g = *GImGui; - ImGuiPayload& payload = g.DragDropPayload; + ImGuiContext &g = *GImGui; + ImGuiPayload &payload = g.DragDropPayload; if (cond == 0) cond = ImGuiCond_Always; @@ -12091,7 +12747,7 @@ bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_s IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long"); IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0)); IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once); - IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() + IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() if (cond == ImGuiCond_Always || payload.DataFrameCount == -1) { @@ -12124,14 +12780,14 @@ bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_s return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1); } -bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) +bool ImGui::BeginDragDropTargetCustom(const ImRect &bb, ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.DragDropActive) return false; - ImGuiWindow* window = g.CurrentWindow; - ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; + ImGuiWindow *window = g.CurrentWindow; + ImGuiWindow *hovered_window = g.HoveredWindowUnderMovingWindow; if (hovered_window == NULL || window->RootWindowDockTree != hovered_window->RootWindowDockTree) return false; IM_ASSERT(id != 0); @@ -12153,18 +12809,18 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) // Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) bool ImGui::BeginDragDropTarget() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.DragDropActive) return false; - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow *window = g.CurrentWindow; if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect)) return false; - ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; + ImGuiWindow *hovered_window = g.HoveredWindowUnderMovingWindow; if (hovered_window == NULL || window->RootWindowDockTree != hovered_window->RootWindowDockTree || window->SkipItems) return false; - const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect; + const ImRect &display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect; ImGuiID id = g.LastItemData.ID; if (id == 0) { @@ -12183,17 +12839,17 @@ bool ImGui::BeginDragDropTarget() bool ImGui::IsDragDropPayloadBeingAccepted() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.DragDropActive && g.DragDropAcceptIdPrev != 0; } -const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags) +const ImGuiPayload *ImGui::AcceptDragDropPayload(const char *type, ImGuiDragDropFlags flags) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiPayload& payload = g.DragDropPayload; - IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ? - IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ? + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + ImGuiPayload &payload = g.DragDropPayload; + IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ? + IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ? if (type != NULL && !payload.IsDataType(type)) return NULL; @@ -12214,7 +12870,7 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop payload.Preview = was_accepted_previously; flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame) if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview) - window->DrawList->AddRect(r.Min - ImVec2(3.5f,3.5f), r.Max + ImVec2(3.5f, 3.5f), GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f); + window->DrawList->AddRect(r.Min - ImVec2(3.5f, 3.5f), r.Max + ImVec2(3.5f, 3.5f), GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f); g.DragDropAcceptFrameCount = g.FrameCount; payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased() @@ -12224,16 +12880,16 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop return &payload; } -const ImGuiPayload* ImGui::GetDragDropPayload() +const ImGuiPayload *ImGui::GetDragDropPayload() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.DragDropActive ? &g.DragDropPayload : NULL; } // We don't really use/need this now, but added it for the sake of consistency and because we might need it later. void ImGui::EndDragDropTarget() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.DragDropActive); IM_ASSERT(g.DragDropWithinTarget); g.DragDropWithinTarget = false; @@ -12247,7 +12903,7 @@ void ImGui::EndDragDropTarget() //----------------------------------------------------------------------------- // Pass text data straight to log (without being displayed) -static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args) +static inline void LogTextV(ImGuiContext &g, const char *fmt, va_list args) { if (g.LogFile) { @@ -12261,9 +12917,9 @@ static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args) } } -void ImGui::LogText(const char* fmt, ...) +void ImGui::LogText(const char *fmt, ...) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.LogEnabled) return; @@ -12273,9 +12929,9 @@ void ImGui::LogText(const char* fmt, ...) va_end(args); } -void ImGui::LogTextV(const char* fmt, va_list args) +void ImGui::LogTextV(const char *fmt, va_list args) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.LogEnabled) return; @@ -12285,13 +12941,13 @@ void ImGui::LogTextV(const char* fmt, va_list args) // Internal version that takes a position to decide on newline placement and pad items according to their depth. // We split text into individual lines to add current tree level padding // FIXME: This code is a little complicated perhaps, considering simplifying the whole system. -void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end) +void ImGui::LogRenderedText(const ImVec2 *ref_pos, const char *text, const char *text_end) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; - const char* prefix = g.LogNextPrefix; - const char* suffix = g.LogNextSuffix; + const char *prefix = g.LogNextPrefix; + const char *suffix = g.LogNextSuffix; g.LogNextPrefix = g.LogNextSuffix = NULL; if (!text_end) @@ -12314,13 +12970,13 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* g.LogDepthRef = window->DC.TreeDepth; const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef); - const char* text_remaining = text; + const char *text_remaining = text; for (;;) { // Split the string. Each new line (after a '\n') is followed by indentation corresponding to the current depth of our log entry. // We don't add a trailing \n yet to allow a subsequent item on the same line to be captured. - const char* line_start = text_remaining; - const char* line_end = ImStreolRange(line_start, text_end); + const char *line_start = text_remaining; + const char *line_end = ImStreolRange(line_start, text_end); const bool is_last_line = (line_end == text_end); if (line_start != line_end || !is_last_line) { @@ -12346,8 +13002,8 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* // Start logging/capturing text output void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; IM_ASSERT(g.LogEnabled == false); IM_ASSERT(g.LogFile == NULL); IM_ASSERT(g.LogBuffer.empty()); @@ -12361,16 +13017,16 @@ void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) } // Important: doesn't copy underlying data, use carefully (prefix/suffix must be in scope at the time of the next LogRenderedText) -void ImGui::LogSetNextTextDecoration(const char* prefix, const char* suffix) +void ImGui::LogSetNextTextDecoration(const char *prefix, const char *suffix) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.LogNextPrefix = prefix; g.LogNextSuffix = suffix; } void ImGui::LogToTTY(int auto_open_depth) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.LogEnabled) return; IM_UNUSED(auto_open_depth); @@ -12381,9 +13037,9 @@ void ImGui::LogToTTY(int auto_open_depth) } // Start logging/capturing text output to given file -void ImGui::LogToFile(int auto_open_depth, const char* filename) +void ImGui::LogToFile(int auto_open_depth, const char *filename) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.LogEnabled) return; @@ -12408,7 +13064,7 @@ void ImGui::LogToFile(int auto_open_depth, const char* filename) // Start logging/capturing text output to clipboard void ImGui::LogToClipboard(int auto_open_depth) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.LogEnabled) return; LogBegin(ImGuiLogType_Clipboard, auto_open_depth); @@ -12416,7 +13072,7 @@ void ImGui::LogToClipboard(int auto_open_depth) void ImGui::LogToBuffer(int auto_open_depth) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.LogEnabled) return; LogBegin(ImGuiLogType_Buffer, auto_open_depth); @@ -12424,7 +13080,7 @@ void ImGui::LogToBuffer(int auto_open_depth) void ImGui::LogFinish() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.LogEnabled) return; @@ -12460,16 +13116,19 @@ void ImGui::LogFinish() // FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!) void ImGui::LogButtons() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; PushID("LogButtons"); #ifndef IMGUI_DISABLE_TTY_FUNCTIONS - const bool log_to_tty = Button("Log To TTY"); SameLine(); + const bool log_to_tty = Button("Log To TTY"); + SameLine(); #else const bool log_to_tty = false; #endif - const bool log_to_file = Button("Log To File"); SameLine(); - const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); + const bool log_to_file = Button("Log To File"); + SameLine(); + const bool log_to_clipboard = Button("Log To Clipboard"); + SameLine(); PushAllowKeyboardFocus(false); SetNextItemWidth(80.0f); SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL); @@ -12485,7 +13144,6 @@ void ImGui::LogButtons() LogToClipboard(); } - //----------------------------------------------------------------------------- // [SECTION] SETTINGS //----------------------------------------------------------------------------- @@ -12507,7 +13165,7 @@ void ImGui::LogButtons() void ImGui::UpdateSettings() { // Load settings on first frame (if not explicitly loaded manually before) - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!g.SettingsLoaded) { IM_ASSERT(g.SettingsWindows.empty()); @@ -12525,7 +13183,7 @@ void ImGui::UpdateSettings() if (g.IO.IniFilename != NULL) SaveIniSettingsToDisk(g.IO.IniFilename); else - g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves. + g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves. g.SettingsDirtyTimer = 0.0f; } } @@ -12533,74 +13191,75 @@ void ImGui::UpdateSettings() void ImGui::MarkIniSettingsDirty() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.SettingsDirtyTimer <= 0.0f) g.SettingsDirtyTimer = g.IO.IniSavingRate; } -void ImGui::MarkIniSettingsDirty(ImGuiWindow* window) +void ImGui::MarkIniSettingsDirty(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings)) if (g.SettingsDirtyTimer <= 0.0f) g.SettingsDirtyTimer = g.IO.IniSavingRate; } -ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name) +ImGuiWindowSettings *ImGui::CreateNewWindowSettings(const char *name) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; #if !IMGUI_DEBUG_INI_SETTINGS // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() // Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier. - if (const char* p = strstr(name, "###")) + if (const char *p = strstr(name, "###")) name = p; #endif const size_t name_len = strlen(name); // Allocate chunk const size_t chunk_size = sizeof(ImGuiWindowSettings) + name_len + 1; - ImGuiWindowSettings* settings = g.SettingsWindows.alloc_chunk(chunk_size); - IM_PLACEMENT_NEW(settings) ImGuiWindowSettings(); + ImGuiWindowSettings *settings = g.SettingsWindows.alloc_chunk(chunk_size); + IM_PLACEMENT_NEW(settings) + ImGuiWindowSettings(); settings->ID = ImHashStr(name, name_len); - memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator + memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator return settings; } -ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) +ImGuiWindowSettings *ImGui::FindWindowSettings(ImGuiID id) { - ImGuiContext& g = *GImGui; - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + ImGuiContext &g = *GImGui; + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (settings->ID == id) return settings; return NULL; } -ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name) +ImGuiWindowSettings *ImGui::FindOrCreateWindowSettings(const char *name) { - if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name))) + if (ImGuiWindowSettings *settings = FindWindowSettings(ImHashStr(name))) return settings; return CreateNewWindowSettings(name); } -void ImGui::AddSettingsHandler(const ImGuiSettingsHandler* handler) +void ImGui::AddSettingsHandler(const ImGuiSettingsHandler *handler) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(FindSettingsHandler(handler->TypeName) == NULL); g.SettingsHandlers.push_back(*handler); } -void ImGui::RemoveSettingsHandler(const char* type_name) +void ImGui::RemoveSettingsHandler(const char *type_name) { - ImGuiContext& g = *GImGui; - if (ImGuiSettingsHandler* handler = FindSettingsHandler(type_name)) + ImGuiContext &g = *GImGui; + if (ImGuiSettingsHandler *handler = FindSettingsHandler(type_name)) g.SettingsHandlers.erase(handler); } -ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name) +ImGuiSettingsHandler *ImGui::FindSettingsHandler(const char *type_name) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const ImGuiID type_hash = ImHashStr(type_name); for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) if (g.SettingsHandlers[handler_n].TypeHash == type_hash) @@ -12610,17 +13269,17 @@ ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name) void ImGui::ClearIniSettings() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.SettingsIniData.clear(); for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) if (g.SettingsHandlers[handler_n].ClearAllFn) g.SettingsHandlers[handler_n].ClearAllFn(&g, &g.SettingsHandlers[handler_n]); } -void ImGui::LoadIniSettingsFromDisk(const char* ini_filename) +void ImGui::LoadIniSettingsFromDisk(const char *ini_filename) { size_t file_data_size = 0; - char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); + char *file_data = (char *)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); if (!file_data) return; if (file_data_size > 0) @@ -12629,20 +13288,20 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename) } // Zero-tolerance, no error reporting, cheap .ini parsing -void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) +void ImGui::LoadIniSettingsFromMemory(const char *ini_data, size_t ini_size) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.Initialized); - //IM_ASSERT(!g.WithinFrameScope && "Cannot be called between NewFrame() and EndFrame()"); - //IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0); + // IM_ASSERT(!g.WithinFrameScope && "Cannot be called between NewFrame() and EndFrame()"); + // IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0); // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter). // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy.. if (ini_size == 0) ini_size = strlen(ini_data); g.SettingsIniData.Buf.resize((int)ini_size + 1); - char* const buf = g.SettingsIniData.Buf.Data; - char* const buf_end = buf + ini_size; + char *const buf = g.SettingsIniData.Buf.Data; + char *const buf_end = buf + ini_size; memcpy(buf, ini_data, ini_size); buf_end[0] = 0; @@ -12652,11 +13311,11 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) if (g.SettingsHandlers[handler_n].ReadInitFn) g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]); - void* entry_data = NULL; - ImGuiSettingsHandler* entry_handler = NULL; + void *entry_data = NULL; + ImGuiSettingsHandler *entry_handler = NULL; - char* line_end = NULL; - for (char* line = buf; line < buf_end; line = line_end + 1) + char *line_end = NULL; + for (char *line = buf; line < buf_end; line = line_end + 1) { // Skip new lines markers, then find end of the line while (*line == '\n' || *line == '\r') @@ -12671,10 +13330,10 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) { // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code. line_end[-1] = 0; - const char* name_end = line_end - 1; - const char* type_start = line + 1; - char* type_end = (char*)(void*)ImStrchrRange(type_start, name_end, ']'); - const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; + const char *name_end = line_end - 1; + const char *type_start = line + 1; + char *type_end = (char *)(void *)ImStrchrRange(type_start, name_end, ']'); + const char *name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; if (!type_end || !name_start) continue; *type_end = 0; // Overwrite first ']' @@ -12699,15 +13358,15 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]); } -void ImGui::SaveIniSettingsToDisk(const char* ini_filename) +void ImGui::SaveIniSettingsToDisk(const char *ini_filename) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.SettingsDirtyTimer = 0.0f; if (!ini_filename) return; size_t ini_data_size = 0; - const char* ini_data = SaveIniSettingsToMemory(&ini_data_size); + const char *ini_data = SaveIniSettingsToMemory(&ini_data_size); ImFileHandle f = ImFileOpen(ini_filename, "wt"); if (!f) return; @@ -12716,15 +13375,15 @@ void ImGui::SaveIniSettingsToDisk(const char* ini_filename) } // Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer -const char* ImGui::SaveIniSettingsToMemory(size_t* out_size) +const char *ImGui::SaveIniSettingsToMemory(size_t *out_size) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.SettingsDirtyTimer = 0.0f; g.SettingsIniData.Buf.resize(0); g.SettingsIniData.Buf.push_back(0); for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) { - ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n]; + ImGuiSettingsHandler *handler = &g.SettingsHandlers[handler_n]; handler->WriteAllFn(&g, handler, &g.SettingsIniData); } if (out_size) @@ -12732,65 +13391,91 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size) return g.SettingsIniData.c_str(); } -static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +static void WindowSettingsHandler_ClearAll(ImGuiContext *ctx, ImGuiSettingsHandler *) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; for (int i = 0; i != g.Windows.Size; i++) g.Windows[i]->SettingsOffset = -1; g.SettingsWindows.clear(); } -static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) +static void *WindowSettingsHandler_ReadOpen(ImGuiContext *, ImGuiSettingsHandler *, const char *name) { - ImGuiWindowSettings* settings = ImGui::FindOrCreateWindowSettings(name); + ImGuiWindowSettings *settings = ImGui::FindOrCreateWindowSettings(name); ImGuiID id = settings->ID; *settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry settings->ID = id; settings->WantApply = true; - return (void*)settings; + return (void *)settings; } -static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) +static void WindowSettingsHandler_ReadLine(ImGuiContext *, ImGuiSettingsHandler *, void *entry, const char *line) { - ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry; + ImGuiWindowSettings *settings = (ImGuiWindowSettings *)entry; int x, y; int i; ImU32 u1; - if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); } - else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); } - else if (sscanf(line, "ViewportId=0x%08X", &u1) == 1) { settings->ViewportId = u1; } - else if (sscanf(line, "ViewportPos=%i,%i", &x, &y) == 2){ settings->ViewportPos = ImVec2ih((short)x, (short)y); } - else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); } - else if (sscanf(line, "DockId=0x%X,%d", &u1, &i) == 2) { settings->DockId = u1; settings->DockOrder = (short)i; } - else if (sscanf(line, "DockId=0x%X", &u1) == 1) { settings->DockId = u1; settings->DockOrder = -1; } - else if (sscanf(line, "ClassId=0x%X", &u1) == 1) { settings->ClassId = u1; } + if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) + { + settings->Pos = ImVec2ih((short)x, (short)y); + } + else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) + { + settings->Size = ImVec2ih((short)x, (short)y); + } + else if (sscanf(line, "ViewportId=0x%08X", &u1) == 1) + { + settings->ViewportId = u1; + } + else if (sscanf(line, "ViewportPos=%i,%i", &x, &y) == 2) + { + settings->ViewportPos = ImVec2ih((short)x, (short)y); + } + else if (sscanf(line, "Collapsed=%d", &i) == 1) + { + settings->Collapsed = (i != 0); + } + else if (sscanf(line, "DockId=0x%X,%d", &u1, &i) == 2) + { + settings->DockId = u1; + settings->DockOrder = (short)i; + } + else if (sscanf(line, "DockId=0x%X", &u1) == 1) + { + settings->DockId = u1; + settings->DockOrder = -1; + } + else if (sscanf(line, "ClassId=0x%X", &u1) == 1) + { + settings->ClassId = u1; + } } // Apply to existing windows (if any) -static void WindowSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +static void WindowSettingsHandler_ApplyAll(ImGuiContext *ctx, ImGuiSettingsHandler *) { - ImGuiContext& g = *ctx; - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + ImGuiContext &g = *ctx; + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (settings->WantApply) { - if (ImGuiWindow* window = ImGui::FindWindowByID(settings->ID)) + if (ImGuiWindow *window = ImGui::FindWindowByID(settings->ID)) ApplyWindowSettings(window, settings); settings->WantApply = false; } } -static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) +static void WindowSettingsHandler_WriteAll(ImGuiContext *ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf) { // Gather data from windows that were active during this session // (if a window wasn't opened in this session we preserve its settings) - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; for (int i = 0; i != g.Windows.Size; i++) { - ImGuiWindow* window = g.Windows[i]; + ImGuiWindow *window = g.Windows[i]; if (window->Flags & ImGuiWindowFlags_NoSavedSettings) continue; - ImGuiWindowSettings* settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID); + ImGuiWindowSettings *settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID); if (!settings) { settings = ImGui::CreateNewWindowSettings(window->Name); @@ -12810,9 +13495,9 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl // Write to text buffer buf->reserve(buf->size() + g.SettingsWindows.size() * 6); // ballpark reserve - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) { - const char* settings_name = settings->GetName(); + const char *settings_name = settings->GetName(); buf->appendf("[%s][%s]\n", handler->TypeName, settings_name); if (settings->ViewportId != 0 && settings->ViewportId != ImGui::IMGUI_VIEWPORT_DEFAULT_ID) { @@ -12826,7 +13511,7 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl buf->appendf("Collapsed=%d\n", settings->Collapsed); if (settings->DockId != 0) { - //buf->appendf("TabId=0x%08X\n", ImHashStr("#TAB", 4, settings->ID)); // window->TabId: this is not read back but writing it makes "debugging" the .ini data easier. + // buf->appendf("TabId=0x%08X\n", ImHashStr("#TAB", 4, settings->ID)); // window->TabId: this is not read back but writing it makes "debugging" the .ini data easier. if (settings->DockOrder == -1) buf->appendf("DockId=0x%08X\n", settings->DockId); else @@ -12838,7 +13523,6 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl } } - //----------------------------------------------------------------------------- // [SECTION] VIEWPORTS, PLATFORM WINDOWS //----------------------------------------------------------------------------- @@ -12867,34 +13551,34 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl // - DestroyPlatformWindows() //----------------------------------------------------------------------------- -ImGuiViewport* ImGui::GetMainViewport() +ImGuiViewport *ImGui::GetMainViewport() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.Viewports[0]; } // FIXME: This leaks access to viewports not listed in PlatformIO.Viewports[]. Problematic? (#4236) -ImGuiViewport* ImGui::FindViewportByID(ImGuiID id) +ImGuiViewport *ImGui::FindViewportByID(ImGuiID id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int n = 0; n < g.Viewports.Size; n++) if (g.Viewports[n]->ID == id) return g.Viewports[n]; return NULL; } -ImGuiViewport* ImGui::FindViewportByPlatformHandle(void* platform_handle) +ImGuiViewport *ImGui::FindViewportByPlatformHandle(void *platform_handle) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int i = 0; i != g.Viewports.Size; i++) if (g.Viewports[i]->PlatformHandle == platform_handle) return g.Viewports[i]; return NULL; } -void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* viewport) +void ImGui::SetCurrentViewport(ImGuiWindow *current_window, ImGuiViewportP *viewport) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; (void)current_window; if (viewport) @@ -12903,7 +13587,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view return; g.CurrentDpiScale = viewport ? viewport->DpiScale : 1.0f; g.CurrentViewport = viewport; - //IMGUI_DEBUG_LOG_VIEWPORT("[viewport] SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0); + // IMGUI_DEBUG_LOG_VIEWPORT("[viewport] SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0); // Notify platform layer of viewport changes // FIXME-DPI: This is only currently used for experimenting with handling of multiple DPI @@ -12911,7 +13595,7 @@ void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* view g.PlatformIO.Platform_OnChangedViewport(g.CurrentViewport); } -void ImGui::SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport) +void ImGui::SetWindowViewport(ImGuiWindow *window, ImGuiViewportP *viewport) { // Abandon viewport if (window->ViewportOwned && window->Viewport->Window == window) @@ -12922,10 +13606,10 @@ void ImGui::SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport) window->ViewportOwned = (viewport->Window == window); } -static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window) +static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow *window) { // Tooltips and menus are not automatically forced into their own viewport when the NoMerge flag is set, however the multiplication of viewports makes them more likely to protrude and create their own. - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.IO.ConfigViewportsNoAutoMerge || (window->WindowClass.ViewportFlagsOverrideSet & ImGuiViewportFlags_NoAutoMerge)) if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable) if (!window->DockIsActive) @@ -12935,9 +13619,9 @@ static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window) return false; } -static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport) +static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow *window, ImGuiViewportP *viewport) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (window->Viewport == viewport) return false; if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) == 0) @@ -12952,7 +13636,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG // FIXME: Can't use g.WindowsFocusOrder[] for root windows only as we care about Z order. If we maintained a DisplayOrder along with FocusOrder we could.. for (int n = 0; n < g.Windows.Size; n++) { - ImGuiWindow* window_behind = g.Windows[n]; + ImGuiWindow *window_behind = g.Windows[n]; if (window_behind == window) break; if (window_behind->WasActive && window_behind->ViewportOwned && !(window_behind->Flags & ImGuiWindowFlags_ChildWindow)) @@ -12961,7 +13645,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG } // Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child) - ImGuiViewportP* old_viewport = window->Viewport; + ImGuiViewportP *old_viewport = window->Viewport; if (window->ViewportOwned) for (int n = 0; n < g.Windows.Size; n++) if (g.Windows[n]->Viewport == old_viewport) @@ -12973,17 +13657,17 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG } // FIXME: handle 0 to N host viewports -static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window) +static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]); } // Translate Dear ImGui windows when a Host Viewport has been moved // (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!) -void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos) +void ImGui::TranslateWindowsInViewport(ImGuiViewportP *viewport, const ImVec2 &old_pos, const ImVec2 &new_pos) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(viewport->Window == NULL && (viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows)); // 1) We test if ImGuiConfigFlags_ViewportsEnable was just toggled, which allows us to conveniently @@ -13000,9 +13684,9 @@ void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& o } // Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!) -void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale) +void ImGui::ScaleWindowsInViewport(ImGuiViewportP *viewport, float scale) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (viewport->Window) { ScaleWindow(viewport->Window, scale); @@ -13018,13 +13702,13 @@ void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale) // If the backend doesn't set MouseLastHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs, we do a search ourselves. // A) It won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window. // B) It requires Platform_GetWindowFocus to be implemented by backend. -ImGuiViewportP* ImGui::FindHoveredViewportFromPlatformWindowStack(const ImVec2& mouse_platform_pos) +ImGuiViewportP *ImGui::FindHoveredViewportFromPlatformWindowStack(const ImVec2 &mouse_platform_pos) { - ImGuiContext& g = *GImGui; - ImGuiViewportP* best_candidate = NULL; + ImGuiContext &g = *GImGui; + ImGuiViewportP *best_candidate = NULL; for (int n = 0; n < g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; if (!(viewport->Flags & (ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_Minimized)) && viewport->GetMainRect().Contains(mouse_platform_pos)) if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount) best_candidate = viewport; @@ -13036,7 +13720,7 @@ ImGuiViewportP* ImGui::FindHoveredViewportFromPlatformWindowStack(const ImVec2& // Note that this is running even if 'ImGuiConfigFlags_ViewportsEnable' is not set, in order to clear unused viewports (if any) and update monitor info. static void ImGui::UpdateViewportsNewFrame() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size); // Update Minimized status (we need it first in order to decide if we'll apply Pos/Size of the main viewport) @@ -13045,7 +13729,7 @@ static void ImGui::UpdateViewportsNewFrame() { for (int n = 0; n < g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; const bool platform_funcs_available = viewport->PlatformWindowCreated; if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available) { @@ -13060,14 +13744,14 @@ static void ImGui::UpdateViewportsNewFrame() // Create/update main viewport with current platform position. // FIXME-VIEWPORT: Size is driven by backend/user code for backward-compatibility but we should aim to make this more consistent. - ImGuiViewportP* main_viewport = g.Viewports[0]; + ImGuiViewportP *main_viewport = g.Viewports[0]; IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID); IM_ASSERT(main_viewport->Window == NULL); ImVec2 main_viewport_pos = viewports_enabled ? g.PlatformIO.Platform_GetWindowPos(main_viewport) : ImVec2(0.0f, 0.0f); ImVec2 main_viewport_size = g.IO.DisplaySize; if (viewports_enabled && (main_viewport->Flags & ImGuiViewportFlags_Minimized)) { - main_viewport_pos = main_viewport->Pos; // Preserve last pos/size when minimized (FIXME: We don't do the same for Size outside of the viewport path) + main_viewport_pos = main_viewport->Pos; // Preserve last pos/size when minimized (FIXME: We don't do the same for Size outside of the viewport path) main_viewport_size = main_viewport->Size; } AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_pos, main_viewport_size, ImGuiViewportFlags_OwnedByApp | ImGuiViewportFlags_CanHostOtherWindows); @@ -13077,7 +13761,7 @@ static void ImGui::UpdateViewportsNewFrame() g.MouseViewport = NULL; for (int n = 0; n < g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; viewport->Idx = n; // Erase unused viewports @@ -13134,13 +13818,13 @@ static void ImGui::UpdateViewportsNewFrame() float scale_factor = new_dpi_scale / viewport->DpiScale; if (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports) ScaleWindowsInViewport(viewport, scale_factor); - //if (viewport == GetMainViewport()) - // g.PlatformInterface.SetWindowSize(viewport, viewport->Size * scale_factor); + // if (viewport == GetMainViewport()) + // g.PlatformInterface.SetWindowSize(viewport, viewport->Size * scale_factor); // Scale our window moving pivot so that the window will rescale roughly around the mouse position. // FIXME-VIEWPORT: This currently creates a resizing feedback loop when a window is straddling a DPI transition border. // (Minor: since our sizes do not perfectly linearly scale, deferring the click offset scale until we know the actual window scale ratio may get us slightly more precise mouse positioning.) - //if (g.MovingWindow != NULL && g.MovingWindow->Viewport == viewport) + // if (g.MovingWindow != NULL && g.MovingWindow->Viewport == viewport) // g.ActiveIdClickOffset = ImFloor(g.ActiveIdClickOffset * scale_factor); } viewport->DpiScale = new_dpi_scale; @@ -13149,7 +13833,7 @@ static void ImGui::UpdateViewportsNewFrame() // Update fallback monitor if (g.PlatformIO.Monitors.Size == 0) { - ImGuiPlatformMonitor* monitor = &g.FallbackMonitor; + ImGuiPlatformMonitor *monitor = &g.FallbackMonitor; monitor->MainPos = main_viewport->Pos; monitor->MainSize = main_viewport->Size; monitor->WorkPos = main_viewport->WorkPos; @@ -13165,10 +13849,10 @@ static void ImGui::UpdateViewportsNewFrame() // Mouse handling: decide on the actual mouse viewport for this frame between the active/focused viewport and the hovered viewport. // Note that 'viewport_hovered' should skip over any viewport that has the ImGuiViewportFlags_NoInputs flags set. - ImGuiViewportP* viewport_hovered = NULL; + ImGuiViewportP *viewport_hovered = NULL; if (g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport) { - viewport_hovered = g.IO.MouseHoveredViewport ? (ImGuiViewportP*)FindViewportByID(g.IO.MouseHoveredViewport) : NULL; + viewport_hovered = g.IO.MouseHoveredViewport ? (ImGuiViewportP *)FindViewportByID(g.IO.MouseHoveredViewport) : NULL; if (viewport_hovered && (viewport_hovered->Flags & ImGuiViewportFlags_NoInputs)) viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos); // Backend failed to handle _NoInputs viewport: revert to our fallback. } @@ -13211,11 +13895,11 @@ static void ImGui::UpdateViewportsNewFrame() // Update user-facing viewport list (g.Viewports -> g.PlatformIO.Viewports after filtering out some) static void ImGui::UpdateViewportsEndFrame() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.PlatformIO.Viewports.resize(0); for (int i = 0; i < g.Viewports.Size; i++) { - ImGuiViewportP* viewport = g.Viewports[i]; + ImGuiViewportP *viewport = g.Viewports[i]; viewport->LastPos = viewport->Pos; if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f) if (i > 0) // Always include main viewport in the list @@ -13230,9 +13914,9 @@ static void ImGui::UpdateViewportsEndFrame() } // FIXME: We should ideally refactor the system to call this every frame (we currently don't) -ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags) +ImGuiViewportP *ImGui::AddUpdateViewport(ImGuiWindow *window, ImGuiID id, const ImVec2 &pos, const ImVec2 &size, ImGuiViewportFlags flags) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(id != 0); flags |= ImGuiViewportFlags_IsPlatformWindow; @@ -13246,7 +13930,7 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const flags |= ImGuiViewportFlags_NoFocusOnAppearing; } - ImGuiViewportP* viewport = (ImGuiViewportP*)FindViewportByID(id); + ImGuiViewportP *viewport = (ImGuiViewportP *)FindViewportByID(id); if (viewport) { // Always update for main viewport as we are already pulling correct platform pos/size (see #4900) @@ -13293,13 +13977,13 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const return viewport; } -static void ImGui::DestroyViewport(ImGuiViewportP* viewport) +static void ImGui::DestroyViewport(ImGuiViewportP *viewport) { // Clear references to this viewport in windows (window->ViewportId becomes the master data) - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int window_n = 0; window_n < g.Windows.Size; window_n++) { - ImGuiWindow* window = g.Windows[window_n]; + ImGuiWindow *window = g.Windows[window_n]; if (window->Viewport != viewport) continue; window->Viewport = NULL; @@ -13318,14 +14002,14 @@ static void ImGui::DestroyViewport(ImGuiViewportP* viewport) } // FIXME-VIEWPORT: This is all super messy and ought to be clarified or rewritten. -static void ImGui::WindowSelectViewport(ImGuiWindow* window) +static void ImGui::WindowSelectViewport(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiWindowFlags flags = window->Flags; window->ViewportAllowPlatformMonitorExtend = -1; // Restore main viewport if multi-viewport is not supported by the backend - ImGuiViewportP* main_viewport = (ImGuiViewportP*)(void*)GetMainViewport(); + ImGuiViewportP *main_viewport = (ImGuiViewportP *)(void *)GetMainViewport(); if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)) { SetWindowViewport(window, main_viewport); @@ -13349,7 +14033,7 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window) // Attempt to restore saved viewport id (= window that hasn't been activated yet), try to restore the viewport based on saved 'window->ViewportPos' restored from .ini file if (window->Viewport == NULL && window->ViewportId != 0) { - window->Viewport = (ImGuiViewportP*)FindViewportByID(window->ViewportId); + window->Viewport = (ImGuiViewportP *)FindViewportByID(window->ViewportId); if (window->Viewport == NULL && window->ViewportPos.x != FLT_MAX && window->ViewportPos.y != FLT_MAX) window->Viewport = AddUpdateViewport(window, window->ID, window->ViewportPos, window->Size, ImGuiViewportFlags_None); } @@ -13359,7 +14043,7 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window) if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport) { // Code explicitly request a viewport - window->Viewport = (ImGuiViewportP*)FindViewportByID(g.NextWindowData.ViewportId); + window->Viewport = (ImGuiViewportP *)FindViewportByID(g.NextWindowData.ViewportId); window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet. lock_viewport = true; } @@ -13449,13 +14133,13 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window) window->ViewportId = window->Viewport->ID; // If the OS window has a title bar, hide our imgui title bar - //if (window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_NoDecoration)) + // if (window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_NoDecoration)) // window->Flags |= ImGuiWindowFlags_NoTitleBar; } -void ImGui::WindowSyncOwnedViewport(ImGuiWindow* window, ImGuiWindow* parent_window_in_stack) +void ImGui::WindowSyncOwnedViewport(ImGuiWindow *window, ImGuiWindow *parent_window_in_stack) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; bool viewport_rect_changed = false; @@ -13505,7 +14189,7 @@ void ImGui::WindowSyncOwnedViewport(ImGuiWindow* window, ImGuiWindow* parent_win // Not correct to set modal as topmost because: // - Because other popups can be stacked above a modal (e.g. combo box in a modal) // - ImGuiViewportFlags_TopMost is currently handled different in backends: in Win32 it is "appear top most" whereas in GLFW and SDL it is "stay topmost" - //if (flags & ImGuiWindowFlags_Modal) + // if (flags & ImGuiWindowFlags_Modal) // viewport_flags |= ImGuiViewportFlags_TopMost; // For popups and menus that may be protruding out of their parent viewport, we enable _NoFocusOnClick so that clicking on them @@ -13543,7 +14227,7 @@ void ImGui::WindowSyncOwnedViewport(ImGuiWindow* window, ImGuiWindow* parent_win // This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO api. void ImGui::UpdatePlatformWindows() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before UpdatePlatformWindows()?"); IM_ASSERT(g.FrameCountPlatformEnded < g.FrameCount); g.FrameCountPlatformEnded = g.FrameCount; @@ -13554,7 +14238,7 @@ void ImGui::UpdatePlatformWindows() // Skip the main viewport (index 0), which is always fully handled by the application! for (int i = 1; i < g.Viewports.Size; i++) { - ImGuiViewportP* viewport = g.Viewports[i]; + ImGuiViewportP *viewport = g.Viewports[i]; // Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window // (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame) @@ -13596,10 +14280,10 @@ void ImGui::UpdatePlatformWindows() viewport->LastPlatformSize = viewport->LastRendererSize = viewport->Size; // Update title bar (if it changed) - if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(viewport->Window)) + if (ImGuiWindow *window_for_title = GetWindowForTitleDisplay(viewport->Window)) { - const char* title_begin = window_for_title->Name; - char* title_end = (char*)(intptr_t)FindRenderedTextEnd(title_begin); + const char *title_begin = window_for_title->Name; + char *title_end = (char *)(intptr_t)FindRenderedTextEnd(title_begin); const ImGuiID title_hash = ImHashStr(title_begin, title_end - title_begin); if (viewport->LastNameHash != title_hash) { @@ -13633,7 +14317,7 @@ void ImGui::UpdatePlatformWindows() // This is useful for our platform z-order heuristic when io.MouseHoveredViewport is not available. if (viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount) viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount; - } + } // Clear request flags viewport->ClearRequestFlags(); @@ -13644,10 +14328,10 @@ void ImGui::UpdatePlatformWindows() // FIXME-VIEWPORT: We should use this information to also set dear imgui-side focus, allowing us to handle os-level alt+tab. if (g.PlatformIO.Platform_GetWindowFocus != NULL) { - ImGuiViewportP* focused_viewport = NULL; + ImGuiViewportP *focused_viewport = NULL; for (int n = 0; n < g.Viewports.Size && focused_viewport == NULL; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; if (viewport->PlatformWindowCreated) if (g.PlatformIO.Platform_GetWindowFocus(viewport)) focused_viewport = viewport; @@ -13677,34 +14361,38 @@ void ImGui::UpdatePlatformWindows() // if ((platform_io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0) // MySwapBufferFunction(platform_io.Viewports[i], my_args); // -void ImGui::RenderPlatformWindowsDefault(void* platform_render_arg, void* renderer_render_arg) +void ImGui::RenderPlatformWindowsDefault(void *platform_render_arg, void *renderer_render_arg) { // Skip the main viewport (index 0), which is always fully handled by the application! - ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); + ImGuiPlatformIO &platform_io = ImGui::GetPlatformIO(); for (int i = 1; i < platform_io.Viewports.Size; i++) { - ImGuiViewport* viewport = platform_io.Viewports[i]; + ImGuiViewport *viewport = platform_io.Viewports[i]; if (viewport->Flags & ImGuiViewportFlags_Minimized) continue; - if (platform_io.Platform_RenderWindow) platform_io.Platform_RenderWindow(viewport, platform_render_arg); - if (platform_io.Renderer_RenderWindow) platform_io.Renderer_RenderWindow(viewport, renderer_render_arg); + if (platform_io.Platform_RenderWindow) + platform_io.Platform_RenderWindow(viewport, platform_render_arg); + if (platform_io.Renderer_RenderWindow) + platform_io.Renderer_RenderWindow(viewport, renderer_render_arg); } for (int i = 1; i < platform_io.Viewports.Size; i++) { - ImGuiViewport* viewport = platform_io.Viewports[i]; + ImGuiViewport *viewport = platform_io.Viewports[i]; if (viewport->Flags & ImGuiViewportFlags_Minimized) continue; - if (platform_io.Platform_SwapBuffers) platform_io.Platform_SwapBuffers(viewport, platform_render_arg); - if (platform_io.Renderer_SwapBuffers) platform_io.Renderer_SwapBuffers(viewport, renderer_render_arg); + if (platform_io.Platform_SwapBuffers) + platform_io.Platform_SwapBuffers(viewport, platform_render_arg); + if (platform_io.Renderer_SwapBuffers) + platform_io.Renderer_SwapBuffers(viewport, renderer_render_arg); } } -static int ImGui::FindPlatformMonitorForPos(const ImVec2& pos) +static int ImGui::FindPlatformMonitorForPos(const ImVec2 &pos) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size; monitor_n++) { - const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[monitor_n]; + const ImGuiPlatformMonitor &monitor = g.PlatformIO.Monitors[monitor_n]; if (ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize).Contains(pos)) return monitor_n; } @@ -13714,9 +14402,9 @@ static int ImGui::FindPlatformMonitorForPos(const ImVec2& pos) // Search for the monitor with the largest intersection area with the given rectangle // We generally try to avoid searching loops but the monitor count should be very small here // FIXME-OPT: We could test the last monitor used for that viewport first, and early -static int ImGui::FindPlatformMonitorForRect(const ImRect& rect) +static int ImGui::FindPlatformMonitorForRect(const ImRect &rect) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const int monitor_count = g.PlatformIO.Monitors.Size; if (monitor_count <= 1) @@ -13730,7 +14418,7 @@ static int ImGui::FindPlatformMonitorForRect(const ImRect& rect) for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size && best_monitor_surface < surface_threshold; monitor_n++) { - const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[monitor_n]; + const ImGuiPlatformMonitor &monitor = g.PlatformIO.Monitors[monitor_n]; const ImRect monitor_rect = ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize); if (monitor_rect.Contains(rect)) return monitor_n; @@ -13746,25 +14434,25 @@ static int ImGui::FindPlatformMonitorForRect(const ImRect& rect) } // Update monitor from viewport rectangle (we'll use this info to clamp windows and save windows lost in a removed monitor) -static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP* viewport) +static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP *viewport) { viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetMainRect()); } // Return value is always != NULL, but don't hold on it across frames. -const ImGuiPlatformMonitor* ImGui::GetViewportPlatformMonitor(ImGuiViewport* viewport_p) +const ImGuiPlatformMonitor *ImGui::GetViewportPlatformMonitor(ImGuiViewport *viewport_p) { - ImGuiContext& g = *GImGui; - ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)viewport_p; + ImGuiContext &g = *GImGui; + ImGuiViewportP *viewport = (ImGuiViewportP *)(void *)viewport_p; int monitor_idx = viewport->PlatformMonitor; if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size) return &g.PlatformIO.Monitors[monitor_idx]; return &g.FallbackMonitor; } -void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) +void ImGui::DestroyPlatformWindow(ImGuiViewportP *viewport) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (viewport->PlatformWindowCreated) { if (g.PlatformIO.Renderer_DestroyWindow) @@ -13794,12 +14482,11 @@ void ImGui::DestroyPlatformWindows() // code to operator a consistent manner. // It is expected that the backend can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without // crashing if it doesn't have data stored. - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int i = 0; i < g.Viewports.Size; i++) DestroyPlatformWindow(g.Viewports[i]); } - //----------------------------------------------------------------------------- // [SECTION] DOCKING //----------------------------------------------------------------------------- @@ -13877,20 +14564,20 @@ enum ImGuiDockRequestType ImGuiDockRequestType_None = 0, ImGuiDockRequestType_Dock, ImGuiDockRequestType_Undock, - ImGuiDockRequestType_Split // Split is the same as Dock but without a DockPayload + ImGuiDockRequestType_Split // Split is the same as Dock but without a DockPayload }; struct ImGuiDockRequest { - ImGuiDockRequestType Type; - ImGuiWindow* DockTargetWindow; // Destination/Target Window to dock into (may be a loose window or a DockNode, might be NULL in which case DockTargetNode cannot be NULL) - ImGuiDockNode* DockTargetNode; // Destination/Target Node to dock into - ImGuiWindow* DockPayload; // Source/Payload window to dock (may be a loose window or a DockNode), [Optional] - ImGuiDir DockSplitDir; - float DockSplitRatio; - bool DockSplitOuter; - ImGuiWindow* UndockTargetWindow; - ImGuiDockNode* UndockTargetNode; + ImGuiDockRequestType Type; + ImGuiWindow *DockTargetWindow; // Destination/Target Window to dock into (may be a loose window or a DockNode, might be NULL in which case DockTargetNode cannot be NULL) + ImGuiDockNode *DockTargetNode; // Destination/Target Node to dock into + ImGuiWindow *DockPayload; // Source/Payload window to dock (may be a loose window or a DockNode), [Optional] + ImGuiDir DockSplitDir; + float DockSplitRatio; + bool DockSplitOuter; + ImGuiWindow *UndockTargetWindow; + ImGuiDockNode *UndockTargetNode; ImGuiDockRequest() { @@ -13905,33 +14592,45 @@ struct ImGuiDockRequest struct ImGuiDockPreviewData { - ImGuiDockNode FutureNode; - bool IsDropAllowed; - bool IsCenterAvailable; - bool IsSidesAvailable; // Hold your breath, grammar freaks.. - bool IsSplitDirExplicit; // Set when hovered the drop rect (vs. implicit SplitDir==None when hovered the window) - ImGuiDockNode* SplitNode; - ImGuiDir SplitDir; - float SplitRatio; - ImRect DropRectsDraw[ImGuiDir_COUNT + 1]; // May be slightly different from hit-testing drop rects used in DockNodeCalcDropRects() - - ImGuiDockPreviewData() : FutureNode(0) { IsDropAllowed = IsCenterAvailable = IsSidesAvailable = IsSplitDirExplicit = false; SplitNode = NULL; SplitDir = ImGuiDir_None; SplitRatio = 0.f; for (int n = 0; n < IM_ARRAYSIZE(DropRectsDraw); n++) DropRectsDraw[n] = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX); } + ImGuiDockNode FutureNode; + bool IsDropAllowed; + bool IsCenterAvailable; + bool IsSidesAvailable; // Hold your breath, grammar freaks.. + bool IsSplitDirExplicit; // Set when hovered the drop rect (vs. implicit SplitDir==None when hovered the window) + ImGuiDockNode *SplitNode; + ImGuiDir SplitDir; + float SplitRatio; + ImRect DropRectsDraw[ImGuiDir_COUNT + 1]; // May be slightly different from hit-testing drop rects used in DockNodeCalcDropRects() + + ImGuiDockPreviewData() : FutureNode(0) + { + IsDropAllowed = IsCenterAvailable = IsSidesAvailable = IsSplitDirExplicit = false; + SplitNode = NULL; + SplitDir = ImGuiDir_None; + SplitRatio = 0.f; + for (int n = 0; n < IM_ARRAYSIZE(DropRectsDraw); n++) + DropRectsDraw[n] = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX); + } }; // Persistent Settings data, stored contiguously in SettingsNodes (sizeof() ~32 bytes) struct ImGuiDockNodeSettings { - ImGuiID ID; - ImGuiID ParentNodeId; - ImGuiID ParentWindowId; - ImGuiID SelectedTabId; - signed char SplitAxis; - char Depth; - ImGuiDockNodeFlags Flags; // NB: We save individual flags one by one in ascii format (ImGuiDockNodeFlags_SavedFlagsMask_) - ImVec2ih Pos; - ImVec2ih Size; - ImVec2ih SizeRef; - ImGuiDockNodeSettings() { memset(this, 0, sizeof(*this)); SplitAxis = ImGuiAxis_None; } + ImGuiID ID; + ImGuiID ParentNodeId; + ImGuiID ParentWindowId; + ImGuiID SelectedTabId; + signed char SplitAxis; + char Depth; + ImGuiDockNodeFlags Flags; // NB: We save individual flags one by one in ascii format (ImGuiDockNodeFlags_SavedFlagsMask_) + ImVec2ih Pos; + ImVec2ih Size; + ImVec2ih SizeRef; + ImGuiDockNodeSettings() + { + memset(this, 0, sizeof(*this)); + SplitAxis = ImGuiAxis_None; + } }; //----------------------------------------------------------------------------- @@ -13941,61 +14640,65 @@ struct ImGuiDockNodeSettings namespace ImGui { // ImGuiDockContext - static ImGuiDockNode* DockContextAddNode(ImGuiContext* ctx, ImGuiID id); - static void DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, bool merge_sibling_into_parent_node); - static void DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node); - static void DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req); - static void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref = true); - static void DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node); - static void DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx); - static ImGuiDockNode* DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window); - static void DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count); - static void DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id); // Use root_id==0 to add all + static ImGuiDockNode *DockContextAddNode(ImGuiContext *ctx, ImGuiID id); + static void DockContextRemoveNode(ImGuiContext *ctx, ImGuiDockNode *node, bool merge_sibling_into_parent_node); + static void DockContextQueueNotifyRemovedNode(ImGuiContext *ctx, ImGuiDockNode *node); + static void DockContextProcessDock(ImGuiContext *ctx, ImGuiDockRequest *req); + static void DockContextProcessUndockWindow(ImGuiContext *ctx, ImGuiWindow *window, bool clear_persistent_docking_ref = true); + static void DockContextProcessUndockNode(ImGuiContext *ctx, ImGuiDockNode *node); + static void DockContextPruneUnusedSettingsNodes(ImGuiContext *ctx); + static ImGuiDockNode *DockContextBindNodeToWindow(ImGuiContext *ctx, ImGuiWindow *window); + static void DockContextBuildNodesFromSettings(ImGuiContext *ctx, ImGuiDockNodeSettings *node_settings_array, int node_settings_count); + static void DockContextBuildAddWindowsToNodes(ImGuiContext *ctx, ImGuiID root_id); // Use root_id==0 to add all // ImGuiDockNode - static void DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, bool add_to_tab_bar); - static void DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* src_node); - static void DockNodeMoveChildNodes(ImGuiDockNode* dst_node, ImGuiDockNode* src_node); - static ImGuiWindow* DockNodeFindWindowByID(ImGuiDockNode* node, ImGuiID id); - static void DockNodeApplyPosSizeToWindows(ImGuiDockNode* node); - static void DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id); - static void DockNodeHideHostWindow(ImGuiDockNode* node); - static void DockNodeUpdate(ImGuiDockNode* node); - static void DockNodeUpdateForRootNode(ImGuiDockNode* node); - static void DockNodeUpdateFlagsAndCollapse(ImGuiDockNode* node); - static void DockNodeUpdateHasCentralNodeChild(ImGuiDockNode* node); - static void DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window); - static void DockNodeAddTabBar(ImGuiDockNode* node); - static void DockNodeRemoveTabBar(ImGuiDockNode* node); - static ImGuiID DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar); - static void DockNodeUpdateVisibleFlag(ImGuiDockNode* node); - static void DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window); - static bool DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* payload_window); - static void DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, ImGuiDockNode* payload_node, ImGuiDockPreviewData* preview_data, bool is_explicit_target, bool is_outer_docking); - static void DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, const ImGuiDockPreviewData* preview_data); - static void DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos, ImVec2* out_close_button_pos); - static void DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired); - static bool DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_draw, bool outer_docking, ImVec2* test_mouse_pos); - static const char* DockNodeGetHostWindowTitle(ImGuiDockNode* node, char* buf, int buf_size) { ImFormatString(buf, buf_size, "##DockNode_%02X", node->ID); return buf; } - static int DockNodeGetTabOrder(ImGuiWindow* window); + static void DockNodeAddWindow(ImGuiDockNode *node, ImGuiWindow *window, bool add_to_tab_bar); + static void DockNodeMoveWindows(ImGuiDockNode *dst_node, ImGuiDockNode *src_node); + static void DockNodeMoveChildNodes(ImGuiDockNode *dst_node, ImGuiDockNode *src_node); + static ImGuiWindow *DockNodeFindWindowByID(ImGuiDockNode *node, ImGuiID id); + static void DockNodeApplyPosSizeToWindows(ImGuiDockNode *node); + static void DockNodeRemoveWindow(ImGuiDockNode *node, ImGuiWindow *window, ImGuiID save_dock_id); + static void DockNodeHideHostWindow(ImGuiDockNode *node); + static void DockNodeUpdate(ImGuiDockNode *node); + static void DockNodeUpdateForRootNode(ImGuiDockNode *node); + static void DockNodeUpdateFlagsAndCollapse(ImGuiDockNode *node); + static void DockNodeUpdateHasCentralNodeChild(ImGuiDockNode *node); + static void DockNodeUpdateTabBar(ImGuiDockNode *node, ImGuiWindow *host_window); + static void DockNodeAddTabBar(ImGuiDockNode *node); + static void DockNodeRemoveTabBar(ImGuiDockNode *node); + static ImGuiID DockNodeUpdateWindowMenu(ImGuiDockNode *node, ImGuiTabBar *tab_bar); + static void DockNodeUpdateVisibleFlag(ImGuiDockNode *node); + static void DockNodeStartMouseMovingWindow(ImGuiDockNode *node, ImGuiWindow *window); + static bool DockNodeIsDropAllowed(ImGuiWindow *host_window, ImGuiWindow *payload_window); + static void DockNodePreviewDockSetup(ImGuiWindow *host_window, ImGuiDockNode *host_node, ImGuiWindow *payload_window, ImGuiDockNode *payload_node, ImGuiDockPreviewData *preview_data, bool is_explicit_target, bool is_outer_docking); + static void DockNodePreviewDockRender(ImGuiWindow *host_window, ImGuiDockNode *host_node, ImGuiWindow *payload_window, const ImGuiDockPreviewData *preview_data); + static void DockNodeCalcTabBarLayout(const ImGuiDockNode *node, ImRect *out_title_rect, ImRect *out_tab_bar_rect, ImVec2 *out_window_menu_button_pos, ImVec2 *out_close_button_pos); + static void DockNodeCalcSplitRects(ImVec2 &pos_old, ImVec2 &size_old, ImVec2 &pos_new, ImVec2 &size_new, ImGuiDir dir, ImVec2 size_new_desired); + static bool DockNodeCalcDropRectsAndTestMousePos(const ImRect &parent, ImGuiDir dir, ImRect &out_draw, bool outer_docking, ImVec2 *test_mouse_pos); + static const char *DockNodeGetHostWindowTitle(ImGuiDockNode *node, char *buf, int buf_size) + { + ImFormatString(buf, buf_size, "##DockNode_%02X", node->ID); + return buf; + } + static int DockNodeGetTabOrder(ImGuiWindow *window); // ImGuiDockNode tree manipulations - static void DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_first_child, float split_ratio, ImGuiDockNode* new_node); - static void DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child); - static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, ImGuiDockNode* only_write_to_single_node = NULL); - static void DockNodeTreeUpdateSplitter(ImGuiDockNode* node); - static ImGuiDockNode* DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVec2 pos); - static ImGuiDockNode* DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node); + static void DockNodeTreeSplit(ImGuiContext *ctx, ImGuiDockNode *parent_node, ImGuiAxis split_axis, int split_first_child, float split_ratio, ImGuiDockNode *new_node); + static void DockNodeTreeMerge(ImGuiContext *ctx, ImGuiDockNode *parent_node, ImGuiDockNode *merge_lead_child); + static void DockNodeTreeUpdatePosSize(ImGuiDockNode *node, ImVec2 pos, ImVec2 size, ImGuiDockNode *only_write_to_single_node = NULL); + static void DockNodeTreeUpdateSplitter(ImGuiDockNode *node); + static ImGuiDockNode *DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode *node, ImVec2 pos); + static ImGuiDockNode *DockNodeTreeFindFallbackLeafNode(ImGuiDockNode *node); // Settings - static void DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id); - static void DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count); - static ImGuiDockNodeSettings* DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID node_id); - static void DockSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*); - static void DockSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*); - static void* DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name); - static void DockSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line); - static void DockSettingsHandler_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf); + static void DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id); + static void DockSettingsRemoveNodeReferences(ImGuiID *node_ids, int node_ids_count); + static ImGuiDockNodeSettings *DockSettingsFindNodeSettings(ImGuiContext *ctx, ImGuiID node_id); + static void DockSettingsHandler_ClearAll(ImGuiContext *, ImGuiSettingsHandler *); + static void DockSettingsHandler_ApplyAll(ImGuiContext *, ImGuiSettingsHandler *); + static void *DockSettingsHandler_ReadOpen(ImGuiContext *, ImGuiSettingsHandler *, const char *name); + static void DockSettingsHandler_ReadLine(ImGuiContext *, ImGuiSettingsHandler *, void *entry, const char *line); + static void DockSettingsHandler_WriteAll(ImGuiContext *imgui_ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf); } //----------------------------------------------------------------------------- @@ -14026,9 +14729,9 @@ namespace ImGui // - DockContextBuildAddWindowsToNodes() //----------------------------------------------------------------------------- -void ImGui::DockContextInitialize(ImGuiContext* ctx) +void ImGui::DockContextInitialize(ImGuiContext *ctx) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; // Add .ini handle for persistent docking data ImGuiSettingsHandler ini_handler; @@ -14043,15 +14746,15 @@ void ImGui::DockContextInitialize(ImGuiContext* ctx) g.SettingsHandlers.push_back(ini_handler); } -void ImGui::DockContextShutdown(ImGuiContext* ctx) +void ImGui::DockContextShutdown(ImGuiContext *ctx) { - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiDockContext *dc = &ctx->DockContext; for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) IM_DELETE(node); } -void ImGui::DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_settings_refs) +void ImGui::DockContextClearNodes(ImGuiContext *ctx, ImGuiID root_id, bool clear_settings_refs) { IM_UNUSED(ctx); IM_ASSERT(ctx == GImGui); @@ -14061,10 +14764,10 @@ void ImGui::DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear // [DEBUG] This function also acts as a defacto test to make sure we can rebuild from scratch without a glitch // (Different from DockSettingsHandler_ClearAll() + DockSettingsHandler_ApplyAll() because this reuses current settings!) -void ImGui::DockContextRebuildNodes(ImGuiContext* ctx) +void ImGui::DockContextRebuildNodes(ImGuiContext *ctx) { - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &ctx->DockContext; IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextRebuildNodes\n"); SaveIniSettingsToMemory(); ImGuiID root_id = 0; // Rebuild all @@ -14074,10 +14777,10 @@ void ImGui::DockContextRebuildNodes(ImGuiContext* ctx) } // Docking context update function, called by NewFrame() -void ImGui::DockContextNewFrameUpdateUndocking(ImGuiContext* ctx) +void ImGui::DockContextNewFrameUpdateUndocking(ImGuiContext *ctx) { - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &ctx->DockContext; if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)) { if (dc->Nodes.Data.Size > 0 || dc->Requests.Size > 0) @@ -14088,14 +14791,14 @@ void ImGui::DockContextNewFrameUpdateUndocking(ImGuiContext* ctx) // Setting NoSplit at runtime merges all nodes if (g.IO.ConfigDockingNoSplit) for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) if (node->IsRootNode() && node->IsSplitNode()) { DockBuilderRemoveNodeChildNodes(node->ID); - //dc->WantFullRebuild = true; + // dc->WantFullRebuild = true; } - // Process full rebuild + // Process full rebuild #if 0 if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C))) dc->WantFullRebuild = true; @@ -14109,7 +14812,7 @@ void ImGui::DockContextNewFrameUpdateUndocking(ImGuiContext* ctx) // Process Undocking requests (we need to process them _before_ the UpdateMouseMovingWindowNewFrame call in NewFrame) for (int n = 0; n < dc->Requests.Size; n++) { - ImGuiDockRequest* req = &dc->Requests[n]; + ImGuiDockRequest *req = &dc->Requests[n]; if (req->Type == ImGuiDockRequestType_Undock && req->UndockTargetWindow) DockContextProcessUndockWindow(ctx, req->UndockTargetWindow); else if (req->Type == ImGuiDockRequestType_Undock && req->UndockTargetNode) @@ -14118,10 +14821,10 @@ void ImGui::DockContextNewFrameUpdateUndocking(ImGuiContext* ctx) } // Docking context update function, called by NewFrame() -void ImGui::DockContextNewFrameUpdateDocking(ImGuiContext* ctx) +void ImGui::DockContextNewFrameUpdateDocking(ImGuiContext *ctx) { - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &ctx->DockContext; if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)) return; @@ -14129,7 +14832,7 @@ void ImGui::DockContextNewFrameUpdateDocking(ImGuiContext* ctx) // We could in theory use DockNodeTreeFindVisibleNodeByPos() on the root host dock node, but using ->DockNode is a good shortcut. // Note this is mostly a debug thing and isn't actually used for docking target, because docking involve more detailed filtering. g.DebugHoveredDockNode = NULL; - if (ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow) + if (ImGuiWindow *hovered_window = g.HoveredWindowUnderMovingWindow) { if (hovered_window->DockNodeAsHost) g.DebugHoveredDockNode = DockNodeTreeFindVisibleNodeByPos(hovered_window->DockNodeAsHost, g.IO.MousePos); @@ -14146,18 +14849,18 @@ void ImGui::DockContextNewFrameUpdateDocking(ImGuiContext* ctx) // Create windows for each automatic docking nodes // We can have NULL pointers when we delete nodes, but because ID are recycled this should amortize nicely (and our node count will never be very high) for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) if (node->IsFloatingNode()) DockNodeUpdate(node); } -void ImGui::DockContextEndFrame(ImGuiContext* ctx) +void ImGui::DockContextEndFrame(ImGuiContext *ctx) { // Draw backgrounds of node missing their window - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &g.DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &g.DockContext; for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) if (node->LastFrameActive == g.FrameCount && node->IsVisible && node->HostWindow && node->IsLeafNode() && !node->IsBgDrawnThisFrame) { ImRect bg_rect(node->Pos + ImVec2(0.0f, GetFrameHeight()), node->Pos + node->Size); @@ -14167,12 +14870,12 @@ void ImGui::DockContextEndFrame(ImGuiContext* ctx) } } -ImGuiDockNode* ImGui::DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id) +ImGuiDockNode *ImGui::DockContextFindNodeByID(ImGuiContext *ctx, ImGuiID id) { - return (ImGuiDockNode*)ctx->DockContext.Nodes.GetVoidPtr(id); + return (ImGuiDockNode *)ctx->DockContext.Nodes.GetVoidPtr(id); } -ImGuiID ImGui::DockContextGenNodeID(ImGuiContext* ctx) +ImGuiID ImGui::DockContextGenNodeID(ImGuiContext *ctx) { // Generate an ID for new node (the exact ID value doesn't matter as long as it is not already used) // FIXME-OPT FIXME-DOCK: This is suboptimal, even if the node count is small enough not to be a worry.0 @@ -14183,10 +14886,10 @@ ImGuiID ImGui::DockContextGenNodeID(ImGuiContext* ctx) return id; } -static ImGuiDockNode* ImGui::DockContextAddNode(ImGuiContext* ctx, ImGuiID id) +static ImGuiDockNode *ImGui::DockContextAddNode(ImGuiContext *ctx, ImGuiID id) { // Generate an ID for the new node (the exact ID value doesn't matter as long as it is not already used) and add the first window. - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; if (id == 0) id = DockContextGenNodeID(ctx); else @@ -14194,15 +14897,15 @@ static ImGuiDockNode* ImGui::DockContextAddNode(ImGuiContext* ctx, ImGuiID id) // We don't set node->LastFrameAlive on construction. Nodes are always created at all time to reflect .ini settings! IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextAddNode 0x%08X\n", id); - ImGuiDockNode* node = IM_NEW(ImGuiDockNode)(id); + ImGuiDockNode *node = IM_NEW(ImGuiDockNode)(id); ctx->DockContext.Nodes.SetVoidPtr(node->ID, node); return node; } -static void ImGui::DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, bool merge_sibling_into_parent_node) +static void ImGui::DockContextRemoveNode(ImGuiContext *ctx, ImGuiDockNode *node, bool merge_sibling_into_parent_node) { - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &ctx->DockContext; IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextRemoveNode 0x%08X\n", node->ID); IM_ASSERT(DockContextFindNodeByID(ctx, node->ID) == node); @@ -14212,12 +14915,12 @@ static void ImGui::DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, if (node->HostWindow) node->HostWindow->DockNodeAsHost = NULL; - ImGuiDockNode* parent_node = node->ParentNode; + ImGuiDockNode *parent_node = node->ParentNode; const bool merge = (merge_sibling_into_parent_node && parent_node != NULL); if (merge) { IM_ASSERT(parent_node->ChildNodes[0] == node || parent_node->ChildNodes[1] == node); - ImGuiDockNode* sibling_node = (parent_node->ChildNodes[0] == node ? parent_node->ChildNodes[1] : parent_node->ChildNodes[0]); + ImGuiDockNode *sibling_node = (parent_node->ChildNodes[0] == node ? parent_node->ChildNodes[1] : parent_node->ChildNodes[0]); DockNodeTreeMerge(&g, parent_node, sibling_node); } else @@ -14230,26 +14933,30 @@ static void ImGui::DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, } } -static int IMGUI_CDECL DockNodeComparerDepthMostFirst(const void* lhs, const void* rhs) +static int IMGUI_CDECL DockNodeComparerDepthMostFirst(const void *lhs, const void *rhs) { - const ImGuiDockNode* a = *(const ImGuiDockNode* const*)lhs; - const ImGuiDockNode* b = *(const ImGuiDockNode* const*)rhs; + const ImGuiDockNode *a = *(const ImGuiDockNode *const *)lhs; + const ImGuiDockNode *b = *(const ImGuiDockNode *const *)rhs; return ImGui::DockNodeGetDepth(b) - ImGui::DockNodeGetDepth(a); } // Pre C++0x doesn't allow us to use a function-local type (without linkage) as template parameter, so we moved this here. struct ImGuiDockContextPruneNodeData { - int CountWindows, CountChildWindows, CountChildNodes; - ImGuiID RootId; - ImGuiDockContextPruneNodeData() { CountWindows = CountChildWindows = CountChildNodes = 0; RootId = 0; } + int CountWindows, CountChildWindows, CountChildNodes; + ImGuiID RootId; + ImGuiDockContextPruneNodeData() + { + CountWindows = CountChildWindows = CountChildNodes = 0; + RootId = 0; + } }; // Garbage collect unused nodes (run once at init time) -static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx) +static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext *ctx) { - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &ctx->DockContext; IM_ASSERT(g.Windows.Size == 0); ImPool pool; @@ -14258,8 +14965,8 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx) // Count child nodes and compute RootID for (int settings_n = 0; settings_n < dc->NodesSettings.Size; settings_n++) { - ImGuiDockNodeSettings* settings = &dc->NodesSettings[settings_n]; - ImGuiDockContextPruneNodeData* parent_data = settings->ParentNodeId ? pool.GetByKey(settings->ParentNodeId) : 0; + ImGuiDockNodeSettings *settings = &dc->NodesSettings[settings_n]; + ImGuiDockContextPruneNodeData *parent_data = settings->ParentNodeId ? pool.GetByKey(settings->ParentNodeId) : 0; pool.GetOrAddByKey(settings->ID)->RootId = parent_data ? parent_data->RootId : settings->ID; if (settings->ParentNodeId) pool.GetOrAddByKey(settings->ParentNodeId)->CountChildNodes++; @@ -14269,37 +14976,37 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx) // We track the 'auto-DockNode <- manual-Window <- manual-DockSpace' in order to avoid 'auto-DockNode' being ditched by DockContextPruneUnusedSettingsNodes() for (int settings_n = 0; settings_n < dc->NodesSettings.Size; settings_n++) { - ImGuiDockNodeSettings* settings = &dc->NodesSettings[settings_n]; + ImGuiDockNodeSettings *settings = &dc->NodesSettings[settings_n]; if (settings->ParentWindowId != 0) - if (ImGuiWindowSettings* window_settings = FindWindowSettings(settings->ParentWindowId)) + if (ImGuiWindowSettings *window_settings = FindWindowSettings(settings->ParentWindowId)) if (window_settings->DockId) - if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(window_settings->DockId)) + if (ImGuiDockContextPruneNodeData *data = pool.GetByKey(window_settings->DockId)) data->CountChildNodes++; } // Count reference to dock ids from window settings // We guard against the possibility of an invalid .ini file (RootID may point to a missing node) - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (ImGuiID dock_id = settings->DockId) - if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id)) + if (ImGuiDockContextPruneNodeData *data = pool.GetByKey(dock_id)) { data->CountWindows++; - if (ImGuiDockContextPruneNodeData* data_root = (data->RootId == dock_id) ? data : pool.GetByKey(data->RootId)) + if (ImGuiDockContextPruneNodeData *data_root = (data->RootId == dock_id) ? data : pool.GetByKey(data->RootId)) data_root->CountChildWindows++; } // Prune for (int settings_n = 0; settings_n < dc->NodesSettings.Size; settings_n++) { - ImGuiDockNodeSettings* settings = &dc->NodesSettings[settings_n]; - ImGuiDockContextPruneNodeData* data = pool.GetByKey(settings->ID); + ImGuiDockNodeSettings *settings = &dc->NodesSettings[settings_n]; + ImGuiDockContextPruneNodeData *data = pool.GetByKey(settings->ID); if (data->CountWindows > 1) continue; - ImGuiDockContextPruneNodeData* data_root = (data->RootId == settings->ID) ? data : pool.GetByKey(data->RootId); + ImGuiDockContextPruneNodeData *data_root = (data->RootId == settings->ID) ? data : pool.GetByKey(data->RootId); bool remove = false; - remove |= (data->CountWindows == 1 && settings->ParentNodeId == 0 && data->CountChildNodes == 0 && !(settings->Flags & ImGuiDockNodeFlags_CentralNode)); // Floating root node with only 1 window - remove |= (data->CountWindows == 0 && settings->ParentNodeId == 0 && data->CountChildNodes == 0); // Leaf nodes with 0 window + remove |= (data->CountWindows == 1 && settings->ParentNodeId == 0 && data->CountChildNodes == 0 && !(settings->Flags & ImGuiDockNodeFlags_CentralNode)); // Floating root node with only 1 window + remove |= (data->CountWindows == 0 && settings->ParentNodeId == 0 && data->CountChildNodes == 0); // Leaf nodes with 0 window remove |= (data_root->CountChildWindows == 0); if (remove) { @@ -14310,15 +15017,15 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx) } } -static void ImGui::DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count) +static void ImGui::DockContextBuildNodesFromSettings(ImGuiContext *ctx, ImGuiDockNodeSettings *node_settings_array, int node_settings_count) { // Build nodes for (int node_n = 0; node_n < node_settings_count; node_n++) { - ImGuiDockNodeSettings* settings = &node_settings_array[node_n]; + ImGuiDockNodeSettings *settings = &node_settings_array[node_n]; if (settings->ID == 0) continue; - ImGuiDockNode* node = DockContextAddNode(ctx, settings->ID); + ImGuiDockNode *node = DockContextAddNode(ctx, settings->ID); node->ParentNode = settings->ParentNodeId ? DockContextFindNodeByID(ctx, settings->ParentNodeId) : NULL; node->Pos = ImVec2(settings->Pos.x, settings->Pos.y); node->Size = ImVec2(settings->Size.x, settings->Size.y); @@ -14335,25 +15042,25 @@ static void ImGui::DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDoc // Bind host window immediately if it already exist (in case of a rebuild) // This is useful as the RootWindowForTitleBarHighlight links necessary to highlight the currently focused node requires node->HostWindow to be set. char host_window_title[20]; - ImGuiDockNode* root_node = DockNodeGetRootNode(node); + ImGuiDockNode *root_node = DockNodeGetRootNode(node); node->HostWindow = FindWindowByName(DockNodeGetHostWindowTitle(root_node, host_window_title, IM_ARRAYSIZE(host_window_title))); } } -void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id) +void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext *ctx, ImGuiID root_id) { // Rebind all windows to nodes (they can also lazily rebind but we'll have a visible glitch during the first frame) - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; for (int n = 0; n < g.Windows.Size; n++) { - ImGuiWindow* window = g.Windows[n]; + ImGuiWindow *window = g.Windows[n]; if (window->DockId == 0 || window->LastFrameActive < g.FrameCount - 1) continue; if (window->DockNode != NULL) continue; - ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId); - IM_ASSERT(node != NULL); // This should have been called after DockContextBuildNodesFromSettings() + ImGuiDockNode *node = DockContextFindNodeByID(ctx, window->DockId); + IM_ASSERT(node != NULL); // This should have been called after DockContextBuildNodesFromSettings() if (root_id == 0 || DockNodeGetRootNode(node)->ID == root_id) DockNodeAddWindow(node, window, true); } @@ -14372,7 +15079,7 @@ void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id // - DockContextCalcDropPosForDocking() //----------------------------------------------------------------------------- -void ImGui::DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer) +void ImGui::DockContextQueueDock(ImGuiContext *ctx, ImGuiWindow *target, ImGuiDockNode *target_node, ImGuiWindow *payload, ImGuiDir split_dir, float split_ratio, bool split_outer) { IM_ASSERT(target != payload); ImGuiDockRequest req; @@ -14386,7 +15093,7 @@ void ImGui::DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDo ctx->DockContext.Requests.push_back(req); } -void ImGui::DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window) +void ImGui::DockContextQueueUndockWindow(ImGuiContext *ctx, ImGuiWindow *window) { ImGuiDockRequest req; req.Type = ImGuiDockRequestType_Undock; @@ -14394,7 +15101,7 @@ void ImGui::DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window) ctx->DockContext.Requests.push_back(req); } -void ImGui::DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) +void ImGui::DockContextQueueUndockNode(ImGuiContext *ctx, ImGuiDockNode *node) { ImGuiDockRequest req; req.Type = ImGuiDockRequestType_Undock; @@ -14402,25 +15109,25 @@ void ImGui::DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) ctx->DockContext.Requests.push_back(req); } -void ImGui::DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node) +void ImGui::DockContextQueueNotifyRemovedNode(ImGuiContext *ctx, ImGuiDockNode *node) { - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiDockContext *dc = &ctx->DockContext; for (int n = 0; n < dc->Requests.Size; n++) if (dc->Requests[n].DockTargetNode == node) dc->Requests[n].Type = ImGuiDockRequestType_None; } -void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) +void ImGui::DockContextProcessDock(ImGuiContext *ctx, ImGuiDockRequest *req) { IM_ASSERT((req->Type == ImGuiDockRequestType_Dock && req->DockPayload != NULL) || (req->Type == ImGuiDockRequestType_Split && req->DockPayload == NULL)); IM_ASSERT(req->DockTargetWindow != NULL || req->DockTargetNode != NULL); - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; IM_UNUSED(g); - ImGuiWindow* payload_window = req->DockPayload; // Optional - ImGuiWindow* target_window = req->DockTargetWindow; - ImGuiDockNode* node = req->DockTargetNode; + ImGuiWindow *payload_window = req->DockPayload; // Optional + ImGuiWindow *target_window = req->DockTargetWindow; + ImGuiDockNode *node = req->DockTargetNode; if (payload_window) IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextProcessDock node 0x%08X target '%s' dock window '%s', split_dir %d\n", node ? node->ID : 0, target_window ? target_window->Name : "NULL", payload_window->Name, req->DockSplitDir); else @@ -14428,7 +15135,7 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) // Decide which Tab will be selected at the end of the operation ImGuiID next_selected_id = 0; - ImGuiDockNode* payload_node = NULL; + ImGuiDockNode *payload_node = NULL; if (payload_window) { payload_node = payload_window->DockNodeAsHost; @@ -14467,8 +15174,8 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) const ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y; const int split_inheritor_child_idx = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0; // Current contents will be moved to the opposite side const float split_ratio = req->DockSplitRatio; - DockNodeTreeSplit(ctx, node, split_axis, split_inheritor_child_idx, split_ratio, payload_node); // payload_node may be NULL here! - ImGuiDockNode* new_node = node->ChildNodes[split_inheritor_child_idx ^ 1]; + DockNodeTreeSplit(ctx, node, split_axis, split_inheritor_child_idx, split_ratio, payload_node); // payload_node may be NULL here! + ImGuiDockNode *new_node = node->ChildNodes[split_inheritor_child_idx ^ 1]; new_node->HostWindow = node->HostWindow; node = new_node; } @@ -14495,7 +15202,7 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) // In this situation, we move the windows of the target node into the currently visible node of the payload. // This allows us to preserve some of the underlying dock tree settings nicely. IM_ASSERT(payload_node->OnlyNodeWithWindows != NULL); // The docking should have been blocked by DockNodePreviewDockSetup() early on and never submitted. - ImGuiDockNode* visible_node = payload_node->OnlyNodeWithWindows; + ImGuiDockNode *visible_node = payload_node->OnlyNodeWithWindows; if (visible_node->TabBar) IM_ASSERT(visible_node->TabBar->Tabs.Size > 0); DockNodeMoveWindows(node, visible_node); @@ -14506,9 +15213,9 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) { // Central node property needs to be moved to a leaf node, pick the last focused one. // FIXME-DOCK: If we had to transfer other flags here, what would the policy be? - ImGuiDockNode* last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeId); + ImGuiDockNode *last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeId); IM_ASSERT(last_focused_node != NULL); - ImGuiDockNode* last_focused_root_node = DockNodeGetRootNode(last_focused_node); + ImGuiDockNode *last_focused_root_node = DockNodeGetRootNode(last_focused_node); IM_ASSERT(last_focused_root_node == DockNodeGetRootNode(payload_node)); last_focused_node->SetLocalFlags(last_focused_node->LocalFlags | ImGuiDockNodeFlags_CentralNode); node->SetLocalFlags(node->LocalFlags & ~ImGuiDockNodeFlags_CentralNode); @@ -14543,7 +15250,7 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) } // Update selection immediately - if (ImGuiTabBar* tab_bar = node->TabBar) + if (ImGuiTabBar *tab_bar = node->TabBar) tab_bar->NextSelectedTabId = next_selected_id; MarkIniSettingsDirty(); } @@ -14556,24 +15263,24 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) // Solution: // When undocking a window we currently force its maximum size to 90% of the host viewport or monitor. // Reevaluate this when we implement preserving docked/undocked size ("docking_wip/undocked_size" branch). -static ImVec2 FixLargeWindowsWhenUndocking(const ImVec2& size, ImGuiViewport* ref_viewport) +static ImVec2 FixLargeWindowsWhenUndocking(const ImVec2 &size, ImGuiViewport *ref_viewport) { if (ref_viewport == NULL) return size; - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImVec2 max_size = ImFloor(ref_viewport->WorkSize * 0.90f); if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable) { - const ImGuiPlatformMonitor* monitor = ImGui::GetViewportPlatformMonitor(ref_viewport); + const ImGuiPlatformMonitor *monitor = ImGui::GetViewportPlatformMonitor(ref_viewport); max_size = ImFloor(monitor->WorkSize * 0.90f); } return ImMin(size, max_size); } -void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref) +void ImGui::DockContextProcessUndockWindow(ImGuiContext *ctx, ImGuiWindow *window, bool clear_persistent_docking_ref) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextProcessUndockWindow window '%s', clear_persistent_docking_ref = %d\n", window->Name, clear_persistent_docking_ref); if (window->DockNode) DockNodeRemoveWindow(window->DockNode, window, clear_persistent_docking_ref ? 0 : window->DockId); @@ -14587,9 +15294,9 @@ void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* windo MarkIniSettingsDirty(); } -void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) +void ImGui::DockContextProcessUndockNode(ImGuiContext *ctx, ImGuiDockNode *node) { - ImGuiContext& g = *ctx; + ImGuiContext &g = *ctx; IMGUI_DEBUG_LOG_DOCKING("[docking] DockContextProcessUndockNode node %08X\n", node->ID); IM_ASSERT(node->IsLeafNode()); IM_ASSERT(node->Windows.Size >= 1); @@ -14597,7 +15304,7 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) if (node->IsRootNode() || node->IsCentralNode()) { // In the case of a root node or central node, the node will have to stay in place. Create a new node to receive the payload. - ImGuiDockNode* new_node = DockContextAddNode(ctx, 0); + ImGuiDockNode *new_node = DockContextAddNode(ctx, 0); new_node->Pos = node->Pos; new_node->Size = node->Size; new_node->SizeRef = node->SizeRef; @@ -14617,7 +15324,7 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) } for (int n = 0; n < node->Windows.Size; n++) { - ImGuiWindow* window = node->Windows[n]; + ImGuiWindow *window = node->Windows[n]; window->Flags &= ~ImGuiWindowFlags_ChildWindow; if (window->ParentWindow) window->ParentWindow->DC.ChildWindows.find_erase(window); @@ -14630,7 +15337,7 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) } // This is mostly used for automation. -bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload_window, ImGuiDockNode* payload_node, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos) +bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow *target, ImGuiDockNode *target_node, ImGuiWindow *payload_window, ImGuiDockNode *payload_node, ImGuiDir split_dir, bool split_outer, ImVec2 *out_pos) { // In DockNodePreviewDockSetup() for a root central node instead of showing both "inner" and "outer" drop rects // (which would be functionally identical) we only show the outer one. Reflect this here. @@ -14638,9 +15345,9 @@ bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* split_outer = true; ImGuiDockPreviewData split_data; DockNodePreviewDockSetup(target, target_node, payload_window, payload_node, &split_data, false, split_outer); - if (split_data.DropRectsDraw[split_dir+1].IsInverted()) + if (split_data.DropRectsDraw[split_dir + 1].IsInverted()) return false; - *out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter(); + *out_pos = split_data.DropRectsDraw[split_dir + 1].GetCenter(); return true; } @@ -14709,194 +15416,15 @@ ImGuiDockNode::~ImGuiDockNode() ChildNodes[0] = ChildNodes[1] = NULL; } -int ImGui::DockNodeGetTabOrder(ImGuiWindow* window) -{ - ImGuiTabBar* tab_bar = window->DockNode->TabBar; - if (tab_bar == NULL) - return -1; - ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, window->TabId); - return tab ? tab_bar->GetTabOrder(tab) : -1; -} - -static void DockNodeHideWindowDuringHostWindowCreation(ImGuiWindow* window) -{ - window->Hidden = true; - window->HiddenFramesCanSkipItems = window->Active ? 1 : 2; -} - -static void ImGui::DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, bool add_to_tab_bar) -{ - ImGuiContext& g = *GImGui; (void)g; - if (window->DockNode) - { - // Can overwrite an existing window->DockNode (e.g. pointing to a disabled DockSpace node) - IM_ASSERT(window->DockNode->ID != node->ID); - DockNodeRemoveWindow(window->DockNode, window, 0); - } - IM_ASSERT(window->DockNode == NULL || window->DockNodeAsHost == NULL); - IMGUI_DEBUG_LOG_DOCKING("[docking] DockNodeAddWindow node 0x%08X window '%s'\n", node->ID, window->Name); - - // If more than 2 windows appeared on the same frame leading to the creation of a new hosting window, - // we'll hide windows until the host window is ready. Hide the 1st window after its been output (so it is not visible for one frame). - // We will call DockNodeHideWindowDuringHostWindowCreation() on ourselves in Begin() - if (node->HostWindow == NULL && node->Windows.Size == 1 && node->Windows[0]->WasActive == false) - DockNodeHideWindowDuringHostWindowCreation(node->Windows[0]); - - node->Windows.push_back(window); - node->WantHiddenTabBarUpdate = true; - window->DockNode = node; - window->DockId = node->ID; - window->DockIsActive = (node->Windows.Size > 1); - window->DockTabWantClose = false; - - // When reactivating a node with one or two loose window, the window pos/size/viewport are authoritative over the node storage. - // In particular it is important we init the viewport from the first window so we don't create two viewports and drop one. - if (node->HostWindow == NULL && node->IsFloatingNode()) - { - if (node->AuthorityForPos == ImGuiDataAuthority_Auto) - node->AuthorityForPos = ImGuiDataAuthority_Window; - if (node->AuthorityForSize == ImGuiDataAuthority_Auto) - node->AuthorityForSize = ImGuiDataAuthority_Window; - if (node->AuthorityForViewport == ImGuiDataAuthority_Auto) - node->AuthorityForViewport = ImGuiDataAuthority_Window; - } - - // Add to tab bar if requested - if (add_to_tab_bar) - { - if (node->TabBar == NULL) - { - DockNodeAddTabBar(node); - node->TabBar->SelectedTabId = node->TabBar->NextSelectedTabId = node->SelectedTabId; - - // Add existing windows - for (int n = 0; n < node->Windows.Size - 1; n++) - TabBarAddTab(node->TabBar, ImGuiTabItemFlags_None, node->Windows[n]); - } - TabBarAddTab(node->TabBar, ImGuiTabItemFlags_Unsorted, window); - } - - DockNodeUpdateVisibleFlag(node); - - // Update this without waiting for the next time we Begin() in the window, so our host window will have the proper title bar color on its first frame. - if (node->HostWindow) - UpdateWindowParentAndRootLinks(window, window->Flags | ImGuiWindowFlags_ChildWindow, node->HostWindow); -} - -static void ImGui::DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id) +if (!move_tab_bar && src_node->TabBar) { - ImGuiContext& g = *GImGui; - IM_ASSERT(window->DockNode == node); - //IM_ASSERT(window->RootWindowDockTree == node->HostWindow); - //IM_ASSERT(window->LastFrameActive < g.FrameCount); // We may call this from Begin() - IM_ASSERT(save_dock_id == 0 || save_dock_id == node->ID); - IMGUI_DEBUG_LOG_DOCKING("[docking] DockNodeRemoveWindow node 0x%08X window '%s'\n", node->ID, window->Name); - - window->DockNode = NULL; - window->DockIsActive = window->DockTabWantClose = false; - window->DockId = save_dock_id; - window->Flags &= ~ImGuiWindowFlags_ChildWindow; - if (window->ParentWindow) - window->ParentWindow->DC.ChildWindows.find_erase(window); - UpdateWindowParentAndRootLinks(window, window->Flags, NULL); // Update immediately - - // Remove window - bool erased = false; - for (int n = 0; n < node->Windows.Size; n++) - if (node->Windows[n] == window) - { - node->Windows.erase(node->Windows.Data + n); - erased = true; - break; - } - if (!erased) - IM_ASSERT(erased); - if (node->VisibleWindow == window) - node->VisibleWindow = NULL; - - // Remove tab and possibly tab bar - node->WantHiddenTabBarUpdate = true; - if (node->TabBar) - { - TabBarRemoveTab(node->TabBar, window->TabId); - const int tab_count_threshold_for_tab_bar = node->IsCentralNode() ? 1 : 2; - if (node->Windows.Size < tab_count_threshold_for_tab_bar) - DockNodeRemoveTabBar(node); - } - - if (node->Windows.Size == 0 && !node->IsCentralNode() && !node->IsDockSpace() && window->DockId != node->ID) - { - // Automatic dock node delete themselves if they are not holding at least one tab - DockContextRemoveNode(&g, node, true); - return; - } - - if (node->Windows.Size == 1 && !node->IsCentralNode() && node->HostWindow) - { - ImGuiWindow* remaining_window = node->Windows[0]; - if (node->HostWindow->ViewportOwned && node->IsRootNode()) - { - // Transfer viewport back to the remaining loose window - IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Node %08X transfer Viewport %08X=>%08X for Window '%s'\n", node->ID, node->HostWindow->Viewport->ID, remaining_window->ID, remaining_window->Name); - IM_ASSERT(node->HostWindow->Viewport->Window == node->HostWindow); - node->HostWindow->Viewport->Window = remaining_window; - node->HostWindow->Viewport->ID = remaining_window->ID; - } - remaining_window->Collapsed = node->HostWindow->Collapsed; - } - - // Update visibility immediately is required so the DockNodeUpdateRemoveInactiveChilds() processing can reflect changes up the tree - DockNodeUpdateVisibleFlag(node); + if (dst_node->TabBar) + dst_node->TabBar->SelectedTabId = src_node->TabBar->SelectedTabId; + DockNodeRemoveTabBar(src_node); } - -static void ImGui::DockNodeMoveChildNodes(ImGuiDockNode* dst_node, ImGuiDockNode* src_node) -{ - IM_ASSERT(dst_node->Windows.Size == 0); - dst_node->ChildNodes[0] = src_node->ChildNodes[0]; - dst_node->ChildNodes[1] = src_node->ChildNodes[1]; - if (dst_node->ChildNodes[0]) - dst_node->ChildNodes[0]->ParentNode = dst_node; - if (dst_node->ChildNodes[1]) - dst_node->ChildNodes[1]->ParentNode = dst_node; - dst_node->SplitAxis = src_node->SplitAxis; - dst_node->SizeRef = src_node->SizeRef; - src_node->ChildNodes[0] = src_node->ChildNodes[1] = NULL; } -static void ImGui::DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* src_node) -{ - // Insert tabs in the same orders as currently ordered (node->Windows isn't ordered) - IM_ASSERT(src_node && dst_node && dst_node != src_node); - ImGuiTabBar* src_tab_bar = src_node->TabBar; - if (src_tab_bar != NULL) - IM_ASSERT(src_node->Windows.Size <= src_node->TabBar->Tabs.Size); - - // If the dst_node is empty we can just move the entire tab bar (to preserve selection, scrolling, etc.) - bool move_tab_bar = (src_tab_bar != NULL) && (dst_node->TabBar == NULL); - if (move_tab_bar) - { - dst_node->TabBar = src_node->TabBar; - src_node->TabBar = NULL; - } - - // Tab order is not important here, it is preserved by sorting in DockNodeUpdateTabBar(). - for (ImGuiWindow* window : src_node->Windows) - { - window->DockNode = NULL; - window->DockIsActive = false; - DockNodeAddWindow(dst_node, window, !move_tab_bar); - } - src_node->Windows.clear(); - - if (!move_tab_bar && src_node->TabBar) - { - if (dst_node->TabBar) - dst_node->TabBar->SelectedTabId = src_node->TabBar->SelectedTabId; - DockNodeRemoveTabBar(src_node); - } -} - -static void ImGui::DockNodeApplyPosSizeToWindows(ImGuiDockNode* node) +static void ImGui::DockNodeApplyPosSizeToWindows(ImGuiDockNode *node) { for (int n = 0; n < node->Windows.Size; n++) { @@ -14905,7 +15433,7 @@ static void ImGui::DockNodeApplyPosSizeToWindows(ImGuiDockNode* node) } } -static void ImGui::DockNodeHideHostWindow(ImGuiDockNode* node) +static void ImGui::DockNodeHideHostWindow(ImGuiDockNode *node) { if (node->HostWindow) { @@ -14927,15 +15455,15 @@ static void ImGui::DockNodeHideHostWindow(ImGuiDockNode* node) // Search function called once by root node in DockNodeUpdate() struct ImGuiDockNodeTreeInfo { - ImGuiDockNode* CentralNode; - ImGuiDockNode* FirstNodeWithWindows; - int CountNodesWithWindows; - //ImGuiWindowClass WindowClassForMerges; + ImGuiDockNode *CentralNode; + ImGuiDockNode *FirstNodeWithWindows; + int CountNodesWithWindows; + // ImGuiWindowClass WindowClassForMerges; ImGuiDockNodeTreeInfo() { memset(this, 0, sizeof(*this)); } }; -static void DockNodeFindInfo(ImGuiDockNode* node, ImGuiDockNodeTreeInfo* info) +static void DockNodeFindInfo(ImGuiDockNode *node, ImGuiDockNodeTreeInfo *info) { if (node->Windows.Size > 0) { @@ -14957,7 +15485,7 @@ static void DockNodeFindInfo(ImGuiDockNode* node, ImGuiDockNodeTreeInfo* info) DockNodeFindInfo(node->ChildNodes[1], info); } -static ImGuiWindow* ImGui::DockNodeFindWindowByID(ImGuiDockNode* node, ImGuiID id) +static ImGuiWindow *ImGui::DockNodeFindWindowByID(ImGuiDockNode *node, ImGuiID id) { IM_ASSERT(id != 0); for (int n = 0; n < node->Windows.Size; n++) @@ -14968,9 +15496,9 @@ static ImGuiWindow* ImGui::DockNodeFindWindowByID(ImGuiDockNode* node, ImGuiID i // - Remove inactive windows/nodes. // - Update visibility flag. -static void ImGui::DockNodeUpdateFlagsAndCollapse(ImGuiDockNode* node) +static void ImGui::DockNodeUpdateFlagsAndCollapse(ImGuiDockNode *node) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(node->ParentNode == NULL || node->ParentNode->ChildNodes[0] == node || node->ParentNode->ChildNodes[1] == node); // Inherit most flags @@ -14992,13 +15520,13 @@ static void ImGui::DockNodeUpdateFlagsAndCollapse(ImGuiDockNode* node) node->LocalFlagsInWindows = ImGuiDockNodeFlags_None; for (int window_n = 0; window_n < node->Windows.Size; window_n++) { - ImGuiWindow* window = node->Windows[window_n]; + ImGuiWindow *window = node->Windows[window_n]; IM_ASSERT(window->DockNode == node); bool node_was_active = (node->LastFrameActive + 1 == g.FrameCount); bool remove = false; remove |= node_was_active && (window->LastFrameActive + 1 < g.FrameCount); - remove |= node_was_active && (node->WantCloseAll || node->WantCloseTabId == window->TabId) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument); // Submit all _expected_ closure from last frame + remove |= node_was_active && (node->WantCloseAll || node->WantCloseTabId == window->TabId) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument); // Submit all _expected_ closure from last frame remove |= (window->DockTabWantClose); if (remove) { @@ -15016,7 +15544,7 @@ static void ImGui::DockNodeUpdateFlagsAndCollapse(ImGuiDockNode* node) } // FIXME-DOCKING: Missing policies for conflict resolution, hence the "Experimental" tag on this. - //node->LocalFlagsInWindow &= ~window->WindowClass.DockNodeFlagsOverrideClear; + // node->LocalFlagsInWindow &= ~window->WindowClass.DockNodeFlagsOverrideClear; node->LocalFlagsInWindows |= window->WindowClass.DockNodeFlagsOverrideSet; } node->UpdateMergedFlags(); @@ -15042,7 +15570,7 @@ static void ImGui::DockNodeUpdateFlagsAndCollapse(ImGuiDockNode* node) } // This is rarely called as DockNodeUpdateForRootNode() generally does it most frames. -static void ImGui::DockNodeUpdateHasCentralNodeChild(ImGuiDockNode* node) +static void ImGui::DockNodeUpdateHasCentralNodeChild(ImGuiDockNode *node) { node->HasCentralNodeChild = false; if (node->ChildNodes[0]) @@ -15051,7 +15579,7 @@ static void ImGui::DockNodeUpdateHasCentralNodeChild(ImGuiDockNode* node) DockNodeUpdateHasCentralNodeChild(node->ChildNodes[1]); if (node->IsRootNode()) { - ImGuiDockNode* mark_node = node->CentralNode; + ImGuiDockNode *mark_node = node->CentralNode; while (mark_node) { mark_node->HasCentralNodeChild = true; @@ -15060,7 +15588,7 @@ static void ImGui::DockNodeUpdateHasCentralNodeChild(ImGuiDockNode* node) } } -static void ImGui::DockNodeUpdateVisibleFlag(ImGuiDockNode* node) +static void ImGui::DockNodeUpdateVisibleFlag(ImGuiDockNode *node) { // Update visibility flag bool is_visible = (node->ParentNode == NULL) ? node->IsDockSpace() : node->IsCentralNode(); @@ -15070,9 +15598,9 @@ static void ImGui::DockNodeUpdateVisibleFlag(ImGuiDockNode* node) node->IsVisible = is_visible; } -static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window) +static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode *node, ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(node->WantMouseMove == true); StartMouseMovingWindow(window); g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - node->Pos; @@ -15081,7 +15609,7 @@ static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWind } // Update CentralNode, OnlyNodeWithWindows, LastFocusedNodeID. Copy window class. -static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode* node) +static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode *node) { DockNodeUpdateFlagsAndCollapse(node); @@ -15099,7 +15627,7 @@ static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode* node) // Copy the window class from of our first window so it can be used for proper dock filtering. // When node has mixed windows, prioritize the class with the most constraint (DockingAllowUnclassed = false) as the reference to copy. // FIXME-DOCK: We don't recurse properly, this code could be reworked to work from DockNodeUpdateScanRec. - if (ImGuiDockNode* first_node_with_windows = info.FirstNodeWithWindows) + if (ImGuiDockNode *first_node_with_windows = info.FirstNodeWithWindows) { node->WindowClass = first_node_with_windows->Windows[0]->WindowClass; for (int n = 1; n < first_node_with_windows->Windows.Size; n++) @@ -15110,7 +15638,7 @@ static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode* node) } } - ImGuiDockNode* mark_node = node->CentralNode; + ImGuiDockNode *mark_node = node->CentralNode; while (mark_node) { mark_node->HasCentralNodeChild = true; @@ -15118,7 +15646,7 @@ static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode* node) } } -static void DockNodeSetupHostWindow(ImGuiDockNode* node, ImGuiWindow* host_window) +static void DockNodeSetupHostWindow(ImGuiDockNode *node, ImGuiWindow *host_window) { // Remove ourselves from any previous different host window // This can happen if a user mistakenly does (see #4295 for details): @@ -15132,9 +15660,9 @@ static void DockNodeSetupHostWindow(ImGuiDockNode* node, ImGuiWindow* host_windo node->HostWindow = host_window; } -static void ImGui::DockNodeUpdate(ImGuiDockNode* node) +static void ImGui::DockNodeUpdate(ImGuiDockNode *node) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(node->LastFrameActive != g.FrameCount); node->LastFrameAlive = g.FrameCount; node->IsBgDrawnThisFrame = false; @@ -15162,7 +15690,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) if (node->Windows.Size == 1) { // Floating window pos/size is authoritative - ImGuiWindow* single_window = node->Windows[0]; + ImGuiWindow *single_window = node->Windows[0]; node->Pos = single_window->Pos; node->Size = single_window->SizeFull; node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Window; @@ -15207,7 +15735,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) if (node->IsVisible && node->HostWindow == NULL && node->IsFloatingNode() && node->IsLeafNode()) { IM_ASSERT(node->Windows.Size > 0); - ImGuiWindow* ref_window = NULL; + ImGuiWindow *ref_window = NULL; if (node->SelectedTabId != 0) // Note that we prune single-window-node settings on .ini loading, so this is generally 0 for them! ref_window = DockNodeFindWindowByID(node, node->SelectedTabId); if (ref_window == NULL) @@ -15227,7 +15755,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) for (int window_n = 0; window_n < node->Windows.Size; window_n++) { // FIXME-DOCK: Setting DockIsActive here means that for single active window in a leaf node, DockIsActive will be cleared until the next Begin() call. - ImGuiWindow* window = node->Windows[window_n]; + ImGuiWindow *window = node->Windows[window_n]; node->HasCloseButton |= window->HasCloseButton; window->DockIsActive = (node->Windows.Size > 1); } @@ -15235,7 +15763,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) node->HasCloseButton = false; // Bind or create host window - ImGuiWindow* host_window = NULL; + ImGuiWindow *host_window = NULL; bool beginned_into_host_window = false; if (node->IsDockSpace()) { @@ -15248,7 +15776,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) // [Automatic root or child nodes] if (node->IsRootNode() && node->IsVisible) { - ImGuiWindow* ref_window = (node->Windows.Size > 0) ? node->Windows[0] : NULL; + ImGuiWindow *ref_window = (node->Windows.Size > 0) ? node->Windows[0] : NULL; // Sync Pos if (node->AuthorityForPos == ImGuiDataAuthority_Window && ref_window) @@ -15320,12 +15848,12 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) node->LastFocusedNodeId = g.NavWindow->RootWindow->DockNode->ID; // Register a hit-test hole in the window unless we are currently dragging a window that is compatible with our dockspace - ImGuiDockNode* central_node = node->CentralNode; + ImGuiDockNode *central_node = node->CentralNode; const bool central_node_hole = node->IsRootNode() && host_window && (node_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0 && central_node != NULL && central_node->IsEmpty(); bool central_node_hole_register_hit_test_hole = central_node_hole; if (central_node_hole) - if (const ImGuiPayload* payload = ImGui::GetDragDropPayload()) - if (payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && DockNodeIsDropAllowed(host_window, *(ImGuiWindow**)payload->Data)) + if (const ImGuiPayload *payload = ImGui::GetDragDropPayload()) + if (payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && DockNodeIsDropAllowed(host_window, *(ImGuiWindow **)payload->Data)) central_node_hole_register_hit_test_hole = false; if (central_node_hole_register_hit_test_hole) { @@ -15333,14 +15861,26 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) // (But we only add it if there's something else on the other side of the hole, otherwise for e.g. fullscreen // covering passthru node we'd have a gap on the edge not covered by the hole) IM_ASSERT(node->IsDockSpace()); // We cannot pass this flag without the DockSpace() api. Testing this because we also setup the hole in host_window->ParentNode - ImGuiDockNode* root_node = DockNodeGetRootNode(central_node); + ImGuiDockNode *root_node = DockNodeGetRootNode(central_node); ImRect root_rect(root_node->Pos, root_node->Pos + root_node->Size); ImRect hole_rect(central_node->Pos, central_node->Pos + central_node->Size); - if (hole_rect.Min.x > root_rect.Min.x) { hole_rect.Min.x += WINDOWS_HOVER_PADDING; } - if (hole_rect.Max.x < root_rect.Max.x) { hole_rect.Max.x -= WINDOWS_HOVER_PADDING; } - if (hole_rect.Min.y > root_rect.Min.y) { hole_rect.Min.y += WINDOWS_HOVER_PADDING; } - if (hole_rect.Max.y < root_rect.Max.y) { hole_rect.Max.y -= WINDOWS_HOVER_PADDING; } - //GetForegroundDrawList()->AddRect(hole_rect.Min, hole_rect.Max, IM_COL32(255, 0, 0, 255)); + if (hole_rect.Min.x > root_rect.Min.x) + { + hole_rect.Min.x += WINDOWS_HOVER_PADDING; + } + if (hole_rect.Max.x < root_rect.Max.x) + { + hole_rect.Max.x -= WINDOWS_HOVER_PADDING; + } + if (hole_rect.Min.y > root_rect.Min.y) + { + hole_rect.Min.y += WINDOWS_HOVER_PADDING; + } + if (hole_rect.Max.y < root_rect.Max.y) + { + hole_rect.Max.y -= WINDOWS_HOVER_PADDING; + } + // GetForegroundDrawList()->AddRect(hole_rect.Min, hole_rect.Max, IM_COL32(255, 0, 0, 255)); if (central_node_hole && !hole_rect.IsInverted()) { SetWindowHitTestHole(host_window, hole_rect.Min, hole_rect.Max - hole_rect.Min); @@ -15425,19 +15965,19 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) } // Compare TabItem nodes given the last known DockOrder (will persist in .ini file as hint), used to sort tabs when multiple tabs are added on the same frame. -static int IMGUI_CDECL TabItemComparerByDockOrder(const void* lhs, const void* rhs) +static int IMGUI_CDECL TabItemComparerByDockOrder(const void *lhs, const void *rhs) { - ImGuiWindow* a = ((const ImGuiTabItem*)lhs)->Window; - ImGuiWindow* b = ((const ImGuiTabItem*)rhs)->Window; + ImGuiWindow *a = ((const ImGuiTabItem *)lhs)->Window; + ImGuiWindow *b = ((const ImGuiTabItem *)rhs)->Window; if (int d = ((a->DockOrder == -1) ? INT_MAX : a->DockOrder) - ((b->DockOrder == -1) ? INT_MAX : b->DockOrder)) return d; return (a->BeginOrderWithinContext - b->BeginOrderWithinContext); } -static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar) +static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode *node, ImGuiTabBar *tab_bar) { // Try to position the menu so it is more likely to stays within the same viewport - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; ImGuiID ret_tab_id = 0; if (g.Style.WindowMenuButtonPosition == ImGuiDir_Left) SetNextWindowPos(ImVec2(node->Pos.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(0.0f, 0.0f)); @@ -15455,7 +15995,7 @@ static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* { for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + ImGuiTabItem *tab = &tab_bar->Tabs[tab_n]; if (tab->Flags & ImGuiTabItemFlags_Button) continue; if (Selectable(tab_bar->GetTabName(tab), tab->ID == tab_bar->SelectedTabId)) @@ -15470,7 +16010,7 @@ static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* } // User helper to append/amend into a dock node tab bar. Most commonly used to add e.g. a "+" button. -bool ImGui::DockNodeBeginAmendTabBar(ImGuiDockNode* node) +bool ImGui::DockNodeBeginAmendTabBar(ImGuiDockNode *node) { if (node->TabBar == NULL || node->HostWindow == NULL) return false; @@ -15491,26 +16031,26 @@ void ImGui::DockNodeEndAmendTabBar() End(); } -static bool IsDockNodeTitleBarHighlighted(ImGuiDockNode* node, ImGuiDockNode* root_node, ImGuiWindow* host_window) +static bool IsDockNodeTitleBarHighlighted(ImGuiDockNode *node, ImGuiDockNode *root_node, ImGuiWindow *host_window) { // CTRL+Tab highlight (only highlighting leaf node, not whole hierarchy) - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.NavWindowingTarget) return (g.NavWindowingTarget->DockNode == node); // FIXME-DOCKING: May want alternative to treat central node void differently? e.g. if (g.NavWindow == host_window) if (g.NavWindow && g.NavWindow->RootWindowForTitleBarHighlight == host_window->RootWindowDockTree && root_node->LastFocusedNodeId == node->ID) - for (ImGuiDockNode* parent_node = g.NavWindow->RootWindow->DockNode; parent_node != NULL; parent_node = parent_node->HostWindow ? parent_node->HostWindow->RootWindow->DockNode : NULL) + for (ImGuiDockNode *parent_node = g.NavWindow->RootWindow->DockNode; parent_node != NULL; parent_node = parent_node->HostWindow ? parent_node->HostWindow->RootWindow->DockNode : NULL) if ((parent_node = ImGui::DockNodeGetRootNode(parent_node)) == root_node) return true; return false; } // Submit the tab bar corresponding to a dock node and various housekeeping details. -static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window) +static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode *node, ImGuiWindow *host_window) { - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; + ImGuiContext &g = *GImGui; + ImGuiStyle &style = g.Style; const bool node_was_active = (node->LastFrameActive + 1 == g.FrameCount); const bool closed_all = node->WantCloseAll && node_was_active; @@ -15520,7 +16060,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w // Decide if we should use a focused title bar color bool is_focused = false; - ImGuiDockNode* root_node = DockNodeGetRootNode(node); + ImGuiDockNode *root_node = DockNodeGetRootNode(node); if (IsDockNodeTitleBarHighlighted(node, root_node, host_window)) is_focused = true; @@ -15554,7 +16094,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w // This is to facilitate computing those ID from the outside, and will affect more or less only the ID of the collapse button, popup and tabs, // as docked windows themselves will override the stack with their own root ID. PushOverrideID(node->ID); - ImGuiTabBar* tab_bar = node->TabBar; + ImGuiTabBar *tab_bar = node->TabBar; bool tab_bar_is_recreated = (tab_bar == NULL); // Tab bar are automatically destroyed when a node gets hidden if (tab_bar == NULL) { @@ -15587,7 +16127,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w const int tabs_count_old = tab_bar->Tabs.Size; for (int window_n = 0; window_n < node->Windows.Size; window_n++) { - ImGuiWindow* window = node->Windows[window_n]; + ImGuiWindow *window = node->Windows[window_n]; if (TabBarFindTabByID(tab_bar, window->TabId) == NULL) TabBarAddTab(tab_bar, ImGuiTabItemFlags_Unsorted, window); } @@ -15595,7 +16135,8 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w // Title bar if (is_focused) node->LastFrameFocused = g.FrameCount; - ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg); + ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive + : ImGuiCol_TitleBg); ImDrawFlags rounding_flags = CalcRoundingFlagsForRectInRect(title_bar_rect, host_window->Rect(), DOCKING_SPLITTER_SIZE); host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, rounding_flags); @@ -15641,7 +16182,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w if (!host_window->Collapsed && is_focused) tab_bar_flags |= ImGuiTabBarFlags_IsFocused; BeginTabBarEx(tab_bar, tab_bar_rect, tab_bar_flags, node); - //host_window->DrawList->AddRect(tab_bar_rect.Min, tab_bar_rect.Max, IM_COL32(255,0,255,255)); + // host_window->DrawList->AddRect(tab_bar_rect.Min, tab_bar_rect.Max, IM_COL32(255,0,255,255)); // Backup style colors ImVec4 backup_style_cols[ImGuiWindowDockStyleCol_COUNT]; @@ -15652,7 +16193,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w node->VisibleWindow = NULL; for (int window_n = 0; window_n < node->Windows.Size; window_n++) { - ImGuiWindow* window = node->Windows[window_n]; + ImGuiWindow *window = node->Windows[window_n]; if ((closed_all || closed_one == window->TabId) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument)) continue; if (window->LastFrameActive + 1 >= g.FrameCount || !node_was_active) @@ -15699,13 +16240,13 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w // Note that VisibleWindow may have been overrided by CTRL+Tabbing, so VisibleWindow->TabId may be != from tab_bar->SelectedTabId const bool close_button_is_enabled = node->HasCloseButton && node->VisibleWindow && node->VisibleWindow->HasCloseButton; const bool close_button_is_visible = node->HasCloseButton; - //const bool close_button_is_visible = close_button_is_enabled; // Most people would expect this behavior of not even showing the button (leaving a hole since we can't claim that space as other windows in the tba bar have one) + // const bool close_button_is_visible = close_button_is_enabled; // Most people would expect this behavior of not even showing the button (leaving a hole since we can't claim that space as other windows in the tba bar have one) if (close_button_is_visible) { if (!close_button_is_enabled) { PushItemFlag(ImGuiItemFlags_Disabled, true); - PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_Text] * ImVec4(1.0f,1.0f,1.0f,0.4f)); + PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_Text] * ImVec4(1.0f, 1.0f, 1.0f, 0.4f)); } if (CloseButton(host_window->GetID("#CLOSE"), close_button_pos)) { @@ -15713,8 +16254,8 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w for (int n = 0; n < tab_bar->Tabs.Size; n++) TabBarCloseTab(tab_bar, &tab_bar->Tabs[n]); } - //if (IsItemActive()) - // focus_tab_id = tab_bar->SelectedTabId; + // if (IsItemActive()) + // focus_tab_id = tab_bar->SelectedTabId; if (!close_button_is_enabled) { PopStyleColor(); @@ -15742,13 +16283,13 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w focus_tab_id = tab_bar->SelectedTabId; // Forward moving request to selected window - if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId)) + if (ImGuiTabItem *tab = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId)) StartMouseMovingWindowOrNode(tab->Window ? tab->Window : node->HostWindow, node, false); } } // Forward focus from host node to selected window - //if (is_focused && g.NavWindow == host_window && !g.NavWindowingTarget) + // if (is_focused && g.NavWindow == host_window && !g.NavWindowingTarget) // focus_tab_id = tab_bar->SelectedTabId; // When clicked on a tab we requested focus to the docked child @@ -15758,7 +16299,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w // Apply navigation focus if (focus_tab_id != 0) - if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, focus_tab_id)) + if (ImGuiTabItem *tab = TabBarFindTabByID(tab_bar, focus_tab_id)) if (tab->Window) { FocusWindow(tab->Window); @@ -15776,13 +16317,13 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w } } -static void ImGui::DockNodeAddTabBar(ImGuiDockNode* node) +static void ImGui::DockNodeAddTabBar(ImGuiDockNode *node) { IM_ASSERT(node->TabBar == NULL); node->TabBar = IM_NEW(ImGuiTabBar); } -static void ImGui::DockNodeRemoveTabBar(ImGuiDockNode* node) +static void ImGui::DockNodeRemoveTabBar(ImGuiDockNode *node) { if (node->TabBar == NULL) return; @@ -15790,13 +16331,13 @@ static void ImGui::DockNodeRemoveTabBar(ImGuiDockNode* node) node->TabBar = NULL; } -static bool DockNodeIsDropAllowedOne(ImGuiWindow* payload, ImGuiWindow* host_window) +static bool DockNodeIsDropAllowedOne(ImGuiWindow *payload, ImGuiWindow *host_window) { if (host_window->DockNodeAsHost && host_window->DockNodeAsHost->IsDockSpace() && payload->BeginOrderWithinContext < host_window->BeginOrderWithinContext) return false; - ImGuiWindowClass* host_class = host_window->DockNodeAsHost ? &host_window->DockNodeAsHost->WindowClass : &host_window->WindowClass; - ImGuiWindowClass* payload_class = &payload->WindowClass; + ImGuiWindowClass *host_class = host_window->DockNodeAsHost ? &host_window->DockNodeAsHost->WindowClass : &host_window->WindowClass; + ImGuiWindowClass *payload_class = &payload->WindowClass; if (host_class->ClassId != payload_class->ClassId) { if (host_class->ClassId != 0 && host_class->DockingAllowUnclassed && payload_class->ClassId == 0) @@ -15811,16 +16352,16 @@ static bool DockNodeIsDropAllowedOne(ImGuiWindow* payload, ImGuiWindow* host_win // by e.g. adding a 'if (!ImGui::IsWindowWithinBeginStackOf(host_window, popup_window))' test. // But it would requires more work on our end because the dock host windows is technically created in NewFrame() // and our ->ParentXXX and ->RootXXX pointers inside windows are currently mislading or lacking. - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; for (int i = g.OpenPopupStack.Size - 1; i >= 0; i--) - if (ImGuiWindow* popup_window = g.OpenPopupStack[i].Window) - if (ImGui::IsWindowWithinBeginStackOf(payload, popup_window)) // Payload is created from within a popup begin stack. + if (ImGuiWindow *popup_window = g.OpenPopupStack[i].Window) + if (ImGui::IsWindowWithinBeginStackOf(payload, popup_window)) // Payload is created from within a popup begin stack. return false; return true; } -static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* root_payload) +static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow *host_window, ImGuiWindow *root_payload) { if (root_payload->DockNodeAsHost && root_payload->DockNodeAsHost->IsSplitNode()) // FIXME-DOCK: Missing filtering return true; @@ -15828,7 +16369,7 @@ static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* const int payload_count = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows.Size : 1; for (int payload_n = 0; payload_n < payload_count; payload_n++) { - ImGuiWindow* payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows[payload_n] : root_payload; + ImGuiWindow *payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows[payload_n] : root_payload; if (DockNodeIsDropAllowedOne(payload, host_window)) return true; } @@ -15837,13 +16378,16 @@ static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* // window menu button == collapse button when not in a dock node. // FIXME: This is similar to RenderWindowTitleBarContents(), may want to share code. -static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos, ImVec2* out_close_button_pos) +static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode *node, ImRect *out_title_rect, ImRect *out_tab_bar_rect, ImVec2 *out_window_menu_button_pos, ImVec2 *out_close_button_pos) { - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; + ImGuiContext &g = *GImGui; + ImGuiStyle &style = g.Style; ImRect r = ImRect(node->Pos.x, node->Pos.y, node->Pos.x + node->Size.x, node->Pos.y + g.FontSize + g.Style.FramePadding.y * 2.0f); - if (out_title_rect) { *out_title_rect = r; } + if (out_title_rect) + { + *out_title_rect = r; + } r.Min.x += style.WindowBorderSize; r.Max.x -= style.WindowBorderSize; @@ -15856,7 +16400,8 @@ static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* o if (node->HasCloseButton) { r.Max.x -= button_sz; - if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - style.FramePadding.x, r.Min.y); + if (out_close_button_pos) + *out_close_button_pos = ImVec2(r.Max.x - style.FramePadding.x, r.Min.y); } if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Left) { @@ -15867,13 +16412,19 @@ static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* o r.Max.x -= button_sz + style.FramePadding.x; window_menu_button_pos = ImVec2(r.Max.x, r.Min.y); } - if (out_tab_bar_rect) { *out_tab_bar_rect = r; } - if (out_window_menu_button_pos) { *out_window_menu_button_pos = window_menu_button_pos; } + if (out_tab_bar_rect) + { + *out_tab_bar_rect = r; + } + if (out_window_menu_button_pos) + { + *out_window_menu_button_pos = window_menu_button_pos; + } } -void ImGui::DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired) +void ImGui::DockNodeCalcSplitRects(ImVec2 &pos_old, ImVec2 &size_old, ImVec2 &pos_new, ImVec2 &size_new, ImGuiDir dir, ImVec2 size_new_desired) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const float dock_spacing = g.Style.ItemInnerSpacing.x; const ImGuiAxis axis = (dir == ImGuiDir_Left || dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y; pos_new[axis ^ 1] = pos_old[axis ^ 1]; @@ -15905,9 +16456,9 @@ void ImGui::DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& po } // Retrieve the drop rectangles for a given direction or for the center + perform hit testing. -bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_r, bool outer_docking, ImVec2* test_mouse_pos) +bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect &parent, ImGuiDir dir, ImRect &out_r, bool outer_docking, ImVec2 *test_mouse_pos) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const float parent_smaller_axis = ImMin(parent.GetWidth(), parent.GetHeight()); const float hs_for_central_nodes = ImMin(g.FontSize * 1.5f, ImMax(g.FontSize * 0.5f, parent_smaller_axis / 8.0f)); @@ -15916,9 +16467,9 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir ImVec2 off; // Distance from edge or center if (outer_docking) { - //hs_w = ImFloor(ImClamp(parent_smaller_axis - hs_for_central_nodes * 4.0f, g.FontSize * 0.5f, g.FontSize * 8.0f)); - //hs_h = ImFloor(hs_w * 0.15f); - //off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h)); + // hs_w = ImFloor(ImClamp(parent_smaller_axis - hs_for_central_nodes * 4.0f, g.FontSize * 0.5f, g.FontSize * 8.0f)); + // hs_h = ImFloor(hs_w * 0.15f); + // off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h)); hs_w = ImFloor(hs_for_central_nodes * 1.50f); hs_h = ImFloor(hs_for_central_nodes * 0.80f); off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - hs_h), ImFloor(parent.GetHeight() * 0.5f - hs_h)); @@ -15931,11 +16482,26 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir } ImVec2 c = ImFloor(parent.GetCenter()); - if (dir == ImGuiDir_None) { out_r = ImRect(c.x - hs_w, c.y - hs_w, c.x + hs_w, c.y + hs_w); } - else if (dir == ImGuiDir_Up) { out_r = ImRect(c.x - hs_w, c.y - off.y - hs_h, c.x + hs_w, c.y - off.y + hs_h); } - else if (dir == ImGuiDir_Down) { out_r = ImRect(c.x - hs_w, c.y + off.y - hs_h, c.x + hs_w, c.y + off.y + hs_h); } - else if (dir == ImGuiDir_Left) { out_r = ImRect(c.x - off.x - hs_h, c.y - hs_w, c.x - off.x + hs_h, c.y + hs_w); } - else if (dir == ImGuiDir_Right) { out_r = ImRect(c.x + off.x - hs_h, c.y - hs_w, c.x + off.x + hs_h, c.y + hs_w); } + if (dir == ImGuiDir_None) + { + out_r = ImRect(c.x - hs_w, c.y - hs_w, c.x + hs_w, c.y + hs_w); + } + else if (dir == ImGuiDir_Up) + { + out_r = ImRect(c.x - hs_w, c.y - off.y - hs_h, c.x + hs_w, c.y - off.y + hs_h); + } + else if (dir == ImGuiDir_Down) + { + out_r = ImRect(c.x - hs_w, c.y + off.y - hs_h, c.x + hs_w, c.y + off.y + hs_h); + } + else if (dir == ImGuiDir_Left) + { + out_r = ImRect(c.x - off.x - hs_h, c.y - hs_w, c.x - off.x + hs_h, c.y + hs_w); + } + else if (dir == ImGuiDir_Right) + { + out_r = ImRect(c.x + off.x - hs_h, c.y - hs_w, c.x + off.x + hs_h, c.y + hs_w); + } if (test_mouse_pos == NULL) return false; @@ -15959,16 +16525,16 @@ bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir // host_node may be NULL if the window doesn't have a DockNode already. // FIXME-DOCK: This is misnamed since it's also doing the filtering. -static void ImGui::DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, ImGuiDockNode* payload_node, ImGuiDockPreviewData* data, bool is_explicit_target, bool is_outer_docking) +static void ImGui::DockNodePreviewDockSetup(ImGuiWindow *host_window, ImGuiDockNode *host_node, ImGuiWindow *payload_window, ImGuiDockNode *payload_node, ImGuiDockPreviewData *data, bool is_explicit_target, bool is_outer_docking) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; // There is an edge case when docking into a dockspace which only has inactive nodes. // In this case DockNodeTreeFindNodeByPos() will have selected a leaf node which is inactive. // Because the inactive leaf node doesn't have proper pos/size yet, we'll use the root node as reference. if (payload_node == NULL) payload_node = payload_window->DockNodeAsHost; - ImGuiDockNode* ref_node_for_rect = (host_node && !host_node->IsVisible) ? DockNodeGetRootNode(host_node) : host_node; + ImGuiDockNode *ref_node_for_rect = (host_node && !host_node->IsVisible) ? DockNodeGetRootNode(host_node) : host_node; if (ref_node_for_rect) IM_ASSERT(ref_node_for_rect->IsVisible == true); @@ -16017,7 +16583,7 @@ static void ImGui::DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockN continue; if (dir != ImGuiDir_None && !data->IsSidesAvailable) continue; - if (DockNodeCalcDropRectsAndTestMousePos(data->FutureNode.Rect(), (ImGuiDir)dir, data->DropRectsDraw[dir+1], is_outer_docking, &g.IO.MousePos)) + if (DockNodeCalcDropRectsAndTestMousePos(data->FutureNode.Rect(), (ImGuiDir)dir, data->DropRectsDraw[dir + 1], is_outer_docking, &g.IO.MousePos)) { data->SplitDir = (ImGuiDir)dir; data->IsSplitDirExplicit = true; @@ -16047,10 +16613,10 @@ static void ImGui::DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockN } } -static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, const ImGuiDockPreviewData* data) +static void ImGui::DockNodePreviewDockRender(ImGuiWindow *host_window, ImGuiDockNode *host_node, ImGuiWindow *root_payload, const ImGuiDockPreviewData *data) { - ImGuiContext& g = *GImGui; - IM_ASSERT(g.CurrentWindow == host_window); // Because we rely on font size to calculate tab sizes + ImGuiContext &g = *GImGui; + IM_ASSERT(g.CurrentWindow == host_window); // Because we rely on font size to calculate tab sizes // With this option, we only display the preview on the target viewport, and the payload viewport is made transparent. // To compensate for the single layer obstructed by the payload, we'll increase the alpha of the preview nodes. @@ -16058,7 +16624,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock // In case the two windows involved are on different viewports, we will draw the overlay on each of them. int overlay_draw_lists_count = 0; - ImDrawList* overlay_draw_lists[2]; + ImDrawList *overlay_draw_lists[2]; overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(host_window->Viewport); if (host_window->Viewport != root_payload->Viewport && !is_transparent_payload) overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(root_payload->Viewport); @@ -16103,12 +16669,12 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock // Draw tab shape/label preview (payload may be a loose window or a host window carrying multiple tabbed windows) if (root_payload->DockNodeAsHost) IM_ASSERT(root_payload->DockNodeAsHost->Windows.Size <= root_payload->DockNodeAsHost->TabBar->Tabs.Size); - ImGuiTabBar* tab_bar_with_payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar : NULL; + ImGuiTabBar *tab_bar_with_payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar : NULL; const int payload_count = tab_bar_with_payload ? tab_bar_with_payload->Tabs.Size : 1; for (int payload_n = 0; payload_n < payload_count; payload_n++) { // DockNode's TabBar may have non-window Tabs manually appended by user - ImGuiWindow* payload_window = tab_bar_with_payload ? tab_bar_with_payload->Tabs[payload_n].Window : root_payload; + ImGuiWindow *payload_window = tab_bar_with_payload ? tab_bar_with_payload->Tabs[payload_n].Window : root_payload; if (tab_bar_with_payload && payload_window == NULL) continue; if (!DockNodeIsDropAllowedOne(payload_window, host_window)) @@ -16175,18 +16741,18 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock // - DockNodeTreeFindNodeByPos() //----------------------------------------------------------------------------- -void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_inheritor_child_idx, float split_ratio, ImGuiDockNode* new_node) +void ImGui::DockNodeTreeSplit(ImGuiContext *ctx, ImGuiDockNode *parent_node, ImGuiAxis split_axis, int split_inheritor_child_idx, float split_ratio, ImGuiDockNode *new_node) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(split_axis != ImGuiAxis_None); - ImGuiDockNode* child_0 = (new_node && split_inheritor_child_idx != 0) ? new_node : DockContextAddNode(ctx, 0); + ImGuiDockNode *child_0 = (new_node && split_inheritor_child_idx != 0) ? new_node : DockContextAddNode(ctx, 0); child_0->ParentNode = parent_node; - ImGuiDockNode* child_1 = (new_node && split_inheritor_child_idx != 1) ? new_node : DockContextAddNode(ctx, 0); + ImGuiDockNode *child_1 = (new_node && split_inheritor_child_idx != 1) ? new_node : DockContextAddNode(ctx, 0); child_1->ParentNode = parent_node; - ImGuiDockNode* child_inheritor = (split_inheritor_child_idx == 0) ? child_0 : child_1; + ImGuiDockNode *child_inheritor = (split_inheritor_child_idx == 0) ? child_0 : child_1; DockNodeMoveChildNodes(child_inheritor, parent_node); parent_node->ChildNodes[0] = child_0; parent_node->ChildNodes[1] = child_1; @@ -16219,12 +16785,12 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG DockNodeGetRootNode(parent_node)->CentralNode = child_inheritor; } -void ImGui::DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child) +void ImGui::DockNodeTreeMerge(ImGuiContext *ctx, ImGuiDockNode *parent_node, ImGuiDockNode *merge_lead_child) { // When called from DockContextProcessUndockNode() it is possible that one of the child is NULL. - ImGuiContext& g = *GImGui; - ImGuiDockNode* child_0 = parent_node->ChildNodes[0]; - ImGuiDockNode* child_1 = parent_node->ChildNodes[1]; + ImGuiContext &g = *GImGui; + ImGuiDockNode *child_0 = parent_node->ChildNodes[0]; + ImGuiDockNode *child_1 = parent_node->ChildNodes[1]; IM_ASSERT(child_0 || child_1); IM_ASSERT(merge_lead_child == child_0 || merge_lead_child == child_1); if ((child_0 && child_0->Windows.Size > 0) || (child_1 && child_1->Windows.Size > 0)) @@ -16272,7 +16838,7 @@ void ImGui::DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG // Update Pos/Size for a node hierarchy (don't affect child Windows yet) // (Depth-first, Pre-Order) -void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, ImGuiDockNode* only_write_to_single_node) +void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode *node, ImVec2 pos, ImVec2 size, ImGuiDockNode *only_write_to_single_node) { // During the regular dock node update we write to all nodes. // 'only_write_to_single_node' is only set when turning a node visible mid-frame and we need its size right-away. @@ -16286,8 +16852,8 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si if (node->IsLeafNode()) return; - ImGuiDockNode* child_0 = node->ChildNodes[0]; - ImGuiDockNode* child_1 = node->ChildNodes[1]; + ImGuiDockNode *child_0 = node->ChildNodes[0]; + ImGuiDockNode *child_1 = node->ChildNodes[1]; ImVec2 child_0_pos = pos, child_1_pos = pos; ImVec2 child_0_size = size, child_1_size = size; @@ -16298,7 +16864,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si if (child_0_is_or_will_be_visible && child_1_is_or_will_be_visible) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const float spacing = DOCKING_SPLITTER_SIZE; const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis; const float size_avail = ImMax(size[axis] - spacing, 0.0f); @@ -16367,7 +16933,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si DockNodeTreeUpdatePosSize(child_1, child_1_pos, child_1_size); } -static void DockNodeTreeUpdateSplitterFindTouchingNode(ImGuiDockNode* node, ImGuiAxis axis, int side, ImVector* touching_nodes) +static void DockNodeTreeUpdateSplitterFindTouchingNode(ImGuiDockNode *node, ImGuiAxis axis, int side, ImVector *touching_nodes) { if (node->IsLeafNode()) { @@ -16383,15 +16949,15 @@ static void DockNodeTreeUpdateSplitterFindTouchingNode(ImGuiDockNode* node, ImGu } // (Depth-First, Pre-Order) -void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node) +void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode *node) { if (node->IsLeafNode()) return; - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; - ImGuiDockNode* child_0 = node->ChildNodes[0]; - ImGuiDockNode* child_1 = node->ChildNodes[1]; + ImGuiDockNode *child_0 = node->ChildNodes[0]; + ImGuiDockNode *child_1 = node->ChildNodes[1]; if (child_0->IsVisible && child_1->IsVisible) { // Bounding box of the splitter cover the space between both nodes (w = Spacing, h = Size[xy^1] for when splitting horizontally) @@ -16402,23 +16968,23 @@ void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node) bb.Max = child_1->Pos; bb.Min[axis] += child_0->Size[axis]; bb.Max[axis ^ 1] += child_1->Size[axis ^ 1]; - //if (g.IO.KeyCtrl) GetForegroundDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255)); + // if (g.IO.KeyCtrl) GetForegroundDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255)); const ImGuiDockNodeFlags merged_flags = child_0->MergedFlags | child_1->MergedFlags; // Merged flags for BOTH childs const ImGuiDockNodeFlags no_resize_axis_flag = (axis == ImGuiAxis_X) ? ImGuiDockNodeFlags_NoResizeX : ImGuiDockNodeFlags_NoResizeY; if ((merged_flags & ImGuiDockNodeFlags_NoResize) || (merged_flags & no_resize_axis_flag)) { - ImGuiWindow* window = g.CurrentWindow; + ImGuiWindow *window = g.CurrentWindow; window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator), g.Style.FrameRounding); } else { - //bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node. - //bb.Max[axis] -= 1; + // bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node. + // bb.Max[axis] -= 1; PushID(node->ID); // Find resizing limits by gathering list of nodes that are touching the splitter line. - ImVector touching_nodes[2]; + ImVector touching_nodes[2]; float min_size = g.Style.WindowMinSize[axis]; float resize_limits[2]; resize_limits[0] = node->ChildNodes[0]->Pos[axis] + min_size; @@ -16468,18 +17034,18 @@ void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node) for (int side_n = 0; side_n < 2; side_n++) for (int touching_node_n = 0; touching_node_n < touching_nodes[side_n].Size; touching_node_n++) { - ImGuiDockNode* touching_node = touching_nodes[side_n][touching_node_n]; - //ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList(GetMainViewport()); - //draw_list->AddRect(touching_node->Pos, touching_node->Pos + touching_node->Size, IM_COL32(255, 128, 0, 255)); + ImGuiDockNode *touching_node = touching_nodes[side_n][touching_node_n]; + // ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList(GetMainViewport()); + // draw_list->AddRect(touching_node->Pos, touching_node->Pos + touching_node->Size, IM_COL32(255, 128, 0, 255)); while (touching_node->ParentNode != node) { if (touching_node->ParentNode->SplitAxis == axis) { // Mark other node so its size will be preserved during the upcoming call to DockNodeTreeUpdatePosSize(). - ImGuiDockNode* node_to_preserve = touching_node->ParentNode->ChildNodes[side_n]; + ImGuiDockNode *node_to_preserve = touching_node->ParentNode->ChildNodes[side_n]; node_to_preserve->WantLockSizeOnce = true; - //draw_list->AddRect(touching_node->Pos, touching_node->Rect().Max, IM_COL32(255, 0, 0, 255)); - //draw_list->AddRectFilled(node_to_preserve->Pos, node_to_preserve->Rect().Max, IM_COL32(0, 255, 0, 100)); + // draw_list->AddRect(touching_node->Pos, touching_node->Rect().Max, IM_COL32(255, 0, 0, 255)); + // draw_list->AddRectFilled(node_to_preserve->Pos, node_to_preserve->Rect().Max, IM_COL32(0, 255, 0, 100)); } touching_node = touching_node->ParentNode; } @@ -16500,23 +17066,23 @@ void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node) DockNodeTreeUpdateSplitter(child_1); } -ImGuiDockNode* ImGui::DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node) +ImGuiDockNode *ImGui::DockNodeTreeFindFallbackLeafNode(ImGuiDockNode *node) { if (node->IsLeafNode()) return node; - if (ImGuiDockNode* leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[0])) + if (ImGuiDockNode *leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[0])) return leaf_node; - if (ImGuiDockNode* leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[1])) + if (ImGuiDockNode *leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[1])) return leaf_node; return NULL; } -ImGuiDockNode* ImGui::DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVec2 pos) +ImGuiDockNode *ImGui::DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode *node, ImVec2 pos) { if (!node->IsVisible) return NULL; - const float dock_spacing = 0.0f;// g.Style.ItemInnerSpacing.x; // FIXME: Relation to DOCKING_SPLITTER_SIZE? + const float dock_spacing = 0.0f; // g.Style.ItemInnerSpacing.x; // FIXME: Relation to DOCKING_SPLITTER_SIZE? ImRect r(node->Pos, node->Pos + node->Size); r.Expand(dock_spacing * 0.5f); bool inside = r.Contains(pos); @@ -16525,9 +17091,9 @@ ImGuiDockNode* ImGui::DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVe if (node->IsLeafNode()) return node; - if (ImGuiDockNode* hovered_node = DockNodeTreeFindVisibleNodeByPos(node->ChildNodes[0], pos)) + if (ImGuiDockNode *hovered_node = DockNodeTreeFindVisibleNodeByPos(node->ChildNodes[0], pos)) return hovered_node; - if (ImGuiDockNode* hovered_node = DockNodeTreeFindVisibleNodeByPos(node->ChildNodes[1], pos)) + if (ImGuiDockNode *hovered_node = DockNodeTreeFindVisibleNodeByPos(node->ChildNodes[1], pos)) return hovered_node; return NULL; @@ -16542,7 +17108,7 @@ ImGuiDockNode* ImGui::DockNodeTreeFindVisibleNodeByPos(ImGuiDockNode* node, ImVe //----------------------------------------------------------------------------- // [Internal] Called via SetNextWindowDockID() -void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond) +void ImGui::SetWindowDock(ImGuiWindow *window, ImGuiID dock_id, ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowDockAllowFlags & cond) == 0) @@ -16553,8 +17119,8 @@ void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond) return; // If the user attempt to set a dock id that is a split node, we'll dig within to find a suitable docking spot - ImGuiContext* ctx = GImGui; - if (ImGuiDockNode* new_node = DockContextFindNodeByID(ctx, dock_id)) + ImGuiContext *ctx = GImGui; + if (ImGuiDockNode *new_node = DockContextFindNodeByID(ctx, dock_id)) if (new_node->IsSplitNode()) { // Policy: Find central node or latest focused node. We first move back to our root node. @@ -16581,11 +17147,11 @@ void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond) // Create an explicit dockspace node within an existing window. Also expose dock node flags and creates a CentralNode by default. // The Central Node is always displayed even when empty and shrink/extend according to the requested size of its neighbors. // DockSpace() needs to be submitted _before_ any window they can host. If you use a dockspace, submit it early in your app. -ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags flags, const ImGuiWindowClass* window_class) +ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2 &size_arg, ImGuiDockNodeFlags flags, const ImGuiWindowClass *window_class) { - ImGuiContext* ctx = GImGui; - ImGuiContext& g = *ctx; - ImGuiWindow* window = GetCurrentWindow(); + ImGuiContext *ctx = GImGui; + ImGuiContext &g = *ctx; + ImGuiWindow *window = GetCurrentWindow(); if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)) return 0; @@ -16597,7 +17163,7 @@ ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0); IM_ASSERT(id != 0); - ImGuiDockNode* node = DockContextFindNodeByID(ctx, id); + ImGuiDockNode *node = DockContextFindNodeByID(ctx, id); if (!node) { IMGUI_DEBUG_LOG_DOCKING("[docking] DockSpace: dockspace node 0x%08X created\n", id); @@ -16654,7 +17220,7 @@ ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags Begin(title, NULL, window_flags); PopStyleVar(); - ImGuiWindow* host_window = g.CurrentWindow; + ImGuiWindow *host_window = g.CurrentWindow; DockNodeSetupHostWindow(node, host_window); host_window->ChildId = window->GetID(title); node->OnlyNodeWithWindows = NULL; @@ -16682,7 +17248,7 @@ ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags // The limitation with this call is that your window won't have a menu bar. // Even though we could pass window flags, it would also require the user to be able to call BeginMenuBar() somehow meaning we can't Begin/End in a single function. // But you can also use BeginMainMenuBar(). If you really want a menu bar inside the same window as the one hosting the dockspace, you will need to copy this code somewhere and tweak it. -ImGuiID ImGui::DockSpaceOverViewport(const ImGuiViewport* viewport, ImGuiDockNodeFlags dockspace_flags, const ImGuiWindowClass* window_class) +ImGuiID ImGui::DockSpaceOverViewport(const ImGuiViewport *viewport, ImGuiDockNodeFlags dockspace_flags, const ImGuiWindowClass *window_class) { if (viewport == NULL) viewport = GetMainViewport(); @@ -16736,11 +17302,11 @@ ImGuiID ImGui::DockSpaceOverViewport(const ImGuiViewport* viewport, ImGuiDockNod // - DockBuilderFinish() //----------------------------------------------------------------------------- -void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id) +void ImGui::DockBuilderDockWindow(const char *window_name, ImGuiID node_id) { // We don't preserve relative order of multiple docked windows (by clearing DockOrder back to -1) ImGuiID window_id = ImHashStr(window_name); - if (ImGuiWindow* window = FindWindowByID(window_id)) + if (ImGuiWindow *window = FindWindowByID(window_id)) { // Apply to created window SetWindowDock(window, node_id, ImGuiCond_Always); @@ -16749,7 +17315,7 @@ void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id) else { // Apply to settings - ImGuiWindowSettings* settings = FindWindowSettings(window_id); + ImGuiWindowSettings *settings = FindWindowSettings(window_id); if (settings == NULL) settings = CreateNewWindowSettings(window_name); settings->DockId = node_id; @@ -16757,16 +17323,16 @@ void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id) } } -ImGuiDockNode* ImGui::DockBuilderGetNode(ImGuiID node_id) +ImGuiDockNode *ImGui::DockBuilderGetNode(ImGuiID node_id) { - ImGuiContext* ctx = GImGui; + ImGuiContext *ctx = GImGui; return DockContextFindNodeByID(ctx, node_id); } void ImGui::DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos) { - ImGuiContext* ctx = GImGui; - ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id); + ImGuiContext *ctx = GImGui; + ImGuiDockNode *node = DockContextFindNodeByID(ctx, node_id); if (node == NULL) return; node->Pos = pos; @@ -16775,8 +17341,8 @@ void ImGui::DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos) void ImGui::DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size) { - ImGuiContext* ctx = GImGui; - ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id); + ImGuiContext *ctx = GImGui; + ImGuiDockNode *node = DockContextFindNodeByID(ctx, node_id); if (node == NULL) return; IM_ASSERT(size.x > 0.0f && size.y > 0.0f); @@ -16793,12 +17359,12 @@ void ImGui::DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size) // - Existing node with a same id will be removed. ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags) { - ImGuiContext* ctx = GImGui; + ImGuiContext *ctx = GImGui; if (id != 0) DockBuilderRemoveNode(id); - ImGuiDockNode* node = NULL; + ImGuiDockNode *node = NULL; if (flags & ImGuiDockNodeFlags_DockSpace) { DockSpace(id, ImVec2(0, 0), (flags & ~ImGuiDockNodeFlags_DockSpace) | ImGuiDockNodeFlags_KeepAliveOnly); @@ -16809,14 +17375,14 @@ ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags) node = DockContextAddNode(ctx, id); node->SetLocalFlags(flags); } - node->LastFrameAlive = ctx->FrameCount; // Set this otherwise BeginDocked will undock during the same frame. + node->LastFrameAlive = ctx->FrameCount; // Set this otherwise BeginDocked will undock during the same frame. return node->ID; } void ImGui::DockBuilderRemoveNode(ImGuiID node_id) { - ImGuiContext* ctx = GImGui; - ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id); + ImGuiContext *ctx = GImGui; + ImGuiDockNode *node = DockContextFindNodeByID(ctx, node_id); if (node == NULL) return; DockBuilderRemoveNodeDockedWindows(node_id, true); @@ -16833,10 +17399,10 @@ void ImGui::DockBuilderRemoveNode(ImGuiID node_id) // root_id = 0 to remove all, root_id != 0 to remove child of given node. void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id) { - ImGuiContext* ctx = GImGui; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext *ctx = GImGui; + ImGuiDockContext *dc = &ctx->DockContext; - ImGuiDockNode* root_node = root_id ? DockContextFindNodeByID(ctx, root_id) : NULL; + ImGuiDockNode *root_node = root_id ? DockContextFindNodeByID(ctx, root_id) : NULL; if (root_id && root_node == NULL) return; bool has_central_node = false; @@ -16845,9 +17411,9 @@ void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id) ImGuiDataAuthority backup_root_node_authority_for_size = root_node ? root_node->AuthorityForSize : ImGuiDataAuthority_Auto; // Process active windows - ImVector nodes_to_remove; + ImVector nodes_to_remove; for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) { bool want_removal = (root_id == 0) || (node->ID != root_id && DockNodeGetRootNode(node)->ID == root_id); if (want_removal) @@ -16874,7 +17440,7 @@ void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id) } // Apply to settings - for (ImGuiWindowSettings* settings = ctx->SettingsWindows.begin(); settings != NULL; settings = ctx->SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = ctx->SettingsWindows.begin(); settings != NULL; settings = ctx->SettingsWindows.next_chunk(settings)) if (ImGuiID window_settings_dock_id = settings->DockId) for (int n = 0; n < nodes_to_remove.Size; n++) if (nodes_to_remove[n]->ID == window_settings_dock_id) @@ -16885,7 +17451,7 @@ void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id) // Not really efficient, but easier to destroy a whole hierarchy considering DockContextRemoveNode is attempting to merge nodes if (nodes_to_remove.Size > 1) - ImQsort(nodes_to_remove.Data, nodes_to_remove.Size, sizeof(ImGuiDockNode*), DockNodeComparerDepthMostFirst); + ImQsort(nodes_to_remove.Data, nodes_to_remove.Size, sizeof(ImGuiDockNode *), DockNodeComparerDepthMostFirst); for (int n = 0; n < nodes_to_remove.Size; n++) DockContextRemoveNode(ctx, nodes_to_remove[n], false); @@ -16904,15 +17470,15 @@ void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id) void ImGui::DockBuilderRemoveNodeDockedWindows(ImGuiID root_id, bool clear_settings_refs) { // Clear references in settings - ImGuiContext* ctx = GImGui; - ImGuiContext& g = *ctx; + ImGuiContext *ctx = GImGui; + ImGuiContext &g = *ctx; if (clear_settings_refs) { - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) { bool want_removal = (root_id == 0) || (settings->DockId == root_id); if (!want_removal && settings->DockId != 0) - if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, settings->DockId)) + if (ImGuiDockNode *node = DockContextFindNodeByID(ctx, settings->DockId)) if (DockNodeGetRootNode(node)->ID == root_id) want_removal = true; if (want_removal) @@ -16923,7 +17489,7 @@ void ImGui::DockBuilderRemoveNodeDockedWindows(ImGuiID root_id, bool clear_setti // Clear references in windows for (int n = 0; n < g.Windows.Size; n++) { - ImGuiWindow* window = g.Windows[n]; + ImGuiWindow *window = g.Windows[n]; bool want_removal = (root_id == 0) || (window->DockNode && DockNodeGetRootNode(window->DockNode)->ID == root_id) || (window->DockNodeAsHost && window->DockNodeAsHost->ID == root_id); if (want_removal) { @@ -16939,13 +17505,13 @@ void ImGui::DockBuilderRemoveNodeDockedWindows(ImGuiID root_id, bool clear_setti // If 'out_id_at_dir' or 'out_id_at_opposite_dir' are non NULL, the function will write out the ID of the two new nodes created. // Return value is ID of the node at the specified direction, so same as (*out_id_at_dir) if that pointer is set. // FIXME-DOCK: We are not exposing nor using split_outer. -ImGuiID ImGui::DockBuilderSplitNode(ImGuiID id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir) +ImGuiID ImGui::DockBuilderSplitNode(ImGuiID id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID *out_id_at_dir, ImGuiID *out_id_at_opposite_dir) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(split_dir != ImGuiDir_None); IMGUI_DEBUG_LOG_DOCKING("[docking] DockBuilderSplitNode: node 0x%08X, split_dir %d\n", id, split_dir); - ImGuiDockNode* node = DockContextFindNodeByID(&g, id); + ImGuiDockNode *node = DockContextFindNodeByID(&g, id); if (node == NULL) { IM_ASSERT(node != NULL); @@ -16973,10 +17539,10 @@ ImGuiID ImGui::DockBuilderSplitNode(ImGuiID id, ImGuiDir split_dir, float size_r return id_at_dir; } -static ImGuiDockNode* DockBuilderCopyNodeRec(ImGuiDockNode* src_node, ImGuiID dst_node_id_if_known, ImVector* out_node_remap_pairs) +static ImGuiDockNode *DockBuilderCopyNodeRec(ImGuiDockNode *src_node, ImGuiID dst_node_id_if_known, ImVector *out_node_remap_pairs) { - ImGuiContext& g = *GImGui; - ImGuiDockNode* dst_node = ImGui::DockContextAddNode(&g, dst_node_id_if_known); + ImGuiContext &g = *GImGui; + ImGuiDockNode *dst_node = ImGui::DockContextAddNode(&g, dst_node_id_if_known); dst_node->SharedFlags = src_node->SharedFlags; dst_node->LocalFlags = src_node->LocalFlags; dst_node->LocalFlagsInWindows = ImGuiDockNodeFlags_None; @@ -17000,16 +17566,16 @@ static ImGuiDockNode* DockBuilderCopyNodeRec(ImGuiDockNode* src_node, ImGuiID ds return dst_node; } -void ImGui::DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector* out_node_remap_pairs) +void ImGui::DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector *out_node_remap_pairs) { - ImGuiContext* ctx = GImGui; + ImGuiContext *ctx = GImGui; IM_ASSERT(src_node_id != 0); IM_ASSERT(dst_node_id != 0); IM_ASSERT(out_node_remap_pairs != NULL); DockBuilderRemoveNode(dst_node_id); - ImGuiDockNode* src_node = DockContextFindNodeByID(ctx, src_node_id); + ImGuiDockNode *src_node = DockContextFindNodeByID(ctx, src_node_id); IM_ASSERT(src_node != NULL); out_node_remap_pairs->clear(); @@ -17018,19 +17584,19 @@ void ImGui::DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVect IM_ASSERT((out_node_remap_pairs->Size % 2) == 0); } -void ImGui::DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name) +void ImGui::DockBuilderCopyWindowSettings(const char *src_name, const char *dst_name) { - ImGuiWindow* src_window = FindWindowByName(src_name); + ImGuiWindow *src_window = FindWindowByName(src_name); if (src_window == NULL) return; - if (ImGuiWindow* dst_window = FindWindowByName(dst_name)) + if (ImGuiWindow *dst_window = FindWindowByName(dst_name)) { dst_window->Pos = src_window->Pos; dst_window->Size = src_window->Size; dst_window->SizeFull = src_window->SizeFull; dst_window->Collapsed = src_window->Collapsed; } - else if (ImGuiWindowSettings* dst_settings = FindOrCreateWindowSettings(dst_name)) + else if (ImGuiWindowSettings *dst_settings = FindOrCreateWindowSettings(dst_name)) { ImVec2ih window_pos_2ih = ImVec2ih(src_window->Pos); if (src_window->ViewportId != 0 && src_window->ViewportId != IMGUI_VIEWPORT_DEFAULT_ID) @@ -17049,9 +17615,9 @@ void ImGui::DockBuilderCopyWindowSettings(const char* src_name, const char* dst_ } // FIXME: Will probably want to change this signature, in particular how the window remapping pairs are passed. -void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector* in_window_remap_pairs) +void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector *in_window_remap_pairs) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(src_dockspace_id != 0); IM_ASSERT(dst_dockspace_id != 0); IM_ASSERT(in_window_remap_pairs != NULL); @@ -17068,23 +17634,23 @@ void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_docks ImVector src_windows; for (int remap_window_n = 0; remap_window_n < in_window_remap_pairs->Size; remap_window_n += 2) { - const char* src_window_name = (*in_window_remap_pairs)[remap_window_n]; - const char* dst_window_name = (*in_window_remap_pairs)[remap_window_n + 1]; + const char *src_window_name = (*in_window_remap_pairs)[remap_window_n]; + const char *dst_window_name = (*in_window_remap_pairs)[remap_window_n + 1]; ImGuiID src_window_id = ImHashStr(src_window_name); src_windows.push_back(src_window_id); // Search in the remapping tables ImGuiID src_dock_id = 0; - if (ImGuiWindow* src_window = FindWindowByID(src_window_id)) + if (ImGuiWindow *src_window = FindWindowByID(src_window_id)) src_dock_id = src_window->DockId; - else if (ImGuiWindowSettings* src_window_settings = FindWindowSettings(src_window_id)) + else if (ImGuiWindowSettings *src_window_settings = FindWindowSettings(src_window_id)) src_dock_id = src_window_settings->DockId; ImGuiID dst_dock_id = 0; for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2) if (node_remap_pairs[dock_remap_n] == src_dock_id) { dst_dock_id = node_remap_pairs[dock_remap_n + 1]; - //node_remap_pairs[dock_remap_n] = node_remap_pairs[dock_remap_n + 1] = 0; // Clear + // node_remap_pairs[dock_remap_n] = node_remap_pairs[dock_remap_n + 1] = 0; // Clear break; } @@ -17109,10 +17675,10 @@ void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_docks if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n]) { ImGuiID dst_dock_id = node_remap_pairs[dock_remap_n + 1]; - ImGuiDockNode* node = DockBuilderGetNode(src_dock_id); + ImGuiDockNode *node = DockBuilderGetNode(src_dock_id); for (int window_n = 0; window_n < node->Windows.Size; window_n++) { - ImGuiWindow* window = node->Windows[window_n]; + ImGuiWindow *window = node->Windows[window_n]; if (src_windows.contains(window->ID)) continue; @@ -17126,8 +17692,8 @@ void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_docks // FIXME-DOCK: This is awkward because in series of split user is likely to loose access to its root node. void ImGui::DockBuilderFinish(ImGuiID root_id) { - ImGuiContext* ctx = GImGui; - //DockContextRebuild(ctx); + ImGuiContext *ctx = GImGui; + // DockContextRebuild(ctx); DockContextBuildAddWindowsToNodes(ctx, root_id); } @@ -17141,20 +17707,20 @@ void ImGui::DockBuilderFinish(ImGuiID root_id) // - BeginDockableDragDropTarget() //----------------------------------------------------------------------------- -bool ImGui::GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window) +bool ImGui::GetWindowAlwaysWantOwnTabBar(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (g.IO.ConfigDockingAlwaysTabBar || window->WindowClass.DockingAlwaysTabBar) if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking)) == 0) - if (!window->IsFallbackWindow) // We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise + if (!window->IsFallbackWindow) // We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise return true; return false; } -static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window) +static ImGuiDockNode *ImGui::DockContextBindNodeToWindow(ImGuiContext *ctx, ImGuiWindow *window) { - ImGuiContext& g = *ctx; - ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId); + ImGuiContext &g = *ctx; + ImGuiDockNode *node = DockContextFindNodeByID(ctx, window->DockId); IM_ASSERT(window->DockNode == NULL); // We should not be docking into a split node (SetWindowDock should avoid this) @@ -17178,7 +17744,7 @@ static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGu // This is a little wonky because we don't normally update the Pos/Size of visible node mid-frame. if (!node->IsVisible) { - ImGuiDockNode* ancestor_node = node; + ImGuiDockNode *ancestor_node = node; while (!ancestor_node->IsVisible && ancestor_node->ParentNode) ancestor_node = ancestor_node->ParentNode; IM_ASSERT(ancestor_node->Size.x > 0.0f && ancestor_node->Size.y > 0.0f); @@ -17194,10 +17760,10 @@ static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGu return node; } -void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) +void ImGui::BeginDocked(ImGuiWindow *window, bool *p_open) { - ImGuiContext* ctx = GImGui; - ImGuiContext& g = *ctx; + ImGuiContext *ctx = GImGui; + ImGuiContext &g = *ctx; // Clear fields ahead so most early-out paths don't have to do it window->DockIsActive = window->DockNodeIsVisible = window->DockTabIsVisible = false; @@ -17225,7 +17791,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) } // Bind to our dock node - ImGuiDockNode* node = window->DockNode; + ImGuiDockNode *node = window->DockNode; if (node != NULL) IM_ASSERT(window->DockId == node->ID); if (window->DockId != 0 && node == NULL) @@ -17249,7 +17815,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) if (node->LastFrameAlive < g.FrameCount) { // If the window has been orphaned, transition the docknode to an implicit node processed in DockContextNewFrameUpdateDocking() - ImGuiDockNode* root_node = DockNodeGetRootNode(node); + ImGuiDockNode *root_node = DockNodeGetRootNode(node); if (root_node->LastFrameAlive < g.FrameCount) DockContextProcessUndockWindow(ctx, window); else @@ -17306,7 +17872,7 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) if (node->IsHiddenTabBar() || node->IsNoTabBar()) window->Flags |= ImGuiWindowFlags_NoTitleBar; else - window->Flags &= ~ImGuiWindowFlags_NoTitleBar; // Clear the NoTitleBar flag in case the user set it: confusingly enough we need a title bar height so we are correctly offset, but it won't be displayed! + window->Flags &= ~ImGuiWindowFlags_NoTitleBar; // Clear the NoTitleBar flag in case the user set it: confusingly enough we need a title bar height so we are correctly offset, but it won't be displayed! // Save new dock order only if the window has been visible once already // This allows multiple windows to be created in the same frame and have their respective dock orders preserved. @@ -17317,13 +17883,13 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) *p_open = false; // Update ChildId to allow returning from Child to Parent with Escape - ImGuiWindow* parent_window = window->DockNode->HostWindow; + ImGuiWindow *parent_window = window->DockNode->HostWindow; window->ChildId = parent_window->GetID(window->Name); } -void ImGui::BeginDockableDragDropSource(ImGuiWindow* window) +void ImGui::BeginDockableDragDropSource(ImGuiWindow *window) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IM_ASSERT(g.ActiveId == window->MoveId); IM_ASSERT(g.MovingWindow == window); IM_ASSERT(g.CurrentWindow == window); @@ -17343,35 +17909,35 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window) } } -void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window) +void ImGui::BeginDockableDragDropTarget(ImGuiWindow *window) { - ImGuiContext* ctx = GImGui; - ImGuiContext& g = *ctx; + ImGuiContext *ctx = GImGui; + ImGuiContext &g = *ctx; - //IM_ASSERT(window->RootWindowDockTree == window); // May also be a DockSpace + // IM_ASSERT(window->RootWindowDockTree == window); // May also be a DockSpace IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0); if (!g.DragDropActive) return; - //GetForegroundDrawList(window)->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); + // GetForegroundDrawList(window)->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); if (!BeginDragDropTargetCustom(window->Rect(), window->ID)) return; // Peek into the payload before calling AcceptDragDropPayload() so we can handle overlapping dock nodes with filtering // (this is a little unusual pattern, normally most code would call AcceptDragDropPayload directly) - const ImGuiPayload* payload = &g.DragDropPayload; - if (!payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) || !DockNodeIsDropAllowed(window, *(ImGuiWindow**)payload->Data)) + const ImGuiPayload *payload = &g.DragDropPayload; + if (!payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) || !DockNodeIsDropAllowed(window, *(ImGuiWindow **)payload->Data)) { EndDragDropTarget(); return; } - ImGuiWindow* payload_window = *(ImGuiWindow**)payload->Data; + ImGuiWindow *payload_window = *(ImGuiWindow **)payload->Data; if (AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect)) { // Select target node // (Important: we cannot use g.HoveredDockNode here! Because each of our target node have filters based on payload, each candidate drop target will do its own evaluation) bool dock_into_floating_window = false; - ImGuiDockNode* node = NULL; + ImGuiDockNode *node = NULL; if (window->DockNodeAsHost) { // Cannot assume that node will != NULL even though we passed the rectangle test: it depends on padding/spacing handled by DockNodeTreeFindVisibleNodeByPos(). @@ -17395,15 +17961,15 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window) const bool is_explicit_target = g.IO.ConfigDockingWithShift || IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max); // Preview docking request and find out split direction/ratio - //const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window. + // const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window. const bool do_preview = payload->IsPreview() || payload->IsDelivery(); if (do_preview && (node != NULL || dock_into_floating_window)) { ImGuiDockPreviewData split_inner; ImGuiDockPreviewData split_outer; - ImGuiDockPreviewData* split_data = &split_inner; + ImGuiDockPreviewData *split_data = &split_inner; if (node && (node->ParentNode || node->IsCentralNode())) - if (ImGuiDockNode* root_node = DockNodeGetRootNode(node)) + if (ImGuiDockNode *root_node = DockNodeGetRootNode(node)) { DockNodePreviewDockSetup(window, root_node, payload_window, NULL, &split_outer, is_explicit_target, true); if (split_outer.IsSplitDirExplicit) @@ -17440,27 +18006,27 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window) static void ImGui::DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; IMGUI_DEBUG_LOG_DOCKING("[docking] DockSettingsRenameNodeReferences: from 0x%08X -> to 0x%08X\n", old_node_id, new_node_id); for (int window_n = 0; window_n < g.Windows.Size; window_n++) { - ImGuiWindow* window = g.Windows[window_n]; + ImGuiWindow *window = g.Windows[window_n]; if (window->DockId == old_node_id && window->DockNode == NULL) window->DockId = new_node_id; } //// FIXME-OPT: We could remove this loop by storing the index in the map - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (settings->DockId == old_node_id) settings->DockId = new_node_id; } // Remove references stored in ImGuiWindowSettings to the given ImGuiDockNodeSettings -static void ImGui::DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count) +static void ImGui::DockSettingsRemoveNodeReferences(ImGuiID *node_ids, int node_ids_count) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; int found = 0; //// FIXME-OPT: We could remove this loop by storing the index in the map - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) for (int node_n = 0; node_n < node_ids_count; node_n++) if (settings->DockId == node_ids[node_n]) { @@ -17472,10 +18038,10 @@ static void ImGui::DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ } } -static ImGuiDockNodeSettings* ImGui::DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID id) +static ImGuiDockNodeSettings *ImGui::DockSettingsFindNodeSettings(ImGuiContext *ctx, ImGuiID id) { // FIXME-OPT - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiDockContext *dc = &ctx->DockContext; for (int n = 0; n < dc->NodesSettings.Size; n++) if (dc->NodesSettings[n].ID == id) return &dc->NodesSettings[n]; @@ -17483,32 +18049,32 @@ static ImGuiDockNodeSettings* ImGui::DockSettingsFindNodeSettings(ImGuiContext* } // Clear settings data -static void ImGui::DockSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +static void ImGui::DockSettingsHandler_ClearAll(ImGuiContext *ctx, ImGuiSettingsHandler *) { - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiDockContext *dc = &ctx->DockContext; dc->NodesSettings.clear(); DockContextClearNodes(ctx, 0, true); } // Recreate nodes based on settings data -static void ImGui::DockSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*) +static void ImGui::DockSettingsHandler_ApplyAll(ImGuiContext *ctx, ImGuiSettingsHandler *) { // Prune settings at boot time only - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiDockContext *dc = &ctx->DockContext; if (ctx->Windows.Size == 0) DockContextPruneUnusedSettingsNodes(ctx); DockContextBuildNodesFromSettings(ctx, dc->NodesSettings.Data, dc->NodesSettings.Size); DockContextBuildAddWindowsToNodes(ctx, 0); } -static void* ImGui::DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) +static void *ImGui::DockSettingsHandler_ReadOpen(ImGuiContext *, ImGuiSettingsHandler *, const char *name) { if (strcmp(name, "Data") != 0) return NULL; - return (void*)1; + return (void *)1; } -static void ImGui::DockSettingsHandler_ReadLine(ImGuiContext* ctx, ImGuiSettingsHandler*, void*, const char* line) +static void ImGui::DockSettingsHandler_ReadLine(ImGuiContext *ctx, ImGuiSettingsHandler *, void *, const char *line) { char c = 0; int x = 0, y = 0; @@ -17520,36 +18086,115 @@ static void ImGui::DockSettingsHandler_ReadLine(ImGuiContext* ctx, ImGuiSettings // Important: this code expect currently fields in a fixed order. ImGuiDockNodeSettings node; line = ImStrSkipBlank(line); - if (strncmp(line, "DockNode", 8) == 0) { line = ImStrSkipBlank(line + strlen("DockNode")); } - else if (strncmp(line, "DockSpace", 9) == 0) { line = ImStrSkipBlank(line + strlen("DockSpace")); node.Flags |= ImGuiDockNodeFlags_DockSpace; } - else return; - if (sscanf(line, "ID=0x%08X%n", &node.ID, &r) == 1) { line += r; } else return; - if (sscanf(line, " Parent=0x%08X%n", &node.ParentNodeId, &r) == 1) { line += r; if (node.ParentNodeId == 0) return; } - if (sscanf(line, " Window=0x%08X%n", &node.ParentWindowId, &r) ==1) { line += r; if (node.ParentWindowId == 0) return; } + if (strncmp(line, "DockNode", 8) == 0) + { + line = ImStrSkipBlank(line + strlen("DockNode")); + } + else if (strncmp(line, "DockSpace", 9) == 0) + { + line = ImStrSkipBlank(line + strlen("DockSpace")); + node.Flags |= ImGuiDockNodeFlags_DockSpace; + } + else + return; + if (sscanf(line, "ID=0x%08X%n", &node.ID, &r) == 1) + { + line += r; + } + else + return; + if (sscanf(line, " Parent=0x%08X%n", &node.ParentNodeId, &r) == 1) + { + line += r; + if (node.ParentNodeId == 0) + return; + } + if (sscanf(line, " Window=0x%08X%n", &node.ParentWindowId, &r) == 1) + { + line += r; + if (node.ParentWindowId == 0) + return; + } if (node.ParentNodeId == 0) { - if (sscanf(line, " Pos=%i,%i%n", &x, &y, &r) == 2) { line += r; node.Pos = ImVec2ih((short)x, (short)y); } else return; - if (sscanf(line, " Size=%i,%i%n", &x, &y, &r) == 2) { line += r; node.Size = ImVec2ih((short)x, (short)y); } else return; + if (sscanf(line, " Pos=%i,%i%n", &x, &y, &r) == 2) + { + line += r; + node.Pos = ImVec2ih((short)x, (short)y); + } + else + return; + if (sscanf(line, " Size=%i,%i%n", &x, &y, &r) == 2) + { + line += r; + node.Size = ImVec2ih((short)x, (short)y); + } + else + return; } else { - if (sscanf(line, " SizeRef=%i,%i%n", &x, &y, &r) == 2) { line += r; node.SizeRef = ImVec2ih((short)x, (short)y); } + if (sscanf(line, " SizeRef=%i,%i%n", &x, &y, &r) == 2) + { + line += r; + node.SizeRef = ImVec2ih((short)x, (short)y); + } + } + if (sscanf(line, " Split=%c%n", &c, &r) == 1) + { + line += r; + if (c == 'X') + node.SplitAxis = ImGuiAxis_X; + else if (c == 'Y') + node.SplitAxis = ImGuiAxis_Y; + } + if (sscanf(line, " NoResize=%d%n", &x, &r) == 1) + { + line += r; + if (x != 0) + node.Flags |= ImGuiDockNodeFlags_NoResize; + } + if (sscanf(line, " CentralNode=%d%n", &x, &r) == 1) + { + line += r; + if (x != 0) + node.Flags |= ImGuiDockNodeFlags_CentralNode; + } + if (sscanf(line, " NoTabBar=%d%n", &x, &r) == 1) + { + line += r; + if (x != 0) + node.Flags |= ImGuiDockNodeFlags_NoTabBar; + } + if (sscanf(line, " HiddenTabBar=%d%n", &x, &r) == 1) + { + line += r; + if (x != 0) + node.Flags |= ImGuiDockNodeFlags_HiddenTabBar; + } + if (sscanf(line, " NoWindowMenuButton=%d%n", &x, &r) == 1) + { + line += r; + if (x != 0) + node.Flags |= ImGuiDockNodeFlags_NoWindowMenuButton; + } + if (sscanf(line, " NoCloseButton=%d%n", &x, &r) == 1) + { + line += r; + if (x != 0) + node.Flags |= ImGuiDockNodeFlags_NoCloseButton; + } + if (sscanf(line, " Selected=0x%08X%n", &node.SelectedTabId, &r) == 1) + { + line += r; } - if (sscanf(line, " Split=%c%n", &c, &r) == 1) { line += r; if (c == 'X') node.SplitAxis = ImGuiAxis_X; else if (c == 'Y') node.SplitAxis = ImGuiAxis_Y; } - if (sscanf(line, " NoResize=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoResize; } - if (sscanf(line, " CentralNode=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_CentralNode; } - if (sscanf(line, " NoTabBar=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoTabBar; } - if (sscanf(line, " HiddenTabBar=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_HiddenTabBar; } - if (sscanf(line, " NoWindowMenuButton=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoWindowMenuButton; } - if (sscanf(line, " NoCloseButton=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoCloseButton; } - if (sscanf(line, " Selected=0x%08X%n", &node.SelectedTabId,&r) == 1) { line += r; } if (node.ParentNodeId != 0) - if (ImGuiDockNodeSettings* parent_settings = DockSettingsFindNodeSettings(ctx, node.ParentNodeId)) + if (ImGuiDockNodeSettings *parent_settings = DockSettingsFindNodeSettings(ctx, node.ParentNodeId)) node.Depth = parent_settings->Depth + 1; ctx->DockContext.NodesSettings.push_back(node); } -static void DockSettingsHandler_DockNodeToSettings(ImGuiDockContext* dc, ImGuiDockNode* node, int depth) +static void DockSettingsHandler_DockNodeToSettings(ImGuiDockContext *dc, ImGuiDockNode *node, int depth) { ImGuiDockNodeSettings node_settings; IM_ASSERT(depth < (1 << (sizeof(node_settings.Depth) << 3))); @@ -17570,10 +18215,10 @@ static void DockSettingsHandler_DockNodeToSettings(ImGuiDockContext* dc, ImGuiDo DockSettingsHandler_DockNodeToSettings(dc, node->ChildNodes[1], depth + 1); } -static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) +static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext *ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf) { - ImGuiContext& g = *ctx; - ImGuiDockContext* dc = &ctx->DockContext; + ImGuiContext &g = *ctx; + ImGuiDockContext *dc = &ctx->DockContext; if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)) return; @@ -17582,7 +18227,7 @@ static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettings dc->NodesSettings.resize(0); dc->NodesSettings.reserve(dc->Nodes.Data.Size); for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) if (node->IsRootNode()) DockSettingsHandler_DockNodeToSettings(dc, node, 0); @@ -17594,9 +18239,10 @@ static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettings buf->appendf("[%s][Data]\n", handler->TypeName); for (int node_n = 0; node_n < dc->NodesSettings.Size; node_n++) { - const int line_start_pos = buf->size(); (void)line_start_pos; - const ImGuiDockNodeSettings* node_settings = &dc->NodesSettings[node_n]; - buf->appendf("%*s%s%*s", node_settings->Depth * 2, "", (node_settings->Flags & ImGuiDockNodeFlags_DockSpace) ? "DockSpace" : "DockNode ", (max_depth - node_settings->Depth) * 2, ""); // Text align nodes to facilitate looking at .ini file + const int line_start_pos = buf->size(); + (void)line_start_pos; + const ImGuiDockNodeSettings *node_settings = &dc->NodesSettings[node_n]; + buf->appendf("%*s%s%*s", node_settings->Depth * 2, "", (node_settings->Flags & ImGuiDockNodeFlags_DockSpace) ? "DockSpace" : "DockNode ", (max_depth - node_settings->Depth) * 2, ""); // Text align nodes to facilitate looking at .ini file buf->appendf(" ID=0x%08X", node_settings->ID); if (node_settings->ParentNodeId) { @@ -17627,14 +18273,14 @@ static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettings #if IMGUI_DEBUG_INI_SETTINGS // [DEBUG] Include comments in the .ini file to ease debugging - if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_settings->ID)) + if (ImGuiDockNode *node = DockContextFindNodeByID(ctx, node_settings->ID)) { - buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything + buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything if (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow) buf->appendf(" ; in '%s'", node->HostWindow->ParentWindow->Name); // Iterate settings so we can give info about windows that didn't exist during the session. int contains_window = 0; - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (settings->DockId == node_settings->ID) { if (contains_window++ == 0) @@ -17648,6 +18294,28 @@ static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettings buf->appendf("\n"); } +#if IMGUI_DEBUG_INI_SETTINGS +// [DEBUG] Include comments in the .ini file to ease debugging +if (ImGuiDockNode *node = DockContextFindNodeByID(ctx, node_settings->ID)) +{ + buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything + if (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow) + buf->appendf(" ; in '%s'", node->HostWindow->ParentWindow->Name); + // Iterate settings so we can give info about windows that didn't exist during the session. + int contains_window = 0; + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + if (settings->DockId == node_settings->ID) + { + if (contains_window++ == 0) + buf->appendf(" ; contains "); + buf->appendf("'%s' ", settings->GetName()); + } +} +#endif +buf->appendf("\n"); +} +buf->appendf("\n"); +} //----------------------------------------------------------------------------- // [SECTION] PLATFORM DEPENDENT HELPERS @@ -17662,9 +18330,9 @@ static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettings // Win32 clipboard implementation // We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown() -static const char* GetClipboardTextFn_DefaultImpl(void*) +static const char *GetClipboardTextFn_DefaultImpl(void *) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.ClipboardHandlerData.clear(); if (!::OpenClipboard(NULL)) return NULL; @@ -17674,7 +18342,7 @@ static const char* GetClipboardTextFn_DefaultImpl(void*) ::CloseClipboard(); return NULL; } - if (const WCHAR* wbuf_global = (const WCHAR*)::GlobalLock(wbuf_handle)) + if (const WCHAR *wbuf_global = (const WCHAR *)::GlobalLock(wbuf_handle)) { int buf_len = ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, NULL, 0, NULL, NULL); g.ClipboardHandlerData.resize(buf_len); @@ -17685,7 +18353,7 @@ static const char* GetClipboardTextFn_DefaultImpl(void*) return g.ClipboardHandlerData.Data; } -static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +static void SetClipboardTextFn_DefaultImpl(void *, const char *text) { if (!::OpenClipboard(NULL)) return; @@ -17696,7 +18364,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text) ::CloseClipboard(); return; } - WCHAR* wbuf_global = (WCHAR*)::GlobalLock(wbuf_handle); + WCHAR *wbuf_global = (WCHAR *)::GlobalLock(wbuf_handle); ::MultiByteToWideChar(CP_UTF8, 0, text, -1, wbuf_global, wbuf_length); ::GlobalUnlock(wbuf_handle); ::EmptyClipboard(); @@ -17707,17 +18375,17 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text) #elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) -#include // Use old API to avoid need for separate .mm file +#include // Use old API to avoid need for separate .mm file static PasteboardRef main_clipboard = 0; // OSX clipboard implementation // If you enable this you will need to add '-framework ApplicationServices' to your linker command-line! -static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +static void SetClipboardTextFn_DefaultImpl(void *, const char *text) { if (!main_clipboard) PasteboardCreate(kPasteboardClipboard, &main_clipboard); PasteboardClear(main_clipboard); - CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text)); + CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)text, strlen(text)); if (cf_data) { PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0); @@ -17725,7 +18393,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text) } } -static const char* GetClipboardTextFn_DefaultImpl(void*) +static const char *GetClipboardTextFn_DefaultImpl(void *) { if (!main_clipboard) PasteboardCreate(kPasteboardClipboard, &main_clipboard); @@ -17744,11 +18412,11 @@ static const char* GetClipboardTextFn_DefaultImpl(void*) CFDataRef cf_data; if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.ClipboardHandlerData.clear(); int length = (int)CFDataGetLength(cf_data); g.ClipboardHandlerData.resize(length + 1); - CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)g.ClipboardHandlerData.Data); + CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8 *)g.ClipboardHandlerData.Data); g.ClipboardHandlerData[length] = 0; CFRelease(cf_data); return g.ClipboardHandlerData.Data; @@ -17761,17 +18429,17 @@ static const char* GetClipboardTextFn_DefaultImpl(void*) #else // Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers. -static const char* GetClipboardTextFn_DefaultImpl(void*) +static const char *GetClipboardTextFn_DefaultImpl(void *) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin(); } -static void SetClipboardTextFn_DefaultImpl(void*, const char* text) +static void SetClipboardTextFn_DefaultImpl(void *, const char *text) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.ClipboardHandlerData.clear(); - const char* text_end = text + strlen(text); + const char *text_end = text + strlen(text); g.ClipboardHandlerData.resize((int)(text_end - text) + 1); memcpy(&g.ClipboardHandlerData[0], text, (size_t)(text_end - text)); g.ClipboardHandlerData[(int)(text_end - text)] = 0; @@ -17787,7 +18455,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text) #pragma comment(lib, "imm32") #endif -static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data) +static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport *viewport, ImGuiPlatformImeData *data) { // Notify OS Input Method Editor of text input position HWND hwnd = (HWND)viewport->PlatformHandleRaw; @@ -17817,7 +18485,9 @@ static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatf #else -static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport*, ImGuiPlatformImeData*) {} +static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport *, ImGuiPlatformImeData *) +{ +} #endif @@ -17847,10 +18517,10 @@ static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport*, ImGuiPlatformImeDat #ifndef IMGUI_DISABLE_DEBUG_TOOLS -void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb) +void ImGui::DebugRenderViewportThumbnail(ImDrawList *draw_list, ImGuiViewportP *viewport, const ImRect &bb) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; ImVec2 scale = bb.GetSize() / viewport->Size; ImVec2 off = bb.Min - viewport->Pos * scale; @@ -17858,7 +18528,7 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f)); for (int i = 0; i != g.Windows.Size; i++) { - ImGuiWindow* thumb_window = g.Windows[i]; + ImGuiWindow *thumb_window = g.Windows[i]; if (!thumb_window->WasActive || (thumb_window->Flags & ImGuiWindowFlags_ChildWindow)) continue; if (thumb_window->Viewport != viewport) @@ -17866,8 +18536,8 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* ImRect thumb_r = thumb_window->Rect(); ImRect title_r = thumb_window->TitleBarRect(); - thumb_r = ImRect(ImFloor(off + thumb_r.Min * scale), ImFloor(off + thumb_r.Max * scale)); - title_r = ImRect(ImFloor(off + title_r.Min * scale), ImFloor(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height + thumb_r = ImRect(ImFloor(off + thumb_r.Min * scale), ImFloor(off + thumb_r.Max * scale)); + title_r = ImRect(ImFloor(off + title_r.Min * scale), ImFloor(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0, 5)); // Exaggerate title bar height thumb_r.ClipWithFull(bb); title_r.ClipWithFull(bb); const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight); @@ -17881,8 +18551,8 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* static void RenderViewportsThumbnails() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; // We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports. float SCALE = 1.0f / 8.0f; @@ -17893,22 +18563,22 @@ static void RenderViewportsThumbnails() ImVec2 off = p - bb_full.Min * SCALE; for (int n = 0; n < g.Viewports.Size; n++) { - ImGuiViewportP* viewport = g.Viewports[n]; + ImGuiViewportP *viewport = g.Viewports[n]; ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE); ImGui::DebugRenderViewportThumbnail(window->DrawList, viewport, viewport_draw_bb); } ImGui::Dummy(bb_full.GetSize() * SCALE); } -static int IMGUI_CDECL ViewportComparerByFrontMostStampCount(const void* lhs, const void* rhs) +static int IMGUI_CDECL ViewportComparerByFrontMostStampCount(const void *lhs, const void *rhs) { - const ImGuiViewportP* a = *(const ImGuiViewportP* const*)lhs; - const ImGuiViewportP* b = *(const ImGuiViewportP* const*)rhs; + const ImGuiViewportP *a = *(const ImGuiViewportP *const *)lhs; + const ImGuiViewportP *b = *(const ImGuiViewportP *const *)rhs; return b->LastFrontMostStampCount - a->LastFrontMostStampCount; } // Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct. -void ImGui::DebugTextEncoding(const char* str) +void ImGui::DebugTextEncoding(const char *str) { Text("Text: \"%s\"", str); if (!BeginTable("list", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) @@ -17918,7 +18588,7 @@ void ImGui::DebugTextEncoding(const char* str) TableSetupColumn("Glyph"); TableSetupColumn("Codepoint"); TableHeadersRow(); - for (const char* p = str; *p != 0; ) + for (const char *p = str; *p != 0;) { unsigned int c; const int c_utf8_len = ImTextCharFromUtf8(&c, p, NULL); @@ -17944,7 +18614,7 @@ void ImGui::DebugTextEncoding(const char* str) } // Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds. -static void MetricsHelpMarker(const char* desc) +static void MetricsHelpMarker(const char *desc) { ImGui::TextDisabled("(?)"); if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) @@ -17958,11 +18628,11 @@ static void MetricsHelpMarker(const char* desc) } // [DEBUG] List fonts in a font atlas and display its texture -void ImGui::ShowFontAtlas(ImFontAtlas* atlas) +void ImGui::ShowFontAtlas(ImFontAtlas *atlas) { for (int i = 0; i < atlas->Fonts.Size; i++) { - ImFont* font = atlas->Fonts[i]; + ImFont *font = atlas->Fonts[i]; PushID(font); DebugNodeFont(font); PopID(); @@ -17976,11 +18646,11 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas) } } -void ImGui::ShowMetricsWindow(bool* p_open) +void ImGui::ShowMetricsWindow(bool *p_open) { - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; + ImGuiContext &g = *GImGui; + ImGuiIO &io = g.IO; + ImGuiMetricsConfig *cfg = &g.DebugMetricsConfig; if (cfg->ShowDebugLog) ShowDebugLogWindow(&cfg->ShowDebugLog); if (cfg->ShowStackTool) @@ -17997,15 +18667,42 @@ void ImGui::ShowMetricsWindow(bool* p_open) Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3); Text("%d visible windows, %d active allocations", io.MetricsRenderWindows, io.MetricsActiveAllocations); - //SameLine(); if (SmallButton("GC")) { g.GcCompactAll = true; } + // SameLine(); if (SmallButton("GC")) { g.GcCompactAll = true; } Separator(); // Debugging enums - enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentIdeal, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type - const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentIdeal", "ContentRegionRect" }; - enum { TRT_OuterRect, TRT_InnerRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsWorkRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type - const char* trt_rects_names[TRT_Count] = { "OuterRect", "InnerRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsWorkRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" }; + enum + { + WRT_OuterRect, + WRT_OuterRectClipped, + WRT_InnerRect, + WRT_InnerClipRect, + WRT_WorkRect, + WRT_Content, + WRT_ContentIdeal, + WRT_ContentRegionRect, + WRT_Count + }; // Windows Rect Type + const char *wrt_rects_names[WRT_Count] = {"OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentIdeal", "ContentRegionRect"}; + enum + { + TRT_OuterRect, + TRT_InnerRect, + TRT_WorkRect, + TRT_HostClipRect, + TRT_InnerClipRect, + TRT_BackgroundClipRect, + TRT_ColumnsRect, + TRT_ColumnsWorkRect, + TRT_ColumnsClipRect, + TRT_ColumnsContentHeadersUsed, + TRT_ColumnsContentHeadersIdeal, + TRT_ColumnsContentFrozen, + TRT_ColumnsContentUnfrozen, + TRT_Count + }; // Tables Rect Type + const char *trt_rects_names[TRT_Count] = {"OuterRect", "InnerRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsWorkRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen"}; if (cfg->ShowWindowsRectsType < 0) cfg->ShowWindowsRectsType = WRT_WorkRect; if (cfg->ShowTablesRectsType < 0) @@ -18013,36 +18710,108 @@ void ImGui::ShowMetricsWindow(bool* p_open) struct Funcs { - static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n) - { - ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); // Always using last submitted instance - if (rect_type == TRT_OuterRect) { return table->OuterRect; } - else if (rect_type == TRT_InnerRect) { return table->InnerRect; } - else if (rect_type == TRT_WorkRect) { return table->WorkRect; } - else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; } - else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; } - else if (rect_type == TRT_BackgroundClipRect) { return table->BgClipRect; } - else if (rect_type == TRT_ColumnsRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table_instance->LastOuterHeight); } - else if (rect_type == TRT_ColumnsWorkRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->WorkRect.Min.y, c->WorkMaxX, table->WorkRect.Max.y); } - else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; } - else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight); } // Note: y1/y2 not always accurate - else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight); } - else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight); } - else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); } + static ImRect GetTableRect(ImGuiTable *table, int rect_type, int n) + { + ImGuiTableInstanceData *table_instance = TableGetInstanceData(table, table->InstanceCurrent); // Always using last submitted instance + if (rect_type == TRT_OuterRect) + { + return table->OuterRect; + } + else if (rect_type == TRT_InnerRect) + { + return table->InnerRect; + } + else if (rect_type == TRT_WorkRect) + { + return table->WorkRect; + } + else if (rect_type == TRT_HostClipRect) + { + return table->HostClipRect; + } + else if (rect_type == TRT_InnerClipRect) + { + return table->InnerClipRect; + } + else if (rect_type == TRT_BackgroundClipRect) + { + return table->BgClipRect; + } + else if (rect_type == TRT_ColumnsRect) + { + ImGuiTableColumn *c = &table->Columns[n]; + return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table_instance->LastOuterHeight); + } + else if (rect_type == TRT_ColumnsWorkRect) + { + ImGuiTableColumn *c = &table->Columns[n]; + return ImRect(c->WorkMinX, table->WorkRect.Min.y, c->WorkMaxX, table->WorkRect.Max.y); + } + else if (rect_type == TRT_ColumnsClipRect) + { + ImGuiTableColumn *c = &table->Columns[n]; + return c->ClipRect; + } + else if (rect_type == TRT_ColumnsContentHeadersUsed) + { + ImGuiTableColumn *c = &table->Columns[n]; + return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight); + } // Note: y1/y2 not always accurate + else if (rect_type == TRT_ColumnsContentHeadersIdeal) + { + ImGuiTableColumn *c = &table->Columns[n]; + return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight); + } + else if (rect_type == TRT_ColumnsContentFrozen) + { + ImGuiTableColumn *c = &table->Columns[n]; + return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight); + } + else if (rect_type == TRT_ColumnsContentUnfrozen) + { + ImGuiTableColumn *c = &table->Columns[n]; + return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table_instance->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); + } IM_ASSERT(0); return ImRect(); } - static ImRect GetWindowRect(ImGuiWindow* window, int rect_type) + static ImRect GetWindowRect(ImGuiWindow *window, int rect_type) { - if (rect_type == WRT_OuterRect) { return window->Rect(); } - else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; } - else if (rect_type == WRT_InnerRect) { return window->InnerRect; } - else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; } - else if (rect_type == WRT_WorkRect) { return window->WorkRect; } - else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); } - else if (rect_type == WRT_ContentIdeal) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSizeIdeal); } - else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; } + if (rect_type == WRT_OuterRect) + { + return window->Rect(); + } + else if (rect_type == WRT_OuterRectClipped) + { + return window->OuterRectClipped; + } + else if (rect_type == WRT_InnerRect) + { + return window->InnerRect; + } + else if (rect_type == WRT_InnerClipRect) + { + return window->InnerClipRect; + } + else if (rect_type == WRT_WorkRect) + { + return window->WorkRect; + } + else if (rect_type == WRT_Content) + { + ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; + return ImRect(min, min + window->ContentSize); + } + else if (rect_type == WRT_ContentIdeal) + { + ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; + return ImRect(min, min + window->ContentSizeIdeal); + } + else if (rect_type == WRT_ContentRegionRect) + { + return window->ContentRegionRect; + } IM_ASSERT(0); return ImRect(); } @@ -18105,7 +18874,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) { for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++) { - ImGuiTable* table = g.Tables.TryGetMapData(table_n); + ImGuiTable *table = g.Tables.TryGetMapData(table_n); if (table == NULL || table->LastFrameActive < g.FrameCount - 1 || (table->OuterWindow != g.NavWindow && table->InnerWindow != g.NavWindow)) continue; @@ -18148,19 +18917,22 @@ void ImGui::ShowMetricsWindow(bool* p_open) // Windows if (TreeNode("Windows", "Windows (%d)", g.Windows.Size)) { - //SetNextItemOpen(true, ImGuiCond_Once); + // SetNextItemOpen(true, ImGuiCond_Once); DebugNodeWindowsList(&g.Windows, "By display order"); DebugNodeWindowsList(&g.WindowsFocusOrder, "By focus order (root windows)"); if (TreeNode("By submission order (begin stack)")) { // Here we display windows in their submitted order/hierarchy, however note that the Begin stack doesn't constitute a Parent<>Child relationship! - ImVector& temp_buffer = g.WindowsTempSortBuffer; + ImVector &temp_buffer = g.WindowsTempSortBuffer; temp_buffer.resize(0); for (int i = 0; i < g.Windows.Size; i++) if (g.Windows[i]->LastFrameActive + 1 >= g.FrameCount) temp_buffer.push_back(g.Windows[i]); - struct Func { static int IMGUI_CDECL WindowComparerByBeginOrder(const void* lhs, const void* rhs) { return ((int)(*(const ImGuiWindow* const *)lhs)->BeginOrderWithinContext - (*(const ImGuiWindow* const*)rhs)->BeginOrderWithinContext); } }; - ImQsort(temp_buffer.Data, (size_t)temp_buffer.Size, sizeof(ImGuiWindow*), Func::WindowComparerByBeginOrder); + struct Func + { + static int IMGUI_CDECL WindowComparerByBeginOrder(const void *lhs, const void *rhs) { return ((int)(*(const ImGuiWindow *const *)lhs)->BeginOrderWithinContext - (*(const ImGuiWindow *const *)rhs)->BeginOrderWithinContext); } + }; + ImQsort(temp_buffer.Data, (size_t)temp_buffer.Size, sizeof(ImGuiWindow *), Func::WindowComparerByBeginOrder); DebugNodeWindowsListByBeginStackParent(temp_buffer.Data, temp_buffer.Size, NULL); TreePop(); } @@ -18178,7 +18950,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) Checkbox("Show ImDrawCmd bounding boxes when hovering", &cfg->ShowDrawCmdBoundingBoxes); for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++) { - ImGuiViewportP* viewport = g.Viewports[viewport_i]; + ImGuiViewportP *viewport = g.Viewports[viewport_i]; bool viewport_has_drawlist = false; for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++) for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++) @@ -18206,11 +18978,11 @@ void ImGui::ShowMetricsWindow(bool* p_open) { for (int i = 0; i < g.PlatformIO.Monitors.Size; i++) { - const ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[i]; + const ImGuiPlatformMonitor &mon = g.PlatformIO.Monitors[i]; BulletText("Monitor #%d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)", - i, mon.DpiScale * 100.0f, - mon.MainPos.x, mon.MainPos.y, mon.MainPos.x + mon.MainSize.x, mon.MainPos.y + mon.MainSize.y, mon.MainSize.x, mon.MainSize.y, - mon.WorkPos.x, mon.WorkPos.y, mon.WorkPos.x + mon.WorkSize.x, mon.WorkPos.y + mon.WorkSize.y, mon.WorkSize.x, mon.WorkSize.y); + i, mon.DpiScale * 100.0f, + mon.MainPos.x, mon.MainPos.y, mon.MainPos.x + mon.MainSize.x, mon.MainPos.y + mon.MainSize.y, mon.MainSize.x, mon.MainSize.y, + mon.WorkPos.x, mon.WorkPos.y, mon.WorkPos.x + mon.WorkSize.x, mon.WorkPos.y + mon.WorkSize.y, mon.WorkSize.x, mon.WorkSize.y); } TreePop(); } @@ -18218,11 +18990,11 @@ void ImGui::ShowMetricsWindow(bool* p_open) BulletText("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport ? g.MouseViewport->ID : 0, g.IO.MouseHoveredViewport, g.MouseLastHoveredViewport ? g.MouseLastHoveredViewport->ID : 0); if (TreeNode("Inferred Z order (front-to-back)")) { - static ImVector viewports; + static ImVector viewports; viewports.resize(g.Viewports.Size); memcpy(viewports.Data, g.Viewports.Data, g.Viewports.size_in_bytes()); if (viewports.Size > 1) - ImQsort(viewports.Data, viewports.Size, sizeof(ImGuiViewport*), ViewportComparerByFrontMostStampCount); + ImQsort(viewports.Data, viewports.Size, sizeof(ImGuiViewport *), ViewportComparerByFrontMostStampCount); for (int i = 0; i < viewports.Size; i++) BulletText("Viewport #%d, ID: 0x%08X, FrontMostStampCount = %08d, Window: \"%s\"", viewports[i]->Idx, viewports[i]->ID, viewports[i]->LastFrontMostStampCount, viewports[i]->Window ? viewports[i]->Window->Name : "N/A"); TreePop(); @@ -18239,11 +19011,11 @@ void ImGui::ShowMetricsWindow(bool* p_open) for (int i = 0; i < g.OpenPopupStack.Size; i++) { // As it's difficult to interact with tree nodes while popups are open, we display everything inline. - const ImGuiPopupData* popup_data = &g.OpenPopupStack[i]; - ImGuiWindow* window = popup_data->Window; + const ImGuiPopupData *popup_data = &g.OpenPopupStack[i]; + ImGuiWindow *window = popup_data->Window; BulletText("PopupID: %08x, Window: '%s' (%s%s), BackupNavWindow '%s', ParentWindow '%s'", - popup_data->PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? "Child;" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? "Menu;" : "", - popup_data->BackupNavWindow ? popup_data->BackupNavWindow->Name : "NULL", window && window->ParentWindow ? window->ParentWindow->Name : "NULL"); + popup_data->PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? "Child;" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? "Menu;" : "", + popup_data->BackupNavWindow ? popup_data->BackupNavWindow->Name : "NULL", window && window->ParentWindow ? window->ParentWindow->Name : "NULL"); } TreePop(); } @@ -18252,7 +19024,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) if (TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetAliveCount())) { for (int n = 0; n < g.TabBars.GetMapSize(); n++) - if (ImGuiTabBar* tab_bar = g.TabBars.TryGetMapData(n)) + if (ImGuiTabBar *tab_bar = g.TabBars.TryGetMapData(n)) { PushID(tab_bar); DebugNodeTabBar(tab_bar, "TabBar"); @@ -18265,13 +19037,13 @@ void ImGui::ShowMetricsWindow(bool* p_open) if (TreeNode("Tables", "Tables (%d)", g.Tables.GetAliveCount())) { for (int n = 0; n < g.Tables.GetMapSize(); n++) - if (ImGuiTable* table = g.Tables.TryGetMapData(n)) + if (ImGuiTable *table = g.Tables.TryGetMapData(n)) DebugNodeTable(table); TreePop(); } // Details for Fonts - ImFontAtlas* atlas = g.IO.Fonts; + ImFontAtlas *atlas = g.IO.Fonts; if (TreeNode("Fonts", "Fonts (%d)", atlas->Fonts.Size)) { ShowFontAtlas(atlas); @@ -18290,14 +19062,20 @@ void ImGui::ShowMetricsWindow(bool* p_open) if (TreeNode("Docking")) { static bool root_nodes_only = true; - ImGuiDockContext* dc = &g.DockContext; + ImGuiDockContext *dc = &g.DockContext; Checkbox("List root nodes", &root_nodes_only); Checkbox("Ctrl shows window dock info", &cfg->ShowDockingNodes); - if (SmallButton("Clear nodes")) { DockContextClearNodes(&g, 0, true); } + if (SmallButton("Clear nodes")) + { + DockContextClearNodes(&g, 0, true); + } SameLine(); - if (SmallButton("Rebuild all")) { dc->WantFullRebuild = true; } + if (SmallButton("Rebuild all")) + { + dc->WantFullRebuild = true; + } for (int n = 0; n < dc->Nodes.Data.Size; n++) - if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p) + if (ImGuiDockNode *node = (ImGuiDockNode *)dc->Nodes.Data[n].val_p) if (!root_nodes_only || node->IsRootNode()) DebugNodeDockNode(node, "Node"); TreePop(); @@ -18329,14 +19107,14 @@ void ImGui::ShowMetricsWindow(bool* p_open) } if (TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size())) { - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) DebugNodeWindowSettings(settings); TreePop(); } if (TreeNode("SettingsTables", "Settings packed data: Tables: %d bytes", g.SettingsTables.size())) { - for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) + for (ImGuiTableSettings *settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) DebugNodeTableSettings(settings); TreePop(); } @@ -18344,24 +19122,25 @@ void ImGui::ShowMetricsWindow(bool* p_open) #ifdef IMGUI_HAS_DOCK if (TreeNode("SettingsDocking", "Settings packed data: Docking")) { - ImGuiDockContext* dc = &g.DockContext; + ImGuiDockContext *dc = &g.DockContext; Text("In SettingsWindows:"); - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) + for (ImGuiWindowSettings *settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) if (settings->DockId != 0) BulletText("Window '%s' -> DockId %08X", settings->GetName(), settings->DockId); Text("In SettingsNodes:"); for (int n = 0; n < dc->NodesSettings.Size; n++) { - ImGuiDockNodeSettings* settings = &dc->NodesSettings[n]; - const char* selected_tab_name = NULL; + ImGuiDockNodeSettings *settings = &dc->NodesSettings[n]; + const char *selected_tab_name = NULL; if (settings->SelectedTabId) { - if (ImGuiWindow* window = FindWindowByID(settings->SelectedTabId)) + if (ImGuiWindow *window = FindWindowByID(settings->SelectedTabId)) selected_tab_name = window->Name; - else if (ImGuiWindowSettings* window_settings = FindWindowSettings(settings->SelectedTabId)) + else if (ImGuiWindowSettings *window_settings = FindWindowSettings(settings->SelectedTabId)) selected_tab_name = window_settings->GetName(); } - BulletText("Node %08X, Parent %08X, SelectedTab %08X ('%s')", settings->ID, settings->ParentNodeId, settings->SelectedTabId, selected_tab_name ? selected_tab_name : settings->SelectedTabId ? "N/A" : ""); + BulletText("Node %08X, Parent %08X, SelectedTab %08X ('%s')", settings->ID, settings->ParentNodeId, settings->SelectedTabId, selected_tab_name ? selected_tab_name : settings->SelectedTabId ? "N/A" + : ""); } TreePop(); } @@ -18369,7 +19148,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) if (TreeNode("SettingsIniData", "Settings unpacked data (.ini): %d bytes", g.SettingsIniData.size())) { - InputTextMultiline("##Ini", (char*)(void*)g.SettingsIniData.c_str(), g.SettingsIniData.Buf.Size, ImVec2(-FLT_MIN, GetTextLineHeight() * 20), ImGuiInputTextFlags_ReadOnly); + InputTextMultiline("##Ini", (char *)(void *)g.SettingsIniData.c_str(), g.SettingsIniData.Buf.Size, ImVec2(-FLT_MIN, GetTextLineHeight() * 20), ImGuiInputTextFlags_ReadOnly); TreePop(); } TreePop(); @@ -18423,10 +19202,10 @@ void ImGui::ShowMetricsWindow(bool* p_open) { for (int n = 0; n < g.Windows.Size; n++) { - ImGuiWindow* window = g.Windows[n]; + ImGuiWindow *window = g.Windows[n]; if (!window->WasActive) continue; - ImDrawList* draw_list = GetForegroundDrawList(window); + ImDrawList *draw_list = GetForegroundDrawList(window); if (cfg->ShowWindowsRects) { ImRect r = Funcs::GetWindowRect(window, cfg->ShowWindowsRectsType); @@ -18448,10 +19227,10 @@ void ImGui::ShowMetricsWindow(bool* p_open) { for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++) { - ImGuiTable* table = g.Tables.TryGetMapData(table_n); + ImGuiTable *table = g.Tables.TryGetMapData(table_n); if (table == NULL || table->LastFrameActive < g.FrameCount - 1) continue; - ImDrawList* draw_list = GetForegroundDrawList(table->OuterWindow); + ImDrawList *draw_list = GetForegroundDrawList(table->OuterWindow); if (cfg->ShowTablesRectsType >= TRT_ColumnsRect) { for (int column_n = 0; column_n < table->ColumnsCount; column_n++) @@ -18475,9 +19254,9 @@ void ImGui::ShowMetricsWindow(bool* p_open) if (cfg->ShowDockingNodes && g.IO.KeyCtrl && g.DebugHoveredDockNode) { char buf[64] = ""; - char* p = buf; - ImGuiDockNode* node = g.DebugHoveredDockNode; - ImDrawList* overlay_draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList(GetMainViewport()); + char *p = buf; + ImGuiDockNode *node = g.DebugHoveredDockNode; + ImDrawList *overlay_draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList(GetMainViewport()); p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "DockId: %X%s\n", node->ID, node->IsCentralNode() ? " *CentralNode*" : ""); p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "WindowClass: %08X\n", node->WindowClass.ClassId); p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "Size: (%.0f, %.0f)\n", node->Size.x, node->Size.y); @@ -18494,9 +19273,9 @@ void ImGui::ShowMetricsWindow(bool* p_open) } // [DEBUG] Display contents of Columns -void ImGui::DebugNodeColumns(ImGuiOldColumns* columns) +void ImGui::DebugNodeColumns(ImGuiOldColumns *columns) { - if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) + if (!TreeNode((void *)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) return; BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX); for (int column_n = 0; column_n < columns->Columns.Size; column_n++) @@ -18504,7 +19283,7 @@ void ImGui::DebugNodeColumns(ImGuiOldColumns* columns) TreePop(); } -static void DebugNodeDockNodeFlags(ImGuiDockNodeFlags* p_flags, const char* label, bool enabled) +static void DebugNodeDockNodeFlags(ImGuiDockNodeFlags *p_flags, const char *label, bool enabled) { using namespace ImGui; PushID(label); @@ -18515,7 +19294,7 @@ static void DebugNodeDockNodeFlags(ImGuiDockNodeFlags* p_flags, const char* labe CheckboxFlags("NoSplit", p_flags, ImGuiDockNodeFlags_NoSplit); CheckboxFlags("NoResize", p_flags, ImGuiDockNodeFlags_NoResize); CheckboxFlags("NoResizeX", p_flags, ImGuiDockNodeFlags_NoResizeX); - CheckboxFlags("NoResizeY",p_flags, ImGuiDockNodeFlags_NoResizeY); + CheckboxFlags("NoResizeY", p_flags, ImGuiDockNodeFlags_NoResizeY); CheckboxFlags("NoTabBar", p_flags, ImGuiDockNodeFlags_NoTabBar); CheckboxFlags("HiddenTabBar", p_flags, ImGuiDockNodeFlags_HiddenTabBar); CheckboxFlags("NoWindowMenuButton", p_flags, ImGuiDockNodeFlags_NoWindowMenuButton); @@ -18533,45 +19312,57 @@ static void DebugNodeDockNodeFlags(ImGuiDockNodeFlags* p_flags, const char* labe } // [DEBUG] Display contents of ImDockNode -void ImGui::DebugNodeDockNode(ImGuiDockNode* node, const char* label) +void ImGui::DebugNodeDockNode(ImGuiDockNode *node, const char *label) { - ImGuiContext& g = *GImGui; - const bool is_alive = (g.FrameCount - node->LastFrameAlive < 2); // Submitted with ImGuiDockNodeFlags_KeepAliveOnly - const bool is_active = (g.FrameCount - node->LastFrameActive < 2); // Submitted - if (!is_alive) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } + ImGuiContext &g = *GImGui; + const bool is_alive = (g.FrameCount - node->LastFrameAlive < 2); // Submitted with ImGuiDockNodeFlags_KeepAliveOnly + const bool is_active = (g.FrameCount - node->LastFrameActive < 2); // Submitted + if (!is_alive) + { + PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); + } bool open; ImGuiTreeNodeFlags tree_node_flags = node->IsFocused ? ImGuiTreeNodeFlags_Selected : ImGuiTreeNodeFlags_None; if (node->Windows.Size > 0) - open = TreeNodeEx((void*)(intptr_t)node->ID, tree_node_flags, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL"); + open = TreeNodeEx((void *)(intptr_t)node->ID, tree_node_flags, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL"); else - open = TreeNodeEx((void*)(intptr_t)node->ID, tree_node_flags, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL"); - if (!is_alive) { PopStyleColor(); } + open = TreeNodeEx((void *)(intptr_t)node->ID, tree_node_flags, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" + : "n/a", + node->VisibleWindow ? node->VisibleWindow->Name : "NULL"); + if (!is_alive) + { + PopStyleColor(); + } if (is_active && IsItemHovered()) - if (ImGuiWindow* window = node->HostWindow ? node->HostWindow : node->VisibleWindow) + if (ImGuiWindow *window = node->HostWindow ? node->HostWindow : node->VisibleWindow) GetForegroundDrawList(window)->AddRect(node->Pos, node->Pos + node->Size, IM_COL32(255, 255, 0, 255)); if (open) { IM_ASSERT(node->ChildNodes[0] == NULL || node->ChildNodes[0]->ParentNode == node); IM_ASSERT(node->ChildNodes[1] == NULL || node->ChildNodes[1]->ParentNode == node); BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)", - node->Pos.x, node->Pos.y, node->Size.x, node->Size.y, node->SizeRef.x, node->SizeRef.y); + node->Pos.x, node->Pos.y, node->Size.x, node->Size.y, node->SizeRef.x, node->SizeRef.y); DebugNodeWindow(node->HostWindow, "HostWindow"); DebugNodeWindow(node->VisibleWindow, "VisibleWindow"); BulletText("SelectedTabID: 0x%08X, LastFocusedNodeID: 0x%08X", node->SelectedTabId, node->LastFocusedNodeId); BulletText("Misc:%s%s%s%s%s%s%s", - node->IsDockSpace() ? " IsDockSpace" : "", - node->IsCentralNode() ? " IsCentralNode" : "", - is_alive ? " IsAlive" : "", is_active ? " IsActive" : "", node->IsFocused ? " IsFocused" : "", - node->WantLockSizeOnce ? " WantLockSizeOnce" : "", - node->HasCentralNodeChild ? " HasCentralNodeChild" : ""); + node->IsDockSpace() ? " IsDockSpace" : "", + node->IsCentralNode() ? " IsCentralNode" : "", + is_alive ? " IsAlive" : "", is_active ? " IsActive" : "", node->IsFocused ? " IsFocused" : "", + node->WantLockSizeOnce ? " WantLockSizeOnce" : "", + node->HasCentralNodeChild ? " HasCentralNodeChild" : ""); if (TreeNode("flags", "Flags Merged: 0x%04X, Local: 0x%04X, InWindows: 0x%04X, Shared: 0x%04X", node->MergedFlags, node->LocalFlags, node->LocalFlagsInWindows, node->SharedFlags)) { if (BeginTable("flags", 4)) { - TableNextColumn(); DebugNodeDockNodeFlags(&node->MergedFlags, "MergedFlags", false); - TableNextColumn(); DebugNodeDockNodeFlags(&node->LocalFlags, "LocalFlags", true); - TableNextColumn(); DebugNodeDockNodeFlags(&node->LocalFlagsInWindows, "LocalFlagsInWindows", false); - TableNextColumn(); DebugNodeDockNodeFlags(&node->SharedFlags, "SharedFlags", true); + TableNextColumn(); + DebugNodeDockNodeFlags(&node->MergedFlags, "MergedFlags", false); + TableNextColumn(); + DebugNodeDockNodeFlags(&node->LocalFlags, "LocalFlags", true); + TableNextColumn(); + DebugNodeDockNodeFlags(&node->LocalFlagsInWindows, "LocalFlagsInWindows", false); + TableNextColumn(); + DebugNodeDockNodeFlags(&node->SharedFlags, "SharedFlags", true); EndTable(); } TreePop(); @@ -18592,10 +19383,10 @@ void ImGui::DebugNodeDockNode(ImGuiDockNode* node, const char* label) // [DEBUG] Display contents of ImDrawList // Note that both 'window' and 'viewport' may be NULL here. Viewport is generally null of destroyed popups which previously owned a viewport. -void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label) +void ImGui::DebugNodeDrawList(ImGuiWindow *window, ImGuiViewportP *viewport, const ImDrawList *draw_list, const char *label) { - ImGuiContext& g = *GImGui; - ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; + ImGuiContext &g = *GImGui; + ImGuiMetricsConfig *cfg = &g.DebugMetricsConfig; int cmd_count = draw_list->CmdBuffer.Size; if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) cmd_count--; @@ -18609,7 +19400,7 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con return; } - ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list + ImDrawList *fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list if (window && IsItemHovered() && fg_draw_list) fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); if (!node_open) @@ -18618,7 +19409,7 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con if (window && !window->WasActive) TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); - for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) + for (const ImDrawCmd *pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) { if (pcmd->UserCallback) { @@ -18628,9 +19419,9 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con char buf[300]; ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", - pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId, - pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); - bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); + pcmd->ElemCount / 3, (void *)(intptr_t)pcmd->TextureId, + pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); + bool pcmd_node_open = TreeNode((void *)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); if (!pcmd_node_open) @@ -18638,10 +19429,10 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con // Calculate approximate coverage area (touched pixel count) // This will be in pixels squared as long there's no post-scaling happening to the renderer output. - const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; - const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; + const ImDrawIdx *idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; + const ImDrawVert *vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; float total_area = 0.0f; - for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) + for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount;) { ImVec2 triangle[3]; for (int n = 0; n < 3; n++, idx_n++) @@ -18661,14 +19452,14 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con while (clipper.Step()) for (int prim = clipper.DisplayStart, idx_i = pcmd->IdxOffset + clipper.DisplayStart * 3; prim < clipper.DisplayEnd; prim++) { - char* buf_p = buf, * buf_end = buf + IM_ARRAYSIZE(buf); + char *buf_p = buf, *buf_end = buf + IM_ARRAYSIZE(buf); ImVec2 triangle[3]; for (int n = 0; n < 3; n++, idx_i++) { - const ImDrawVert& v = vtx_buffer[idx_buffer ? idx_buffer[idx_i] : idx_i]; + const ImDrawVert &v = vtx_buffer[idx_buffer ? idx_buffer[idx_i] : idx_i]; triangle[n] = v.pos; buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n", - (n == 0) ? "Vert:" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); + (n == 0) ? "Vert:" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); } Selectable(buf, false); @@ -18686,7 +19477,7 @@ void ImGui::DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, con } // [DEBUG] Display mesh/aabb of a ImDrawCmd -void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb) +void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList *out_draw_list, const ImDrawList *draw_list, const ImDrawCmd *draw_cmd, bool show_mesh, bool show_aabb) { IM_ASSERT(show_mesh || show_aabb); @@ -18695,10 +19486,10 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); ImDrawListFlags backup_flags = out_draw_list->Flags; out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. - for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; ) + for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end;) { - ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; // We don't hold on those pointers past iterations as ->AddPolyline() may invalidate them if out_draw_list==draw_list - ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset; + ImDrawIdx *idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; // We don't hold on those pointers past iterations as ->AddPolyline() may invalidate them if out_draw_list==draw_list + ImDrawVert *vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset; ImVec2 triangle[3]; for (int n = 0; n < 3; n++, idx_n++) @@ -18716,10 +19507,10 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co } // [DEBUG] Display details for a single font, called by ShowStyleEditor(). -void ImGui::DebugNodeFont(ImFont* font) +void ImGui::DebugNodeFont(ImFont *font) { bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)", - font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); + font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); SameLine(); if (SmallButton("Set as default")) GetIO().FontDefault = font; @@ -18734,7 +19525,8 @@ void ImGui::DebugNodeFont(ImFont* font) // Display details SetNextItemWidth(GetFontSize() * 8); DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); - SameLine(); MetricsHelpMarker( + SameLine(); + MetricsHelpMarker( "Note than the default embedded font is NOT meant to be scaled.\n\n" "Font are currently rendered into bitmaps at a given size at the time of building the atlas. " "You may oversample them to get some flexibility with scaling. " @@ -18748,14 +19540,14 @@ void ImGui::DebugNodeFont(ImFont* font) Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt); for (int config_i = 0; config_i < font->ConfigDataCount; config_i++) if (font->ConfigData) - if (const ImFontConfig* cfg = &font->ConfigData[config_i]) + if (const ImFontConfig *cfg = &font->ConfigData[config_i]) BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)", - config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y); + config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y); // Display all glyphs of the fonts in separate pages of 256 characters if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) { - ImDrawList* draw_list = GetWindowDrawList(); + ImDrawList *draw_list = GetWindowDrawList(); const ImU32 glyph_col = GetColorU32(ImGuiCol_Text); const float cell_size = font->FontSize * 1; const float cell_spacing = GetStyle().ItemSpacing.y; @@ -18776,7 +19568,7 @@ void ImGui::DebugNodeFont(ImFont* font) count++; if (count <= 0) continue; - if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) + if (!TreeNode((void *)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) continue; // Draw a 16x16 grid of glyphs @@ -18787,7 +19579,7 @@ void ImGui::DebugNodeFont(ImFont* font) // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string. ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing)); ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size); - const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n)); + const ImFontGlyph *glyph = font->FindGlyphNoFallback((ImWchar)(base + n)); draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50)); if (!glyph) continue; @@ -18807,7 +19599,7 @@ void ImGui::DebugNodeFont(ImFont* font) TreePop(); } -void ImGui::DebugNodeFontGlyph(ImFont*, const ImFontGlyph* glyph) +void ImGui::DebugNodeFontGlyph(ImFont *, const ImFontGlyph *glyph) { Text("Codepoint: U+%04X", glyph->Codepoint); Separator(); @@ -18818,41 +19610,47 @@ void ImGui::DebugNodeFontGlyph(ImFont*, const ImFontGlyph* glyph) } // [DEBUG] Display contents of ImGuiStorage -void ImGui::DebugNodeStorage(ImGuiStorage* storage, const char* label) +void ImGui::DebugNodeStorage(ImGuiStorage *storage, const char *label) { if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes())) return; for (int n = 0; n < storage->Data.Size; n++) { - const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n]; + const ImGuiStorage::ImGuiStoragePair &p = storage->Data[n]; BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer. } TreePop(); } // [DEBUG] Display contents of ImGuiTabBar -void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) +void ImGui::DebugNodeTabBar(ImGuiTabBar *tab_bar, const char *label) { // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. char buf[256]; - char* p = buf; - const char* buf_end = buf + IM_ARRAYSIZE(buf); + char *p = buf; + const char *buf_end = buf + IM_ARRAYSIZE(buf); const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2); p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*"); p += ImFormatString(p, buf_end - p, " { "); for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++) { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + ImGuiTabItem *tab = &tab_bar->Tabs[tab_n]; p += ImFormatString(p, buf_end - p, "%s'%s'", - tab_n > 0 ? ", " : "", (tab->Window || tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???"); + tab_n > 0 ? ", " : "", (tab->Window || tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???"); } p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } "); - if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } + if (!is_active) + { + PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); + } bool open = TreeNode(label, "%s", buf); - if (!is_active) { PopStyleColor(); } + if (!is_active) + { + PopStyleColor(); + } if (is_active && IsItemHovered()) { - ImDrawList* draw_list = GetForegroundDrawList(); + ImDrawList *draw_list = GetForegroundDrawList(); draw_list->AddRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, IM_COL32(255, 255, 0, 255)); draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); @@ -18861,43 +19659,61 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) { for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) { - const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; + const ImGuiTabItem *tab = &tab_bar->Tabs[tab_n]; PushID(tab); - if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2); - if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine(); + if (SmallButton("<")) + { + TabBarQueueReorder(tab_bar, tab, -1); + } + SameLine(0, 2); + if (SmallButton(">")) + { + TabBarQueueReorder(tab_bar, tab, +1); + } + SameLine(); Text("%02d%c Tab 0x%08X '%s' Offset: %.1f, Width: %.1f/%.1f", - tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->Window || tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth); + tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->Window || tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth); PopID(); } TreePop(); } } -void ImGui::DebugNodeViewport(ImGuiViewportP* viewport) +void ImGui::DebugNodeViewport(ImGuiViewportP *viewport) { SetNextItemOpen(true, ImGuiCond_Once); - if (TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A")) + if (TreeNode((void *)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A")) { ImGuiWindowFlags flags = viewport->Flags; BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nWorkArea Offset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f\nMonitor: %d, DpiScale: %.0f%%", - viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, - viewport->WorkOffsetMin.x, viewport->WorkOffsetMin.y, viewport->WorkOffsetMax.x, viewport->WorkOffsetMax.y, - viewport->PlatformMonitor, viewport->DpiScale * 100.0f); - if (viewport->Idx > 0) { SameLine(); if (SmallButton("Reset Pos")) { viewport->Pos = ImVec2(200, 200); viewport->UpdateWorkRect(); if (viewport->Window) viewport->Window->Pos = viewport->Pos; } } + viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, + viewport->WorkOffsetMin.x, viewport->WorkOffsetMin.y, viewport->WorkOffsetMax.x, viewport->WorkOffsetMax.y, + viewport->PlatformMonitor, viewport->DpiScale * 100.0f); + if (viewport->Idx > 0) + { + SameLine(); + if (SmallButton("Reset Pos")) + { + viewport->Pos = ImVec2(200, 200); + viewport->UpdateWorkRect(); + if (viewport->Window) + viewport->Window->Pos = viewport->Pos; + } + } BulletText("Flags: 0x%04X =%s%s%s%s%s%s%s%s%s%s%s%s", viewport->Flags, - //(flags & ImGuiViewportFlags_IsPlatformWindow) ? " IsPlatformWindow" : "", // Omitting because it is the standard - (flags & ImGuiViewportFlags_IsPlatformMonitor) ? " IsPlatformMonitor" : "", - (flags & ImGuiViewportFlags_OwnedByApp) ? " OwnedByApp" : "", - (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "", - (flags & ImGuiViewportFlags_NoTaskBarIcon) ? " NoTaskBarIcon" : "", - (flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", - (flags & ImGuiViewportFlags_NoFocusOnClick) ? " NoFocusOnClick" : "", - (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "", - (flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", - (flags & ImGuiViewportFlags_TopMost) ? " TopMost" : "", - (flags & ImGuiViewportFlags_Minimized) ? " Minimized" : "", - (flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "", - (flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : ""); + //(flags & ImGuiViewportFlags_IsPlatformWindow) ? " IsPlatformWindow" : "", // Omitting because it is the standard + (flags & ImGuiViewportFlags_IsPlatformMonitor) ? " IsPlatformMonitor" : "", + (flags & ImGuiViewportFlags_OwnedByApp) ? " OwnedByApp" : "", + (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "", + (flags & ImGuiViewportFlags_NoTaskBarIcon) ? " NoTaskBarIcon" : "", + (flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", + (flags & ImGuiViewportFlags_NoFocusOnClick) ? " NoFocusOnClick" : "", + (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "", + (flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", + (flags & ImGuiViewportFlags_TopMost) ? " TopMost" : "", + (flags & ImGuiViewportFlags_Minimized) ? " Minimized" : "", + (flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "", + (flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : ""); for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++) for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++) DebugNodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList"); @@ -18905,7 +19721,7 @@ void ImGui::DebugNodeViewport(ImGuiViewportP* viewport) } } -void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) +void ImGui::DebugNodeWindow(ImGuiWindow *window, const char *label) { if (window == NULL) { @@ -18913,12 +19729,18 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) return; } - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const bool is_active = window->WasActive; ImGuiTreeNodeFlags tree_node_flags = (window == g.NavWindow) ? ImGuiTreeNodeFlags_Selected : ImGuiTreeNodeFlags_None; - if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } + if (!is_active) + { + PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); + } const bool open = TreeNodeEx(label, tree_node_flags, "%s '%s'%s", label, window->Name, is_active ? "" : " *Inactive*"); - if (!is_active) { PopStyleColor(); } + if (!is_active) + { + PopStyleColor(); + } if (IsItemHovered() && is_active) GetForegroundDrawList(window)->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); if (!open) @@ -18931,9 +19753,9 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) DebugNodeDrawList(window, window->Viewport, window->DrawList, "DrawList"); BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f) Ideal (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y, window->ContentSizeIdeal.x, window->ContentSizeIdeal.y); BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, - (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" : ""); + (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" : ""); BulletText("WindowClassId: 0x%08X", window->WindowClass.ClassId); 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); @@ -18958,10 +19780,22 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) if (window->DockNode || window->DockNodeAsHost) DebugNodeDockNode(window->DockNodeAsHost ? window->DockNodeAsHost : window->DockNode, window->DockNodeAsHost ? "DockNodeAsHost" : "DockNode"); - if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); } - if (window->RootWindowDockTree != window->RootWindow) { DebugNodeWindow(window->RootWindowDockTree, "RootWindowDockTree"); } - if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); } - if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); } + if (window->RootWindow != window) + { + DebugNodeWindow(window->RootWindow, "RootWindow"); + } + if (window->RootWindowDockTree != window->RootWindow) + { + DebugNodeWindow(window->RootWindowDockTree, "RootWindowDockTree"); + } + if (window->ParentWindow != NULL) + { + DebugNodeWindow(window->ParentWindow, "ParentWindow"); + } + if (window->DC.ChildWindows.Size > 0) + { + DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); + } if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size)) { for (int n = 0; n < window->ColumnsStorage.Size; n++) @@ -18972,13 +19806,13 @@ void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) TreePop(); } -void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings* settings) +void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings *settings) { Text("0x%08X \"%s\" Pos (%d,%d) Size (%d,%d) Collapsed=%d", - settings->ID, settings->GetName(), settings->Pos.x, settings->Pos.y, settings->Size.x, settings->Size.y, settings->Collapsed); + settings->ID, settings->GetName(), settings->Pos.x, settings->Pos.y, settings->Size.x, settings->Size.y, settings->Collapsed); } -void ImGui::DebugNodeWindowsList(ImVector* windows, const char* label) +void ImGui::DebugNodeWindowsList(ImVector *windows, const char *label) { if (!TreeNode(label, "%s (%d)", label, windows->Size)) return; @@ -18992,16 +19826,16 @@ void ImGui::DebugNodeWindowsList(ImVector* windows, const char* la } // FIXME-OPT: This is technically suboptimal, but it is simpler this way. -void ImGui::DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack) +void ImGui::DebugNodeWindowsListByBeginStackParent(ImGuiWindow **windows, int windows_size, ImGuiWindow *parent_in_begin_stack) { for (int i = 0; i < windows_size; i++) { - ImGuiWindow* window = windows[i]; + ImGuiWindow *window = windows[i]; if (window->ParentWindowInBeginStack != parent_in_begin_stack) continue; char buf[20]; ImFormatString(buf, IM_ARRAYSIZE(buf), "[%04d] Window", window->BeginOrderWithinContext); - //BulletText("[%04d] Window '%s'", window->BeginOrderWithinContext, window->Name); + // BulletText("[%04d] Window '%s'", window->BeginOrderWithinContext, window->Name); DebugNodeWindow(window, buf); Indent(); DebugNodeWindowsListByBeginStackParent(windows + i + 1, windows_size - i - 1, window); @@ -19013,7 +19847,7 @@ void ImGui::DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int wi // [SECTION] DEBUG LOG //----------------------------------------------------------------------------- -void ImGui::DebugLog(const char* fmt, ...) +void ImGui::DebugLog(const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -19021,9 +19855,9 @@ void ImGui::DebugLog(const char* fmt, ...) va_end(args); } -void ImGui::DebugLogV(const char* fmt, va_list args) +void ImGui::DebugLogV(const char *fmt, va_list args) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; const int old_size = g.DebugLogBuf.size(); g.DebugLogBuf.appendf("[%05d] ", g.FrameCount); g.DebugLogBuf.appendfv(fmt, args); @@ -19031,9 +19865,9 @@ void ImGui::DebugLogV(const char* fmt, va_list args) IMGUI_DEBUG_PRINTF("%s", g.DebugLogBuf.begin() + old_size); } -void ImGui::ShowDebugLogWindow(bool* p_open) +void ImGui::ShowDebugLogWindow(bool *p_open) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize)) SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 12.0f), ImGuiCond_FirstUseEver); if (!Begin("Dear ImGui Debug Log", p_open) || GetCurrentWindow()->BeginCount > 1) @@ -19044,15 +19878,24 @@ void ImGui::ShowDebugLogWindow(bool* p_open) AlignTextToFramePadding(); Text("Log events:"); - SameLine(); CheckboxFlags("All", &g.DebugLogFlags, ImGuiDebugLogFlags_EventMask_); - SameLine(); CheckboxFlags("ActiveId", &g.DebugLogFlags, ImGuiDebugLogFlags_EventActiveId); - SameLine(); CheckboxFlags("Focus", &g.DebugLogFlags, ImGuiDebugLogFlags_EventFocus); - SameLine(); CheckboxFlags("Popup", &g.DebugLogFlags, ImGuiDebugLogFlags_EventPopup); - SameLine(); CheckboxFlags("Nav", &g.DebugLogFlags, ImGuiDebugLogFlags_EventNav); - SameLine(); CheckboxFlags("Clipper", &g.DebugLogFlags, ImGuiDebugLogFlags_EventClipper); - SameLine(); CheckboxFlags("IO", &g.DebugLogFlags, ImGuiDebugLogFlags_EventIO); - SameLine(); CheckboxFlags("Docking", &g.DebugLogFlags, ImGuiDebugLogFlags_EventDocking); - SameLine(); CheckboxFlags("Viewport", &g.DebugLogFlags, ImGuiDebugLogFlags_EventViewport); + SameLine(); + CheckboxFlags("All", &g.DebugLogFlags, ImGuiDebugLogFlags_EventMask_); + SameLine(); + CheckboxFlags("ActiveId", &g.DebugLogFlags, ImGuiDebugLogFlags_EventActiveId); + SameLine(); + CheckboxFlags("Focus", &g.DebugLogFlags, ImGuiDebugLogFlags_EventFocus); + SameLine(); + CheckboxFlags("Popup", &g.DebugLogFlags, ImGuiDebugLogFlags_EventPopup); + SameLine(); + CheckboxFlags("Nav", &g.DebugLogFlags, ImGuiDebugLogFlags_EventNav); + SameLine(); + CheckboxFlags("Clipper", &g.DebugLogFlags, ImGuiDebugLogFlags_EventClipper); + SameLine(); + CheckboxFlags("IO", &g.DebugLogFlags, ImGuiDebugLogFlags_EventIO); + SameLine(); + CheckboxFlags("Docking", &g.DebugLogFlags, ImGuiDebugLogFlags_EventDocking); + SameLine(); + CheckboxFlags("Viewport", &g.DebugLogFlags, ImGuiDebugLogFlags_EventViewport); if (SmallButton("Clear")) g.DebugLogBuf.clear(); @@ -19075,7 +19918,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open) // [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. void ImGui::UpdateDebugToolItemPicker() { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; g.DebugItemPickerBreakId = 0; if (!g.DebugItemPickerActive) return; @@ -19097,7 +19940,7 @@ void ImGui::UpdateDebugToolItemPicker() BeginTooltip(); Text("HoveredId: 0x%08X", hovered_id); Text("Press ESC to abort picking."); - const char* mouse_button_names[] = { "Left", "Right", "Middle" }; + const char *mouse_button_names[] = {"Left", "Right", "Middle"}; if (change_mapping) Text("Remap w/ Ctrl+Shift: click anywhere to select new mouse button."); else @@ -19108,8 +19951,8 @@ void ImGui::UpdateDebugToolItemPicker() // [DEBUG] Stack Tool: update queries. Called by NewFrame() void ImGui::UpdateDebugToolStackQueries() { - ImGuiContext& g = *GImGui; - ImGuiStackTool* tool = &g.DebugStackTool; + ImGuiContext &g = *GImGui; + ImGuiStackTool *tool = &g.DebugStackTool; // Clear hook when stack tool is not visible g.DebugHookIdInfo = 0; @@ -19146,11 +19989,11 @@ void ImGui::UpdateDebugToolStackQueries() } // [DEBUG] Stack tool: hooks called by GetID() family functions -void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end) +void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void *data_id, const void *data_id_end) { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiStackTool* tool = &g.DebugStackTool; + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + ImGuiStackTool *tool = &g.DebugStackTool; // Step 0: stack query // This assume that the ID was computed with the current ID stack, which tends to be the case for our widget. @@ -19167,7 +20010,7 @@ void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* dat IM_ASSERT(tool->StackLevel >= 0); if (tool->StackLevel != window->IDStack.Size) return; - ImGuiStackLevelInfo* info = &tool->Results[tool->StackLevel]; + ImGuiStackLevelInfo *info = &tool->Results[tool->StackLevel]; IM_ASSERT(info->ID == id && info->QueryFrameCount > 0); switch (data_type) @@ -19176,7 +20019,7 @@ void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* dat ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%d", (int)(intptr_t)data_id); break; case ImGuiDataType_String: - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%.*s", data_id_end ? (int)((const char*)data_id_end - (const char*)data_id) : (int)strlen((const char*)data_id), (const char*)data_id); + ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%.*s", data_id_end ? (int)((const char *)data_id_end - (const char *)data_id) : (int)strlen((const char *)data_id), (const char *)data_id); break; case ImGuiDataType_Pointer: ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "(void*)0x%p", data_id); @@ -19193,27 +20036,27 @@ void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* dat info->DataType = data_type; } -static int StackToolFormatLevelInfo(ImGuiStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size) +static int StackToolFormatLevelInfo(ImGuiStackTool *tool, int n, bool format_for_ui, char *buf, size_t buf_size) { - ImGuiStackLevelInfo* info = &tool->Results[n]; - ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL; - if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked) + ImGuiStackLevelInfo *info = &tool->Results[n]; + ImGuiWindow *window = (info->Desc[0] == 0 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL; + if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked) return ImFormatString(buf, buf_size, format_for_ui ? "\"%s\" [window]" : "%s", window->Name); - if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id) + if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id) return ImFormatString(buf, buf_size, (format_for_ui && info->DataType == ImGuiDataType_String) ? "\"%s\"" : "%s", info->Desc); - if (tool->StackLevel < tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers. + if (tool->StackLevel < tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers. return (*buf = 0); #ifdef IMGUI_ENABLE_TEST_ENGINE - if (const char* label = ImGuiTestEngine_FindItemDebugLabel(GImGui, info->ID)) // Source: ImGuiTestEngine's ItemInfo() + if (const char *label = ImGuiTestEngine_FindItemDebugLabel(GImGui, info->ID)) // Source: ImGuiTestEngine's ItemInfo() return ImFormatString(buf, buf_size, format_for_ui ? "??? \"%s\"" : "%s", label); #endif return ImFormatString(buf, buf_size, "???"); } // Stack Tool: Display UI -void ImGui::ShowStackToolWindow(bool* p_open) +void ImGui::ShowStackToolWindow(bool *p_open) { - ImGuiContext& g = *GImGui; + ImGuiContext &g = *GImGui; if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize)) SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver); if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) @@ -19223,7 +20066,7 @@ void ImGui::ShowStackToolWindow(bool* p_open) } // Display hovered/active status - ImGuiStackTool* tool = &g.DebugStackTool; + ImGuiStackTool *tool = &g.DebugStackTool; const ImGuiID hovered_id = g.HoveredIdPreviousFrame; const ImGuiID active_id = g.ActiveId; #ifdef IMGUI_ENABLE_TEST_ENGINE @@ -19242,8 +20085,8 @@ void ImGui::ShowStackToolWindow(bool* p_open) if (tool->CopyToClipboardOnCtrlC && IsKeyDown(ImGuiKey_ModCtrl) && IsKeyPressed(ImGuiKey_C)) { tool->CopyToClipboardLastTime = (float)g.Time; - char* p = g.TempBuffer.Data; - char* p_end = p + g.TempBuffer.Size; + char *p = g.TempBuffer.Data; + char *p_end = p + g.TempBuffer.Size; for (int stack_n = 0; stack_n < tool->Results.Size && p + 3 < p_end; stack_n++) { *p++ = '/'; @@ -19271,7 +20114,7 @@ void ImGui::ShowStackToolWindow(bool* p_open) TableHeadersRow(); for (int n = 0; n < tool->Results.Size; n++) { - ImGuiStackLevelInfo* info = &tool->Results[n]; + ImGuiStackLevelInfo *info = &tool->Results[n]; TableNextColumn(); Text("0x%08X", (n > 0) ? tool->Results[n - 1].ID : 0); TableNextColumn(); @@ -19289,24 +20132,26 @@ void ImGui::ShowStackToolWindow(bool* p_open) #else -void ImGui::ShowMetricsWindow(bool*) {} -void ImGui::ShowFontAtlas(ImFontAtlas*) {} -void ImGui::DebugNodeColumns(ImGuiOldColumns*) {} -void ImGui::DebugNodeDrawList(ImGuiWindow*, ImGuiViewportP*, const ImDrawList*, const char*) {} -void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList*, const ImDrawList*, const ImDrawCmd*, bool, bool) {} -void ImGui::DebugNodeFont(ImFont*) {} -void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {} -void ImGui::DebugNodeTabBar(ImGuiTabBar*, const char*) {} -void ImGui::DebugNodeWindow(ImGuiWindow*, const char*) {} -void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings*) {} -void ImGui::DebugNodeWindowsList(ImVector*, const char*) {} -void ImGui::DebugNodeViewport(ImGuiViewportP*) {} - -void ImGui::DebugLog(const char*, ...) {} -void ImGui::DebugLogV(const char*, va_list) {} -void ImGui::ShowDebugLogWindow(bool*) {} -void ImGui::ShowStackToolWindow(bool*) {} -void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void*, const void*) {} +void ImGui::ShowMetricsWindow(bool *) +{ +} +void ImGui::ShowFontAtlas(ImFontAtlas *) {} +void ImGui::DebugNodeColumns(ImGuiOldColumns *) {} +void ImGui::DebugNodeDrawList(ImGuiWindow *, ImGuiViewportP *, const ImDrawList *, const char *) {} +void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList *, const ImDrawList *, const ImDrawCmd *, bool, bool) {} +void ImGui::DebugNodeFont(ImFont *) {} +void ImGui::DebugNodeStorage(ImGuiStorage *, const char *) {} +void ImGui::DebugNodeTabBar(ImGuiTabBar *, const char *) {} +void ImGui::DebugNodeWindow(ImGuiWindow *, const char *) {} +void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings *) {} +void ImGui::DebugNodeWindowsList(ImVector *, const char *) {} +void ImGui::DebugNodeViewport(ImGuiViewportP *) {} + +void ImGui::DebugLog(const char *, ...) {} +void ImGui::DebugLogV(const char *, va_list) {} +void ImGui::ShowDebugLogWindow(bool *) {} +void ImGui::ShowStackToolWindow(bool *) {} +void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void *, const void *) {} void ImGui::UpdateDebugToolItemPicker() {} void ImGui::UpdateDebugToolStackQueries() {}