mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
IsItemHovered, Tooltips: Added io.HoveredFlagsForTooltipMouse, io.HoveredFlagsForTooltipNav now pulled by ImGuiHoveredFlags_Tooltip. (#1485)
This commit is contained in:
parent
b3b8cbd001
commit
0f72652c2d
@ -43,6 +43,18 @@ Breaking changes:
|
|||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
|
|
||||||
|
- Tooltips/IsItemHovered() related changes:
|
||||||
|
- IsItemHovered: Added ImGuiHoveredFlags_Stationary to require mouse being
|
||||||
|
stationary when hovering a new item. Added style.HoverStationaryDelay (~0.15 sec).
|
||||||
|
Once the mouse has been stationary once the state is preserved for same item. (#1485)
|
||||||
|
- IsItemHovered: Added ImGuiHoveredFlags_ForTooltip as a shortcut for pulling flags
|
||||||
|
from style.HoverFlagsForTooltipMouse or style.HoverFlagsForTooltipNav. (#1485)
|
||||||
|
- style.HoverFlagsForTooltipMouse defaults to ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort
|
||||||
|
- style.HoverFlagsForTooltipNav defaults to ImGuiHoveredFlags_NoSharedDelay | ImGuiHoveredFlags_DelayNormal
|
||||||
|
- IsItemHovered: Tweaked default value of style.HoverDelayNormal from 0.30 to 0.40,
|
||||||
|
Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485)
|
||||||
|
- Tooltips: Tweak default offset for non-drag and drop tooltips so underlying items
|
||||||
|
isn't covered as much. (Match offset for drag and drop tooltips)
|
||||||
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
|
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
|
||||||
ScrollX or ScrollY flags from being impossible to resize. (#6503)
|
ScrollX or ScrollY flags from being impossible to resize. (#6503)
|
||||||
- Clipper: Rework inner logic to allow functioning with a zero-clear constructor.
|
- Clipper: Rework inner logic to allow functioning with a zero-clear constructor.
|
||||||
@ -50,15 +62,6 @@ Other changes:
|
|||||||
where user may not be callinga constructor manually. (#5856)
|
where user may not be callinga constructor manually. (#5856)
|
||||||
- Modals: In the case of nested modal, made sure that focused or appearing windows are
|
- Modals: In the case of nested modal, made sure that focused or appearing windows are
|
||||||
moved below the lowest blocking modal (rather than the highest one). (#4317)
|
moved below the lowest blocking modal (rather than the highest one). (#4317)
|
||||||
- IsItemHovered: Added ImGuiHoveredFlags_ForTooltip as a shortcut for using _Stationary
|
|
||||||
and _DelayNormal flags. (#1485)
|
|
||||||
- IsItemHovered: Added ImGuiHoveredFlags_Stationary to add a stationary test on
|
|
||||||
hovering a new item. Added style.HoverStationaryDelay (default 0.15 sec). Once the mouse
|
|
||||||
has been stationary once the state is preserved. (#1485)
|
|
||||||
- IsItemHovered: Tweaked default value style.HoverDelayNormal from 0.30 to 0.40,
|
|
||||||
Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485)
|
|
||||||
- Tooltips: Tweak default offset for non-drag and drop tooltips so underlying items
|
|
||||||
isn't covered as much. (Match offset for drag and drop tooltips)
|
|
||||||
- Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra
|
- Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra
|
||||||
comments. Currently mainly for inspecting Docking .ini data, but makes saving slower.
|
comments. Currently mainly for inspecting Docking .ini data, but makes saving slower.
|
||||||
- Backends: OpenGL3: Fixed support for glBindSampler() backup/restore on ES3. (#6375, #6508) [@jsm174]
|
- Backends: OpenGL3: Fixed support for glBindSampler() backup/restore on ES3. (#6375, #6508) [@jsm174]
|
||||||
|
11
imgui.cpp
11
imgui.cpp
@ -1167,6 +1167,8 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
HoverStationaryDelay = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
HoverStationaryDelay = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
||||||
HoverDelayShort = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
|
HoverDelayShort = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
|
||||||
HoverDelayNormal = 0.40f; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
|
HoverDelayNormal = 0.40f; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
|
||||||
|
HoverFlagsForTooltipMouse = ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using mouse.
|
||||||
|
HoverFlagsForTooltipNav = ImGuiHoveredFlags_NoSharedDelay | ImGuiHoveredFlags_DelayNormal; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using keyboard/gamepad.
|
||||||
|
|
||||||
// Default theme
|
// Default theme
|
||||||
ImGui::StyleColorsDark(this);
|
ImGui::StyleColorsDark(this);
|
||||||
@ -1260,7 +1262,6 @@ ImGuiIO::ImGuiIO()
|
|||||||
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||||
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
|
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||||
MouseSource = ImGuiMouseSource_Mouse;
|
MouseSource = ImGuiMouseSource_Mouse;
|
||||||
MouseDragThreshold = 6.0f;
|
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; }
|
for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; }
|
||||||
AppAcceptingEvents = true;
|
AppAcceptingEvents = true;
|
||||||
@ -3939,12 +3940,16 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
|
||||||
if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride))
|
if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride))
|
||||||
{
|
{
|
||||||
if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
||||||
return false;
|
return false;
|
||||||
if (!IsItemFocused())
|
if (!IsItemFocused())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (flags & ImGuiHoveredFlags_ForTooltip)
|
||||||
|
flags |= g.Style.HoverFlagsForTooltipNav;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3952,6 +3957,10 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||||||
ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags;
|
ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags;
|
||||||
if (!(status_flags & ImGuiItemStatusFlags_HoveredRect))
|
if (!(status_flags & ImGuiItemStatusFlags_HoveredRect))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (flags & ImGuiHoveredFlags_ForTooltip)
|
||||||
|
flags |= g.Style.HoverFlagsForTooltipMouse;
|
||||||
|
|
||||||
IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0); // Flags not supported by this function
|
IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0); // Flags not supported by this function
|
||||||
|
|
||||||
// Done with rectangle culling so we can perform heavier checks now
|
// Done with rectangle culling so we can perform heavier checks now
|
||||||
|
26
imgui.h
26
imgui.h
@ -1285,14 +1285,22 @@ enum ImGuiHoveredFlags_
|
|||||||
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
|
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
|
||||||
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows,
|
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows,
|
||||||
|
|
||||||
// Mouse Hovering delays (e.g. for tooltips)
|
// Tooltips mode
|
||||||
// - for frequently actioned or hovered items providing a tooltip, you want may to use ImGuiHoveredFlags_ForTooltip (stationary + normal delay) so the tooltip doesn't show too often.
|
// - typically used in IsItemHovered() + SetTooltip() sequence.
|
||||||
// - for items which main purpose is to be hovered for a tooltip, or items with low affordance, prefer no delay or shorter delay.
|
// - this is a shortcut to pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' where you can reconfigure desired behavior.
|
||||||
ImGuiHoveredFlags_Stationary = 1 << 11, // IsItemHovered() only: Require mouse to be stationary for style.HoverStationaryDelay (~0.15 sec) _at least one time_. After this, can move on same item.
|
// e.g. 'TooltipHoveredFlagsForMouse' defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
|
||||||
ImGuiHoveredFlags_DelayShort = 1 << 13, // IsItemHovered() only: Return true after style.HoverDelayShort elapsed (~0.15 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
// - for frequently actioned or hovered items providing a tooltip, you want may to use ImGuiHoveredFlags_ForTooltip (stationary + delay) so the tooltip doesn't show too often.
|
||||||
ImGuiHoveredFlags_DelayNormal = 1 << 14, // IsItemHovered() only: Return true after style.HoverDelayNormal elapsed (~0.40 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
// - for items which main purpose is to be hovered, or items with low affordance, or less consistent app, prefer no delay or shorter delay.
|
||||||
ImGuiHoveredFlags_NoSharedDelay = 1 << 15, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
|
ImGuiHoveredFlags_ForTooltip = 1 << 11, // Shortcut for standard flags when using IsItemHovered() + SetTooltip() sequence.
|
||||||
ImGuiHoveredFlags_ForTooltip = ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayNormal,
|
|
||||||
|
// (Advanced) Mouse Hovering delays.
|
||||||
|
// - generally you can use ImGuiHoveredFlags_ForTooltip to use application-standardized flags.
|
||||||
|
// - use those if you need specific overrides.
|
||||||
|
ImGuiHoveredFlags_Stationary = 1 << 12, // IsItemHovered() only: Require mouse to be stationary for style.HoverStationaryDelay (~0.15 sec) _at least one time_. After this, can move on same item.
|
||||||
|
ImGuiHoveredFlags_DelayNone = 1 << 13, // IsItemHovered() only: Return true immediately (default). As this is the default you generally ignore this.
|
||||||
|
ImGuiHoveredFlags_DelayShort = 1 << 14, // IsItemHovered() only: Return true after style.HoverDelayShort elapsed (~0.15 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
||||||
|
ImGuiHoveredFlags_DelayNormal = 1 << 15, // IsItemHovered() only: Return true after style.HoverDelayNormal elapsed (~0.40 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
|
||||||
|
ImGuiHoveredFlags_NoSharedDelay = 1 << 16, // IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
|
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
|
||||||
@ -1898,6 +1906,8 @@ struct ImGuiStyle
|
|||||||
float HoverStationaryDelay; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
float HoverStationaryDelay; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
||||||
float HoverDelayShort; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
|
float HoverDelayShort; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
|
||||||
float HoverDelayNormal; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
|
float HoverDelayNormal; // Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
|
||||||
|
ImGuiHoveredFlags HoverFlagsForTooltipMouse;// Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using mouse.
|
||||||
|
ImGuiHoveredFlags HoverFlagsForTooltipNav; // Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using keyboard/gamepad.
|
||||||
|
|
||||||
IMGUI_API ImGuiStyle();
|
IMGUI_API ImGuiStyle();
|
||||||
IMGUI_API void ScaleAllSizes(float scale_factor);
|
IMGUI_API void ScaleAllSizes(float scale_factor);
|
||||||
|
@ -6241,6 +6241,19 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%0.f");
|
ImGui::SliderFloat2("SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%0.f");
|
||||||
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
|
||||||
|
|
||||||
|
ImGui::SeparatorText("Tooltips");
|
||||||
|
for (int n = 0; n < 2; n++)
|
||||||
|
if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav"))
|
||||||
|
{
|
||||||
|
ImGuiHoveredFlags* p = (n == 0) ? &style.HoverFlagsForTooltipMouse : &style.HoverFlagsForTooltipNav;
|
||||||
|
ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNone", p, ImGuiHoveredFlags_DelayNone);
|
||||||
|
ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayShort", p, ImGuiHoveredFlags_DelayShort);
|
||||||
|
ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNormal", p, ImGuiHoveredFlags_DelayNormal);
|
||||||
|
ImGui::CheckboxFlags("ImGuiHoveredFlags_Stationary", p, ImGuiHoveredFlags_Stationary);
|
||||||
|
ImGui::CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", p, ImGuiHoveredFlags_NoSharedDelay);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::SeparatorText("Misc");
|
ImGui::SeparatorText("Misc");
|
||||||
ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
|
ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user