1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-13 18:50:58 +01:00

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)

This commit is contained in:
omar 2019-02-20 00:20:11 +01:00
parent 257f5d204e
commit 7c51cba74f
2 changed files with 10 additions and 1 deletions

View File

@ -33,6 +33,12 @@ HOW TO UPDATE?
VERSION 1.69 (In Progress) 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) VERSION 1.68 (Released 2019-02-19)

View File

@ -2648,7 +2648,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
return false; return false;
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; ImGuiStyle& style = g.Style;
IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT); IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT);
if (format == NULL) if (format == NULL)
@ -2674,6 +2674,8 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p
PopItemWidth(); PopItemWidth();
// Step buttons // Step buttons
const ImVec2 backup_frame_padding = style.FramePadding;
style.FramePadding.x = style.FramePadding.y;
ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups;
if (flags & ImGuiInputTextFlags_ReadOnly) if (flags & ImGuiInputTextFlags_ReadOnly)
button_flags |= ImGuiButtonFlags_Disabled; 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); SameLine(0, style.ItemInnerSpacing.x);
TextUnformatted(label, FindRenderedTextEnd(label)); TextUnformatted(label, FindRenderedTextEnd(label));
style.FramePadding = backup_frame_padding;
PopID(); PopID();
EndGroup(); EndGroup();