UI Code Quality: Use derived struct for number buttons

For the man rationale behind this design, see 49f088e2d0. Further,
this removes users of uiBut.a1/uiBut.a2, which is a very ugly design
choice (hard to reason about).

Note that I had to do rather ugly, specific exceptions for the number
buttons in `ui_def_but_rna()`. But once all users of a1/a2 are removed,
this special handling shouldn't be needed anymore.
I also had to move a sanity check out of the button definition. It's now
moved into a new debug only sanity checking function executed when
finishing the layout definition (block end).
This commit is contained in:
Julian Eisel 2020-09-04 21:18:45 +02:00
parent 47881791be
commit e6f0b60c2e
Notes: blender-bot 2024-02-01 19:45:09 +01:00
Referenced by commit fd110291a5, Fix T81794: ColorRampElement step regression
Referenced by commit 3cafaf0fa8, Fix possible use-after-free for number slider buttons
Referenced by issue #81794, Color Ramp Element position stepping is unusable
Referenced by issue #80613, Assert in UI_but_number_precision_set
Referenced by commit 5155feeeb8, Cleanup: UI: Remove a1 and a2 unused arguments from uiDefButF function
12 changed files with 788 additions and 604 deletions

View File

@ -196,9 +196,10 @@ static void draw_modifier__generator(uiLayout *layout,
&data->poly_order,
1,
100,
1,
0,
0,
TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
UI_but_number_step_size_set(but, 1);
UI_but_func_set(but, validate_fmodifier_cb, fcm, fcurve_owner_id);
/* calculate maximum width of label for "x^n" labels */
@ -256,20 +257,22 @@ static void draw_modifier__generator(uiLayout *layout,
}
/* coefficient */
uiDefButF(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
"",
0,
0,
bwidth / 2,
UI_UNIT_Y,
cp,
-UI_FLT_MAX,
UI_FLT_MAX,
10,
3,
TIP_("Coefficient for polynomial"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
"",
0,
0,
bwidth / 2,
UI_UNIT_Y,
cp,
-UI_FLT_MAX,
UI_FLT_MAX,
0,
0,
TIP_("Coefficient for polynomial"));
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 3);
/* 'x' param (and '+' if necessary) */
if (i == 0) {
@ -334,10 +337,11 @@ static void draw_modifier__generator(uiLayout *layout,
&data->poly_order,
1,
100,
1,
0,
0,
TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
UI_but_func_set(but, validate_fmodifier_cb, fcm, fcurve_owner_id);
UI_but_number_step_size_set(but, 1);
/* draw controls for each pair of coefficients */
row = uiLayoutRow(layout, true);
@ -386,20 +390,22 @@ static void draw_modifier__generator(uiLayout *layout,
block, UI_BTYPE_LABEL, 1, "(", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
/* coefficients */
uiDefButF(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
"",
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
cp,
-UI_FLT_MAX,
UI_FLT_MAX,
10,
3,
TIP_("Coefficient of x"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
"",
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
cp,
-UI_FLT_MAX,
UI_FLT_MAX,
0,
0,
TIP_("Coefficient of x"));
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 3);
uiDefBut(block,
UI_BTYPE_LABEL,
@ -416,20 +422,22 @@ static void draw_modifier__generator(uiLayout *layout,
0,
"");
uiDefButF(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
"",
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
cp + 1,
-UI_FLT_MAX,
UI_FLT_MAX,
10,
3,
TIP_("Second coefficient"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
"",
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
cp + 1,
-UI_FLT_MAX,
UI_FLT_MAX,
0,
0,
TIP_("Second coefficient"));
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 3);
/* closing bracket and multiplication sign */
if ((i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2)) {
@ -724,54 +732,60 @@ static void draw_modifier__envelope(uiLayout *layout,
block = uiLayoutGetBlock(row);
UI_block_align_begin(block);
uiDefButR(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
IFACE_("Fra:"),
0,
0,
4.5 * UI_UNIT_X,
UI_UNIT_Y,
&ctrl_ptr,
"frame",
-1,
-MAXFRAMEF,
MAXFRAMEF,
10,
1,
NULL);
uiDefButR(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
IFACE_("Min:"),
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
&ctrl_ptr,
"min",
-1,
-UI_FLT_MAX,
UI_FLT_MAX,
10,
2,
NULL);
uiDefButR(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
IFACE_("Max:"),
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
&ctrl_ptr,
"max",
-1,
-UI_FLT_MAX,
UI_FLT_MAX,
10,
2,
NULL);
but = uiDefButR(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
IFACE_("Fra:"),
0,
0,
4.5 * UI_UNIT_X,
UI_UNIT_Y,
&ctrl_ptr,
"frame",
-1,
-MAXFRAMEF,
MAXFRAMEF,
0,
0,
NULL);
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 1);
but = uiDefButR(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
IFACE_("Min:"),
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
&ctrl_ptr,
"min",
-1,
-UI_FLT_MAX,
UI_FLT_MAX,
0,
0,
NULL);
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 2);
but = uiDefButR(block,
UI_BTYPE_NUM,
B_FMODIFIER_REDRAW,
IFACE_("Max:"),
0,
0,
5 * UI_UNIT_X,
UI_UNIT_Y,
&ctrl_ptr,
"max",
-1,
-UI_FLT_MAX,
UI_FLT_MAX,
0,
0,
NULL);
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 2);
but = uiDefIconBut(block,
UI_BTYPE_BUT,

View File

@ -1602,6 +1602,9 @@ int UI_search_items_find_index(uiSearchItems *items, const char *name);
void UI_but_node_link_set(uiBut *but, struct bNodeSocket *socket, const float draw_color[4]);
void UI_but_number_step_size_set(uiBut *but, float step_size);
void UI_but_number_precision_set(uiBut *but, float precision);
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg);
void UI_block_func_butmenu_set(uiBlock *block, uiMenuHandleFunc func, void *arg);
void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);

View File

@ -622,9 +622,18 @@ void UI_block_bounds_set_explicit(uiBlock *block, int minx, int miny, int maxx,
block->bounds_type = UI_BLOCK_BOUNDS_NONE;
}
static float ui_but_get_float_precision(uiBut *but)
{
if (but->type == UI_BTYPE_NUM) {
return ((uiButNumber *)but)->precision;
}
return but->a2;
}
static int ui_but_calc_float_precision(uiBut *but, double value)
{
int prec = (int)but->a2;
int prec = (int)ui_but_get_float_precision(but);
/* first check for various special cases:
* * If button is radians, we want additional precision (see T39861).
@ -1737,6 +1746,24 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block)
block->oldblock = NULL;
}
#ifndef NDEBUG
/**
* Extra sanity checks for invariants (debug builds only).
*/
static void ui_but_validate(const uiBut *but)
{
/* Number buttons must have a click-step,
* assert instead of correcting the value to ensure the caller knows what they're doing. */
if (but->type == UI_BTYPE_NUM) {
uiButNumber *number_but = (uiButNumber *)but;
if (ELEM(but->pointype, UI_BUT_POIN_CHAR, UI_BUT_POIN_SHORT, UI_BUT_POIN_INT)) {
BLI_assert((int)number_but->step_size > 0);
}
}
}
#endif
void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_xy[2])
{
wmWindow *window = CTX_wm_window(C);
@ -1778,6 +1805,10 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
ui_but_anim_decorate_update_from_flag((uiButDecorator *)but);
}
ui_but_predefined_extra_operator_icons_add(but);
#ifndef NDEBUG
ui_but_validate(but);
#endif
}
/* handle pending stuff */
@ -2562,7 +2593,7 @@ static void ui_get_but_string_unit(
/* Use precision override? */
if (float_precision == -1) {
/* Sanity checks */
precision = (int)but->a2;
precision = (int)ui_but_get_float_precision(but);
if (precision > UI_PRECISION_FLOAT_MAX) {
precision = UI_PRECISION_FLOAT_MAX;
}
@ -3768,6 +3799,10 @@ static void ui_but_alloc_info(const eButType type,
bool has_custom_type = true;
switch (type) {
case UI_BTYPE_NUM:
alloc_size = sizeof(uiButNumber);
alloc_str = "uiButNumber";
break;
case UI_BTYPE_COLOR:
alloc_size = sizeof(uiButColor);
alloc_str = "uiButColor";
@ -3914,14 +3949,6 @@ static uiBut *ui_def_but(uiBlock *block,
(a1 != 0.0f && a1 != 1.0f)) == false);
}
/* Number buttons must have a click-step,
* assert instead of correcting the value to ensure the caller knows what they're doing. */
if ((type & BUTTYPE) == UI_BTYPE_NUM) {
if (ELEM((type & UI_BUT_POIN_TYPES), UI_BUT_POIN_CHAR, UI_BUT_POIN_SHORT, UI_BUT_POIN_INT)) {
BLI_assert((int)a1 > 0);
}
}
if (type & UI_BUT_POIN_TYPES) { /* a pointer is required */
if (poin == NULL) {
BLI_assert(0);
@ -4360,6 +4387,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
uiBut *but;
int icon = 0;
uiMenuCreateFunc func = NULL;
const bool always_set_a1_a2 = ELEM(type, UI_BTYPE_NUM);
if (ELEM(type, UI_BTYPE_COLOR, UI_BTYPE_HSVCIRCLE, UI_BTYPE_HSVCUBE)) {
BLI_assert(index == -1);
@ -4424,7 +4452,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
tip = RNA_property_ui_description(prop);
}
if (min == max || a1 == -1 || a2 == -1) {
if (min == max || a1 == -1 || a2 == -1 || always_set_a1_a2) {
if (proptype == PROP_INT) {
int hardmin, hardmax, softmin, softmax, step;
@ -4435,10 +4463,10 @@ static uiBut *ui_def_but_rna(uiBlock *block,
min = hardmin;
max = hardmax;
}
if (a1 == -1) {
if (a1 == -1 || always_set_a1_a2) {
a1 = step;
}
if (a2 == -1) {
if (a2 == -1 || always_set_a1_a2) {
a2 = 0;
}
}
@ -4452,10 +4480,10 @@ static uiBut *ui_def_but_rna(uiBlock *block,
min = hardmin;
max = hardmax;
}
if (a1 == -1) {
if (a1 == -1 || always_set_a1_a2) {
a1 = step;
}
if (a2 == -1) {
if (a2 == -1 || always_set_a1_a2) {
a2 = precision;
}
}
@ -4469,6 +4497,12 @@ static uiBut *ui_def_but_rna(uiBlock *block,
/* now create button */
but = ui_def_but(block, type, retval, str, x, y, width, height, NULL, min, max, a1, a2, tip);
if (but->type == UI_BTYPE_NUM) {
/* Set default values, can be overriden later. */
UI_but_number_step_size_set(but, a1);
UI_but_number_precision_set(but, a2);
}
but->rnapoin = *ptr;
but->rnaprop = prop;
@ -4506,7 +4540,13 @@ static uiBut *ui_def_but_rna(uiBlock *block,
/* If this button uses units, calculate the step from this */
if ((proptype == PROP_FLOAT) && ui_but_is_unit(but)) {
but->a1 = ui_get_but_step_unit(but, but->a1);
if (type == UI_BTYPE_NUM) {
uiButNumber *number_but = (uiButNumber *)but;
number_but->step_size = ui_get_but_step_unit(but, number_but->step_size);
}
else {
but->a1 = ui_get_but_step_unit(but, but->a1);
}
}
if (func) {
@ -6707,6 +6747,24 @@ void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_colo
rgba_float_to_uchar(but->col, draw_color);
}
void UI_but_number_step_size_set(uiBut *but, float step_size)
{
uiButNumber *but_number = (uiButNumber *)but;
BLI_assert(but->type == UI_BTYPE_NUM);
but_number->step_size = step_size;
BLI_assert(step_size > 0);
}
void UI_but_number_precision_set(uiBut *but, float precision)
{
uiButNumber *but_number = (uiButNumber *)but;
BLI_assert(but->type == UI_BTYPE_NUM);
but_number->precision = precision;
BLI_assert(precision > -1);
}
/**
* push a new event onto event queue to activate the given button
* (usually a text-field) upon entering a popup

View File

@ -3896,12 +3896,14 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
softrange = softmax - softmin;
if ((but->type == UI_BTYPE_NUM) && (ui_but_is_cursor_warp(but) == false)) {
uiButNumber *number_but = (uiButNumber *)but;
/* Use a minimum so we have a predictable range,
* otherwise some float buttons get a large range. */
const float value_step_float_min = 0.1f;
const bool is_float = ui_but_is_float(but);
const double value_step = is_float ? (double)(but->a1 * UI_PRECISION_FLOAT_SCALE) :
(int)but->a1;
const double value_step = is_float ?
(double)(number_but->step_size * UI_PRECISION_FLOAT_SCALE) :
(int)number_but->step_size;
const float drag_map_softrange_max = UI_DRAG_MAP_SOFT_RANGE_PIXEL_MAX * UI_DPI_FAC;
const float softrange_max = min_ff(
softrange,
@ -4699,13 +4701,14 @@ static float ui_numedit_apply_snap(int temp,
return temp;
}
static bool ui_numedit_but_NUM(uiBut *but,
static bool ui_numedit_but_NUM(uiButNumber *number_but,
uiHandleButtonData *data,
int mx,
const bool is_motion,
const enum eSnapType snap,
float fac)
{
uiBut *but = &number_but->but;
float deler, tempf;
int lvalue, temp;
bool changed = false;
@ -4724,7 +4727,7 @@ static bool ui_numedit_but_NUM(uiBut *but,
/* Mouse location isn't screen clamped to the screen so use a linear mapping
* 2px == 1-int, or 1px == 1-ClickStep */
if (is_float) {
fac *= 0.01f * but->a1;
fac *= 0.01f * number_but->step_size;
tempf = (float)data->startvalue + ((float)(mx - data->dragstartx) * fac);
tempf = ui_numedit_apply_snapf(but, tempf, softmin, softmax, snap);
@ -4927,6 +4930,7 @@ static void ui_numedit_set_active(uiBut *but)
static int ui_do_but_NUM(
bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
uiButNumber *number_but = (uiButNumber *)but;
int click = 0;
int retval = WM_UI_HANDLER_CONTINUE;
@ -4936,6 +4940,8 @@ static int ui_do_but_NUM(
/* mouse location kept at screen pixel coords */
const int screen_mx = event->x;
BLI_assert(but->type == UI_BTYPE_NUM);
ui_window_to_block(data->region, block, &mx, &my);
ui_numedit_set_active(but);
@ -5028,8 +5034,12 @@ static int ui_do_but_NUM(
fac /= 10.0f;
}
if (ui_numedit_but_NUM(
but, data, (ui_but_is_cursor_warp(but) ? screen_mx : mx), is_motion, snap, fac)) {
if (ui_numedit_but_NUM(number_but,
data,
(ui_but_is_cursor_warp(but) ? screen_mx : mx),
is_motion,
snap,
fac)) {
ui_numedit_apply(C, block, but, data);
}
#ifdef USE_DRAG_MULTINUM
@ -5060,7 +5070,7 @@ static int ui_do_but_NUM(
if (but->drawflag & (UI_BUT_ACTIVE_LEFT | UI_BUT_ACTIVE_RIGHT)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
const int value_step = (int)but->a1;
const int value_step = (int)number_but->step_size;
BLI_assert(value_step > 0);
const int softmin = round_fl_to_int_clamp(but->softmin);
const int softmax = round_fl_to_int_clamp(but->softmax);
@ -5084,7 +5094,7 @@ static int ui_do_but_NUM(
if (but->drawflag & (UI_BUT_ACTIVE_LEFT | UI_BUT_ACTIVE_RIGHT)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
const double value_step = (double)but->a1 * UI_PRECISION_FLOAT_SCALE;
const double value_step = (double)number_but->step_size * UI_PRECISION_FLOAT_SCALE;
BLI_assert(value_step > 0.0f);
const double value_test = (but->drawflag & UI_BUT_ACTIVE_LEFT) ?
(double)max_ff(but->softmin,

View File

@ -174,7 +174,6 @@ struct uiBut {
/**
* For #uiBut.type:
* - UI_BTYPE_NUM: Use to store RNA 'step' value, for dragging and click-step.
* - UI_BTYPE_LABEL: Use `(a1 == 1.0f)` to use a2 as a blending factor (imaginative!).
* - UI_BTYPE_SCROLL: Use as scroll size.
* - UI_BTYPE_SEARCH_MENU: Use as number or rows.
@ -184,7 +183,6 @@ struct uiBut {
/**
* For #uiBut.type:
* - UI_BTYPE_HSVCIRCLE: Use to store the luminosity.
* - UI_BTYPE_NUM: Use to store RNA 'precision' value, for dragging and click-step.
* - UI_BTYPE_LABEL: If `(a1 == 1.0f)` use a2 as a blending factor.
* - UI_BTYPE_SEARCH_MENU: Use as number or columns.
*/
@ -276,6 +274,14 @@ struct uiBut {
uiBlock *block;
};
/** Derived struct for #UI_BTYPE_NUM */
typedef struct uiButNumber {
uiBut but;
float step_size;
float precision;
} uiButNumber;
/** Derived struct for #UI_BTYPE_COLOR */
typedef struct uiButColor {
uiBut but;

View File

@ -629,7 +629,10 @@ static void ui_item_array(uiLayout *layout,
w,
UI_UNIT_Y);
if (slider && but->type == UI_BTYPE_NUM) {
but->type = UI_BTYPE_NUM_SLIDER;
uiButNumber *number_but = (uiButNumber *)but;
but->a1 = number_but->step_size;
ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
}
}
}
@ -697,7 +700,10 @@ static void ui_item_array(uiLayout *layout,
but = uiDefAutoButR(block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y);
if (slider && but->type == UI_BTYPE_NUM) {
but->type = UI_BTYPE_NUM_SLIDER;
uiButNumber *number_but = (uiButNumber *)but;
but->a1 = number_but->step_size;
ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
}
if ((toggle == 1) && but->type == UI_BTYPE_CHECKBOX) {
but->type = UI_BTYPE_TOGGLE;
@ -2290,7 +2296,10 @@ void uiItemFullR(uiLayout *layout,
but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h);
if (slider && but->type == UI_BTYPE_NUM) {
but->type = UI_BTYPE_NUM_SLIDER;
uiButNumber *num_but = (uiButNumber *)but;
but->a1 = num_but->step_size;
ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
}
if (flag & UI_ITEM_R_CHECKBOX_INVERT) {

View File

@ -3319,20 +3319,22 @@ static void colorband_buttons_layout(uiLayout *layout,
split = uiLayoutSplit(layout, 0.3f, false);
row = uiLayoutRow(split, false);
uiDefButS(block,
UI_BTYPE_NUM,
0,
"",
0,
0,
5.0f * UI_UNIT_X,
UI_UNIT_Y,
&coba->cur,
0.0,
(float)(MAX2(0, coba->tot - 1)),
1,
0,
TIP_("Choose active color stop"));
bt = uiDefButS(block,
UI_BTYPE_NUM,
0,
"",
0,
0,
5.0f * UI_UNIT_X,
UI_UNIT_Y,
&coba->cur,
0.0,
(float)(MAX2(0, coba->tot - 1)),
0,
0,
TIP_("Choose active color stop"));
UI_but_number_step_size_set(bt, 1);
row = uiLayoutRow(split, false);
uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE);
bt = block->buttons.last;
@ -3349,20 +3351,22 @@ static void colorband_buttons_layout(uiLayout *layout,
subsplit = uiLayoutSplit(split, 0.35f, false);
row = uiLayoutRow(subsplit, false);
uiDefButS(block,
UI_BTYPE_NUM,
0,
"",
0,
0,
5.0f * UI_UNIT_X,
UI_UNIT_Y,
&coba->cur,
0.0,
(float)(MAX2(0, coba->tot - 1)),
1,
0,
TIP_("Choose active color stop"));
bt = uiDefButS(block,
UI_BTYPE_NUM,
0,
"",
0,
0,
5.0f * UI_UNIT_X,
UI_UNIT_Y,
&coba->cur,
0.0,
(float)(MAX2(0, coba->tot - 1)),
0,
0,
TIP_("Choose active color stop"));
UI_but_number_step_size_set(bt, 1);
row = uiLayoutRow(subsplit, false);
uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), ICON_NONE);
bt = block->buttons.last;
@ -3915,62 +3919,70 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
UI_but_func_set(bt, curvemap_buttons_setclip, cumap, NULL);
UI_block_align_begin(block);
uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Min X:"),
0,
4 * UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.xmin,
-100.0,
cumap->clipr.xmax,
10,
2,
"");
uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Min Y:"),
0,
3 * UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.ymin,
-100.0,
cumap->clipr.ymax,
10,
2,
"");
uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Max X:"),
0,
2 * UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.xmax,
cumap->clipr.xmin,
100.0,
10,
2,
"");
uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Max Y:"),
0,
UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.ymax,
cumap->clipr.ymin,
100.0,
10,
2,
"");
bt = uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Min X:"),
0,
4 * UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.xmin,
-100.0,
cumap->clipr.xmax,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
bt = uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Min Y:"),
0,
3 * UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.ymin,
-100.0,
cumap->clipr.ymax,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
bt = uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Max X:"),
0,
2 * UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.xmax,
cumap->clipr.xmin,
100.0,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
bt = uiDefButF(block,
UI_BTYPE_NUM,
0,
IFACE_("Max Y:"),
0,
UI_UNIT_Y,
width,
UI_UNIT_Y,
&cumap->clipr.ymax,
cumap->clipr.ymin,
100.0,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
UI_block_direction_set(block, UI_DIR_DOWN);
@ -4464,34 +4476,38 @@ static void curvemap_buttons_layout(uiLayout *layout,
uiLayoutRow(layout, true);
UI_block_funcN_set(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap);
uiDefButF(block,
UI_BTYPE_NUM,
0,
"X",
0,
2 * UI_UNIT_Y,
UI_UNIT_X * 10,
UI_UNIT_Y,
&cmp->x,
bounds.xmin,
bounds.xmax,
1,
5,
"");
uiDefButF(block,
UI_BTYPE_NUM,
0,
"Y",
0,
1 * UI_UNIT_Y,
UI_UNIT_X * 10,
UI_UNIT_Y,
&cmp->y,
bounds.ymin,
bounds.ymax,
1,
5,
"");
bt = uiDefButF(block,
UI_BTYPE_NUM,
0,
"X",
0,
2 * UI_UNIT_Y,
UI_UNIT_X * 10,
UI_UNIT_Y,
&cmp->x,
bounds.xmin,
bounds.xmax,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
bt = uiDefButF(block,
UI_BTYPE_NUM,
0,
"Y",
0,
1 * UI_UNIT_Y,
UI_UNIT_X * 10,
UI_UNIT_Y,
&cmp->y,
bounds.ymin,
bounds.ymax,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
}
/* black/white levels */
@ -5075,9 +5091,11 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
selection_x,
bounds.xmin,
bounds.xmax,
1,
5,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
UI_but_funcN_set(bt, CurveProfile_buttons_update, MEM_dupallocN(cb), profile);
if (point_last_or_first) {
UI_but_flag_enable(bt, UI_BUT_DISABLED);
@ -5093,9 +5111,11 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
selection_y,
bounds.ymin,
bounds.ymax,
1,
5,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
UI_but_funcN_set(bt, CurveProfile_buttons_update, MEM_dupallocN(cb), profile);
if (point_last_or_first) {
UI_but_flag_enable(bt, UI_BUT_DISABLED);

View File

@ -164,7 +164,7 @@ uiBut *uiDefAutoButR(uiBlock *block,
}
else {
but = uiDefButR_prop(
block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, 0, 0, NULL);
}
if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {

View File

@ -585,34 +585,38 @@ void uiTemplateMarker(uiLayout *layout,
0,
0,
"");
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_POS,
IFACE_("X:"),
0.5 * UI_UNIT_X,
9 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pos[0],
-10 * width,
10.0 * width,
step,
digits,
TIP_("X-position of marker at frame in screen coordinates"));
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_POS,
IFACE_("Y:"),
8.25 * UI_UNIT_X,
9 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pos[1],
-10 * height,
10.0 * height,
step,
digits,
TIP_("Y-position of marker at frame in screen coordinates"));
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_POS,
IFACE_("X:"),
0.5 * UI_UNIT_X,
9 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pos[0],
-10 * width,
10.0 * width,
0,
0,
TIP_("X-position of marker at frame in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_POS,
IFACE_("Y:"),
8.25 * UI_UNIT_X,
9 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pos[1],
-10 * height,
10.0 * height,
0,
0,
TIP_("Y-position of marker at frame in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
uiDefBut(block,
UI_BTYPE_LABEL,
@ -628,34 +632,38 @@ void uiTemplateMarker(uiLayout *layout,
0,
0,
"");
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_OFFSET,
IFACE_("X:"),
0.5 * UI_UNIT_X,
7 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->track_offset[0],
-10 * width,
10.0 * width,
step,
digits,
TIP_("X-offset to parenting point"));
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_OFFSET,
IFACE_("Y:"),
8.25 * UI_UNIT_X,
7 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->track_offset[1],
-10 * height,
10.0 * height,
step,
digits,
TIP_("Y-offset to parenting point"));
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_OFFSET,
IFACE_("X:"),
0.5 * UI_UNIT_X,
7 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->track_offset[0],
-10 * width,
10.0 * width,
0,
0,
TIP_("X-offset to parenting point"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_OFFSET,
IFACE_("Y:"),
8.25 * UI_UNIT_X,
7 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->track_offset[1],
-10 * height,
10.0 * height,
0,
0,
TIP_("Y-offset to parenting point"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
uiDefBut(block,
UI_BTYPE_LABEL,
@ -671,34 +679,38 @@ void uiTemplateMarker(uiLayout *layout,
0,
0,
"");
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_PAT_DIM,
IFACE_("Width:"),
0.5 * UI_UNIT_X,
5 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pat[0],
3.0f,
10.0 * width,
step,
digits,
TIP_("Width of marker's pattern in screen coordinates"));
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_PAT_DIM,
IFACE_("Height:"),
0.5 * UI_UNIT_X,
4 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pat[1],
3.0f,
10.0 * height,
step,
digits,
TIP_("Height of marker's pattern in screen coordinates"));
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_PAT_DIM,
IFACE_("Width:"),
0.5 * UI_UNIT_X,
5 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pat[0],
3.0f,
10.0 * width,
0,
0,
TIP_("Width of marker's pattern in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_PAT_DIM,
IFACE_("Height:"),
0.5 * UI_UNIT_X,
4 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_pat[1],
3.0f,
10.0 * height,
0,
0,
TIP_("Height of marker's pattern in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
uiDefBut(block,
UI_BTYPE_LABEL,
@ -714,62 +726,70 @@ void uiTemplateMarker(uiLayout *layout,
0,
0,
"");
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_POS,
IFACE_("X:"),
0.5 * UI_UNIT_X,
2 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search_pos[0],
-width,
width,
step,
digits,
TIP_("X-position of search at frame relative to marker's position"));
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_POS,
IFACE_("Y:"),
8.25 * UI_UNIT_X,
2 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search_pos[1],
-height,
height,
step,
digits,
TIP_("Y-position of search at frame relative to marker's position"));
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_DIM,
IFACE_("Width:"),
0.5 * UI_UNIT_X,
1 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search[0],
3.0f,
10.0 * width,
step,
digits,
TIP_("Width of marker's search in screen coordinates"));
uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_DIM,
IFACE_("Height:"),
0.5 * UI_UNIT_X,
0 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search[1],
3.0f,
10.0 * height,
step,
digits,
TIP_("Height of marker's search in screen coordinates"));
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_POS,
IFACE_("X:"),
0.5 * UI_UNIT_X,
2 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search_pos[0],
-width,
width,
0,
0,
TIP_("X-position of search at frame relative to marker's position"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_POS,
IFACE_("Y:"),
8.25 * UI_UNIT_X,
2 * UI_UNIT_Y,
7.25 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search_pos[1],
-height,
height,
0,
0,
TIP_("Y-position of search at frame relative to marker's position"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_DIM,
IFACE_("Width:"),
0.5 * UI_UNIT_X,
1 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search[0],
3.0f,
10.0 * width,
0,
0,
TIP_("Width of marker's search in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
bt = uiDefButF(block,
UI_BTYPE_NUM,
B_MARKER_SEARCH_DIM,
IFACE_("Height:"),
0.5 * UI_UNIT_X,
0 * UI_UNIT_Y,
15 * UI_UNIT_X,
UI_UNIT_Y,
&cb->marker_search[1],
3.0f,
10.0 * height,
0,
0,
TIP_("Height of marker's search in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
UI_block_align_end(block);
}

View File

@ -437,8 +437,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
-1,
-1,
0,
0,
NULL);
uiItemL_respect_property_split(col, IFACE_("Value"), ICON_NONE);
@ -455,8 +455,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
1,
0,
0,
-1,
-1,
0,
0,
NULL);
UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
@ -501,8 +501,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
-1,
-1,
0,
0,
NULL);
UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
@ -520,8 +520,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
1,
0,
0,
-1,
-1,
0,
0,
NULL);
UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);
@ -565,8 +565,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
0,
0,
0,
-1,
-1,
0,
0,
NULL);
UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
@ -584,8 +584,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel)
1,
0,
0,
-1,
-1,
0,
0,
NULL);
UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
UI_but_unit_type_set(but, unit);

View File

@ -472,9 +472,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&tfp->ve_median.generic.location[0],
-lim,
lim,
10,
RNA_TRANSLATION_PREC_DEFAULT,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
but = uiDefButF(block,
UI_BTYPE_NUM,
@ -487,9 +489,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&tfp->ve_median.generic.location[1],
-lim,
lim,
10,
RNA_TRANSLATION_PREC_DEFAULT,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
but = uiDefButF(block,
UI_BTYPE_NUM,
@ -502,26 +506,30 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&tfp->ve_median.generic.location[2],
-lim,
lim,
10,
RNA_TRANSLATION_PREC_DEFAULT,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
if (totcurvebweight == tot) {
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("W:"),
0,
yi -= buth,
butw,
buth,
&(tfp->ve_median.curve.b_weight),
0.01,
100.0,
1,
3,
"");
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("W:"),
0,
yi -= buth,
butw,
buth,
&(tfp->ve_median.curve.b_weight),
0.01,
100.0,
0,
0,
"");
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
}
UI_block_align_begin(block);
@ -576,51 +584,57 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
0,
"");
/* customdata layer added on demand */
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
tot == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->bv_weight,
0.0,
1.0,
1,
2,
TIP_("Vertex weight used by Bevel modifier"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
tot == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->bv_weight,
0.0,
1.0,
0,
0,
TIP_("Vertex weight used by Bevel modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
}
if (has_skinradius) {
UI_block_align_begin(block);
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
tot == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->skin[0],
0.0,
100.0,
1,
3,
TIP_("X radius used by Skin modifier"));
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
tot == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->skin[1],
0.0,
100.0,
1,
3,
TIP_("Y radius used by Skin modifier"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
tot == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->skin[0],
0.0,
100.0,
0,
0,
TIP_("X radius used by Skin modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
tot == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->skin[1],
0.0,
100.0,
0,
0,
TIP_("Y radius used by Skin modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
UI_block_align_end(block);
}
if (totedgedata) {
@ -639,119 +653,133 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
0,
"");
/* customdata layer added on demand */
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->be_weight,
0.0,
1.0,
1,
2,
TIP_("Edge weight used by Bevel modifier"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->be_weight,
0.0,
1.0,
0,
0,
TIP_("Edge weight used by Bevel modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
/* customdata layer added on demand */
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->crease,
0.0,
1.0,
1,
2,
TIP_("Weight used by the Subdivision Surface modifier"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->crease,
0.0,
1.0,
0,
0,
TIP_("Weight used by the Subdivision Surface modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
}
}
/* Curve... */
else if (totcurvedata) {
TransformMedian_Curve *ve_median = &tfp->ve_median.curve;
if (totcurvedata == 1) {
uiDefButR(block,
UI_BTYPE_NUM,
0,
IFACE_("Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&data_ptr,
"weight_softbody",
0,
0.0,
1.0,
1,
3,
NULL);
uiDefButR(block,
UI_BTYPE_NUM,
0,
IFACE_("Radius:"),
0,
yi -= buth + but_margin,
butw,
buth,
&data_ptr,
"radius",
0,
0.0,
100.0,
1,
3,
NULL);
uiDefButR(block,
UI_BTYPE_NUM,
0,
IFACE_("Tilt:"),
0,
yi -= buth + but_margin,
butw,
buth,
&data_ptr,
"tilt",
0,
-tilt_limit,
tilt_limit,
1,
3,
NULL);
but = uiDefButR(block,
UI_BTYPE_NUM,
0,
IFACE_("Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&data_ptr,
"weight_softbody",
0,
0.0,
1.0,
0,
0,
NULL);
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
but = uiDefButR(block,
UI_BTYPE_NUM,
0,
IFACE_("Radius:"),
0,
yi -= buth + but_margin,
butw,
buth,
&data_ptr,
"radius",
0,
0.0,
100.0,
0,
0,
NULL);
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
but = uiDefButR(block,
UI_BTYPE_NUM,
0,
IFACE_("Tilt:"),
0,
yi -= buth + but_margin,
butw,
buth,
&data_ptr,
"tilt",
0,
-tilt_limit,
tilt_limit,
0,
0,
NULL);
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
}
else if (totcurvedata > 1) {
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("Mean Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->weight,
0.0,
1.0,
1,
3,
TIP_("Weight used for Soft Body Goal"));
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("Mean Radius:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->radius,
0.0,
100.0,
1,
3,
TIP_("Radius of curve control points"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("Mean Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->weight,
0.0,
1.0,
0,
0,
TIP_("Weight used for Soft Body Goal"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("Mean Radius:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->radius,
0.0,
100.0,
0,
0,
TIP_("Radius of curve control points"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
@ -763,9 +791,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->tilt,
-tilt_limit,
tilt_limit,
1,
3,
0,
0,
TIP_("Tilt of curve control points"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
UI_but_unit_type_set(but, PROP_UNIT_ROTATION);
}
}
@ -786,25 +816,29 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
0,
0.0,
1.0,
1,
3,
0,
0,
NULL);
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
}
else if (totlattdata > 1) {
uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("Mean Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->weight,
0.0,
1.0,
1,
3,
TIP_("Weight used for Soft Body Goal"));
but = uiDefButF(block,
UI_BTYPE_NUM,
B_TRANSFORM_PANEL_MEDIAN,
IFACE_("Mean Weight:"),
0,
yi -= buth + but_margin,
butw,
buth,
&ve_median->weight,
0.0,
1.0,
0,
0,
TIP_("Weight used for Soft Body Goal"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
}
}
@ -1083,9 +1117,11 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d
&(tfp->ob_dims[i]),
0.0f,
lim,
10,
3,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 3);
UI_but_unit_type_set(but, PROP_UNIT_LENGTH);
}
UI_block_align_end(block);
@ -1225,9 +1261,11 @@ static void view3d_panel_vgroup(const bContext *C, Panel *panel)
&dw->weight,
0.0,
1.0,
1,
3,
0,
0,
"");
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
UI_but_drawflag_enable(but, UI_BUT_TEXT_LEFT);
if (locked) {
lock_count++;

View File

@ -175,33 +175,39 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
digits = 2;
}
uiBut *but;
UI_block_align_begin(block);
uiDefButF(block,
UI_BTYPE_NUM,
B_UVEDIT_VERTEX,
IFACE_("X:"),
0,
0,
width,
UI_UNIT_Y,
&uvedit_old_center[0],
UNPACK2(range_xy[0]),
step,
digits,
"");
uiDefButF(block,
UI_BTYPE_NUM,
B_UVEDIT_VERTEX,
IFACE_("Y:"),
width,
0,
width,
UI_UNIT_Y,
&uvedit_old_center[1],
UNPACK2(range_xy[1]),
step,
digits,
"");
but = uiDefButF(block,
UI_BTYPE_NUM,
B_UVEDIT_VERTEX,
IFACE_("X:"),
0,
0,
width,
UI_UNIT_Y,
&uvedit_old_center[0],
UNPACK2(range_xy[0]),
0,
0,
"");
UI_but_number_step_size_set(but, step);
UI_but_number_precision_set(but, digits);
but = uiDefButF(block,
UI_BTYPE_NUM,
B_UVEDIT_VERTEX,
IFACE_("Y:"),
width,
0,
width,
UI_UNIT_Y,
&uvedit_old_center[1],
UNPACK2(range_xy[1]),
0,
0,
"");
UI_but_number_step_size_set(but, step);
UI_but_number_precision_set(but, digits);
UI_block_align_end(block);
}