Skip to content

Commit

Permalink
Examples: Minimum supported version is now Dear ImGui 1.89 (August 2022)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedmd committed Jul 21, 2024
1 parent b9db503 commit b302971
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 51 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 1 addition & 23 deletions examples/blueprints-example/blueprints-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions examples/blueprints-example/utilities/builders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
24 changes: 0 additions & 24 deletions examples/blueprints-example/utilities/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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
{
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions examples/widgets-example/widgets-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b302971

Please sign in to comment.