|
@@ -1044,6 +1044,7 @@ static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time
|
|
|
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
|
|
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
|
|
|
static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
|
|
static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. 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_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 certaint time, unless mouse moved.
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
//-------------------------------------------------------------------------
|
|
|
// [SECTION] FORWARD DECLARATIONS
|
|
// [SECTION] FORWARD DECLARATIONS
|
|
@@ -1091,6 +1092,7 @@ static int FindWindowFocusIndex(ImGuiWindow* window);
|
|
|
static void UpdateMouseInputs();
|
|
static void UpdateMouseInputs();
|
|
|
static void UpdateMouseWheel();
|
|
static void UpdateMouseWheel();
|
|
|
static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
|
static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
|
|
|
|
+static void UpdateDebugToolItemPicker();
|
|
|
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
|
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
|
|
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
|
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, 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 RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
|
@@ -3466,19 +3468,45 @@ static void ImGui::UpdateMouseInputs()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void ImGui::UpdateMouseWheel()
|
|
|
|
|
|
|
+static void StartLockWheelingWindow(ImGuiWindow* window)
|
|
|
{
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
- if (!g.HoveredWindow || g.HoveredWindow->Collapsed)
|
|
|
|
|
|
|
+ if (g.WheelingWindow == window)
|
|
|
return;
|
|
return;
|
|
|
|
|
+ g.WheelingWindow = window;
|
|
|
|
|
+ g.WheelingWindowRefMousePos = g.IO.MousePos;
|
|
|
|
|
+ g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void ImGui::UpdateMouseWheel()
|
|
|
|
|
+{
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
|
+
|
|
|
|
|
+ // Reset the locked window if we move the mouse or after the timer elapses
|
|
|
|
|
+ if (g.WheelingWindow != NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ g.WheelingWindowTimer -= g.IO.DeltaTime;
|
|
|
|
|
+ if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold)
|
|
|
|
|
+ g.WheelingWindowTimer = 0.0f;
|
|
|
|
|
+ if (g.WheelingWindowTimer <= 0.0f)
|
|
|
|
|
+ {
|
|
|
|
|
+ g.WheelingWindow = NULL;
|
|
|
|
|
+ g.WheelingWindowTimer = 0.0f;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f)
|
|
if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
|
|
+ ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
|
|
|
|
|
+ if (!window || window->Collapsed)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
// Zoom / Scale window
|
|
// Zoom / Scale window
|
|
|
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
|
|
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
|
|
|
if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
|
|
if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
|
|
|
{
|
|
{
|
|
|
- ImGuiWindow* window = g.HoveredWindow;
|
|
|
|
|
|
|
+ StartLockWheelingWindow(window);
|
|
|
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
|
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
|
|
|
const float scale = new_font_scale / window->FontWindowScale;
|
|
const float scale = new_font_scale / window->FontWindowScale;
|
|
|
window->FontWindowScale = new_font_scale;
|
|
window->FontWindowScale = new_font_scale;
|
|
@@ -3494,20 +3522,19 @@ void ImGui::UpdateMouseWheel()
|
|
|
|
|
|
|
|
// Mouse wheel scrolling
|
|
// Mouse wheel scrolling
|
|
|
// If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent
|
|
// If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent
|
|
|
- // FIXME: Lock scrolling window while not moving (see #2604)
|
|
|
|
|
|
|
|
|
|
// Vertical Mouse Wheel scrolling
|
|
// Vertical Mouse Wheel scrolling
|
|
|
const float wheel_y = (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
|
|
const float wheel_y = (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
|
|
|
if (wheel_y != 0.0f && !g.IO.KeyCtrl)
|
|
if (wheel_y != 0.0f && !g.IO.KeyCtrl)
|
|
|
{
|
|
{
|
|
|
- ImGuiWindow* window = g.HoveredWindow;
|
|
|
|
|
|
|
+ StartLockWheelingWindow(window);
|
|
|
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
|
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
|
|
window = window->ParentWindow;
|
|
window = window->ParentWindow;
|
|
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
|
{
|
|
{
|
|
|
float max_step = window->InnerRect.GetHeight() * 0.67f;
|
|
float max_step = window->InnerRect.GetHeight() * 0.67f;
|
|
|
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
|
|
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
|
|
|
- SetWindowScrollY(window, window->Scroll.y - wheel_y * scroll_step);
|
|
|
|
|
|
|
+ SetScrollY(window, window->Scroll.y - wheel_y * scroll_step);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -3515,14 +3542,14 @@ void ImGui::UpdateMouseWheel()
|
|
|
const float wheel_x = (g.IO.MouseWheelH != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheelH : (g.IO.MouseWheel != 0.0f && g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
|
|
const float wheel_x = (g.IO.MouseWheelH != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheelH : (g.IO.MouseWheel != 0.0f && g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
|
|
|
if (wheel_x != 0.0f && !g.IO.KeyCtrl)
|
|
if (wheel_x != 0.0f && !g.IO.KeyCtrl)
|
|
|
{
|
|
{
|
|
|
- ImGuiWindow* window = g.HoveredWindow;
|
|
|
|
|
|
|
+ StartLockWheelingWindow(window);
|
|
|
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
|
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
|
|
|
window = window->ParentWindow;
|
|
window = window->ParentWindow;
|
|
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
|
|
|
{
|
|
{
|
|
|
float max_step = window->InnerRect.GetWidth() * 0.67f;
|
|
float max_step = window->InnerRect.GetWidth() * 0.67f;
|
|
|
float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step));
|
|
float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step));
|
|
|
- SetWindowScrollX(window, window->Scroll.x - wheel_x * scroll_step);
|
|
|
|
|
|
|
+ SetScrollX(window, window->Scroll.x - wheel_x * scroll_step);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -3586,15 +3613,10 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|
|
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
|
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void ImGui::NewFrame()
|
|
|
|
|
|
|
+static void NewFrameSanityChecks()
|
|
|
{
|
|
{
|
|
|
- IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
|
|
-#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
|
|
|
- ImGuiTestEngineHook_PreNewFrame(&g);
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
// Check user data
|
|
// 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)
|
|
// (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.Initialized);
|
|
@@ -3607,7 +3629,6 @@ void ImGui::NewFrame()
|
|
|
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
|
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (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.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
|
|
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
|
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
|
|
-
|
|
|
|
|
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
|
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
|
|
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
|
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
|
|
|
|
|
|
@@ -3618,6 +3639,19 @@ void ImGui::NewFrame()
|
|
|
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
|
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
|
|
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
|
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
|
|
g.IO.ConfigWindowsResizeFromEdges = false;
|
|
g.IO.ConfigWindowsResizeFromEdges = false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void ImGui::NewFrame()
|
|
|
|
|
+{
|
|
|
|
|
+ IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
|
+
|
|
|
|
|
+#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
|
|
|
+ ImGuiTestEngineHook_PreNewFrame(&g);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+ // Check and assert for various common IO and Configuration mistakes
|
|
|
|
|
+ NewFrameSanityChecks();
|
|
|
|
|
|
|
|
// Load settings on first frame (if not explicitly loaded manually before)
|
|
// Load settings on first frame (if not explicitly loaded manually before)
|
|
|
if (!g.SettingsLoaded)
|
|
if (!g.SettingsLoaded)
|
|
@@ -3800,6 +3834,24 @@ void ImGui::NewFrame()
|
|
|
ClosePopupsOverWindow(g.NavWindow, false);
|
|
ClosePopupsOverWindow(g.NavWindow, false);
|
|
|
|
|
|
|
|
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
|
|
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
|
|
|
|
|
+ UpdateDebugToolItemPicker();
|
|
|
|
|
+
|
|
|
|
|
+ // Create implicit/fallback window - which we will only render it if the user has added something to it.
|
|
|
|
|
+ // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
|
|
|
|
+ // This fallback is particularly important as it avoid ImGui:: calls from crashing.
|
|
|
|
|
+ SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
|
|
|
|
+ Begin("Debug##Default");
|
|
|
|
|
+ g.FrameScopePushedImplicitWindow = true;
|
|
|
|
|
+
|
|
|
|
|
+#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
|
|
|
+ ImGuiTestEngineHook_PostNewFrame(&g);
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// [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;
|
|
|
g.DebugItemPickerBreakID = 0;
|
|
g.DebugItemPickerBreakID = 0;
|
|
|
if (g.DebugItemPickerActive)
|
|
if (g.DebugItemPickerActive)
|
|
|
{
|
|
{
|
|
@@ -3819,17 +3871,6 @@ void ImGui::NewFrame()
|
|
|
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
|
|
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
|
|
|
ImGui::EndTooltip();
|
|
ImGui::EndTooltip();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // Create implicit/fallback window - which we will only render it if the user has added something to it.
|
|
|
|
|
- // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
|
|
|
|
- // This fallback is particularly important as it avoid ImGui:: calls from crashing.
|
|
|
|
|
- SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
|
|
|
|
- Begin("Debug##Default");
|
|
|
|
|
- g.FrameScopePushedImplicitWindow = true;
|
|
|
|
|
-
|
|
|
|
|
-#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
|
|
|
- ImGuiTestEngineHook_PostNewFrame(&g);
|
|
|
|
|
-#endif
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ImGui::Initialize(ImGuiContext* context)
|
|
void ImGui::Initialize(ImGuiContext* context)
|
|
@@ -5583,7 +5624,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
|
|
|
|
|
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0);
|
|
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0);
|
|
|
if (window_pos_with_pivot)
|
|
if (window_pos_with_pivot)
|
|
|
- SetWindowPos(window, ImMax(style.DisplaySafeAreaPadding, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot), 0); // Position given a pivot (e.g. for centering)
|
|
|
|
|
|
|
+ SetWindowPos(window, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot, 0); // Position given a pivot (e.g. for centering)
|
|
|
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
|
|
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
|
|
|
window->Pos = FindBestWindowPosForPopup(window);
|
|
window->Pos = FindBestWindowPosForPopup(window);
|
|
|
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
|
|
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
|
|
@@ -5743,6 +5784,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
if (render_decorations_in_parent)
|
|
if (render_decorations_in_parent)
|
|
|
window->DrawList = parent_window->DrawList;
|
|
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);
|
|
const bool title_bar_is_highlight = want_focus || (window_to_highlight && window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight);
|
|
|
RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size);
|
|
RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size);
|
|
@@ -6510,16 +6552,6 @@ ImVec2 ImGui::GetWindowPos()
|
|
|
return window->Pos;
|
|
return window->Pos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void ImGui::SetWindowScrollX(ImGuiWindow* window, float new_scroll_x)
|
|
|
|
|
-{
|
|
|
|
|
- window->Scroll.x = new_scroll_x;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void ImGui::SetWindowScrollY(ImGuiWindow* window, float new_scroll_y)
|
|
|
|
|
-{
|
|
|
|
|
- window->Scroll.y = new_scroll_y;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
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
|
|
// Test condition (NB: bit 0 is always true) and clear flags for next time
|
|
@@ -6907,6 +6939,18 @@ void ImGui::SetScrollY(float scroll_y)
|
|
|
window->ScrollTargetCenterRatio.y = 0.0f;
|
|
window->ScrollTargetCenterRatio.y = 0.0f;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x)
|
|
|
|
|
+{
|
|
|
|
|
+ window->ScrollTarget.x = new_scroll_x;
|
|
|
|
|
+ window->ScrollTargetCenterRatio.x = 0.0f;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y)
|
|
|
|
|
+{
|
|
|
|
|
+ window->ScrollTarget.y = new_scroll_y;
|
|
|
|
|
+ window->ScrollTargetCenterRatio.y = 0.0f;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
|
|
void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
|
|
|
{
|
|
{
|
|
|
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
|
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
|
@@ -8319,9 +8363,9 @@ static void ImGui::NavUpdate()
|
|
|
if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest)
|
|
if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest)
|
|
|
{
|
|
{
|
|
|
if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right)
|
|
if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right)
|
|
|
- SetWindowScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
|
|
|
|
|
|
|
+ SetScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
|
|
|
if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down)
|
|
if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down)
|
|
|
- SetWindowScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed));
|
|
|
|
|
|
|
+ SetScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// *Normal* Manual scroll with NavScrollXXX keys
|
|
// *Normal* Manual scroll with NavScrollXXX keys
|
|
@@ -8329,12 +8373,12 @@ static void ImGui::NavUpdate()
|
|
|
ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f);
|
|
ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f);
|
|
|
if (scroll_dir.x != 0.0f && window->ScrollbarX)
|
|
if (scroll_dir.x != 0.0f && window->ScrollbarX)
|
|
|
{
|
|
{
|
|
|
- SetWindowScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
|
|
|
|
|
|
|
+ SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
|
|
|
g.NavMoveFromClampedRefRect = true;
|
|
g.NavMoveFromClampedRefRect = true;
|
|
|
}
|
|
}
|
|
|
if (scroll_dir.y != 0.0f)
|
|
if (scroll_dir.y != 0.0f)
|
|
|
{
|
|
{
|
|
|
- SetWindowScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed));
|
|
|
|
|
|
|
+ SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed));
|
|
|
g.NavMoveFromClampedRefRect = true;
|
|
g.NavMoveFromClampedRefRect = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -8438,42 +8482,44 @@ static void ImGui::NavUpdateMoveResult()
|
|
|
static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags)
|
|
static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags)
|
|
|
{
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
- if (g.NavMoveDir == ImGuiDir_None && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget && g.NavLayer == 0)
|
|
|
|
|
|
|
+ if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL)
|
|
|
|
|
+ return 0.0f;
|
|
|
|
|
+ if ((g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != 0)
|
|
|
|
|
+ return 0.0f;
|
|
|
|
|
+
|
|
|
|
|
+ ImGuiWindow* window = g.NavWindow;
|
|
|
|
|
+ bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && (allowed_dir_flags & (1 << ImGuiDir_Up));
|
|
|
|
|
+ bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && (allowed_dir_flags & (1 << ImGuiDir_Down));
|
|
|
|
|
+ if (page_up_held != page_down_held) // If either (not both) are pressed
|
|
|
{
|
|
{
|
|
|
- ImGuiWindow* window = g.NavWindow;
|
|
|
|
|
- bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && (allowed_dir_flags & (1 << ImGuiDir_Up));
|
|
|
|
|
- bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && (allowed_dir_flags & (1 << ImGuiDir_Down));
|
|
|
|
|
- if (page_up_held != page_down_held) // If either (not both) are pressed
|
|
|
|
|
|
|
+ if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Fallback manual-scroll when window has no navigable item
|
|
|
|
|
+ if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
|
|
|
|
|
+ SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight());
|
|
|
|
|
+ else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
|
|
|
|
|
+ SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight());
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll)
|
|
|
|
|
|
|
+ const 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(g.IO.KeyMap[ImGuiKey_PageUp], true))
|
|
|
{
|
|
{
|
|
|
- // Fallback manual-scroll when window has no navigable item
|
|
|
|
|
- if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
|
|
|
|
|
- SetWindowScrollY(window, window->Scroll.y - window->InnerRect.GetHeight());
|
|
|
|
|
- else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
|
|
|
|
|
- SetWindowScrollY(window, window->Scroll.y + window->InnerRect.GetHeight());
|
|
|
|
|
|
|
+ nav_scoring_rect_offset_y = -page_offset_y;
|
|
|
|
|
+ g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
|
|
|
|
|
+ g.NavMoveClipDir = ImGuiDir_Up;
|
|
|
|
|
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
|
|
|
{
|
|
{
|
|
|
- const 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(g.IO.KeyMap[ImGuiKey_PageUp], true))
|
|
|
|
|
- {
|
|
|
|
|
- nav_scoring_rect_offset_y = -page_offset_y;
|
|
|
|
|
- g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
|
|
|
|
|
- g.NavMoveClipDir = ImGuiDir_Up;
|
|
|
|
|
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
|
|
|
|
- }
|
|
|
|
|
- else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
|
|
|
|
|
- {
|
|
|
|
|
- nav_scoring_rect_offset_y = +page_offset_y;
|
|
|
|
|
- g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
|
|
|
|
|
- g.NavMoveClipDir = ImGuiDir_Down;
|
|
|
|
|
- g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
|
|
|
|
- }
|
|
|
|
|
- return nav_scoring_rect_offset_y;
|
|
|
|
|
|
|
+ nav_scoring_rect_offset_y = +page_offset_y;
|
|
|
|
|
+ g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
|
|
|
|
|
+ g.NavMoveClipDir = ImGuiDir_Down;
|
|
|
|
|
+ g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
|
|
}
|
|
}
|
|
|
|
|
+ return nav_scoring_rect_offset_y;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return 0.0f;
|
|
return 0.0f;
|
|
@@ -9491,12 +9537,13 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
|
::CloseClipboard();
|
|
::CloseClipboard();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#elif defined(__APPLE__) && TARGET_OS_OSX && !defined(IMGUI_DISABLE_OSX_FUNCTIONS)
|
|
|
|
|
|
|
+#elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS)
|
|
|
|
|
|
|
|
#include <Carbon/Carbon.h> // Use old API to avoid need for separate .mm file
|
|
#include <Carbon/Carbon.h> // Use old API to avoid need for separate .mm file
|
|
|
static PasteboardRef main_clipboard = 0;
|
|
static PasteboardRef main_clipboard = 0;
|
|
|
|
|
|
|
|
// OSX clipboard implementation
|
|
// 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)
|
|
if (!main_clipboard)
|