mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Added IsItemActivated() as an extension to the IsItemDeactivated/IsItemDeactivatedAfterEdit functions which are useful to implement variety of undo patterns. (#820, #956, #1875)
This commit is contained in:
parent
c59611a3b3
commit
e3dd95d335
@ -43,10 +43,13 @@ Other Changes:
|
||||
- InputText: Fixed a bug where ESCAPE would be first captured by the Keyboard Navigation code. (#2321, #787)
|
||||
- InputText: Fixed redo buffer exhaustion handling (rare) which could corrupt the undo character buffer. (#2333)
|
||||
The way the redo/undo buffers work would have made it generally unnoticeable to the user.
|
||||
- Added IsItemActivated() as an extension to the IsItemDeactivated/IsItemDeactivatedAfterEdit functions
|
||||
which are useful to implement variety of undo patterns. (#820, #956, #1875)
|
||||
- Fixed range-version of PushID() and GetID() not honoring the ### operator to restart from the seed value.
|
||||
- Fixed CloseCurrentPopup() on a child-menu of a modal incorrectly closing the modal. (#2308)
|
||||
- Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351)
|
||||
- Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use.
|
||||
- Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame.
|
||||
- RadioButton: Fixed label horizontal alignment to precisely match Checkbox().
|
||||
- Window: When resizing from an edge, the border is more visible and better follow the rounded corners.
|
||||
- ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle"
|
||||
|
12
imgui.cpp
12
imgui.cpp
@ -4215,6 +4215,18 @@ bool ImGui::IsItemActive()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGui::IsItemActivated()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.ActiveId)
|
||||
{
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (g.ActiveId == window->DC.LastItemId && g.ActiveIdPreviousFrame != window->DC.LastItemId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGui::IsItemDeactivated()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
1
imgui.h
1
imgui.h
@ -607,6 +607,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on) == IsMouseClicked(mouse_button) && IsItemHovered()
|
||||
IMGUI_API bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling)
|
||||
IMGUI_API bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets.
|
||||
IMGUI_API bool IsItemActivated(); // was the last item just made active (item was previously inactive).
|
||||
IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing.
|
||||
IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item).
|
||||
IMGUI_API bool IsAnyItemHovered();
|
||||
|
@ -1420,7 +1420,7 @@ static void ShowDemoWindowWidgets()
|
||||
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
||||
ImGui::RadioButton("Text", &item_type, 0);
|
||||
ImGui::RadioButton("Button", &item_type, 1);
|
||||
ImGui::RadioButton("CheckBox", &item_type, 2);
|
||||
ImGui::RadioButton("Checkbox", &item_type, 2);
|
||||
ImGui::RadioButton("SliderFloat", &item_type, 3);
|
||||
ImGui::RadioButton("ColorEdit4", &item_type, 4);
|
||||
ImGui::RadioButton("ListBox", &item_type, 5);
|
||||
@ -1428,7 +1428,7 @@ static void ShowDemoWindowWidgets()
|
||||
bool ret = false;
|
||||
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
||||
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
||||
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: CheckBox", &b); } // Testing checkbox
|
||||
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
|
||||
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
||||
if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||
if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
||||
@ -1442,6 +1442,7 @@ static void ShowDemoWindowWidgets()
|
||||
"IsItemHovered(_RectOnly) = %d\n"
|
||||
"IsItemActive() = %d\n"
|
||||
"IsItemEdited() = %d\n"
|
||||
"IsItemActivated() = %d\n"
|
||||
"IsItemDeactivated() = %d\n"
|
||||
"IsItemDeactivatedEdit() = %d\n"
|
||||
"IsItemVisible() = %d\n"
|
||||
@ -1457,6 +1458,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly),
|
||||
ImGui::IsItemActive(),
|
||||
ImGui::IsItemEdited(),
|
||||
ImGui::IsItemActivated(),
|
||||
ImGui::IsItemDeactivated(),
|
||||
ImGui::IsItemDeactivatedAfterEdit(),
|
||||
ImGui::IsItemVisible(),
|
||||
|
Loading…
Reference in New Issue
Block a user