Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Schittek <lone_noel>2022-03-07 19:47:57 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-03-07 20:32:47 +0300
commit1cb303242fa67574449315c59a786a7ad52ea957 (patch)
tree45e0fd63be0ef61741bf54473c8d40d9f3a0a32e
parent21d633f83b3ab09342ad32c4c3d896d3a8308404 (diff)
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
-rw-r--r--source/blender/editors/interface/interface_widgets.c15
1 files changed, 8 insertions, 7 deletions
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;
}
}