mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-17 19:09:27 +01:00
Internals: Track ActiveIdHasBeenPressed (similar to ActiveIdHasBeenEdited). This is currently mostly for the benefit of the range_select branch. (#1861)
This commit is contained in:
parent
52a9f8bd3e
commit
0d4a2a2cd0
@ -2636,6 +2636,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|||||||
if (g.ActiveIdIsJustActivated)
|
if (g.ActiveIdIsJustActivated)
|
||||||
{
|
{
|
||||||
g.ActiveIdTimer = 0.0f;
|
g.ActiveIdTimer = 0.0f;
|
||||||
|
g.ActiveIdHasBeenPressed = false;
|
||||||
g.ActiveIdHasBeenEdited = false;
|
g.ActiveIdHasBeenEdited = false;
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -423,7 +423,7 @@ enum ImGuiNavHighlightFlags_
|
|||||||
ImGuiNavHighlightFlags_None = 0,
|
ImGuiNavHighlightFlags_None = 0,
|
||||||
ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
|
ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
|
||||||
ImGuiNavHighlightFlags_TypeThin = 1 << 1,
|
ImGuiNavHighlightFlags_TypeThin = 1 << 1,
|
||||||
ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2,
|
ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
|
||||||
ImGuiNavHighlightFlags_NoRounding = 1 << 3
|
ImGuiNavHighlightFlags_NoRounding = 1 << 3
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -792,6 +792,7 @@ struct ImGuiContext
|
|||||||
float ActiveIdTimer;
|
float ActiveIdTimer;
|
||||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||||
|
bool ActiveIdHasBeenPressed; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
||||||
bool ActiveIdHasBeenEdited; // Was the value associated to the widget Edited over the course of the Active state.
|
bool ActiveIdHasBeenEdited; // Was the value associated to the widget Edited over the course of the Active state.
|
||||||
bool ActiveIdPreviousFrameIsAlive;
|
bool ActiveIdPreviousFrameIsAlive;
|
||||||
bool ActiveIdPreviousFrameHasBeenEdited;
|
bool ActiveIdPreviousFrameHasBeenEdited;
|
||||||
@ -897,7 +898,8 @@ struct ImGuiContext
|
|||||||
ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
|
ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
|
||||||
|
|
||||||
// Platform support
|
// Platform support
|
||||||
ImVec2 PlatformImePos, PlatformImeLastPos; // Cursor position request & last passed to the OS Input Method Editor
|
ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor
|
||||||
|
ImVec2 PlatformImeLastPos;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
bool SettingsLoaded;
|
bool SettingsLoaded;
|
||||||
@ -948,6 +950,7 @@ struct ImGuiContext
|
|||||||
ActiveIdTimer = 0.0f;
|
ActiveIdTimer = 0.0f;
|
||||||
ActiveIdIsJustActivated = false;
|
ActiveIdIsJustActivated = false;
|
||||||
ActiveIdAllowOverlap = false;
|
ActiveIdAllowOverlap = false;
|
||||||
|
ActiveIdHasBeenPressed = false;
|
||||||
ActiveIdHasBeenEdited = false;
|
ActiveIdHasBeenEdited = false;
|
||||||
ActiveIdPreviousFrameIsAlive = false;
|
ActiveIdPreviousFrameIsAlive = false;
|
||||||
ActiveIdPreviousFrameHasBeenEdited = false;
|
ActiveIdPreviousFrameHasBeenEdited = false;
|
||||||
|
@ -507,6 +507,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
bool held = false;
|
bool held = false;
|
||||||
if (g.ActiveId == id)
|
if (g.ActiveId == id)
|
||||||
{
|
{
|
||||||
|
if (pressed)
|
||||||
|
g.ActiveIdHasBeenPressed = true;
|
||||||
if (g.ActiveIdSource == ImGuiInputSource_Mouse)
|
if (g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||||
{
|
{
|
||||||
if (g.ActiveIdIsJustActivated)
|
if (g.ActiveIdIsJustActivated)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user