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/interface/interface_templates.c
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/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c252
1 files changed, 136 insertions, 116 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index e5b485def65..5fbd26a4f5a 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -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);