mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Tooltips, Drag and Drop: Stabilized name of drag and drop tooltip window. (#8036)
This commit is contained in:
parent
f0575411c0
commit
014b722963
@ -73,6 +73,9 @@ Other changes:
|
|||||||
Set io.ConfigScrollbarScrollByPage=false to enforce always scrolling to clicked location.
|
Set io.ConfigScrollbarScrollByPage=false to enforce always scrolling to clicked location.
|
||||||
- Tooltips, Drag and Drop: Fixed an issue where the fallback drag and drop payload tooltip
|
- Tooltips, Drag and Drop: Fixed an issue where the fallback drag and drop payload tooltip
|
||||||
appeared during drag and drop release.
|
appeared during drag and drop release.
|
||||||
|
- Tooltips, Drag and Drop: Stabilized name of drag and drop tooltip window so that
|
||||||
|
transitioning from an item tooltip to a drag tooltip doesn't leak window auto-sizing
|
||||||
|
info from one to the other. (#8036)
|
||||||
- Backends: SDL3: Update for API changes: SDL_bool removal. SDL_INIT_TIMER removal.
|
- Backends: SDL3: Update for API changes: SDL_bool removal. SDL_INIT_TIMER removal.
|
||||||
- Backends: WebGPU: Fixed DAWN api change using WGPUStringView in WGPUShaderSourceWGSL.
|
- Backends: WebGPU: Fixed DAWN api change using WGPUStringView in WGPUShaderSourceWGSL.
|
||||||
(#8009, #8010) [@blitz-research]
|
(#8009, #8010) [@blitz-research]
|
||||||
|
28
imgui.cpp
28
imgui.cpp
@ -3964,6 +3964,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|||||||
DisabledStackSize = 0;
|
DisabledStackSize = 0;
|
||||||
LockMarkEdited = 0;
|
LockMarkEdited = 0;
|
||||||
TooltipOverrideCount = 0;
|
TooltipOverrideCount = 0;
|
||||||
|
TooltipPreviousWindow = NULL;
|
||||||
|
|
||||||
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
|
PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
|
||||||
PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
|
PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
|
||||||
@ -5152,6 +5153,7 @@ void ImGui::NewFrame()
|
|||||||
g.DragDropWithinSource = false;
|
g.DragDropWithinSource = false;
|
||||||
g.DragDropWithinTarget = false;
|
g.DragDropWithinTarget = false;
|
||||||
g.DragDropHoldJustPressedId = 0;
|
g.DragDropHoldJustPressedId = 0;
|
||||||
|
g.TooltipPreviousWindow = NULL;
|
||||||
|
|
||||||
// Close popups on focus lost (currently wip/opt-in)
|
// Close popups on focus lost (currently wip/opt-in)
|
||||||
//if (g.IO.AppFocusLost)
|
//if (g.IO.AppFocusLost)
|
||||||
@ -7549,6 +7551,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// Clear hit test shape every frame
|
// Clear hit test shape every frame
|
||||||
window->HitTestHoleSize.x = window->HitTestHoleSize.y = 0;
|
window->HitTestHoleSize.x = window->HitTestHoleSize.y = 0;
|
||||||
|
|
||||||
|
if (flags & ImGuiWindowFlags_Tooltip)
|
||||||
|
g.TooltipPreviousWindow = window;
|
||||||
|
|
||||||
// Pressing CTRL+C while holding on a window copy its content to the clipboard
|
// Pressing CTRL+C while holding on a window copy its content to the clipboard
|
||||||
// This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope.
|
// This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope.
|
||||||
// Maybe we can support CTRL+C on every element?
|
// Maybe we can support CTRL+C on every element?
|
||||||
@ -11504,7 +11509,8 @@ bool ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags ext
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
if (g.DragDropWithinSource || g.DragDropWithinTarget)
|
const bool is_dragdrop_tooltip = g.DragDropWithinSource || g.DragDropWithinTarget;
|
||||||
|
if (is_dragdrop_tooltip)
|
||||||
{
|
{
|
||||||
// Drag and Drop tooltips are positioning differently than other tooltips:
|
// Drag and Drop tooltips are positioning differently than other tooltips:
|
||||||
// - offset visibility to increase visibility around mouse.
|
// - offset visibility to increase visibility around mouse.
|
||||||
@ -11520,16 +11526,16 @@ bool ImGui::BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags ext
|
|||||||
tooltip_flags |= ImGuiTooltipFlags_OverridePrevious;
|
tooltip_flags |= ImGuiTooltipFlags_OverridePrevious;
|
||||||
}
|
}
|
||||||
|
|
||||||
char window_name[16];
|
const char* window_name_template = is_dragdrop_tooltip ? "##Tooltip_DragDrop_%02d" : "##Tooltip_%02d";
|
||||||
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
|
char window_name[32];
|
||||||
if (tooltip_flags & ImGuiTooltipFlags_OverridePrevious)
|
ImFormatString(window_name, IM_ARRAYSIZE(window_name), window_name_template, g.TooltipOverrideCount);
|
||||||
if (ImGuiWindow* window = FindWindowByName(window_name))
|
if ((tooltip_flags & ImGuiTooltipFlags_OverridePrevious) && g.TooltipPreviousWindow != NULL && g.TooltipPreviousWindow->Active)
|
||||||
if (window->Active)
|
{
|
||||||
{
|
// Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
|
||||||
// Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
|
//IMGUI_DEBUG_LOG("[tooltip] '%s' already active, using +1 for this frame\n", window_name);
|
||||||
SetWindowHiddenAndSkipItemsForCurrentFrame(window);
|
SetWindowHiddenAndSkipItemsForCurrentFrame(g.TooltipPreviousWindow);
|
||||||
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
|
ImFormatString(window_name, IM_ARRAYSIZE(window_name), window_name_template, ++g.TooltipOverrideCount);
|
||||||
}
|
}
|
||||||
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
|
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
|
||||||
Begin(window_name, NULL, flags | extra_window_flags);
|
Begin(window_name, NULL, flags | extra_window_flags);
|
||||||
// 2023-03-09: Added bool return value to the API, but currently always returning true.
|
// 2023-03-09: Added bool return value to the API, but currently always returning true.
|
||||||
|
2
imgui.h
2
imgui.h
@ -29,7 +29,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.91.3 WIP"
|
#define IMGUI_VERSION "1.91.3 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19123
|
#define IMGUI_VERSION_NUM 19124
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2283,6 +2283,7 @@ struct ImGuiContext
|
|||||||
short DisabledStackSize;
|
short DisabledStackSize;
|
||||||
short LockMarkEdited;
|
short LockMarkEdited;
|
||||||
short TooltipOverrideCount;
|
short TooltipOverrideCount;
|
||||||
|
ImGuiWindow* TooltipPreviousWindow; // Window of last tooltip submitted during the frame
|
||||||
ImVector<char> ClipboardHandlerData; // If no custom clipboard handler is defined
|
ImVector<char> ClipboardHandlerData; // If no custom clipboard handler is defined
|
||||||
ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
|
ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
|
||||||
ImGuiTypingSelectState TypingSelectState; // State for GetTypingSelectRequest()
|
ImGuiTypingSelectState TypingSelectState; // State for GetTypingSelectRequest()
|
||||||
|
Loading…
Reference in New Issue
Block a user