Browse Source

ColorEdit: Fix label alignment when using ImGuiColorEditFlags_NoInputs. (#2955)

Rokas Kupstys 5 years ago
parent
commit
e254167afd
2 changed files with 3 additions and 1 deletions
  1. 1 0
      docs/CHANGELOG.txt
  2. 2 1
      imgui_widgets.cpp

+ 1 - 0
docs/CHANGELOG.txt

@@ -64,6 +64,7 @@ Breaking Changes:
 Other Changes:
 Other Changes:
 - Inputs: Added ImGuiMouseButton enum for convenience (e.g. ImGuiMouseButton_Right=1).
 - Inputs: Added ImGuiMouseButton enum for convenience (e.g. ImGuiMouseButton_Right=1).
   We forever guarantee that the existing value will not changes so existing code is free to use 0/1/2.
   We forever guarantee that the existing value will not changes so existing code is free to use 0/1/2.
+- ColorEdit: Fix label alignment when using ImGuiColorEditFlags_NoInputs. (#2955) [@rokups]
 - Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups]
 - Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups]
 - ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count.
 - ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count.
   In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as
   In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as

+ 2 - 1
imgui_widgets.cpp

@@ -4340,7 +4340,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
 
 
     if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel))
     if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel))
     {
     {
-        window->DC.CursorPos = ImVec2(pos.x + w_full + style.ItemInnerSpacing.x, pos.y + style.FramePadding.y);
+        const float text_offset_x = (flags & ImGuiColorEditFlags_NoInputs) ? w_button : w_full + style.ItemInnerSpacing.x;
+        window->DC.CursorPos = ImVec2(pos.x + text_offset_x, pos.y + style.FramePadding.y);
         TextEx(label, label_display_end);
         TextEx(label, label_display_end);
     }
     }