[Bf-blender-cvs] [1cb303242fa] master: UI: align labels of number fields and value sliders

Leon Schittek noreply at git.blender.org
Mon Mar 7 18:32:52 CET 2022


Commit: 1cb303242fa67574449315c59a786a7ad52ea957
Author: Leon Schittek
Date:   Mon Mar 7 17:47:57 2022 +0100
Branches: master
https://developer.blender.org/rB1cb303242fa67574449315c59a786a7ad52ea957

UI: align labels of number fields and value sliders

Previously the labels and values in number fields and value sliders
used different padding for the text. This looks weird when they are
placed underneath each other in a column and, as noted by a comment
in the code of `widget_numslider`, they are actually meant to be
aligned.

This patch fixes that by using the same padding that is used for the
number field for the value slider, as well. This also has the benefit,
that the labels of the value sliders don't shift anymore when adjusting
the corner roundness.

Differential Revision: https://developer.blender.org/D14091

===================================================================

M	source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d1f3843c643..35cf952b5ce 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -3319,6 +3319,8 @@ static void ui_draw_separator(const rcti *rect, const uiWidgetColors *wcol)
 /** \name Button Draw Callbacks
  * \{ */
 
+#define NUM_BUT_PADDING_FACTOR 0.425f
+
 static void widget_numbut_draw(
     uiWidgetColors *wcol, rcti *rect, const float zoom, int state, int roundboxalign, bool emboss)
 {
@@ -3413,11 +3415,10 @@ static void widget_numbut_draw(
   }
 
   if (!(state & UI_STATE_TEXT_INPUT)) {
-    const float textofs = 0.425f * BLI_rcti_size_y(rect);
+    const float text_padding = NUM_BUT_PADDING_FACTOR * BLI_rcti_size_y(rect);
 
-    /* text space */
-    rect->xmin += textofs;
-    rect->xmax -= textofs;
+    rect->xmin += text_padding;
+    rect->xmax -= text_padding;
   }
 }
 
@@ -3745,7 +3746,6 @@ static void widget_numslider(
 
   /* Backdrop first. */
   const float ofs = widget_radius_from_zoom(zoom, wcol);
-  const float toffs = ofs * 0.75f;
   round_box_edges(&wtb, roundboxalign, rect, ofs);
 
   wtb.draw_outline = false;
@@ -3838,8 +3838,9 @@ static void widget_numslider(
   /* Add space at either side of the button so text aligns with number-buttons
    * (which have arrow icons). */
   if (!(state & UI_STATE_TEXT_INPUT)) {
-    rect->xmax -= toffs;
-    rect->xmin += toffs;
+    const float text_padding = NUM_BUT_PADDING_FACTOR * BLI_rcti_size_y(rect);
+    rect->xmax -= text_padding;
+    rect->xmin += text_padding;
   }
 }



More information about the Bf-blender-cvs mailing list