mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 16:29:02 +08:00
Internals: Extracted StartMouseMovingWindow so we can add code to turn an arbitrary widget into a window mover (will be useful to make the Collapse button a window mover past a mouse drag threshold) + added a couple of _None flags.
This commit is contained in:
parent
dc021f1c23
commit
4dfb9ef751
33
imgui.cpp
33
imgui.cpp
@ -3590,7 +3590,21 @@ static void ImGui::NavUpdate()
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::UpdateMovingWindow()
|
||||
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.
|
||||
ImGuiContext& g = *GImGui;
|
||||
FocusWindow(window);
|
||||
SetActiveID(window->MoveId, window);
|
||||
g.NavDisableHighlight = true;
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos;
|
||||
if (!(window->Flags & ImGuiWindowFlags_NoMove) && !(window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
g.MovingWindow = window;
|
||||
}
|
||||
|
||||
// Handle mouse moving window
|
||||
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
|
||||
void ImGui::UpdateMouseMovingWindow()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.MovingWindow != NULL)
|
||||
@ -3858,7 +3872,7 @@ void ImGui::NewFrame()
|
||||
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
|
||||
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
||||
UpdateMovingWindow();
|
||||
UpdateMouseMovingWindow();
|
||||
UpdateHoveredWindowAndCaptureFlags();
|
||||
|
||||
// Background darkening/whitening
|
||||
@ -4391,20 +4405,9 @@ void ImGui::EndFrame()
|
||||
if (g.IO.MouseClicked[0])
|
||||
{
|
||||
if (g.HoveredRootWindow != NULL)
|
||||
{
|
||||
// Set ActiveId even if the _NoMove flag is set, without it dragging away from a window with _NoMove would activate hover on other windows.
|
||||
FocusWindow(g.HoveredWindow);
|
||||
SetActiveID(g.HoveredWindow->MoveId, g.HoveredWindow);
|
||||
g.NavDisableHighlight = true;
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredRootWindow->Pos;
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
g.MovingWindow = g.HoveredWindow;
|
||||
}
|
||||
StartMouseMovingWindow(g.HoveredWindow);
|
||||
else if (g.NavWindow != NULL && GetFrontMostPopupModal() == NULL)
|
||||
{
|
||||
// Clicking on void disable focus
|
||||
FocusWindow(NULL);
|
||||
}
|
||||
FocusWindow(NULL); // Clicking on void disable focus
|
||||
}
|
||||
|
||||
// With right mouse button we close popups without changing focus
|
||||
|
@ -210,6 +210,7 @@ static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs)
|
||||
|
||||
enum ImGuiButtonFlags_
|
||||
{
|
||||
ImGuiButtonFlags_None = 0,
|
||||
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
|
||||
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
|
||||
@ -228,12 +229,14 @@ enum ImGuiButtonFlags_
|
||||
|
||||
enum ImGuiSliderFlags_
|
||||
{
|
||||
ImGuiSliderFlags_None = 0,
|
||||
ImGuiSliderFlags_Vertical = 1 << 0
|
||||
};
|
||||
|
||||
enum ImGuiColumnsFlags_
|
||||
{
|
||||
// Default: 0
|
||||
ImGuiColumnsFlags_None = 0,
|
||||
ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers
|
||||
ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
|
||||
ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
|
||||
@ -253,6 +256,7 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
|
||||
enum ImGuiSeparatorFlags_
|
||||
{
|
||||
ImGuiSeparatorFlags_None = 0,
|
||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1
|
||||
};
|
||||
@ -260,6 +264,7 @@ enum ImGuiSeparatorFlags_
|
||||
// Storage for LastItem data
|
||||
enum ImGuiItemStatusFlags_
|
||||
{
|
||||
ImGuiItemStatusFlags_None = 0,
|
||||
ImGuiItemStatusFlags_HoveredRect = 1 << 0,
|
||||
ImGuiItemStatusFlags_HasDisplayRect = 1 << 1
|
||||
};
|
||||
@ -1080,7 +1085,8 @@ namespace ImGui
|
||||
IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
|
||||
|
||||
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
||||
IMGUI_API void UpdateMovingWindow();
|
||||
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
||||
IMGUI_API void UpdateMouseMovingWindow();
|
||||
|
||||
IMGUI_API void MarkIniSettingsDirty();
|
||||
IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
|
||||
|
Loading…
Reference in New Issue
Block a user