mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Windows: store BgClickFlags which allows the equivalent of io.ConfigWindowsMoveFromTitleBarOnly to be overridden on a per window basis. (#899, #3071, #5044, + #3379)
io.ConfigWindowsMoveFromTitleBarOnly now sets initial value for BgClickFlags. Using e.g. ImGui::GetCurrentWindow()->BgClickFlags &= ~ImGuiWindowBgClickFlags_Move; allow per-window override. This will be extended for supporting scrolling options for #3379. As a minor side effect: the effect of enabling io.ConfigWindowsMoveFromTitleBarOnly now happens one frame later ('window_modal_bounds_exceeding_work_area" test accidentally broke in some situations because of that)
This commit is contained in:
parent
245e12cca7
commit
40f9e4e8e2
2 changed files with 16 additions and 4 deletions
12
imgui.cpp
12
imgui.cpp
|
|
@ -5217,7 +5217,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
||||||
// Please note how StartMouseMovingWindow() and StopMouseMovingWindow() and not entirely symetrical, at the later doesn't clear ActiveId.
|
// Please note how StartMouseMovingWindow() and StopMouseMovingWindow() and not entirely symetrical, at the later doesn't clear ActiveId.
|
||||||
|
|
||||||
// Cancel moving if clicked outside of title bar
|
// Cancel moving if clicked outside of title bar
|
||||||
if (g.IO.ConfigWindowsMoveFromTitleBarOnly)
|
if ((hovered_window->BgClickFlags & ImGuiWindowBgClickFlags_Move) == 0) // set by io.ConfigWindowsMoveFromTitleBarOnly
|
||||||
if (!(hovered_root->Flags & ImGuiWindowFlags_NoTitleBar))
|
if (!(hovered_root->Flags & ImGuiWindowFlags_NoTitleBar))
|
||||||
if (!hovered_root->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
if (!hovered_root->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
||||||
g.MovingWindow = NULL;
|
g.MovingWindow = NULL;
|
||||||
|
|
@ -6768,7 +6768,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
||||||
const float grip_hover_outer_size = g.WindowsBorderHoverPadding;
|
const float grip_hover_outer_size = g.WindowsBorderHoverPadding;
|
||||||
|
|
||||||
ImRect clamp_rect = visibility_rect;
|
ImRect clamp_rect = visibility_rect;
|
||||||
const bool window_move_from_title_bar = g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar);
|
const bool window_move_from_title_bar = !(window->BgClickFlags & ImGuiWindowBgClickFlags_Move) && !(window->Flags & ImGuiWindowFlags_NoTitleBar);
|
||||||
if (window_move_from_title_bar)
|
if (window_move_from_title_bar)
|
||||||
clamp_rect.Min.y -= window->TitleBarHeight;
|
clamp_rect.Min.y -= window->TitleBarHeight;
|
||||||
|
|
||||||
|
|
@ -6957,9 +6957,8 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
||||||
|
|
||||||
static inline void ClampWindowPos(ImGuiWindow* window, const ImRect& visibility_rect)
|
static inline void ClampWindowPos(ImGuiWindow* window, const ImRect& visibility_rect)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
ImVec2 size_for_clamping = window->Size;
|
ImVec2 size_for_clamping = window->Size;
|
||||||
if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar))
|
if (!(window->BgClickFlags & ImGuiWindowBgClickFlags_Move) && !(window->Flags & ImGuiWindowFlags_NoTitleBar))
|
||||||
size_for_clamping.y = window->TitleBarHeight;
|
size_for_clamping.y = window->TitleBarHeight;
|
||||||
window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max);
|
window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max);
|
||||||
}
|
}
|
||||||
|
|
@ -7928,6 +7927,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||||
if (flags & ImGuiWindowFlags_Tooltip)
|
if (flags & ImGuiWindowFlags_Tooltip)
|
||||||
g.TooltipPreviousWindow = window;
|
g.TooltipPreviousWindow = window;
|
||||||
|
|
||||||
|
// Set default BgClickFlags
|
||||||
|
// This is set at the end of this function, so UpdateManualResize()/ClampWindowPos() may use last-frame value if overriden by user code.
|
||||||
|
// FIXME: The general intent is that we will later expose config options to default to enable scrolling + select scrolling mouse button.
|
||||||
|
window->BgClickFlags = g.IO.ConfigWindowsMoveFromTitleBarOnly ? ImGuiWindowBgClickFlags_None : ImGuiWindowBgClickFlags_Move;
|
||||||
|
|
||||||
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
|
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
|
||||||
// This is useful to allow creating context menus on title bar only, etc.
|
// This is useful to allow creating context menus on title bar only, etc.
|
||||||
window->DC.WindowItemStatusFlags = ImGuiItemStatusFlags_None;
|
window->DC.WindowItemStatusFlags = ImGuiItemStatusFlags_None;
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,7 @@ typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // F
|
||||||
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
||||||
typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
|
typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
|
||||||
typedef int ImGuiTypingSelectFlags; // -> enum ImGuiTypingSelectFlags_ // Flags: for GetTypingSelectRequest()
|
typedef int ImGuiTypingSelectFlags; // -> enum ImGuiTypingSelectFlags_ // Flags: for GetTypingSelectRequest()
|
||||||
|
typedef int ImGuiWindowBgClickFlags; // -> enum ImGuiWindowBgClickFlags_ // Flags: for overriding behavior of clicking on window background/void.
|
||||||
typedef int ImGuiWindowRefreshFlags; // -> enum ImGuiWindowRefreshFlags_ // Flags: for SetNextWindowRefreshPolicy()
|
typedef int ImGuiWindowRefreshFlags; // -> enum ImGuiWindowRefreshFlags_ // Flags: for SetNextWindowRefreshPolicy()
|
||||||
|
|
||||||
// Table column indexing
|
// Table column indexing
|
||||||
|
|
@ -1283,6 +1284,12 @@ enum ImGuiWindowRefreshFlags_
|
||||||
// Refresh policy/frequency, Load Balancing etc.
|
// Refresh policy/frequency, Load Balancing etc.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiWindowBgClickFlags_
|
||||||
|
{
|
||||||
|
ImGuiWindowBgClickFlags_None = 0,
|
||||||
|
ImGuiWindowBgClickFlags_Move = 1 << 0, // Click on bg/void + drag to move window. Cleared by default when using io.ConfigWindowsMoveFromTitleBarOnly.
|
||||||
|
};
|
||||||
|
|
||||||
enum ImGuiNextWindowDataFlags_
|
enum ImGuiNextWindowDataFlags_
|
||||||
{
|
{
|
||||||
ImGuiNextWindowDataFlags_None = 0,
|
ImGuiNextWindowDataFlags_None = 0,
|
||||||
|
|
@ -2662,6 +2669,7 @@ struct IMGUI_API ImGuiWindow
|
||||||
ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
|
ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
|
||||||
ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only
|
ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only
|
||||||
ImS8 DisableInputsFrames; // Disable window interactions for N frames
|
ImS8 DisableInputsFrames; // Disable window interactions for N frames
|
||||||
|
ImGuiWindowBgClickFlags BgClickFlags : 8; // Configure behavior of click+dragging on window bg/void or over items. Default sets by io.ConfigWindowsMoveFromTitleBarOnly. If you use this please report in #3379.
|
||||||
ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
|
ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
|
||||||
ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
|
ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
|
||||||
ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
|
ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue