mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-22 01:54:21 +00:00
Merge branch 'master' into docking (require next commit)
# Conflicts: # backends/imgui_impl_glfw.cpp # backends/imgui_impl_glfw.h # backends/imgui_impl_osx.mm # backends/imgui_impl_sdl3.cpp # backends/imgui_impl_vulkan.cpp # backends/imgui_impl_vulkan.h # backends/imgui_impl_win32.cpp # imgui.cpp
This commit is contained in:
commit
66e08b6575
14 changed files with 152 additions and 91 deletions
53
imgui.cpp
53
imgui.cpp
|
|
@ -402,6 +402,7 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures:
|
|||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
|
||||
- 2026/01/08 (1.92.6) - Commented out legacy names obsoleted in 1.90 (Sept 2023): 'BeginChildFrame()' --> 'BeginChild()' with 'ImGuiChildFlags_FrameStyle'. 'EndChildFrame()' --> 'EndChild()'. 'ShowStackToolWindow()' --> 'ShowIDStackToolWindow()'. 'IM_OFFSETOF()' --> 'offsetof()'.
|
||||
- 2026/01/07 (1.92.6) - Popups: changed compile-time 'ImGuiPopupFlags popup_flags = 1' default value to be '= 0' for BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick(). Default value has same meaning before and after.
|
||||
- Refer to GitHub topic #9157 if you have any question.
|
||||
- Before this version, those functions had a 'ImGuiPopupFlags popup_flags = 1' default value in their function signature.
|
||||
|
|
@ -1365,8 +1366,8 @@ static bool NavScoreItem(ImGuiNavItemData* result, const ImRect& nav
|
|||
static void NavApplyItemToResult(ImGuiNavItemData* result);
|
||||
static void NavProcessItem();
|
||||
static void NavProcessItemForTabbingRequest(ImGuiID id, ImGuiItemFlags item_flags, ImGuiNavMoveFlags move_flags);
|
||||
static ImGuiInputSource NavCalcPreferredRefPosSource();
|
||||
static ImVec2 NavCalcPreferredRefPos();
|
||||
static ImGuiInputSource NavCalcPreferredRefPosSource(ImGuiWindowFlags window_type);
|
||||
static ImVec2 NavCalcPreferredRefPos(ImGuiWindowFlags window_type);
|
||||
static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window);
|
||||
static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window);
|
||||
static void NavRestoreLayer(ImGuiNavLayer layer);
|
||||
|
|
@ -1498,6 +1499,7 @@ ImGuiStyle::ImGuiStyle()
|
|||
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.
|
||||
ImageRounding = 0.0f; // Rounding of Image() calls.
|
||||
ImageBorderSize = 0.0f; // Thickness of border around tabs.
|
||||
TabRounding = 5.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
||||
|
|
@ -1574,6 +1576,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
|||
GrabMinSize = ImTrunc(GrabMinSize * scale_factor);
|
||||
GrabRounding = ImTrunc(GrabRounding * scale_factor);
|
||||
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor);
|
||||
ImageRounding = ImTrunc(ImageRounding * scale_factor);
|
||||
ImageBorderSize = ImTrunc(ImageBorderSize * scale_factor);
|
||||
TabRounding = ImTrunc(TabRounding * scale_factor);
|
||||
TabMinWidthBase = ImTrunc(TabMinWidthBase * scale_factor);
|
||||
|
|
@ -3674,6 +3677,7 @@ static const ImGuiStyleVarInfo GStyleVarsInfo[] =
|
|||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ScrollbarPadding) }, // ImGuiStyleVar_ScrollbarPadding
|
||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageRounding) }, // ImGuiStyleVar_ImageRounding
|
||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, ImageBorderSize) }, // ImGuiStyleVar_ImageBorderSize
|
||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
|
||||
{ 1, ImGuiDataType_Float, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize
|
||||
|
|
@ -4939,7 +4943,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
// Test if another item is active (e.g. being dragged)
|
||||
const ImGuiID id = g.LastItemData.ID;
|
||||
if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
|
||||
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
|
||||
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap && !g.ActiveIdFromShortcut)
|
||||
{
|
||||
// When ActiveId == MoveId it means that either:
|
||||
// - (1) user clicked on void _or_ an item with no id, which triggers moving window (ActiveId is set even when window has _NoMove flag)
|
||||
|
|
@ -6671,10 +6675,8 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
|
|||
IM_ASSERT((child_flags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY)) != 0 && "Must use ImGuiChildFlags_AutoResizeX or ImGuiChildFlags_AutoResizeY with ImGuiChildFlags_AlwaysAutoResize!");
|
||||
}
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//if (window_flags & ImGuiWindowFlags_AlwaysUseWindowPadding)
|
||||
// child_flags |= ImGuiChildFlags_AlwaysUseWindowPadding;
|
||||
//if (window_flags & ImGuiWindowFlags_NavFlattened)
|
||||
// child_flags |= ImGuiChildFlags_NavFlattened;
|
||||
//if (window_flags & ImGuiWindowFlags_AlwaysUseWindowPadding) { child_flags |= ImGuiChildFlags_AlwaysUseWindowPadding; }
|
||||
//if (window_flags & ImGuiWindowFlags_NavFlattened) { child_flags |= ImGuiChildFlags_NavFlattened; }
|
||||
#endif
|
||||
if (child_flags & ImGuiChildFlags_AutoResizeX)
|
||||
child_flags &= ~ImGuiChildFlags_ResizeX;
|
||||
|
|
@ -12884,7 +12886,7 @@ void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags)
|
|||
popup_ref.RestoreNavWindow = 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();
|
||||
popup_ref.OpenPopupPos = NavCalcPreferredRefPos(ImGuiWindowFlags_Popup);
|
||||
popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
|
||||
|
||||
IMGUI_DEBUG_LOG_POPUP("[popup] OpenPopupEx(0x%08X)\n", id);
|
||||
|
|
@ -13138,7 +13140,7 @@ void ImGui::EndPopup()
|
|||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if ((window->Flags & ImGuiWindowFlags_Popup) == 0 || g.BeginPopupStack.Size == 0)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling EndPopup() too many times or in wrong window!");
|
||||
IM_ASSERT_USER_ERROR(0, "Calling EndPopup() in wrong window!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -13373,9 +13375,9 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||
// as drag and drop tooltips are calling SetNextWindowPos() leading to 'window_pos_set_by_api' being set in Begin().
|
||||
IM_ASSERT(g.CurrentWindow == window);
|
||||
const float scale = g.Style.MouseCursorScale;
|
||||
const ImVec2 ref_pos = NavCalcPreferredRefPos();
|
||||
const ImVec2 ref_pos = NavCalcPreferredRefPos(ImGuiWindowFlags_Tooltip);
|
||||
|
||||
if (g.IO.MouseSource == ImGuiMouseSource_TouchScreen && NavCalcPreferredRefPosSource() == ImGuiInputSource_Mouse)
|
||||
if (g.IO.MouseSource == ImGuiMouseSource_TouchScreen && NavCalcPreferredRefPosSource(ImGuiWindowFlags_Tooltip) == ImGuiInputSource_Mouse)
|
||||
{
|
||||
ImVec2 tooltip_pos = ref_pos + TOOLTIP_DEFAULT_OFFSET_TOUCH * scale - (TOOLTIP_DEFAULT_PIVOT_TOUCH * window->Size);
|
||||
if (r_outer.Contains(ImRect(tooltip_pos, tooltip_pos + window->Size)))
|
||||
|
|
@ -13763,6 +13765,8 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|||
window->NavLastIds[nav_layer] = id;
|
||||
if (g.LastItemData.ID == id)
|
||||
window->NavRectRel[nav_layer] = WindowRectAbsToRel(window, g.LastItemData.NavRect);
|
||||
if (id == g.ActiveIdIsAlive)
|
||||
g.NavIdIsAlive = true;
|
||||
|
||||
if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
|
||||
g.NavHighlightItemUnderNav = true;
|
||||
|
|
@ -14278,31 +14282,29 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|||
}
|
||||
}
|
||||
|
||||
static ImGuiInputSource ImGui::NavCalcPreferredRefPosSource()
|
||||
// Positioning logic altered slightly for remote activation: for Popup we want to use item rect, for Tooltip we leave things alone. (#9138)
|
||||
// When calling for ImGuiWindowFlags_Popup we use LastItemData.
|
||||
static ImGuiInputSource ImGui::NavCalcPreferredRefPosSource(ImGuiWindowFlags window_type)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.NavWindow;
|
||||
const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID;
|
||||
|
||||
// Testing for !activated_shortcut here could in theory be removed if we decided that activating a remote shortcut altered one of the g.NavDisableXXX flag.
|
||||
if ((!g.NavCursorVisible || !g.NavHighlightItemUnderNav || !window) && !activated_shortcut)
|
||||
const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID;
|
||||
if ((window_type & ImGuiWindowFlags_Popup) && activated_shortcut)
|
||||
return ImGuiInputSource_Keyboard;
|
||||
|
||||
if (!g.NavCursorVisible || !g.NavHighlightItemUnderNav || !window)
|
||||
return ImGuiInputSource_Mouse;
|
||||
else
|
||||
return ImGuiInputSource_Keyboard; // or Nav in general
|
||||
}
|
||||
|
||||
static ImVec2 ImGui::NavCalcPreferredRefPos()
|
||||
static ImVec2 ImGui::NavCalcPreferredRefPos(ImGuiWindowFlags window_type)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.NavWindow;
|
||||
ImGuiInputSource source = NavCalcPreferredRefPosSource();
|
||||
ImGuiInputSource source = NavCalcPreferredRefPosSource(window_type);
|
||||
|
||||
const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID;
|
||||
|
||||
if (source != ImGuiInputSource_Mouse && !activated_shortcut && window == NULL)
|
||||
source = ImGuiInputSource_Mouse;
|
||||
|
||||
// Testing for !activated_shortcut here could in theory be removed if we decided that activating a remote shortcut altered one of the g.NavDisableXXX flag.
|
||||
if (source == ImGuiInputSource_Mouse)
|
||||
{
|
||||
// Mouse (we need a fallback in case the mouse becomes invalid after being used)
|
||||
|
|
@ -14314,8 +14316,9 @@ static ImVec2 ImGui::NavCalcPreferredRefPos()
|
|||
else
|
||||
{
|
||||
// When navigation is active and mouse is disabled, pick a position around the bottom left of the currently navigated item
|
||||
const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID;
|
||||
ImRect ref_rect;
|
||||
if (activated_shortcut)
|
||||
if (activated_shortcut && (window_type & ImGuiWindowFlags_Popup))
|
||||
ref_rect = g.LastItemData.NavRect;
|
||||
else if (window != NULL)
|
||||
ref_rect = WindowRectRelToAbs(window, window->NavRectRel[g.NavLayer]);
|
||||
|
|
@ -14516,7 +14519,7 @@ static void ImGui::NavUpdate()
|
|||
// Update mouse position if requested
|
||||
// (This will take into account the possibility that a Scroll was queued in the window to offset our absolute mouse position before scroll has been applied)
|
||||
if (set_mouse_pos && io.ConfigNavMoveSetMousePos && (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
|
||||
TeleportMousePos(NavCalcPreferredRefPos());
|
||||
TeleportMousePos(NavCalcPreferredRefPos(ImGuiWindowFlags_Popup));
|
||||
|
||||
// [DEBUG]
|
||||
g.NavScoringDebugCount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue