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:
authorSybren A. Stüvel <sybren@blender.org>2020-07-03 15:20:10 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-07-03 15:48:37 +0300
commitf3b8792b963b0b2a00fe7fe173f1beb85c209fbb (patch)
tree55ffa18ad4a6f2f03a127469780d47c54ad9bd74 /source/blender/editors
parent86e7648f0edc13d613d8fc39af7758e08cfdf9e2 (diff)
Cleanup: Interface, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/editors/interface` module. No functional changes.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface.c291
-rw-r--r--source/blender/editors/interface/interface_context_menu.c13
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c4
-rw-r--r--source/blender/editors/interface/interface_eyedropper_color.c8
-rw-r--r--source/blender/editors/interface/interface_eyedropper_colorband.c8
-rw-r--r--source/blender/editors/interface/interface_eyedropper_datablock.c14
-rw-r--r--source/blender/editors/interface/interface_eyedropper_depth.c8
-rw-r--r--source/blender/editors/interface/interface_eyedropper_driver.c86
-rw-r--r--source/blender/editors/interface/interface_eyedropper_gpencil_color.c8
-rw-r--r--source/blender/editors/interface/interface_handlers.c90
-rw-r--r--source/blender/editors/interface/interface_icons.c19
-rw-r--r--source/blender/editors/interface/interface_layout.c125
-rw-r--r--source/blender/editors/interface/interface_ops.c64
-rw-r--r--source/blender/editors/interface/interface_panel.c52
-rw-r--r--source/blender/editors/interface/interface_query.c8
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c36
-rw-r--r--source/blender/editors/interface/interface_region_search.c6
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c12
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c46
-rw-r--r--source/blender/editors/interface/interface_undo.c4
-rw-r--r--source/blender/editors/interface/interface_utils.c26
-rw-r--r--source/blender/editors/interface/resources.c2
-rw-r--r--source/blender/editors/interface/view2d.c21
-rw-r--r--source/blender/editors/interface/view2d_draw.c4
-rw-r--r--source/blender/editors/interface/view2d_ops.c84
26 files changed, 436 insertions, 605 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 55f41913499..6c1f9d4f017 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -962,11 +962,9 @@ static bool ui_but_is_rna_undo(const uiBut *but)
if (ID_CHECK_UNDO(id) == false) {
return false;
}
- else {
- return true;
- }
+ return true;
}
- else if (but->rnapoin.type && !RNA_struct_undo_check(but->rnapoin.type)) {
+ if (but->rnapoin.type && !RNA_struct_undo_check(but->rnapoin.type)) {
return false;
}
@@ -1482,7 +1480,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
if (but->drawstr[0] == '\0') {
continue;
}
- else if (((block->flag & UI_BLOCK_POPOVER) == 0) && UI_but_is_tool(but)) {
+ if (((block->flag & UI_BLOCK_POPOVER) == 0) && UI_but_is_tool(but)) {
/* For non-popovers, shown in shortcut only
* (has special shortcut handling code). */
continue;
@@ -2305,10 +2303,8 @@ bool ui_but_is_rna_valid(uiBut *but)
if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
return true;
}
- else {
- printf("property removed %s: %p\n", but->drawstr, but->rnaprop);
- return false;
- }
+ printf("property removed %s: %p\n", but->drawstr, but->rnaprop);
+ return false;
}
/**
@@ -2490,9 +2486,7 @@ int ui_but_string_get_max_length(uiBut *but)
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
return but->hardmax;
}
- else {
- return UI_MAX_DRAW_STR;
- }
+ return UI_MAX_DRAW_STR;
}
uiBut *ui_but_drag_multi_edit_get(uiBut *but)
@@ -2520,9 +2514,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
Scene *scene = CTX_data_scene(but->block->evil_C);
return FRA2TIME(value);
}
- else {
- return BKE_scene_unit_scale(unit, RNA_SUBTYPE_UNIT_VALUE(unit_type), value);
- }
+ return BKE_scene_unit_scale(unit, RNA_SUBTYPE_UNIT_VALUE(unit_type), value);
}
/* str will be overwritten */
@@ -2610,9 +2602,7 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
return (float)step_final;
}
- else {
- return step_default;
- }
+ return step_default;
}
/**
@@ -2838,15 +2828,13 @@ static bool ui_number_from_string_factor(bContext *C, const char *str, double *r
*r_value /= 100.0;
return success;
}
- else {
- if (!ui_number_from_string(C, str, r_value)) {
- return false;
- }
- if (U.factor_display_type == USER_FACTOR_AS_PERCENTAGE) {
- *r_value /= 100.0;
- }
- return true;
+ if (!ui_number_from_string(C, str, r_value)) {
+ return false;
+ }
+ if (U.factor_display_type == USER_FACTOR_AS_PERCENTAGE) {
+ *r_value /= 100.0;
}
+ return true;
}
static bool ui_number_from_string_percentage(bContext *C, const char *str, double *r_value)
@@ -2858,9 +2846,7 @@ static bool ui_number_from_string_percentage(bContext *C, const char *str, doubl
MEM_freeN(str_new);
return success;
}
- else {
- return ui_number_from_string(C, str, r_value);
- }
+ return ui_number_from_string(C, str, r_value);
}
bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double *r_value)
@@ -2879,19 +2865,15 @@ bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double
if (ui_but_is_unit(but)) {
return ui_set_but_string_eval_num_unit(C, but, str, r_value);
}
- else if (subtype == PROP_FACTOR) {
+ if (subtype == PROP_FACTOR) {
return ui_number_from_string_factor(C, str, r_value);
}
- else if (subtype == PROP_PERCENTAGE) {
+ if (subtype == PROP_PERCENTAGE) {
return ui_number_from_string_percentage(C, str, r_value);
}
- else {
- return ui_number_from_string(C, str, r_value);
- }
- }
- else {
return ui_number_from_string(C, str, r_value);
}
+ return ui_number_from_string(C, str, r_value);
}
/* just the assignment/free part */
@@ -2934,40 +2916,36 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
RNA_property_string_set(&but->rnapoin, but->rnaprop, str);
return true;
}
- else if (type == PROP_POINTER) {
+
+ if (type == PROP_POINTER) {
if (str[0] == '\0') {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL, NULL);
return true;
}
- else {
- /* RNA pointer */
- PointerRNA rptr;
- PointerRNA ptr = but->rnasearchpoin;
- PropertyRNA *prop = but->rnasearchprop;
-
- /* This is kind of hackish, in theory think we could only ever use the second member of
- * this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
- * we are storing pointers... But keeping str search first for now,
- * to try to break as little as possible existing code. All this is band-aids anyway.
- * Fact remains, using editstr as main 'reference' over whole search button thingy
- * is utterly weak and should be redesigned imho, but that's not a simple task. */
- if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
- RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
- }
- else if (but->func_arg2 != NULL) {
- RNA_pointer_create(NULL,
- RNA_property_pointer_type(&but->rnapoin, but->rnaprop),
- but->func_arg2,
- &rptr);
- RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
- }
-
- return true;
+ /* RNA pointer */
+ PointerRNA rptr;
+ PointerRNA ptr = but->rnasearchpoin;
+ PropertyRNA *prop = but->rnasearchprop;
+
+ /* This is kind of hackish, in theory think we could only ever use the second member of
+ * this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
+ * we are storing pointers... But keeping str search first for now,
+ * to try to break as little as possible existing code. All this is band-aids anyway.
+ * Fact remains, using editstr as main 'reference' over whole search button thingy
+ * is utterly weak and should be redesigned imho, but that's not a simple task. */
+ if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
+ RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
+ }
+ else if (but->func_arg2 != NULL) {
+ RNA_pointer_create(
+ NULL, RNA_property_pointer_type(&but->rnapoin, but->rnaprop), but->func_arg2, &rptr);
+ RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr, NULL);
}
- return false;
+ return true;
}
- else if (type == PROP_ENUM) {
+
+ if (type == PROP_ENUM) {
int value;
if (RNA_property_enum_value(
but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) {
@@ -2976,9 +2954,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
}
return false;
}
- else {
- BLI_assert(0);
- }
+ BLI_assert(0);
}
}
else if (but->type == UI_BTYPE_TAB) {
@@ -3078,12 +3054,10 @@ static double soft_range_round_up(double value, double max)
if (newmax * 0.2 >= max && newmax * 0.2 >= value) {
return newmax * 0.2;
}
- else if (newmax * 0.5 >= max && newmax * 0.5 >= value) {
+ if (newmax * 0.5 >= max && newmax * 0.5 >= value) {
return newmax * 0.5;
}
- else {
- return newmax;
- }
+ return newmax;
}
static double soft_range_round_down(double value, double max)
@@ -3095,12 +3069,10 @@ static double soft_range_round_down(double value, double max)
if (newmax * 5.0 <= max && newmax * 5.0 <= value) {
return newmax * 5.0;
}
- else if (newmax * 2.0 <= max && newmax * 2.0 <= value) {
+ if (newmax * 2.0 <= max && newmax * 2.0 <= value) {
return newmax * 2.0;
}
- else {
- return newmax;
- }
+ return newmax;
}
/* note: this could be split up into functions which handle arrays and not */
@@ -4487,21 +4459,20 @@ uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, short
if (icon == ALERT_ICON_BLENDER) {
return uiDefButImage(block, ibuf, x, y, width, height, NULL);
}
- else {
- uchar icon_color[4];
- ThemeColorID color_id = TH_INFO_WARNING;
- if (icon == ALERT_ICON_ERROR) {
- color_id = TH_INFO_ERROR;
- }
- else if (icon == ALERT_ICON_INFO) {
- color_id = TH_INFO_INFO;
- }
- else if (icon == ALERT_ICON_QUESTION) {
- color_id = TH_INFO_PROPERTY;
- }
- UI_GetThemeColorType4ubv(color_id, SPACE_INFO, icon_color);
- return uiDefButImage(block, ibuf, x, y, width, height, icon_color);
+
+ uchar icon_color[4];
+ ThemeColorID color_id = TH_INFO_WARNING;
+ if (icon == ALERT_ICON_ERROR) {
+ color_id = TH_INFO_ERROR;
+ }
+ else if (icon == ALERT_ICON_INFO) {
+ color_id = TH_INFO_INFO;
+ }
+ else if (icon == ALERT_ICON_QUESTION) {
+ color_id = TH_INFO_PROPERTY;
}
+ UI_GetThemeColorType4ubv(color_id, SPACE_INFO, icon_color);
+ return uiDefButImage(block, ibuf, x, y, width, height, icon_color);
}
/**
@@ -4518,31 +4489,29 @@ static int findBitIndex(uint x)
if (!x || !is_power_of_2_i(x)) { /* is_power_of_2_i(x) strips lowest bit */
return -1;
}
- else {
- int idx = 0;
+ int idx = 0;
- if (x & 0xFFFF0000) {
- idx += 16;
- x >>= 16;
- }
- if (x & 0xFF00) {
- idx += 8;
- x >>= 8;
- }
- if (x & 0xF0) {
- idx += 4;
- x >>= 4;
- }
- if (x & 0xC) {
- idx += 2;
- x >>= 2;
- }
- if (x & 0x2) {
- idx += 1;
- }
-
- return idx;
+ if (x & 0xFFFF0000) {
+ idx += 16;
+ x >>= 16;
+ }
+ if (x & 0xFF00) {
+ idx += 8;
+ x >>= 8;
+ }
+ if (x & 0xF0) {
+ idx += 4;
+ x >>= 4;
+ }
+ if (x & 0xC) {
+ idx += 2;
+ x >>= 2;
}
+ if (x & 0x2) {
+ idx += 1;
+ }
+
+ return idx;
}
/* autocomplete helper functions */
@@ -4591,7 +4560,7 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
truncate[a] = 0;
break;
}
- else if (truncate[a] != name[a]) {
+ if (truncate[a] != name[a]) {
truncate[a] = 0;
}
}
@@ -4651,22 +4620,20 @@ static uiBut *uiDefButBit(uiBlock *block,
if (bitIdx == -1) {
return NULL;
}
- else {
- return uiDefBut(block,
- type | UI_BUT_POIN_BIT | bitIdx,
- retval,
- str,
- x,
- y,
- width,
- height,
- poin,
- min,
- max,
- a1,
- a2,
- tip);
- }
+ return uiDefBut(block,
+ type | UI_BUT_POIN_BIT | bitIdx,
+ retval,
+ str,
+ x,
+ y,
+ width,
+ height,
+ poin,
+ min,
+ max,
+ a1,
+ a2,
+ tip);
}
uiBut *uiDefButF(uiBlock *block,
int type,
@@ -5038,22 +5005,20 @@ static uiBut *uiDefIconButBit(uiBlock *block,
if (bitIdx == -1) {
return NULL;
}
- else {
- return uiDefIconBut(block,
- type | UI_BUT_POIN_BIT | bitIdx,
- retval,
- icon,
- x,
- y,
- width,
- height,
- poin,
- min,
- max,
- a1,
- a2,
- tip);
- }
+ return uiDefIconBut(block,
+ type | UI_BUT_POIN_BIT | bitIdx,
+ retval,
+ icon,
+ x,
+ y,
+ width,
+ height,
+ poin,
+ min,
+ max,
+ a1,
+ a2,
+ tip);
}
uiBut *uiDefIconButF(uiBlock *block,
@@ -5426,23 +5391,21 @@ static uiBut *uiDefIconTextButBit(uiBlock *block,
if (bitIdx == -1) {
return NULL;
}
- else {
- return uiDefIconTextBut(block,
- type | UI_BUT_POIN_BIT | bitIdx,
- retval,
- icon,
- str,
- x,
- y,
- width,
- height,
- poin,
- min,
- max,
- a1,
- a2,
- tip);
- }
+ return uiDefIconTextBut(block,
+ type | UI_BUT_POIN_BIT | bitIdx,
+ retval,
+ icon,
+ str,
+ x,
+ y,
+ width,
+ height,
+ poin,
+ min,
+ max,
+ a1,
+ a2,
+ tip);
}
uiBut *uiDefIconTextButF(uiBlock *block,
@@ -5828,7 +5791,7 @@ void UI_block_order_flip(uiBlock *block)
if (U.uiflag & USER_MENUFIXEDORDER) {
return;
}
- else if (block->flag & UI_BLOCK_NO_FLIP) {
+ if (block->flag & UI_BLOCK_NO_FLIP) {
return;
}
@@ -5994,9 +5957,7 @@ int UI_but_unit_type_get(const uiBut *but)
if ((ownUnit != 0) || (but->rnaprop == NULL)) {
return ownUnit << 16;
}
- else {
- return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
- }
+ return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
}
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg)
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c
index 15d00d8537b..565e9d6820b 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.c
@@ -104,7 +104,8 @@ static const char *shortcut_get_operator_property(bContext *C, uiBut *but, IDPro
*r_prop = (but->opptr && but->opptr->data) ? IDP_CopyProperty(but->opptr->data) : NULL;
return but->optype->idname;
}
- else if (but->rnaprop) {
+
+ if (but->rnaprop) {
const PropertyType rnaprop_type = RNA_property_type(but->rnaprop);
if (rnaprop_type == PROP_BOOLEAN) {
@@ -115,7 +116,7 @@ static const char *shortcut_get_operator_property(bContext *C, uiBut *but, IDPro
}
return "WM_OT_context_toggle";
}
- else if (rnaprop_type == PROP_ENUM) {
+ if (rnaprop_type == PROP_ENUM) {
/* Enum */
*r_prop = shortcut_property_from_rna(C, but);
if (*r_prop == NULL) {
@@ -351,7 +352,7 @@ static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *
return (bUserMenuItem *)ED_screen_user_menu_item_find_operator(
&um->items, but->optype, prop, but->opcontext);
}
- else if (but->rnaprop) {
+ if (but->rnaprop) {
const char *member_id = WM_context_member_from_ptr(C, &but->rnapoin);
const char *data_path = RNA_path_from_ID_to_struct(&but->rnapoin);
const char *member_id_data_path = member_id;
@@ -369,12 +370,10 @@ static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *
}
return umi;
}
- else if ((mt = UI_but_menutype_get(but))) {
+ if ((mt = UI_but_menutype_get(but))) {
return (bUserMenuItem *)ED_screen_user_menu_item_find_menu(&um->items, mt);
}
- else {
- return NULL;
- }
+ return NULL;
}
static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 817cb44db29..a740a152f1c 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -147,9 +147,7 @@ uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *ev
if (ELEM(NULL, but, but->rnapoin.data, but->rnaprop)) {
return NULL;
}
- else {
- return but;
- }
+ return but;
}
/** \} */
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index c917ffb3f3e..93b052b3b69 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -320,9 +320,7 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
return OPERATOR_RUNNING_MODAL;
}
- else {
- return OPERATOR_PASS_THROUGH;
- }
+ return OPERATOR_PASS_THROUGH;
}
/* Repeat operator */
@@ -338,9 +336,7 @@ static int eyedropper_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_PASS_THROUGH;
- }
+ return OPERATOR_PASS_THROUGH;
}
static bool eyedropper_poll(bContext *C)
diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c
index 24d06361c54..7b8357f5ef1 100644
--- a/source/blender/editors/interface/interface_eyedropper_colorband.c
+++ b/source/blender/editors/interface/interface_eyedropper_colorband.c
@@ -314,9 +314,7 @@ static int eyedropper_colorband_invoke(bContext *C, wmOperator *op, const wmEven
return OPERATOR_RUNNING_MODAL;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* Repeat operator */
@@ -332,9 +330,7 @@ static int eyedropper_colorband_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool eyedropper_colorband_poll(bContext *C)
diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c
index f2217db9b7d..a162cac1b02 100644
--- a/source/blender/editors/interface/interface_eyedropper_datablock.c
+++ b/source/blender/editors/interface/interface_eyedropper_datablock.c
@@ -292,10 +292,8 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Could support finished & undo-skip. */
return is_undo ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
- else {
- BKE_report(op->reports, RPT_WARNING, "Failed to set value");
- return OPERATOR_CANCELLED;
- }
+ BKE_report(op->reports, RPT_WARNING, "Failed to set value");
+ return OPERATOR_CANCELLED;
}
}
}
@@ -326,9 +324,7 @@ static int datadropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
return OPERATOR_RUNNING_MODAL;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* Repeat operator */
@@ -341,9 +337,7 @@ static int datadropper_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool datadropper_poll(bContext *C)
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c
index 5c85edc94a1..ac142fe7217 100644
--- a/source/blender/editors/interface/interface_eyedropper_depth.c
+++ b/source/blender/editors/interface/interface_eyedropper_depth.c
@@ -321,9 +321,7 @@ static int depthdropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
return OPERATOR_RUNNING_MODAL;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* Repeat operator */
@@ -336,9 +334,7 @@ static int depthdropper_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool depthdropper_poll(bContext *C)
diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c
index 276cc70f2b5..0162e205c29 100644
--- a/source/blender/editors/interface/interface_eyedropper_driver.c
+++ b/source/blender/editors/interface/interface_eyedropper_driver.c
@@ -102,46 +102,44 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
if (but == NULL) {
return;
}
- else {
- /* Get paths for src... */
- PointerRNA *target_ptr = &but->rnapoin;
- PropertyRNA *target_prop = but->rnaprop;
- int target_index = but->rnaindex;
-
- char *target_path = RNA_path_from_ID_to_property(target_ptr, target_prop);
-
- /* ... and destination */
- char *dst_path = BKE_animdata_driver_path_hack(C, &ddr->ptr, ddr->prop, NULL);
-
- /* Now create driver(s) */
- if (target_path && dst_path) {
- int success = ANIM_add_driver_with_target(op->reports,
- ddr->ptr.owner_id,
- dst_path,
- ddr->index,
- target_ptr->owner_id,
- target_path,
- target_index,
- flag,
- DRIVER_TYPE_PYTHON,
- mapping_type);
-
- if (success) {
- /* send updates */
- UI_context_update_anim_flag(C);
- DEG_relations_tag_update(CTX_data_main(C));
- DEG_id_tag_update(ddr->ptr.owner_id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
- }
+ /* Get paths for src... */
+ PointerRNA *target_ptr = &but->rnapoin;
+ PropertyRNA *target_prop = but->rnaprop;
+ int target_index = but->rnaindex;
+
+ char *target_path = RNA_path_from_ID_to_property(target_ptr, target_prop);
+
+ /* ... and destination */
+ char *dst_path = BKE_animdata_driver_path_hack(C, &ddr->ptr, ddr->prop, NULL);
+
+ /* Now create driver(s) */
+ if (target_path && dst_path) {
+ int success = ANIM_add_driver_with_target(op->reports,
+ ddr->ptr.owner_id,
+ dst_path,
+ ddr->index,
+ target_ptr->owner_id,
+ target_path,
+ target_index,
+ flag,
+ DRIVER_TYPE_PYTHON,
+ mapping_type);
+
+ if (success) {
+ /* send updates */
+ UI_context_update_anim_flag(C);
+ DEG_relations_tag_update(CTX_data_main(C));
+ DEG_id_tag_update(ddr->ptr.owner_id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
}
+ }
- /* cleanup */
- if (target_path) {
- MEM_freeN(target_path);
- }
- if (dst_path) {
- MEM_freeN(dst_path);
- }
+ /* cleanup */
+ if (target_path) {
+ MEM_freeN(target_path);
+ }
+ if (dst_path) {
+ MEM_freeN(dst_path);
}
}
@@ -190,9 +188,7 @@ static int driverdropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
return OPERATOR_RUNNING_MODAL;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* Repeat operator */
@@ -205,9 +201,7 @@ static int driverdropper_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool driverdropper_poll(bContext *C)
@@ -215,9 +209,7 @@ static bool driverdropper_poll(bContext *C)
if (!CTX_wm_window(C)) {
return 0;
}
- else {
- return 1;
- }
+ return 1;
}
void UI_OT_eyedropper_driver(wmOperatorType *ot)
diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
index 3d32ede60c2..978d8ac09de 100644
--- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c
@@ -324,9 +324,7 @@ static int eyedropper_gpencil_invoke(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_RUNNING_MODAL;
}
- else {
- return OPERATOR_PASS_THROUGH;
- }
+ return OPERATOR_PASS_THROUGH;
}
/* Repeat operator */
@@ -340,9 +338,7 @@ static int eyedropper_gpencil_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_PASS_THROUGH;
- }
+ return OPERATOR_PASS_THROUGH;
}
static bool eyedropper_gpencil_poll(bContext *C)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f6bfb492c92..ccbbaf40992 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1384,16 +1384,14 @@ static bool ui_drag_toggle_but_is_supported(const uiBut *but)
if (ui_but_is_bool(but)) {
return true;
}
- else if (UI_but_is_decorator(but)) {
+ if (UI_but_is_decorator(but)) {
return ELEM(but->icon,
ICON_DECORATE,
ICON_DECORATE_KEYFRAME,
ICON_DECORATE_ANIMATE,
ICON_DECORATE_OVERRIDE);
}
- else {
- return false;
- }
+ return false;
}
/* Button pushed state to compare if other buttons match. Can be more
@@ -1404,19 +1402,15 @@ static int ui_drag_toggle_but_pushed_state(bContext *C, uiBut *but)
if (but->pushed_state_func) {
return but->pushed_state_func(C, but->pushed_state_arg);
}
- else {
- /* Assume icon identifies a unique state, for buttons that
- * work though functions callbacks and don't have an boolean
- * value that indicates the state. */
- return but->icon + but->iconadd;
- }
+ /* Assume icon identifies a unique state, for buttons that
+ * work though functions callbacks and don't have an boolean
+ * value that indicates the state. */
+ return but->icon + but->iconadd;
}
- else if (ui_but_is_bool(but)) {
+ if (ui_but_is_bool(but)) {
return ui_but_is_pushed(but);
}
- else {
- return 0;
- }
+ return 0;
}
typedef struct uiDragToggleHandle {
@@ -1582,9 +1576,7 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
WM_event_add_mousemove(win);
return WM_UI_HANDLER_BREAK;
}
- else {
- return WM_UI_HANDLER_CONTINUE;
- }
+ return WM_UI_HANDLER_CONTINUE;
}
static bool ui_but_is_drag_toggle(const uiBut *but)
@@ -2332,9 +2324,7 @@ static bool parse_float_array(char *text, float *values, int expected_length)
memcpy(values, v, sizeof(float) * expected_length);
return true;
}
- else {
- return false;
- }
+ return false;
}
static void ui_but_paste_numeric_array(bContext *C,
@@ -4204,7 +4194,7 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, cons
button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
return WM_UI_HANDLER_BREAK;
}
- else if (event->type == LEFTMOUSE && event->val == KM_RELEASE && but->block->handle) {
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE && but->block->handle) {
/* regular buttons will be 'UI_SELECT', menu items 'UI_ACTIVE' */
if (!(but->flag & (UI_SELECT | UI_ACTIVE))) {
data->cancel = true;
@@ -4212,7 +4202,7 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, cons
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, EVT_PADENTER, EVT_RETKEY) && event->val == KM_PRESS) {
+ if (ELEM(event->type, EVT_PADENTER, EVT_RETKEY) && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH);
return WM_UI_HANDLER_BREAK;
}
@@ -4247,11 +4237,11 @@ static int ui_do_but_HOTKEYEVT(bContext *C,
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
return WM_UI_HANDLER_CONTINUE;
}
- else if (event->type == EVT_UNKNOWNKEY) {
+ if (event->type == EVT_UNKNOWNKEY) {
WM_report(RPT_WARNING, "Unsupported key: Unknown");
return WM_UI_HANDLER_CONTINUE;
}
- else if (event->type == EVT_CAPSLOCKKEY) {
+ if (event->type == EVT_CAPSLOCKKEY) {
WM_report(RPT_WARNING, "Unsupported key: CapsLock");
return WM_UI_HANDLER_CONTINUE;
}
@@ -4301,7 +4291,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C,
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
- else if (event->type == EVT_ESCKEY) {
+ if (event->type == EVT_ESCKEY) {
if (event->val == KM_PRESS) {
data->cancel = true;
data->escapecancel = true;
@@ -4367,7 +4357,7 @@ static int ui_do_but_TAB(
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
return WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY)) {
+ if (ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY)) {
int event_val = (is_property) ? KM_PRESS : KM_CLICK;
if (event->val == event_val) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4469,7 +4459,7 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
+ if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
/* Support alt+wheel on expanded enum rows */
if (but->type == UI_BTYPE_ROW) {
const int direction = (event->type == WHEELDOWNMOUSE) ? -1 : 1;
@@ -5567,7 +5557,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
}
- else if (but->type == UI_BTYPE_MENU) {
+ if (but->type == UI_BTYPE_MENU) {
if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
const int direction = (event->type == WHEELDOWNMOUSE) ? 1 : -1;
@@ -5741,7 +5731,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
+ if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
ColorPicker *cpicker = but->custom_data;
float hsv_static[3] = {0.0f};
float *hsv = cpicker ? cpicker->color_data : hsv_static;
@@ -5768,8 +5758,8 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
ui_apply_but(C, but->block, but, data, true);
return WM_UI_HANDLER_BREAK;
}
- else if ((int)(but->a1) == UI_PALETTE_COLOR && event->type == EVT_DELKEY &&
- event->val == KM_PRESS) {
+ if ((int)(but->a1) == UI_PALETTE_COLOR && event->type == EVT_DELKEY &&
+ event->val == KM_PRESS) {
Palette *palette = (Palette *)but->rnapoin.owner_id;
PaletteColor *color = but->rnapoin.data;
@@ -6174,7 +6164,7 @@ static int ui_do_but_HSVCUBE(
return WM_UI_HANDLER_BREAK;
}
#ifdef WITH_INPUT_NDOF
- else if (event->type == NDOF_MOTION) {
+ if (event->type == NDOF_MOTION) {
const wmNDOFMotionData *ndof = event->customdata;
const enum eSnapType snap = ui_event_to_snap(event);
@@ -6187,7 +6177,7 @@ static int ui_do_but_HSVCUBE(
}
#endif /* WITH_INPUT_NDOF */
/* XXX hardcoded keymap check.... */
- else if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
+ if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) {
int len;
@@ -6450,7 +6440,7 @@ static int ui_do_but_HSVCIRCLE(
return WM_UI_HANDLER_BREAK;
}
#ifdef WITH_INPUT_NDOF
- else if (event->type == NDOF_MOTION) {
+ if (event->type == NDOF_MOTION) {
const enum eSnapType snap = ui_event_to_snap(event);
const wmNDOFMotionData *ndof = event->customdata;
@@ -6463,7 +6453,7 @@ static int ui_do_but_HSVCIRCLE(
}
#endif /* WITH_INPUT_NDOF */
/* XXX hardcoded keymap check.... */
- else if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
+ if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
int len;
/* reset only saturation */
@@ -7257,7 +7247,7 @@ static int ui_do_but_HISTOGRAM(
return WM_UI_HANDLER_BREAK;
}
/* XXX hardcoded keymap check.... */
- else if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
+ if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
Histogram *hist = (Histogram *)but->poin;
hist->ymax = 1.f;
@@ -7333,7 +7323,7 @@ static int ui_do_but_WAVEFORM(
return WM_UI_HANDLER_BREAK;
}
/* XXX hardcoded keymap check.... */
- else if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
+ if (event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS) {
Scopes *scopes = (Scopes *)but->poin;
scopes->wavefrm_yfac = 1.f;
@@ -9423,9 +9413,7 @@ static bool ui_menu_pass_event_to_parent_if_nonactive(uiPopupBlockHandle *menu,
BLI_assert(retval == WM_UI_HANDLER_CONTINUE);
return true;
}
- else {
- return false;
- }
+ return false;
}
static int ui_handle_menu_button(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu)
@@ -10120,12 +10108,10 @@ static int ui_handle_menu_event(bContext *C,
if (menu->menuretval) {
return WM_UI_HANDLER_CONTINUE;
}
- else if (inside) {
+ if (inside) {
return WM_UI_HANDLER_BREAK;
}
- else {
- return retval;
- }
+ return retval;
}
static int ui_handle_menu_return_submenu(bContext *C,
@@ -10180,9 +10166,7 @@ static int ui_handle_menu_return_submenu(bContext *C,
if (menu->menuretval) {
return WM_UI_HANDLER_CONTINUE;
}
- else {
- return WM_UI_HANDLER_BREAK;
- }
+ return WM_UI_HANDLER_BREAK;
}
static bool ui_but_pie_menu_supported_apply(uiBut *but)
@@ -10210,9 +10194,7 @@ static int ui_but_pie_menu_apply(bContext *C,
button_activate_init(C, menu->region, but, BUTTON_ACTIVATE_OPEN);
return retval;
}
- else {
- menu->menuretval = UI_RETURN_CANCEL;
- }
+ menu->menuretval = UI_RETURN_CANCEL;
}
else {
ui_apply_but(C, but->block, but, but->active, false);
@@ -10998,9 +10980,7 @@ bool UI_textbutton_activate_rna(const bContext *C,
UI_but_active_only(C, region, block, but);
return true;
}
- else {
- return false;
- }
+ return false;
}
bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
@@ -11025,9 +11005,7 @@ bool UI_textbutton_activate_but(const bContext *C, uiBut *actbut)
UI_but_active_only(C, region, block, but);
return true;
}
- else {
- return false;
- }
+ return false;
}
/** \} */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 7411639a99f..e1f72cd2898 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -593,10 +593,10 @@ int UI_icon_from_event_type(short event_type, short event_value)
if (event_type == LEFTMOUSE) {
return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_LMB : ICON_MOUSE_LMB_DRAG;
}
- else if (event_type == MIDDLEMOUSE) {
+ if (event_type == MIDDLEMOUSE) {
return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_MMB : ICON_MOUSE_MMB_DRAG;
}
- else if (event_type == RIGHTMOUSE) {
+ if (event_type == RIGHTMOUSE) {
return ELEM(event_value, KM_CLICK, KM_PRESS) ? ICON_MOUSE_RMB : ICON_MOUSE_RMB_DRAG;
}
@@ -2139,7 +2139,8 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
return id->icon_id;
}
- else if (paint_mode != PAINT_MODE_INVALID) {
+
+ if (paint_mode != PAINT_MODE_INVALID) {
items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
const uint tool_offset = BKE_paint_get_brush_tool_offset_from_paintmode(paint_mode);
const int tool_type = *(char *)POINTER_OFFSET(br, tool_offset);
@@ -2198,14 +2199,12 @@ int UI_library_icon_get(const ID *id)
if (id->tag & LIB_TAG_MISSING) {
return ICON_LIBRARY_DATA_BROKEN;
}
- else if (id->tag & LIB_TAG_INDIRECT) {
+ if (id->tag & LIB_TAG_INDIRECT) {
return ICON_LIBRARY_DATA_INDIRECT;
}
- else {
- return ICON_LIBRARY_DATA_DIRECT;
- }
+ return ICON_LIBRARY_DATA_DIRECT;
}
- else if (ID_IS_OVERRIDE_LIBRARY(id)) {
+ if (ID_IS_OVERRIDE_LIBRARY(id)) {
return ICON_LIBRARY_DATA_OVERRIDE;
}
@@ -2239,10 +2238,10 @@ int UI_rnaptr_icon_get(bContext *C, PointerRNA *ptr, int rnaicon, const bool big
if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
return ICON_SHADING_TEXTURE;
}
- else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
+ if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
return ICON_OUTLINER_DATA_MESH;
}
- else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
+ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
return ICON_FILE_IMAGE;
}
}
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 188ff62d923..858b48ba9fa 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -250,28 +250,23 @@ static int ui_item_fit(
if (is_last) {
return available - pos;
}
- else {
- float width = *extra_pixel + (item * available) / (float)all;
- *extra_pixel = width - (int)width;
- return (int)width;
- }
+
+ float width = *extra_pixel + (item * available) / (float)all;
+ *extra_pixel = width - (int)width;
+ return (int)width;
}
- else {
- /* contents is smaller or equal to available space */
- if (alignment == UI_LAYOUT_ALIGN_EXPAND) {
- if (is_last) {
- return available - pos;
- }
- else {
- float width = *extra_pixel + (item * available) / (float)all;
- *extra_pixel = width - (int)width;
- return (int)width;
- }
- }
- else {
- return item;
+
+ /* contents is smaller or equal to available space */
+ if (alignment == UI_LAYOUT_ALIGN_EXPAND) {
+ if (is_last) {
+ return available - pos;
}
+
+ float width = *extra_pixel + (item * available) / (float)all;
+ *extra_pixel = width - (int)width;
+ return (int)width;
}
+ return item;
}
/* variable button size in which direction? */
@@ -323,9 +318,7 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
}
return UI_fontstyle_string_width(fstyle, name) + (unit_x * margin);
}
- else {
- return unit_x * 10;
- }
+ return unit_x * 10;
}
static void ui_item_size(uiItem *item, int *r_w, int *r_h)
@@ -1458,9 +1451,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
/* break since rest of items is handled in new pie level */
break;
}
- else {
- last_iter = true;
- }
+ last_iter = true;
}
else {
continue;
@@ -2579,43 +2570,42 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
RNA_warning("not an enum property: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
- else {
- const EnumPropertyItem *item;
- int totitem, i;
- bool free;
- uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
- uiLayout *column = uiLayoutColumn(split, false);
-
- RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
- for (i = 0; i < totitem; i++) {
- if (item[i].identifier[0]) {
- uiItemEnumR_prop(column, item[i].name, item[i].icon, ptr, prop, item[i].value);
- ui_but_tip_from_enum_item(block->buttons.last, &item[i]);
- }
- else {
- if (item[i].name) {
- if (i != 0) {
- column = uiLayoutColumn(split, false);
- /* inconsistent, but menus with labels do not look good flipped */
- block->flag |= UI_BLOCK_NO_FLIP;
- }
+ const EnumPropertyItem *item;
+ int totitem, i;
+ bool free;
+ uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
+ uiLayout *column = uiLayoutColumn(split, false);
- uiItemL(column, item[i].name, ICON_NONE);
- bt = block->buttons.last;
- bt->drawflag = UI_BUT_TEXT_LEFT;
+ RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
- ui_but_tip_from_enum_item(bt, &item[i]);
- }
- else {
- uiItemS(column);
+ for (i = 0; i < totitem; i++) {
+ if (item[i].identifier[0]) {
+ uiItemEnumR_prop(column, item[i].name, item[i].icon, ptr, prop, item[i].value);
+ ui_but_tip_from_enum_item(block->buttons.last, &item[i]);
+ }
+ else {
+ if (item[i].name) {
+ if (i != 0) {
+ column = uiLayoutColumn(split, false);
+ /* inconsistent, but menus with labels do not look good flipped */
+ block->flag |= UI_BLOCK_NO_FLIP;
}
+
+ uiItemL(column, item[i].name, ICON_NONE);
+ bt = block->buttons.last;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
+
+ ui_but_tip_from_enum_item(bt, &item[i]);
+ }
+ else {
+ uiItemS(column);
}
}
+ }
- if (free) {
- MEM_freeN((void *)item);
- }
+ if (free) {
+ MEM_freeN((void *)item);
}
/* intentionally don't touch UI_BLOCK_IS_FLIP here,
@@ -3199,15 +3189,14 @@ uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int
return split_wrapper.decorate_column;
}
- else {
- char namestr[UI_MAX_NAME_STR];
- if (text) {
- text = ui_item_name_add_colon(text, namestr);
- }
- uiItemL_(layout, text, icon);
- return layout;
+ char namestr[UI_MAX_NAME_STR];
+ if (text) {
+ text = ui_item_name_add_colon(text, namestr);
}
+ uiItemL_(layout, text, icon);
+
+ return layout;
}
void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon)
@@ -5046,9 +5035,7 @@ int uiLayoutGetEmboss(uiLayout *layout)
if (layout->emboss == UI_EMBOSS_UNDEFINED) {
return layout->root->block->dt;
}
- else {
- return layout->emboss;
- }
+ return layout->emboss;
}
/** \} */
@@ -5516,9 +5503,7 @@ MenuType *UI_but_menutype_get(uiBut *but)
if (but->menu_create_func == ui_item_menutype_func) {
return (MenuType *)but->poin;
}
- else {
- return NULL;
- }
+ return NULL;
}
/* this is a bit of a hack but best keep it in one place at least */
@@ -5527,9 +5512,7 @@ PanelType *UI_but_paneltype_get(uiBut *but)
if (but->menu_create_func == ui_item_paneltype_func) {
return (PanelType *)but->poin;
}
- else {
- return NULL;
- }
+ return NULL;
}
void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 924fc6738e1..5237e2ea3f7 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -209,10 +209,9 @@ static int copy_as_driver_button_exec(bContext *C, wmOperator *op)
MEM_freeN(path);
return OPERATOR_FINISHED;
}
- else {
- BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path");
- return OPERATOR_CANCELLED;
- }
+
+ BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path");
+ return OPERATOR_CANCELLED;
}
return OPERATOR_CANCELLED;
@@ -312,9 +311,7 @@ static int operator_button_property_finish(bContext *C, PointerRNA *ptr, Propert
/* do nothing, go ahead with undo */
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
static bool reset_default_button_poll(bContext *C)
@@ -1005,11 +1002,9 @@ static bool copy_to_selected_button(bContext *C, bool all, bool poll)
success = true;
break;
}
- else {
- if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) {
- RNA_property_update(C, &lptr, prop);
- success = true;
- }
+ if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) {
+ RNA_property_update(C, &lptr, prop);
+ success = true;
}
}
}
@@ -1149,7 +1144,7 @@ static bool jump_to_target_button(bContext *C, bool poll)
return jump_to_target_ptr(C, target_ptr, poll);
}
/* For string properties with prop_search, look up the search collection item. */
- else if (type == PROP_STRING) {
+ if (type == PROP_STRING) {
const uiBut *but = UI_context_active_but_get(C);
if (but->type == UI_BTYPE_SEARCH_MENU && but->search &&
@@ -1265,9 +1260,7 @@ static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) {
return true;
}
- else {
- return false;
- }
+ return false;
}
void UI_editsource_active_but_test(uiBut *but)
@@ -1323,22 +1316,21 @@ static int editsource_text_edit(bContext *C,
BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
return OPERATOR_CANCELLED;
}
- else {
- /* naughty!, find text area to set, not good behavior
- * but since this is a dev tool lets allow it - campbell */
- ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
- if (area) {
- SpaceText *st = area->spacedata.first;
- st->text = text;
- }
- else {
- BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
- }
- txt_move_toline(text, line - 1, false);
- WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
+ /* naughty!, find text area to set, not good behavior
+ * but since this is a dev tool lets allow it - campbell */
+ ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
+ if (area) {
+ SpaceText *st = area->spacedata.first;
+ st->text = text;
+ }
+ else {
+ BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
}
+ txt_move_toline(text, line - 1, false);
+ WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
+
return OPERATOR_FINISHED;
}
@@ -1397,10 +1389,9 @@ static int editsource_exec(bContext *C, wmOperator *op)
return ret;
}
- else {
- BKE_report(op->reports, RPT_ERROR, "Active button not found");
- return OPERATOR_CANCELLED;
- }
+
+ BKE_report(op->reports, RPT_ERROR, "Active button not found");
+ return OPERATOR_CANCELLED;
}
static void UI_OT_editsource(wmOperatorType *ot)
@@ -1585,10 +1576,9 @@ static int edittranslation_exec(bContext *C, wmOperator *op)
return ret;
}
- else {
- BKE_report(op->reports, RPT_ERROR, "Active button not found");
- return OPERATOR_CANCELLED;
- }
+
+ BKE_report(op->reports, RPT_ERROR, "Active button not found");
+ return OPERATOR_CANCELLED;
}
static void UI_OT_edittranslation_init(wmOperatorType *ot)
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 2eeab4efbc7..95c804eaccb 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -147,22 +147,22 @@ static int panel_aligned(const ScrArea *area, const ARegion *region)
if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
return BUT_VERTICAL;
}
- else if (area->spacetype == SPACE_USERPREF && region->regiontype == RGN_TYPE_WINDOW) {
+ if (area->spacetype == SPACE_USERPREF && region->regiontype == RGN_TYPE_WINDOW) {
return BUT_VERTICAL;
}
- else if (area->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) {
+ if (area->spacetype == SPACE_FILE && region->regiontype == RGN_TYPE_CHANNELS) {
return BUT_VERTICAL;
}
- else if (area->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) {
+ if (area->spacetype == SPACE_IMAGE && region->regiontype == RGN_TYPE_PREVIEW) {
return BUT_VERTICAL;
}
- else if (ELEM(region->regiontype,
- RGN_TYPE_UI,
- RGN_TYPE_TOOLS,
- RGN_TYPE_TOOL_PROPS,
- RGN_TYPE_HUD,
- RGN_TYPE_NAV_BAR,
- RGN_TYPE_EXECUTE)) {
+ if (ELEM(region->regiontype,
+ RGN_TYPE_UI,
+ RGN_TYPE_TOOLS,
+ RGN_TYPE_TOOL_PROPS,
+ RGN_TYPE_HUD,
+ RGN_TYPE_NAV_BAR,
+ RGN_TYPE_EXECUTE)) {
return BUT_VERTICAL;
}
@@ -1323,9 +1323,7 @@ static int get_panel_real_ofsy(Panel *panel)
if (panel->flag & PNL_CLOSEDY) {
return panel->ofsy + panel->sizey;
}
- else {
- return panel->ofsy;
- }
+ return panel->ofsy;
}
static int get_panel_real_ofsx(Panel *panel)
@@ -1333,9 +1331,7 @@ static int get_panel_real_ofsx(Panel *panel)
if (panel->flag & PNL_CLOSEDX) {
return panel->ofsx + get_panel_header(panel);
}
- else {
- return panel->ofsx + panel->sizex;
- }
+ return panel->ofsx + panel->sizex;
}
bool UI_panel_is_dragging(const struct Panel *panel)
@@ -1363,13 +1359,13 @@ static int find_leftmost_panel(const void *a1, const void *a2)
if (ps1->panel->ofsx > ps2->panel->ofsx) {
return 1;
}
- else if (ps1->panel->ofsx < ps2->panel->ofsx) {
+ if (ps1->panel->ofsx < ps2->panel->ofsx) {
return -1;
}
- else if (ps1->panel->sortorder > ps2->panel->sortorder) {
+ if (ps1->panel->sortorder > ps2->panel->sortorder) {
return 1;
}
- else if (ps1->panel->sortorder < ps2->panel->sortorder) {
+ if (ps1->panel->sortorder < ps2->panel->sortorder) {
return -1;
}
@@ -1385,23 +1381,23 @@ static int find_highest_panel(const void *a1, const void *a2)
if (ps1->panel->type->flag & PNL_NO_HEADER && ps2->panel->type->flag & PNL_NO_HEADER) {
/* skip and check for ofs and sortorder below */
}
- else if (ps1->panel->type->flag & PNL_NO_HEADER) {
+ if (ps1->panel->type->flag & PNL_NO_HEADER) {
return -1;
}
- else if (ps2->panel->type->flag & PNL_NO_HEADER) {
+ if (ps2->panel->type->flag & PNL_NO_HEADER) {
return 1;
}
if (ps1->panel->ofsy + ps1->panel->sizey < ps2->panel->ofsy + ps2->panel->sizey) {
return 1;
}
- else if (ps1->panel->ofsy + ps1->panel->sizey > ps2->panel->ofsy + ps2->panel->sizey) {
+ if (ps1->panel->ofsy + ps1->panel->sizey > ps2->panel->ofsy + ps2->panel->sizey) {
return -1;
}
- else if (ps1->panel->sortorder > ps2->panel->sortorder) {
+ if (ps1->panel->sortorder > ps2->panel->sortorder) {
return 1;
}
- else if (ps1->panel->sortorder < ps2->panel->sortorder) {
+ if (ps1->panel->sortorder < ps2->panel->sortorder) {
return -1;
}
@@ -1415,7 +1411,7 @@ static int compare_panel(const void *a1, const void *a2)
if (ps1->panel->sortorder > ps2->panel->sortorder) {
return 1;
}
- else if (ps1->panel->sortorder < ps2->panel->sortorder) {
+ if (ps1->panel->sortorder < ps2->panel->sortorder) {
return -1;
}
@@ -2838,7 +2834,7 @@ int ui_handler_panel_region(bContext *C,
retval = WM_UI_HANDLER_BREAK;
break;
}
- else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(panel->flag & PNL_CLOSED)) {
+ if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(panel->flag & PNL_CLOSED)) {
panel_activate_state(C, panel, PANEL_STATE_DRAG_SCALE);
retval = WM_UI_HANDLER_BREAK;
break;
@@ -2993,9 +2989,7 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
if (data && data->state == PANEL_STATE_ANIMATION) {
return WM_UI_HANDLER_CONTINUE;
}
- else {
- return WM_UI_HANDLER_BREAK;
- }
+ return WM_UI_HANDLER_BREAK;
}
static void ui_handler_remove_panel(bContext *C, void *userdata)
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 6d05fe15f97..4634f4b95c9 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -107,9 +107,7 @@ bool UI_but_is_utf8(const uiBut *but)
const int subtype = RNA_property_subtype(but->rnaprop);
return !(ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME, PROP_BYTESTRING));
}
- else {
- return !(but->flag & UI_BUT_NO_UTF8);
- }
+ return !(but->flag & UI_BUT_NO_UTF8);
}
#ifdef USE_UI_POPOVER_ONCE
@@ -171,9 +169,7 @@ int ui_but_icon(const uiBut *but)
if (but->drawflag & UI_BUT_ICON_REVERSE) {
return but->icon - but->iconadd;
}
- else {
- return but->icon + but->iconadd;
- }
+ return but->icon + but->iconadd;
}
/** \} */
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c
index 65f5798bdce..077e8888d53 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -77,11 +77,10 @@ int ui_but_menu_step(uiBut *but, int direction)
if (but->menu_step_func) {
return but->menu_step_func(but->block->evil_C, direction, but->poin);
}
- else {
- const int curval = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
- return RNA_property_enum_step(
- but->block->evil_C, &but->rnapoin, but->rnaprop, curval, direction);
- }
+
+ const int curval = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
+ return RNA_property_enum_step(
+ but->block->evil_C, &but->rnapoin, but->rnaprop, curval, direction);
}
printf("%s: cannot cycle button '%s'\n", __func__, but->str);
@@ -129,16 +128,15 @@ static uiBut *ui_popup_menu_memory__internal(uiBlock *block, uiBut *but)
mem[hash_mod] = ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR);
return NULL;
}
- else {
- /* get */
- for (but = block->buttons.first; but; but = but->next) {
- if (mem[hash_mod] == ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR)) {
- return but;
- }
- }
- return NULL;
+ /* get */
+ for (but = block->buttons.first; but; but = but->next) {
+ if (mem[hash_mod] == ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR)) {
+ return but;
+ }
}
+
+ return NULL;
}
uiBut *ui_popup_menu_memory_get(uiBlock *block)
@@ -488,13 +486,11 @@ bool UI_popup_menu_end_or_cancel(bContext *C, uiPopupMenu *pup)
UI_popup_menu_end(C, pup);
return true;
}
- else {
- UI_block_layout_resolve(pup->block, NULL, NULL);
- MEM_freeN(pup->block->handle);
- UI_block_free(C, pup->block);
- MEM_freeN(pup);
- return false;
- }
+ UI_block_layout_resolve(pup->block, NULL, NULL);
+ MEM_freeN(pup->block->handle);
+ UI_block_free(C, pup->block);
+ MEM_freeN(pup);
+ return false;
}
uiLayout *UI_popup_menu_layout(uiPopupMenu *pup)
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index c88dd1954c9..307bab5ad79 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -292,16 +292,14 @@ bool ui_searchbox_apply(uiBut *but, ARegion *region)
return true;
}
- else if (but->flag & UI_BUT_VALUE_CLEAR) {
+ if (but->flag & UI_BUT_VALUE_CLEAR) {
/* It is valid for _VALUE_CLEAR flavor to have no active element
* (it's a valid way to unlink). */
but->editstr[0] = '\0';
return true;
}
- else {
- return false;
- }
+ return false;
}
static struct ARegion *wm_searchbox_tooltip_init(struct bContext *C,
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 9fed98ffda2..46814e11b9e 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -763,9 +763,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
MEM_freeN(data);
return NULL;
}
- else {
- return data;
- }
+ return data;
}
static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
@@ -1045,9 +1043,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
MEM_freeN(data);
return NULL;
}
- else {
- return data;
- }
+ return data;
}
static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz)
@@ -1144,9 +1140,7 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz)
MEM_freeN(data);
return NULL;
}
- else {
- return data;
- }
+ return data;
}
static ARegion *ui_tooltip_create_with_data(bContext *C,
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c
index 8c673e4d5b5..ad5f897e5fe 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.c
@@ -346,7 +346,7 @@ static void menu_types_add_from_keymap_items(bContext *C,
continue;
}
- else if (handler_base->poll == NULL || handler_base->poll(region, win->eventstate)) {
+ if (handler_base->poll == NULL || handler_base->poll(region, win->eventstate)) {
wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
wmKeyMap *keymap = WM_event_get_keymap_from_handler(wm, handler);
if (keymap && WM_keymap_poll(C, keymap)) {
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index baea948e122..992c9e07033 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1152,9 +1152,7 @@ ID *UI_context_active_but_get_tab_ID(bContext *C)
if (but && but->type == UI_BTYPE_TAB) {
return but->custom_data;
}
- else {
- return NULL;
- }
+ return NULL;
}
static void template_ID_tabs(const bContext *C,
@@ -1847,9 +1845,7 @@ static Object *get_context_object(const bContext *C)
if (sbuts != NULL && (sbuts->pinid != NULL) && GS(sbuts->pinid->name) == ID_OB) {
return (Object *)sbuts->pinid;
}
- else {
- return CTX_data_active_object(C);
- }
+ return CTX_data_active_object(C);
}
static void modifier_panel_id(void *md_link, char *r_name)
@@ -2270,10 +2266,9 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
UI_block_lock_set(block, true, "Operator can't' redo");
return return_info;
}
- else {
- /* useful for macros where only one of the steps can't be re-done */
- UI_block_lock_clear(block);
- }
+
+ /* useful for macros where only one of the steps can't be re-done */
+ UI_block_lock_clear(block);
if (layout_flags & UI_TEMPLATE_OP_PROPS_SHOW_TITLE) {
uiItemL(layout, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
@@ -4976,7 +4971,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
selection_y = &point->y;
break;
}
- else if (profile->path[i].flag & PROF_H1_SELECT) {
+ if (profile->path[i].flag & PROF_H1_SELECT) {
point = &profile->path[i];
selection_x = &point->h1_loc[0];
selection_y = &point->h1_loc[1];
@@ -6630,48 +6625,48 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
owner = scene;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_SEQ_BUILD_PREVIEW)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_SEQ_BUILD_PREVIEW)) {
handle_event = B_STOPSEQ;
icon = ICON_SEQUENCE;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_BUILD_PROXY)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_BUILD_PROXY)) {
handle_event = B_STOPCLIP;
icon = ICON_TRACKER;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_PREFETCH)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_PREFETCH)) {
handle_event = B_STOPCLIP;
icon = ICON_TRACKER;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_TRACK_MARKERS)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_TRACK_MARKERS)) {
handle_event = B_STOPCLIP;
icon = ICON_TRACKER;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_SOLVE_CAMERA)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_CLIP_SOLVE_CAMERA)) {
handle_event = B_STOPCLIP;
icon = ICON_TRACKER;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_FILESEL_READDIR)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_FILESEL_READDIR)) {
handle_event = B_STOPFILE;
icon = ICON_FILEBROWSER;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) {
handle_event = B_STOPRENDER;
icon = ICON_SCENE;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) {
handle_event = B_STOPCOMPO;
icon = ICON_RENDERLAYERS;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE) ||
- WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE) ||
+ WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE)) {
/* Skip bake jobs in compositor to avoid compo header displaying
* progress bar which is not being updated (bake jobs only need
* to update NC_IMAGE context.
@@ -6681,23 +6676,24 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
icon = ICON_IMAGE;
break;
}
+ continue;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_DPAINT_BAKE)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_DPAINT_BAKE)) {
handle_event = B_STOPOTHER;
icon = ICON_MOD_DYNAMICPAINT;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_POINTCACHE)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_POINTCACHE)) {
handle_event = B_STOPOTHER;
icon = ICON_PHYSICS;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_SIM_FLUID)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_SIM_FLUID)) {
handle_event = B_STOPOTHER;
icon = ICON_MOD_FLUIDSIM;
break;
}
- else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_SIM_OCEAN)) {
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_SIM_OCEAN)) {
handle_event = B_STOPOTHER;
icon = ICON_MOD_OCEAN;
break;
diff --git a/source/blender/editors/interface/interface_undo.c b/source/blender/editors/interface/interface_undo.c
index 016bc4159db..304d2254a81 100644
--- a/source/blender/editors/interface/interface_undo.c
+++ b/source/blender/editors/interface/interface_undo.c
@@ -88,9 +88,7 @@ const char *ui_textedit_undo(uiUndoStack_Text *stack, int direction, int *r_curs
if (direction < 0) {
return ui_textedit_undo_impl(stack, r_cursor_index);
}
- else {
- return ui_textedit_redo_impl(stack, r_cursor_index);
- }
+ return ui_textedit_redo_impl(stack, r_cursor_index);
}
/**
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 432da3d5dd5..24f90f6b0a0 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -60,13 +60,9 @@ bool ui_str_has_word_prefix(const char *haystack, const char *needle, size_t nee
if ((match == haystack) || (*(match - 1) == ' ') || ispunct(*(match - 1))) {
return true;
}
- else {
- return ui_str_has_word_prefix(match + 1, needle, needle_len);
- }
- }
- else {
- return false;
+ return ui_str_has_word_prefix(match + 1, needle, needle_len);
}
+ return false;
}
/*************************** RNA Utilities ******************************/
@@ -397,9 +393,7 @@ static int sort_search_items_list(const void *a, const void *b)
if (BLI_strcasecmp(cis1->name, cis2->name) > 0) {
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
void ui_rna_collection_search_update_fn(const struct bContext *C,
@@ -535,9 +529,7 @@ int UI_icon_from_id(ID *id)
if (ob->type == OB_EMPTY) {
return ICON_EMPTY_DATA;
}
- else {
- return UI_icon_from_id(ob->data);
- }
+ return UI_icon_from_id(ob->data);
}
/* otherwise get it through RNA, creating the pointer
@@ -553,15 +545,13 @@ int UI_icon_from_report_type(int type)
if (type & RPT_ERROR_ALL) {
return ICON_ERROR;
}
- else if (type & RPT_WARNING_ALL) {
+ if (type & RPT_WARNING_ALL) {
return ICON_ERROR;
}
- else if (type & RPT_INFO_ALL) {
+ if (type & RPT_INFO_ALL) {
return ICON_INFO;
}
- else {
- return ICON_NONE;
- }
+ return ICON_NONE;
}
/********************************** Misc **************************************/
@@ -632,7 +622,7 @@ bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t maxlength)
RNA_property_identifier(but->rnaprop));
return true;
}
- else if (but->optype) {
+ if (but->optype) {
WM_operator_py_idname(r_str, but->optype->idname);
return true;
}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 01c9716ec86..087bb2cae16 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1408,7 +1408,7 @@ bool UI_GetIconThemeColor4ubv(int colorid, uchar col[4])
if (colorid == 0) {
return false;
}
- else if (colorid == TH_ICON_FUND) {
+ if (colorid == TH_ICON_FUND) {
/* Always color development fund icon. */
}
else if (!((theme_spacetype == SPACE_OUTLINER && theme_regionid == RGN_TYPE_WINDOW) ||
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index d696c99851b..0cbf73280a3 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -74,12 +74,10 @@ BLI_INLINE int clamp_float_to_int(const float f)
if (UNLIKELY(f < min)) {
return min;
}
- else if (UNLIKELY(f > max)) {
+ if (UNLIKELY(f > max)) {
return (int)max;
}
- else {
- return (int)f;
- }
+ return (int)f;
}
/**
@@ -1756,12 +1754,11 @@ bool UI_view2d_view_to_region_clip(
return true;
}
- else {
- /* set initial value in case coordinate lies outside of bounds */
- *r_region_x = *r_region_y = V2D_IS_CLIPPED;
- return false;
- }
+ /* set initial value in case coordinate lies outside of bounds */
+ *r_region_x = *r_region_y = V2D_IS_CLIPPED;
+
+ return false;
}
/**
@@ -1855,11 +1852,9 @@ bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src,
return true;
}
- else {
- rect_dst->xmin = rect_dst->xmax = rect_dst->ymin = rect_dst->ymax = V2D_IS_CLIPPED;
- return false;
- }
+ rect_dst->xmin = rect_dst->xmax = rect_dst->ymin = rect_dst->ymax = V2D_IS_CLIPPED;
+ return false;
}
/** \} */
diff --git a/source/blender/editors/interface/view2d_draw.c b/source/blender/editors/interface/view2d_draw.c
index 677043c1ccf..0108dafc531 100644
--- a/source/blender/editors/interface/view2d_draw.c
+++ b/source/blender/editors/interface/view2d_draw.c
@@ -428,9 +428,7 @@ float UI_view2d_grid_resolution_x__frames_or_seconds(const struct View2D *v2d,
if (display_seconds) {
return view2d_major_step_x__time(v2d, scene);
}
- else {
- return view2d_major_step_x__continuous(v2d);
- }
+ return view2d_major_step_x__continuous(v2d);
}
float UI_view2d_grid_resolution_y__values(const struct View2D *v2d)
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 0efb49f42bf..a2c83c24e96 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1608,57 +1608,56 @@ static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
}
- else {
- const wmNDOFMotionData *ndof = event->customdata;
- /* tune these until it feels right */
- const float zoom_sensitivity = 0.5f;
- const float speed = 10.0f; /* match view3d ortho */
- const bool has_translate = (ndof->tvec[0] && ndof->tvec[1]) && view_pan_poll(C);
- const bool has_zoom = (ndof->tvec[2] != 0.0f) && view_zoom_poll(C);
+ const wmNDOFMotionData *ndof = event->customdata;
- if (has_translate) {
- if (view_pan_init(C, op)) {
- v2dViewPanData *vpd;
- float pan_vec[3];
+ /* tune these until it feels right */
+ const float zoom_sensitivity = 0.5f;
+ const float speed = 10.0f; /* match view3d ortho */
+ const bool has_translate = (ndof->tvec[0] && ndof->tvec[1]) && view_pan_poll(C);
+ const bool has_zoom = (ndof->tvec[2] != 0.0f) && view_zoom_poll(C);
- WM_event_ndof_pan_get(ndof, pan_vec, false);
+ if (has_translate) {
+ if (view_pan_init(C, op)) {
+ v2dViewPanData *vpd;
+ float pan_vec[3];
- pan_vec[0] *= speed;
- pan_vec[1] *= speed;
+ WM_event_ndof_pan_get(ndof, pan_vec, false);
- vpd = op->customdata;
+ pan_vec[0] *= speed;
+ pan_vec[1] *= speed;
- view_pan_apply_ex(C, vpd, pan_vec[0], pan_vec[1]);
+ vpd = op->customdata;
- view_pan_exit(op);
- }
+ view_pan_apply_ex(C, vpd, pan_vec[0], pan_vec[1]);
+
+ view_pan_exit(op);
}
+ }
- if (has_zoom) {
- if (view_zoomdrag_init(C, op)) {
- v2dViewZoomData *vzd;
- float zoom_factor = zoom_sensitivity * ndof->dt * -ndof->tvec[2];
+ if (has_zoom) {
+ if (view_zoomdrag_init(C, op)) {
+ v2dViewZoomData *vzd;
+ float zoom_factor = zoom_sensitivity * ndof->dt * -ndof->tvec[2];
- bool do_zoom_xy[2];
+ bool do_zoom_xy[2];
- if (U.ndof_flag & NDOF_ZOOM_INVERT) {
- zoom_factor = -zoom_factor;
- }
+ if (U.ndof_flag & NDOF_ZOOM_INVERT) {
+ zoom_factor = -zoom_factor;
+ }
- view_zoom_axis_lock_defaults(C, do_zoom_xy);
+ view_zoom_axis_lock_defaults(C, do_zoom_xy);
- vzd = op->customdata;
+ vzd = op->customdata;
- view_zoomstep_apply_ex(
- C, vzd, false, do_zoom_xy[0] ? zoom_factor : 0.0f, do_zoom_xy[1] ? zoom_factor : 0.0f);
+ view_zoomstep_apply_ex(
+ C, vzd, false, do_zoom_xy[0] ? zoom_factor : 0.0f, do_zoom_xy[1] ? zoom_factor : 0.0f);
- view_zoomstep_exit(op);
- }
+ view_zoomstep_exit(op);
}
-
- return OPERATOR_FINISHED;
}
+
+ return OPERATOR_FINISHED;
}
static void VIEW2D_OT_ndof(wmOperatorType *ot)
@@ -1975,16 +1974,16 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
if (in_bar) {
return SCROLLHANDLE_BAR;
}
- else if (in_max) {
+ if (in_max) {
return SCROLLHANDLE_MAX;
}
- else if (in_min) {
+ if (in_min) {
return SCROLLHANDLE_MIN;
}
- else if (out_min) {
+ if (out_min) {
return SCROLLHANDLE_MIN_OUTSIDE;
}
- else if (out_max) {
+ if (out_max) {
return SCROLLHANDLE_MAX_OUTSIDE;
}
@@ -2323,11 +2322,10 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
- else {
- /* not in scroller, so nothing happened...
- * (pass through let's something else catch event) */
- return OPERATOR_PASS_THROUGH;
- }
+
+ /* not in scroller, so nothing happened...
+ * (pass through let's something else catch event) */
+ return OPERATOR_PASS_THROUGH;
}
/* LMB-Drag in Scrollers - not repeatable operator! */