From e6f0b60c2e9111af1878d31dcc295c59ed1bea77 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 4 Sep 2020 21:18:45 +0200 Subject: 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). --- source/blender/editors/uvedit/uvedit_buttons.c | 58 ++++++++++++++------------ 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'source/blender/editors/uvedit/uvedit_buttons.c') 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); } -- cgit v1.2.3