ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
Demo: Added extra usage of AlignTextToFramePadding() in a more visible section.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index fc37828..0c42272 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -46,7 +46,8 @@
- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024)
- DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024)
- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f.
-
+- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
+
-----------------------------------------------------------------------
VERSION 1.65 (Released 2018-09-06)
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index c3aa63a..ee53612 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -389,7 +389,8 @@
// Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
for (int i = 0; i < 7; i++)
{
- if (i > 0) ImGui::SameLine();
+ if (i > 0)
+ ImGui::SameLine();
ImGui::PushID(i);
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.6f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.7f));
@@ -399,7 +400,12 @@
ImGui::PopID();
}
- // Arrow buttons
+ // Use AlignTextToFramePadding() to align text baseline to the baseline of framed elements (otherwise a Text+SameLine+Button sequence will have the text a little too high by default)
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("Hold to repeat:");
+ ImGui::SameLine();
+
+ // Arrow buttons with Repeater
static int counter = 0;
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
ImGui::PushButtonRepeat(true);
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 2f55957..67650e2 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -626,7 +626,7 @@
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
RenderNavHighlight(bb, id);
RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
- RenderArrow(bb.Min + ImVec2(ImMax(0.0f, size.x - g.FontSize - g.Style.FramePadding.x), ImMax(0.0f, size.y - g.FontSize - g.Style.FramePadding.y)), dir);
+ RenderArrow(bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), dir);
return pressed;
}