diff options
author | Julian Eisel <julian@blender.org> | 2020-09-04 22:18:45 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-09-04 22:26:31 +0300 |
commit | e6f0b60c2e9111af1878d31dcc295c59ed1bea77 (patch) | |
tree | 4df10fc869f5f512c233a2755246c1749bafc1c7 /source/blender/editors/uvedit | |
parent | 47881791be0538f9558b2ef091e1761187df250d (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/uvedit')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_buttons.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index edfbfd0cdc3..f9949f6b671 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -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); } |