From 7c51cba74f4a871c502cf291bc0d134cf41e3bd4 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 20 Feb 2019 00:20:11 +0100 Subject: [PATCH] InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367) --- docs/CHANGELOG.txt | 6 ++++++ imgui_widgets.cpp | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e2119884..16664518 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -33,6 +33,12 @@ HOW TO UPDATE? VERSION 1.69 (In Progress) ----------------------------------------------------------------------- +Other Changes: + +- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when + style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are + meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367) + ----------------------------------------------------------------------- VERSION 1.68 (Released 2019-02-19) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 327e3d83..1fb7dd6d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -2648,7 +2648,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p return false; ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; + ImGuiStyle& style = g.Style; IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT); if (format == NULL) @@ -2674,6 +2674,8 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p PopItemWidth(); // Step buttons + const ImVec2 backup_frame_padding = style.FramePadding; + style.FramePadding.x = style.FramePadding.y; ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; if (flags & ImGuiInputTextFlags_ReadOnly) button_flags |= ImGuiButtonFlags_Disabled; @@ -2691,6 +2693,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p } SameLine(0, style.ItemInnerSpacing.x); TextUnformatted(label, FindRenderedTextEnd(label)); + style.FramePadding = backup_frame_padding; PopID(); EndGroup();