(Breaking) Obsoleted PushButtonRepeat()/PopButtonRepeat() in favor of using new PushItemFlag()/PopItemFlag() with ImGuiItemFlags_ButtonRepeat.

This commit is contained in:
ocornut
2024-07-15 17:46:32 +02:00
parent 7e0800e718
commit b4ca869c40
4 changed files with 9 additions and 17 deletions

View File

@@ -662,11 +662,11 @@ static void ShowDemoWindowWidgets()
IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Repeating)");
static int counter = 0;
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
ImGui::PushButtonRepeat(true);
ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; }
ImGui::SameLine(0.0f, spacing);
if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; }
ImGui::PopButtonRepeat();
ImGui::PopItemFlag();
ImGui::SameLine();
ImGui::Text("%d", counter);
@@ -2581,7 +2581,7 @@ static void ShowDemoWindowWidgets()
ImGui::BeginDisabled(true);
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) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater)
if (item_type == 2) { ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true); ret = ImGui::Button("ITEM: Button"); ImGui::PopItemFlag(); } // Testing button (with repeater)
if (item_type == 3) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
if (item_type == 4) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
if (item_type == 5) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing)
@@ -5875,7 +5875,6 @@ static void ShowDemoWindowTables()
// Show data
// FIXME-TABLE FIXME-NAV: How we can get decent up/down even though we have the buttons here?
ImGui::PushButtonRepeat(true);
#if 1
// Demonstrate using clipper for large vertical lists
ImGuiListClipper clipper;
@@ -5960,7 +5959,6 @@ static void ShowDemoWindowTables()
ImGui::PopID();
}
}
ImGui::PopButtonRepeat();
// Store some info to display debug details below
table_scroll_cur = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY());