diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-30 20:16:46 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-30 20:16:46 +0300 |
commit | 65e4bfe2f0c233a9df45b620f49a7093e9cc2edf (patch) | |
tree | 1cbf113460d563b170322fe2116299a310a52c86 /source/blender/editors | |
parent | 60e5ebdd62cff75267b6da5911a86e5bb15930b8 (diff) |
Cleanup: Reduce indentation
Instead of indenting the entire functional block, check for the error
case and the supported case early to make the code more readable.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4ab62a28724..efa5613e210 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1188,9 +1188,7 @@ static void ui_multibut_add(uiHandleButtonData *data, uiBut *but) static uiButMultiState *ui_multibut_lookup(uiHandleButtonData *data, const uiBut *but) { for (LinkNode *l = data->multi_data.mbuts; l; l = l->next) { - uiButMultiState *mbut_state; - - mbut_state = l->link; + uiButMultiState *mbut_state = l->link; if (mbut_state->but == but) { return mbut_state; @@ -1342,59 +1340,58 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl BLI_assert(data->multi_data.skip == false); LISTBASE_FOREACH (uiBut *, but, &block->buttons) { - if (but->flag & UI_BUT_DRAG_MULTI) { - /* mbut_states for delta */ - uiButMultiState *mbut_state = ui_multibut_lookup(data, but); + if (!(but->flag & UI_BUT_DRAG_MULTI)) { + continue; + } - if (mbut_state) { - void *active_back; + uiButMultiState *mbut_state = ui_multibut_lookup(data, but); + + if (mbut_state == NULL) { + /* Highly unlikely. */ + printf("%s: Can't find button\n", __func__); + } - ui_but_execute_begin(C, region, but, &active_back); + void *active_back; + ui_but_execute_begin(C, region, but, &active_back); # ifdef USE_ALLSELECT - if (data->select_others.is_enabled) { - /* init once! */ - if (mbut_state->select_others.elems_len == 0) { - ui_selectcontext_begin(C, but, &mbut_state->select_others); - } - if (mbut_state->select_others.elems_len == 0) { - mbut_state->select_others.elems_len = -1; - } - } + if (data->select_others.is_enabled) { + /* init once! */ + if (mbut_state->select_others.elems_len == 0) { + ui_selectcontext_begin(C, but, &mbut_state->select_others); + } + if (mbut_state->select_others.elems_len == 0) { + mbut_state->select_others.elems_len = -1; + } + } - /* needed so we apply the right deltas */ - but->active->origvalue = mbut_state->origvalue; - but->active->select_others = mbut_state->select_others; - but->active->select_others.do_free = false; + /* Needed so we apply the right deltas. */ + but->active->origvalue = mbut_state->origvalue; + but->active->select_others = mbut_state->select_others; + but->active->select_others.do_free = false; # endif - BLI_assert(active_back == NULL); - /* no need to check 'data->state' here */ - if (data->str) { - /* entering text (set all) */ - but->active->value = data->value; - ui_but_string_set(C, but, data->str); - } - else { - /* dragging (use delta) */ - if (data->multi_data.is_proportional) { - but->active->value = mbut_state->origvalue * value_scale; - } - else { - but->active->value = mbut_state->origvalue + value_delta; - } - - /* clamp based on soft limits, see: T40154 */ - CLAMP(but->active->value, (double)but->softmin, (double)but->softmax); - } - ui_but_execute_end(C, region, but, active_back); + BLI_assert(active_back == NULL); + /* No need to check 'data->state' here. */ + if (data->str) { + /* Entering text (set all). */ + but->active->value = data->value; + ui_but_string_set(C, but, data->str); + } + else { + /* Dragging (use delta). */ + if (data->multi_data.is_proportional) { + but->active->value = mbut_state->origvalue * value_scale; } else { - /* highly unlikely */ - printf("%s: cant find button\n", __func__); + but->active->value = mbut_state->origvalue + value_delta; } - /* end */ + + /* Clamp based on soft limits, see T40154. */ + CLAMP(but->active->value, (double)but->softmin, (double)but->softmax); } + + ui_but_execute_end(C, region, but, active_back); } } |