mirror of https://github.com/bkaradzic/bgfx
Updated ImGui.
This commit is contained in:
parent
ac9c330100
commit
87eac9ed06
|
@ -807,7 +807,7 @@ CODE
|
|||
// 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
|
||||
#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower)
|
||||
|
||||
// Visual Studio warnings
|
||||
#ifdef _MSC_VER
|
||||
|
@ -985,7 +985,7 @@ ImGuiStyle::ImGuiStyle()
|
|||
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 when button is larger than text.
|
||||
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
|
||||
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-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
|
||||
|
@ -2623,6 +2623,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|||
SkipItems = false;
|
||||
Appearing = false;
|
||||
Hidden = false;
|
||||
IsFallbackWindow = false;
|
||||
HasCloseButton = false;
|
||||
ResizeBorderHeld = -1;
|
||||
BeginCount = 0;
|
||||
|
@ -2837,8 +2838,7 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla
|
|||
// An active popup disable hovering on other windows (apart from its own children)
|
||||
// FIXME-OPT: This could be cached/stored within the window.
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.NavWindow)
|
||||
return true;
|
||||
if (g.NavWindow)
|
||||
if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
|
||||
if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
|
||||
{
|
||||
|
@ -3292,10 +3292,10 @@ void ImGui::UpdateMouseMovingWindowNewFrame()
|
|||
}
|
||||
}
|
||||
|
||||
// Initiate moving window, handle left-click and right-click focus
|
||||
// Initiate moving window when clicking on empty space or title bar.
|
||||
// Handle left-click and right-click focus.
|
||||
void ImGui::UpdateMouseMovingWindowEndFrame()
|
||||
{
|
||||
// Initiate moving window
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.ActiveId != 0 || g.HoveredId != 0)
|
||||
return;
|
||||
|
@ -3789,9 +3789,10 @@ void ImGui::NewFrame()
|
|||
// 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.
|
||||
g.WithinFrameScopeWithImplicitWindow = true;
|
||||
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
||||
Begin("Debug##Default");
|
||||
g.WithinFrameScopeWithImplicitWindow = true;
|
||||
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
ImGuiTestEngineHook_PostNewFrame(&g);
|
||||
|
@ -4016,10 +4017,8 @@ static void AddWindowToDrawData(ImVector<ImDrawList*>* out_render_list, ImGuiWin
|
|||
static void AddRootWindowToDrawData(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
||||
AddWindowToDrawData(&g.DrawDataBuilder.Layers[1], window);
|
||||
else
|
||||
AddWindowToDrawData(&g.DrawDataBuilder.Layers[0], window);
|
||||
int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
|
||||
AddWindowToDrawData(&g.DrawDataBuilder.Layers[layer], window);
|
||||
}
|
||||
|
||||
void ImDrawDataBuilder::FlattenIntoSingleLayer()
|
||||
|
@ -4158,16 +4157,17 @@ void ImGui::Render()
|
|||
if (g.FrameCountEnded != g.FrameCount)
|
||||
EndFrame();
|
||||
g.FrameCountRendered = g.FrameCount;
|
||||
|
||||
// Gather ImDrawList to render (for each active window)
|
||||
g.IO.MetricsRenderWindows = 0;
|
||||
g.DrawDataBuilder.Clear();
|
||||
|
||||
// Add background ImDrawList
|
||||
if (!g.BackgroundDrawList.VtxBuffer.empty())
|
||||
AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.BackgroundDrawList);
|
||||
|
||||
// Add ImDrawList to render
|
||||
ImGuiWindow* windows_to_render_top_most[2];
|
||||
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
|
||||
windows_to_render_top_most[1] = g.NavWindowingTarget ? g.NavWindowingList : NULL;
|
||||
windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingList : NULL);
|
||||
for (int n = 0; n != g.Windows.Size; n++)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[n];
|
||||
|
@ -4183,6 +4183,7 @@ void ImGui::Render()
|
|||
if (g.IO.MouseDrawCursor)
|
||||
RenderMouseCursor(&g.ForegroundDrawList, g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
|
||||
|
||||
// Add foreground ImDrawList
|
||||
if (!g.ForegroundDrawList.VtxBuffer.empty())
|
||||
AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.ForegroundDrawList);
|
||||
|
||||
|
@ -4839,8 +4840,9 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size
|
|||
// Minimum size
|
||||
if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
|
||||
{
|
||||
ImGuiWindow* window_for_height = window;
|
||||
new_size = ImMax(new_size, g.Style.WindowMinSize);
|
||||
new_size.y = ImMax(new_size.y, window->TitleBarHeight() + window->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
|
||||
new_size.y = ImMax(new_size.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
|
||||
}
|
||||
return new_size;
|
||||
}
|
||||
|
@ -5047,6 +5049,10 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
|||
}
|
||||
PopID();
|
||||
|
||||
// Restore nav layer
|
||||
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
||||
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
||||
|
||||
// Navigation resize (keyboard/gamepad)
|
||||
if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window)
|
||||
{
|
||||
|
@ -5079,10 +5085,6 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
|||
MarkIniSettingsDirty(window);
|
||||
}
|
||||
|
||||
// Resize nav layer
|
||||
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
||||
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
|
||||
|
||||
window->Size = window->SizeFull;
|
||||
return ret_auto_fit;
|
||||
}
|
||||
|
@ -5131,6 +5133,8 @@ 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, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -5342,6 +5346,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
|
||||
const int current_frame = g.FrameCount;
|
||||
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
|
||||
window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow);
|
||||
|
||||
// Update the Appearing flag
|
||||
bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
|
||||
|
@ -5487,6 +5492,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
}
|
||||
}
|
||||
|
||||
// SELECT VIEWPORT
|
||||
// FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style)
|
||||
SetCurrentWindow(window);
|
||||
|
||||
|
@ -5597,14 +5603,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
|
||||
// Clamp position/size so window stays visible within its viewport or monitor
|
||||
|
||||
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
||||
ImRect viewport_rect(GetViewportRect());
|
||||
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
|
||||
{
|
||||
if (g.IO.DisplaySize.x > 0.0f && g.IO.DisplaySize.y > 0.0f) // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
||||
{
|
||||
ImVec2 clamp_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
|
||||
if (viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f)
|
||||
{
|
||||
ClampWindowRect(window, viewport_rect, clamp_padding);
|
||||
}
|
||||
}
|
||||
|
@ -5741,6 +5746,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
// We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child.
|
||||
// We also disabled this when we have dimming overlay behind this specific one child.
|
||||
// FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected.
|
||||
{
|
||||
bool render_decorations_in_parent = false;
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip)
|
||||
if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_window->DrawList->VtxBuffer.Size > 0)
|
||||
|
@ -5755,6 +5761,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
|
||||
if (render_decorations_in_parent)
|
||||
window->DrawList = &window->DrawListInst;
|
||||
}
|
||||
|
||||
// Draw navigation selection/windowing rectangle border
|
||||
if (g.NavWindowingTargetAnim == window)
|
||||
|
@ -7570,7 +7577,7 @@ void ImGui::CloseCurrentPopup()
|
|||
window->DC.NavHideHighlightOneFrame = true;
|
||||
}
|
||||
|
||||
bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
|
||||
bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!IsPopupOpen(id))
|
||||
|
@ -7580,12 +7587,13 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
|
|||
}
|
||||
|
||||
char name[20];
|
||||
if (extra_flags & ImGuiWindowFlags_ChildMenu)
|
||||
if (flags & ImGuiWindowFlags_ChildMenu)
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
|
||||
else
|
||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
|
||||
|
||||
bool is_open = Begin(name, NULL, extra_flags | ImGuiWindowFlags_Popup);
|
||||
flags |= ImGuiWindowFlags_Popup;
|
||||
bool is_open = Begin(name, NULL, flags);
|
||||
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
|
||||
EndPopup();
|
||||
|
||||
|
@ -10079,7 +10087,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
char buf[256];
|
||||
char* p = buf;
|
||||
const char* buf_end = buf + IM_ARRAYSIZE(buf);
|
||||
ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s", tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : "");
|
||||
p += ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s", tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : "");
|
||||
if (ImGui::TreeNode(tab_bar, "%s", buf))
|
||||
{
|
||||
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
|
||||
|
|
|
@ -4685,7 +4685,8 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||
static bool opt_reorderable = true;
|
||||
static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
|
||||
|
||||
if (!ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar))
|
||||
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
|
||||
if (!window_contents_visible)
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
|
|
|
@ -433,7 +433,15 @@ enum ImGuiButtonFlags_
|
|||
ImGuiButtonFlags_NoHoldingActiveId = 1 << 13, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||
ImGuiButtonFlags_NoNavFocus = 1 << 14, // don't override navigation focus when activated
|
||||
ImGuiButtonFlags_NoHoveredOnNav = 1 << 15, // don't report as hovered when navigated on
|
||||
ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold
|
||||
ImGuiButtonFlags_MouseButtonLeft = 1 << 16, // [Default] react on left mouse button
|
||||
ImGuiButtonFlags_MouseButtonRight = 1 << 17, // react on right mouse button
|
||||
ImGuiButtonFlags_MouseButtonMiddle = 1 << 18, // react on center mouse button
|
||||
|
||||
ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
|
||||
ImGuiButtonFlags_MouseButtonShift_ = 16,
|
||||
ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
|
||||
ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
|
||||
ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease
|
||||
};
|
||||
|
||||
enum ImGuiSliderFlags_
|
||||
|
@ -648,6 +656,7 @@ struct ImVec2ih
|
|||
short x, y;
|
||||
ImVec2ih() { x = y = 0; }
|
||||
ImVec2ih(short _x, short _y) { x = _x; y = _y; }
|
||||
explicit ImVec2ih(const ImVec2& rhs) { x = (short)rhs.x; y = (short)rhs.y; }
|
||||
};
|
||||
|
||||
// 2D axis aligned bounding-box
|
||||
|
@ -976,7 +985,7 @@ struct ImGuiPtrOrIndex
|
|||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main imgui context
|
||||
// Main Dear ImGui context
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct ImGuiContext
|
||||
|
@ -1032,6 +1041,7 @@ struct ImGuiContext
|
|||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||
int ActiveIdMouseButton;
|
||||
ImGuiID ActiveIdPreviousFrame;
|
||||
bool ActiveIdPreviousFrameIsAlive;
|
||||
bool ActiveIdPreviousFrameHasBeenEditedBefore;
|
||||
|
@ -1224,6 +1234,7 @@ struct ImGuiContext
|
|||
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||
ActiveIdWindow = NULL;
|
||||
ActiveIdSource = ImGuiInputSource_None;
|
||||
ActiveIdMouseButton = 0;
|
||||
ActiveIdPreviousFrame = 0;
|
||||
ActiveIdPreviousFrameIsAlive = false;
|
||||
ActiveIdPreviousFrameHasBeenEditedBefore = false;
|
||||
|
@ -1416,7 +1427,7 @@ struct IMGUI_API ImGuiWindowTempData
|
|||
struct IMGUI_API ImGuiWindow
|
||||
{
|
||||
char* Name;
|
||||
ImGuiID ID; // == ImHash(Name)
|
||||
ImGuiID ID; // == ImHashStr(Name)
|
||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||
ImVec2 Pos; // Position (always rounded-up to nearest pixel)
|
||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||
|
@ -1443,6 +1454,7 @@ struct IMGUI_API ImGuiWindow
|
|||
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
||||
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
||||
bool Hidden; // Do not display (== (HiddenFrames*** > 0))
|
||||
bool IsFallbackWindow; // Set on the "Debug##Default" window.
|
||||
bool HasCloseButton; // Set when the window has a close button (p_open != NULL)
|
||||
signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3)
|
||||
short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
||||
|
@ -1568,7 +1580,7 @@ struct ImGuiTabBar
|
|||
{
|
||||
ImVector<ImGuiTabItem> Tabs;
|
||||
ImGuiID ID; // Zero for tab-bars used by docking
|
||||
ImGuiID SelectedTabId; // Selected tab
|
||||
ImGuiID SelectedTabId; // Selected tab/window
|
||||
ImGuiID NextSelectedTabId;
|
||||
ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
|
||||
int CurrFrameVisible;
|
||||
|
|
|
@ -464,9 +464,13 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
return false;
|
||||
}
|
||||
|
||||
// Default behavior requires click+release on same spot
|
||||
// Default only reacts to left mouse button
|
||||
if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0)
|
||||
flags |= ImGuiButtonFlags_MouseButtonDefault_;
|
||||
|
||||
// Default behavior requires click + release inside bounding box
|
||||
if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0)
|
||||
flags |= ImGuiButtonFlags_PressedOnClickRelease;
|
||||
flags |= ImGuiButtonFlags_PressedOnDefault_;
|
||||
|
||||
ImGuiWindow* backup_hovered_window = g.HoveredWindow;
|
||||
const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredRootWindow == window;
|
||||
|
@ -505,37 +509,54 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0))
|
||||
hovered = false;
|
||||
|
||||
// Mouse
|
||||
// Mouse handling
|
||||
if (hovered)
|
||||
{
|
||||
if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
|
||||
{
|
||||
if ((flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere)) && g.IO.MouseClicked[0])
|
||||
// Poll buttons
|
||||
int mouse_button_clicked = -1;
|
||||
int mouse_button_released = -1;
|
||||
if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseClicked[0]) { mouse_button_clicked = 0; }
|
||||
else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseClicked[1]) { mouse_button_clicked = 1; }
|
||||
else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseClicked[2]) { mouse_button_clicked = 2; }
|
||||
if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseReleased[0]) { mouse_button_released = 0; }
|
||||
else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseReleased[1]) { mouse_button_released = 1; }
|
||||
else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseReleased[2]) { mouse_button_released = 2; }
|
||||
|
||||
if (mouse_button_clicked != -1 && g.ActiveId != id)
|
||||
{
|
||||
if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere))
|
||||
{
|
||||
SetActiveID(id, window);
|
||||
g.ActiveIdMouseButton = mouse_button_clicked;
|
||||
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
||||
SetFocusID(id, window);
|
||||
FocusWindow(window);
|
||||
}
|
||||
if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0]))
|
||||
if ((flags & ImGuiButtonFlags_PressedOnClick) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[mouse_button_clicked]))
|
||||
{
|
||||
pressed = true;
|
||||
if (flags & ImGuiButtonFlags_NoHoldingActiveId)
|
||||
ClearActiveID();
|
||||
else
|
||||
SetActiveID(id, window); // Hold on ID
|
||||
g.ActiveIdMouseButton = mouse_button_clicked;
|
||||
FocusWindow(window);
|
||||
}
|
||||
if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0])
|
||||
}
|
||||
if ((flags & ImGuiButtonFlags_PressedOnRelease) && mouse_button_released != -1)
|
||||
{
|
||||
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay)) // Repeat mode trumps <on release>
|
||||
// Repeat mode trumps on release behavior
|
||||
if (!((flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay))
|
||||
pressed = true;
|
||||
ClearActiveID();
|
||||
}
|
||||
|
||||
// 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
|
||||
// Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings.
|
||||
if ((flags & ImGuiButtonFlags_Repeat) && g.ActiveId == id && g.IO.MouseDownDuration[0] > 0.0f && IsMouseClicked(0, true))
|
||||
if (g.ActiveId == id && (flags & ImGuiButtonFlags_Repeat))
|
||||
if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, true))
|
||||
pressed = true;
|
||||
}
|
||||
|
||||
|
@ -548,7 +569,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId))
|
||||
if (!(flags & ImGuiButtonFlags_NoHoveredOnNav))
|
||||
hovered = true;
|
||||
|
||||
if (g.NavActivateDownId == id)
|
||||
{
|
||||
bool nav_activated_by_code = (g.NavActivateId == id);
|
||||
|
@ -568,24 +588,25 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
bool held = false;
|
||||
if (g.ActiveId == id)
|
||||
{
|
||||
if (pressed)
|
||||
g.ActiveIdHasBeenPressedBefore = true;
|
||||
if (g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
{
|
||||
if (g.ActiveIdIsJustActivated)
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - bb.Min;
|
||||
if (g.IO.MouseDown[0])
|
||||
|
||||
const int mouse_button = g.ActiveIdMouseButton;
|
||||
IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
|
||||
if (g.IO.MouseDown[mouse_button])
|
||||
{
|
||||
held = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool release_in = hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) != 0;
|
||||
const bool release_anywhere = (flags & ImGuiButtonFlags_PressedOnClickReleaseAnywhere) != 0;
|
||||
bool release_in = hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) != 0;
|
||||
bool release_anywhere = (flags & ImGuiButtonFlags_PressedOnClickReleaseAnywhere) != 0;
|
||||
if ((release_in || release_anywhere) && !g.DragDropActive)
|
||||
{
|
||||
bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[0];
|
||||
bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[0] >= g.IO.KeyRepeatDelay; // Repeat mode trumps <on release>
|
||||
bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[mouse_button];
|
||||
bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button] >= g.IO.KeyRepeatDelay; // Repeat mode trumps <on release>
|
||||
if (!is_double_click_release && !is_repeating_already)
|
||||
pressed = true;
|
||||
}
|
||||
|
@ -599,6 +620,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||
if (g.NavActivateDownId != id)
|
||||
ClearActiveID();
|
||||
}
|
||||
if (pressed)
|
||||
g.ActiveIdHasBeenPressedBefore = true;
|
||||
}
|
||||
|
||||
if (out_hovered) *out_hovered = hovered;
|
||||
|
@ -6062,7 +6085,7 @@ bool ImGui::BeginMenuBar()
|
|||
// We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
|
||||
// We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
|
||||
ImRect bar_rect = window->MenuBarRect();
|
||||
ImRect clip_rect(IM_ROUND(bar_rect.Min.x), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - window->WindowRounding)), IM_ROUND(bar_rect.Max.y));
|
||||
ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y));
|
||||
clip_rect.ClipWith(window->OuterRectClipped);
|
||||
PushClipRect(clip_rect.Min, clip_rect.Max, false);
|
||||
|
||||
|
@ -6369,9 +6392,6 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
|
|||
//-------------------------------------------------------------------------
|
||||
// [SECTION] Widgets: BeginTabBar, EndTabBar, etc.
|
||||
//-------------------------------------------------------------------------
|
||||
// [BETA API] API may evolve! This code has been extracted out of the Docking branch,
|
||||
// and some of the construct which are not used in Master may be left here to facilitate merging.
|
||||
//-------------------------------------------------------------------------
|
||||
// - BeginTabBar()
|
||||
// - BeginTabBarEx() [Internal]
|
||||
// - EndTabBar()
|
||||
|
@ -6886,9 +6906,6 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar)
|
|||
//-------------------------------------------------------------------------
|
||||
// [SECTION] Widgets: BeginTabItem, EndTabItem, etc.
|
||||
//-------------------------------------------------------------------------
|
||||
// [BETA API] API may evolve! This code has been extracted out of the Docking branch,
|
||||
// and some of the construct which are not used in Master may be left here to facilitate merging.
|
||||
//-------------------------------------------------------------------------
|
||||
// - BeginTabItem()
|
||||
// - EndTabItem()
|
||||
// - TabItemEx() [Internal]
|
||||
|
|
Loading…
Reference in New Issue