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:
authorJulian Eisel <julian@blender.org>2020-09-04 22:18:45 +0300
committerJulian Eisel <julian@blender.org>2020-09-04 22:26:31 +0300
commite6f0b60c2e9111af1878d31dcc295c59ed1bea77 (patch)
tree4df10fc869f5f512c233a2755246c1749bafc1c7 /source/blender/editors/animation
parent47881791be0538f9558b2ef091e1761187df250d (diff)
UI Code Quality: Use derived struct for number buttons
For the man rationale behind this design, see 49f088e2d093. 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).
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c198
1 files changed, 106 insertions, 92 deletions
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 1ecdf5accb8..9d54be61171 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -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,