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
This commit is contained in:
Leon Schittek 2022-03-07 17:47:57 +01:00 committed by Brecht Van Lommel
parent 21d633f83b
commit 1cb303242f
1 changed files with 8 additions and 7 deletions

View File

@ -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;
}
}