From b302971455b3719ec9b5fb94b2f92d27c62b9ff0 Mon Sep 17 00:00:00 2001 From: thedmd Date: Mon, 22 Jul 2024 01:46:47 +0200 Subject: [PATCH] Examples: Minimum supported version is now Dear ImGui 1.89 (August 2022) --- docs/CHANGELOG.txt | 2 ++ .../blueprints-example/blueprints-example.cpp | 24 +------------------ .../blueprints-example/utilities/builders.cpp | 4 ---- .../blueprints-example/utilities/drawing.cpp | 24 ------------------- examples/widgets-example/widgets-example.cpp | 8 +++++++ 5 files changed, 11 insertions(+), 51 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 53ba86f8..4011b820 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -8,6 +8,8 @@ v0.10.0 (WIP): BREAKING: Canvas: Minimum supported version is now Dear ImGui 1.89 (August 2022) + BREAKING: Examples: Minimum supported version is now Dear ImGui 1.89 (August 2022) + RESTRUCTURE: Removed local copy of all dependencies in favor of auto checkout. This should also reduce user confusion and attempt to use ancient version of ImGui embedded in the repository. diff --git a/examples/blueprints-example/blueprints-example.cpp b/examples/blueprints-example/blueprints-example.cpp index 1b7fdc1c..96a3d9e5 100644 --- a/examples/blueprints-example/blueprints-example.cpp +++ b/examples/blueprints-example/blueprints-example.cpp @@ -878,7 +878,7 @@ struct Example: for (int i = 0; i < linkCount; ++i) ImGui::Text("Link (%p)", selectedLinks[i].AsPointer()); ImGui::Unindent(); - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z))) + if (ImGui::IsKeyPressed(ImGuiKey_Z)) for (auto& link : m_Links) ed::Flow(link.ID); @@ -1108,11 +1108,7 @@ struct Example: ed::PushStyleVar(ed::StyleVar_PinArrowSize, 10.0f); ed::PushStyleVar(ed::StyleVar_PinArrowWidth, 10.0f); -#if IMGUI_VERSION_NUM > 18101 ed::PushStyleVar(ed::StyleVar_PinCorners, ImDrawFlags_RoundCornersBottom); -#else - ed::PushStyleVar(ed::StyleVar_PinCorners, 12); -#endif ed::BeginPin(pin.ID, ed::PinKind::Input); ed::PinPivotRect(inputsRect.GetTL(), inputsRect.GetBR()); ed::PinRect(inputsRect.GetTL(), inputsRect.GetBR()); @@ -1154,11 +1150,7 @@ struct Example: ImGui::Spring(1, 0); outputsRect = ImGui_GetItemRect(); -#if IMGUI_VERSION_NUM > 18101 ed::PushStyleVar(ed::StyleVar_PinCorners, ImDrawFlags_RoundCornersTop); -#else - ed::PushStyleVar(ed::StyleVar_PinCorners, 3); -#endif ed::BeginPin(pin.ID, ed::PinKind::Output); ed::PinPivotRect(outputsRect.GetTL(), outputsRect.GetBR()); ed::PinRect(outputsRect.GetTL(), outputsRect.GetBR()); @@ -1193,13 +1185,8 @@ struct Example: // drawList->PathStroke(col, true, thickness); //}; -#if IMGUI_VERSION_NUM > 18101 const auto topRoundCornersFlags = ImDrawFlags_RoundCornersTop; const auto bottomRoundCornersFlags = ImDrawFlags_RoundCornersBottom; -#else - const auto topRoundCornersFlags = 1 | 2; - const auto bottomRoundCornersFlags = 4 | 8; -#endif drawList->AddRectFilled(inputsRect.GetTL() + ImVec2(0, 1), inputsRect.GetBR(), IM_COL32((int)(255 * pinBackground.x), (int)(255 * pinBackground.y), (int)(255 * pinBackground.z), inputAlpha), 4.0f, bottomRoundCornersFlags); @@ -1263,11 +1250,7 @@ struct Example: inputsRect.Min.y -= padding; inputsRect.Max.y -= padding; -#if IMGUI_VERSION_NUM > 18101 const auto allRoundCornersFlags = ImDrawFlags_RoundCornersAll; -#else - const auto allRoundCornersFlags = 15; -#endif //ed::PushStyleVar(ed::StyleVar_PinArrowSize, 10.0f); //ed::PushStyleVar(ed::StyleVar_PinArrowWidth, 10.0f); ed::PushStyleVar(ed::StyleVar_PinCorners, allRoundCornersFlags); @@ -1324,13 +1307,8 @@ struct Example: outputsRect.Min.y += padding; outputsRect.Max.y += padding; -#if IMGUI_VERSION_NUM > 18101 const auto allRoundCornersFlags = ImDrawFlags_RoundCornersAll; const auto topRoundCornersFlags = ImDrawFlags_RoundCornersTop; -#else - const auto allRoundCornersFlags = 15; - const auto topRoundCornersFlags = 3; -#endif ed::PushStyleVar(ed::StyleVar_PinCorners, topRoundCornersFlags); ed::BeginPin(pin.ID, ed::PinKind::Output); diff --git a/examples/blueprints-example/utilities/builders.cpp b/examples/blueprints-example/utilities/builders.cpp index e8ae020a..bdff8273 100644 --- a/examples/blueprints-example/utilities/builders.cpp +++ b/examples/blueprints-example/utilities/builders.cpp @@ -66,11 +66,7 @@ void util::BlueprintNodeBuilder::End() HeaderMin - ImVec2(8 - halfBorderWidth, 4 - halfBorderWidth), HeaderMax + ImVec2(8 - halfBorderWidth, 0), ImVec2(0.0f, 0.0f), uv, -#if IMGUI_VERSION_NUM > 18101 headerColor, GetStyle().NodeRounding, ImDrawFlags_RoundCornersTop); -#else - headerColor, GetStyle().NodeRounding, 1 | 2); -#endif if (ContentMin.y > HeaderMax.y) { diff --git a/examples/blueprints-example/utilities/drawing.cpp b/examples/blueprints-example/utilities/drawing.cpp index 1f255eec..cdbd26a7 100644 --- a/examples/blueprints-example/utilities/drawing.cpp +++ b/examples/blueprints-example/utilities/drawing.cpp @@ -112,11 +112,7 @@ void ax::Drawing::DrawIcon(ImDrawList* drawList, const ImVec2& a, const ImVec2& const auto p0 = rect_center - ImVec2(r, r); const auto p1 = rect_center + ImVec2(r, r); -#if IMGUI_VERSION_NUM > 18101 drawList->AddRectFilled(p0, p1, color, 0, ImDrawFlags_RoundCornersAll); -#else - drawList->AddRectFilled(p0, p1, color, 0, 15); -#endif } else { @@ -126,18 +122,10 @@ void ax::Drawing::DrawIcon(ImDrawList* drawList, const ImVec2& a, const ImVec2& if (innerColor & 0xFF000000) { -#if IMGUI_VERSION_NUM > 18101 drawList->AddRectFilled(p0, p1, innerColor, 0, ImDrawFlags_RoundCornersAll); -#else - drawList->AddRectFilled(p0, p1, innerColor, 0, 15); -#endif } -#if IMGUI_VERSION_NUM > 18101 drawList->AddRect(p0, p1, color, 0, ImDrawFlags_RoundCornersAll, 2.0f * outline_scale); -#else - drawList->AddRect(p0, p1, color, 0, 15, 2.0f * outline_scale); -#endif } } @@ -180,11 +168,7 @@ void ax::Drawing::DrawIcon(ImDrawList* drawList, const ImVec2& a, const ImVec2& const auto p0 = rect_center - ImVec2(r, r); const auto p1 = rect_center + ImVec2(r, r); -#if IMGUI_VERSION_NUM > 18101 drawList->AddRectFilled(p0, p1, color, cr, ImDrawFlags_RoundCornersAll); -#else - drawList->AddRectFilled(p0, p1, color, cr, 15); -#endif } else { @@ -195,18 +179,10 @@ void ax::Drawing::DrawIcon(ImDrawList* drawList, const ImVec2& a, const ImVec2& if (innerColor & 0xFF000000) { -#if IMGUI_VERSION_NUM > 18101 drawList->AddRectFilled(p0, p1, innerColor, cr, ImDrawFlags_RoundCornersAll); -#else - drawList->AddRectFilled(p0, p1, innerColor, cr, 15); -#endif } -#if IMGUI_VERSION_NUM > 18101 drawList->AddRect(p0, p1, color, cr, ImDrawFlags_RoundCornersAll, 2.0f * outline_scale); -#else - drawList->AddRect(p0, p1, color, cr, 15, 2.0f * outline_scale); -#endif } } else if (type == IconType::Diamond) diff --git a/examples/widgets-example/widgets-example.cpp b/examples/widgets-example/widgets-example.cpp index c6f741aa..5317e402 100644 --- a/examples/widgets-example/widgets-example.cpp +++ b/examples/widgets-example/widgets-example.cpp @@ -128,11 +128,19 @@ struct Example: // Arrow buttons with Repeater static int counter = 0; float spacing = ImGui::GetStyle().ItemInnerSpacing.x; +# if IMGUI_VERSION_NUM >= 19094 + ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true); +# else ImGui::PushButtonRepeat(true); +# endif if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; } ImGui::SameLine(0.0f, spacing); if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; } +# if IMGUI_VERSION_NUM >= 19094 + ImGui::PopItemFlag(); +# else ImGui::PopButtonRepeat(); +# endif ImGui::SameLine(); ImGui::Text("%d", counter);