diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 229 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 124 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 10 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 34 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 12 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 37 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 19 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 7 |
12 files changed, 345 insertions, 144 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 19eb978a01e..21a63183c1a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -559,19 +559,19 @@ static void ui_draw_links(uiBlock *block) /* ************** BLOCK ENDING FUNCTION ************* */ /* NOTE: if but->poin is allocated memory for every defbut, things fail... */ -static bool ui_but_equals_old(uiBut *but, uiBut *oldbut) +static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut) { /* various properties are being compared here, hopefully sufficient * to catch all cases, but it is simple to add more checks later */ if (but->retval != oldbut->retval) return false; if (but->rnapoin.data != oldbut->rnapoin.data) return false; - if (but->rnaprop != oldbut->rnaprop) - if (but->rnaindex != oldbut->rnaindex) return false; + if (but->rnaprop != oldbut->rnaprop && but->rnaindex != oldbut->rnaindex) return false; if (but->func != oldbut->func) return false; if (but->funcN != oldbut->funcN) return false; if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return false; if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return false; - if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return false; + if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || + (but->pointype != oldbut->pointype))) return false; if (but->optype != oldbut->optype) return false; return true; @@ -620,7 +620,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut return found; for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) { - if (ui_but_equals_old(oldbut, but)) { + if (ui_but_equals_old(but, oldbut)) { if (oldbut->active) { #if 0 // but->flag = oldbut->flag; @@ -901,6 +901,114 @@ static bool ui_but_event_operator_string(const bContext *C, uiBut *but, char *bu return found; } +static bool ui_but_event_property_operator_string(const bContext *C, uiBut *but, char *buf, const size_t buf_len) +{ + /* context toggle operator names to check... */ + const char *ctx_toggle_opnames[] = { + "WM_OT_context_toggle", + "WM_OT_context_toggle_enum", + "WM_OT_context_cycle_int", + "WM_OT_context_cycle_enum", + "WM_OT_context_cycle_array", + "WM_OT_context_menu_enum", + NULL + }; + const size_t num_ops = sizeof(ctx_toggle_opnames) / sizeof(const char *); + + bool found = false; + + /* this version is only for finding hotkeys for properties (which get set via context using operators) */ + if (but->rnaprop) { + /* to avoid massive slowdowns on property panels, for now, we only check the + * hotkeys for Editor / Scene settings... + * + * TODO: userpref settings? + */ + // TODO: value (for enum stuff)? + char *data_path = NULL; + + if (but->rnapoin.id.data) { + ID *id = but->rnapoin.id.data; + + if (GS(id->name) == ID_SCR) { + /* screen/editor property + * NOTE: in most cases, there is actually no info for backwards tracing + * how to get back to ID from the editor data we may be dealing with + */ + if (RNA_struct_is_a(but->rnapoin.type, &RNA_Space)) { + /* data should be directly on here... */ + data_path = BLI_sprintfN("space_data.%s", RNA_property_identifier(but->rnaprop)); + } + else { + /* special exceptions for common nested data in editors... */ + if (RNA_struct_is_a(but->rnapoin.type, &RNA_DopeSheet)) { + /* dopesheet filtering options... */ + data_path = BLI_sprintfN("space_data.dopesheet.%s", RNA_property_identifier(but->rnaprop)); + } + } + } + else if (GS(id->name) == ID_SCE) { + if (RNA_struct_is_a(but->rnapoin.type, &RNA_ToolSettings)) { + /* toolsettings property + * NOTE: toolsettings is usually accessed directly (i.e. not through scene) + */ + data_path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop); + } + else { + /* scene property */ + char *path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop); + + if (path) { + data_path = BLI_sprintfN("scene.%s", path); + MEM_freeN(path); + } + /*else { + printf("ERROR in %s(): Couldn't get path for scene property - %s\n", + __func__, RNA_property_identifier(but->rnaprop)); + }*/ + } + } + else { + //puts("other id"); + } + + //printf("prop shortcut: '%s' (%s)\n", RNA_property_identifier(but->rnaprop), data_path); + } + + /* we have a datapath! */ + if (data_path) { + size_t i; + + /* create a property to host the "datapath" property we're sending to the operators */ + IDProperty *prop_path; + IDProperty *prop_path_value; + + IDPropertyTemplate val = {0}; + prop_path = IDP_New(IDP_GROUP, &val, __func__); + prop_path_value = IDP_NewString(data_path, "data_path", strlen(data_path) + 1); /* len + 1, or else will be truncated */ + IDP_AddToGroup(prop_path, prop_path_value); + + /* check each until one works... */ + for (i = 0; (i < num_ops) && (ctx_toggle_opnames[i]); i++) { + //printf("\t%s\n", ctx_toggle_opnames[i]); + if (WM_key_event_operator_string(C, ctx_toggle_opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false, + buf, buf_len)) + { + found = true; + break; + } + } + + /* cleanup */ + IDP_FreeProperty(prop_path); + MEM_freeN(prop_path); + MEM_freeN(data_path); + } + } + + return found; +} + static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) { uiBut *but; @@ -915,6 +1023,9 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) { ui_but_add_shortcut(but, buf, FALSE); } + else if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) { + ui_but_add_shortcut(but, buf, FALSE); + } } } @@ -2056,6 +2167,15 @@ static void ui_set_but_soft_range(uiBut *but) but->softmin = softmin; but->softmax = softmax; } + else if (but->poin && (but->pointype & UI_BUT_POIN_TYPES)) { + float value = ui_get_but_val(but); + CLAMP(value, but->hardmin, but->hardmax); + but->softmin = min_ff(but->softmin, value); + but->softmax = max_ff(but->softmax, value); + } + else { + BLI_assert(0); + } } /* ******************* Free ********************/ @@ -2257,8 +2377,12 @@ void ui_check_but(uiBut *but) ui_check_but_select(but, &value); /* only update soft range while not editing */ - if (but->rnaprop && !(but->editval || but->editstr || but->editvec)) { - ui_set_but_soft_range(but); + if (!(but->editval || but->editstr || but->editvec)) { + if ((but->rnaprop != NULL) || + (but->poin && (but->pointype & UI_BUT_POIN_TYPES))) + { + ui_set_but_soft_range(but); + } } /* test for min and max, icon sliders, etc */ @@ -2302,35 +2426,37 @@ void ui_check_but(uiBut *but) case NUM: case NUMSLI: - UI_GET_BUT_VALUE_INIT(but, value); + if (!but->editstr) { + UI_GET_BUT_VALUE_INIT(but, value); - if (ui_is_but_float(but)) { - if (value == (double) FLT_MAX) { - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str); - } - else if (value == (double) -FLT_MAX) { - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str); - } - /* support length type buttons */ - else if (ui_is_but_unit(but)) { - char new_str[sizeof(but->drawstr)]; - ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1); - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); + if (ui_is_but_float(but)) { + if (value == (double) FLT_MAX) { + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str); + } + else if (value == (double) -FLT_MAX) { + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str); + } + /* support length type buttons */ + else if (ui_is_but_unit(but)) { + char new_str[sizeof(but->drawstr)]; + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); + } + else { + const int prec = ui_but_float_precision(but, value); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value); + } } else { - const int prec = ui_but_float_precision(but, value); - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value); + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value); + } + + if (but->rnaprop) { + PropertySubType pstype = RNA_property_subtype(but->rnaprop); + + if (pstype == PROP_PERCENTAGE) + strcat(but->drawstr, "%"); } - } - else { - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value); - } - - if (but->rnaprop) { - PropertySubType pstype = RNA_property_subtype(but->rnaprop); - - if (pstype == PROP_PERCENTAGE) - strcat(but->drawstr, "%"); } break; @@ -2353,29 +2479,30 @@ void ui_check_but(uiBut *but) if (!but->editstr) { char str[UI_MAX_DRAW_STR]; - ui_get_but_string(but, str, UI_MAX_DRAW_STR - strlen(but->str)); - + ui_get_but_string(but, str, UI_MAX_DRAW_STR); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str); } break; case KEYEVT: - BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); + { + const char *str; if (but->flag & UI_SELECT) { - strcat(but->drawstr, "Press a key"); + str = "Press a key"; } else { UI_GET_BUT_VALUE_INIT(but, value); - strcat(but->drawstr, WM_key_event_string((short)value)); + str = WM_key_event_string((short)value); } + BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str); break; - + } case HOTKEYEVT: if (but->flag & UI_SELECT) { - but->drawstr[0] = '\0'; if (but->modifier_key) { char *str = but->drawstr; + but->drawstr[0] = '\0'; if (but->modifier_key & KM_SHIFT) str += BLI_strcpy_rlen(str, "Shift "); @@ -2388,8 +2515,9 @@ void ui_check_but(uiBut *but) (void)str; /* UNUSED */ } - else - strcat(but->drawstr, "Press a key "); + else { + BLI_strncpy(but->drawstr, "Press a key", UI_MAX_DRAW_STR); + } } else BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); @@ -2401,6 +2529,7 @@ void ui_check_but(uiBut *but) break; default: BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); + break; } @@ -2646,13 +2775,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, uiBut *but; int slen; - BLI_assert(width >= 0); - BLI_assert(height >= 0); + BLI_assert(width >= 0 && height >= 0); /* we could do some more error checks here */ if ((type & BUTTYPE) == LABEL) { - if ((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f))) - printf("blah\n"); BLI_assert((poin != NULL || min != 0.0f || max != 0.0f || (a1 == 0.0f && a2 != 0.0f) || (a1 != 0.0f && a1 != 1.0f)) == FALSE); } @@ -2740,7 +2866,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } /* keep track of UI_interface.h */ - if (ELEM9(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM, SCROLL, SEPR /* , FTPREVIEW */)) {} + if (ELEM8(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, BUTM, SCROLL, SEPR)) {} else if (but->type >= SEARCH_MENU) {} else but->flag |= UI_BUT_UNDO; @@ -3838,7 +3964,8 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but) { wmEvent event; - event = *(win->eventstate); + wm_event_init_from_window(win, &event); + event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; @@ -4011,9 +4138,17 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...) } } } + else if (type == BUT_GET_PROP_KEYMAP) { + /* for properties that are bound to one of the context cycle, etc. keys... */ + char buf[128]; + if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) { + tmp = BLI_strdup(buf); + } + } si->strinfo = tmp; } + va_end(args); if (free_items && items) MEM_freeN(items); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4c1ad2e41c4..b3df719d95a 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -875,6 +875,10 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); ARegion *ar_prev; + /* call here because regular mouse-up event wont run, + * typically 'button_activate_exit()' handles this */ + ui_apply_autokey(C, but); + drag_info->is_set = ui_is_but_push(but); drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect); drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect); @@ -1297,9 +1301,14 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) { ID *id = (ID *)wmd->poin; - if (but->poin == NULL && but->rnapoin.data == NULL) {} button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); BLI_strncpy(data->str, id->name + 2, data->maxlen); + + if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + but->changed = true; + ui_searchbox_update(C, data->searchbox, but, true); + } + button_activate_state(C, but, BUTTON_STATE_EXIT); } } @@ -1420,6 +1429,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) { /* else uiSearchboxData.active member is not updated [#26856] */ + but->changed = true; ui_searchbox_update(C, data->searchbox, but, true); } button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -1852,7 +1862,6 @@ enum { static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const int mode) { - char buf[UI_MAX_DRAW_STR] = {0}; char *str, *p, *pbuf; int x; bool changed = false; @@ -1868,6 +1877,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in p = pbuf = WM_clipboard_text_get(0); if (p && p[0]) { + char buf[UI_MAX_DRAW_STR] = {0}; unsigned int y; buf_len = 0; while (*p && *p != '\r' && *p != '\n' && buf_len < UI_MAX_DRAW_STR - 1) { @@ -1904,14 +1914,12 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in /* cut & copy */ else if (ELEM(mode, UI_TEXTEDIT_COPY, UI_TEXTEDIT_CUT)) { /* copy the contents to the copypaste buffer */ - for (x = but->selsta; x <= but->selend; x++) { - if (x == but->selend) - buf[x] = '\0'; - else - buf[(x - but->selsta)] = str[x]; - } + int sellen = but->selend - but->selsta; + char *buf = MEM_mallocN(sizeof(char) * (sellen + 1), "ui_textedit_copypaste"); + BLI_strncpy(buf, str + but->selsta, sellen + 1); WM_clipboard_text_set(buf, 0); + MEM_freeN(buf); /* for cut only, delete the selection afterwards */ if (mode == UI_TEXTEDIT_CUT) { @@ -2175,7 +2183,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle ui_searchbox_event(C, data->searchbox, but, event); break; } - /* pass on purposedly */ + /* fall-through */ case ENDKEY: ui_textedit_move(but, data, STRCUR_DIR_NEXT, event->shift, STRCUR_JUMP_ALL); @@ -2190,7 +2198,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle ui_searchbox_event(C, data->searchbox, but, event); break; } - /* pass on purposedly */ + /* fall-through */ case HOMEKEY: ui_textedit_move(but, data, STRCUR_DIR_PREV, event->shift, STRCUR_JUMP_ALL); @@ -2597,7 +2605,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, c static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { if (data->state == BUTTON_STATE_HIGHLIGHT) { - if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) { + if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) { if (but->dt == UI_EMBOSSN && !event->ctrl) { /* pass */ } @@ -2622,7 +2630,7 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) { /* unlink icon is on right */ - if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) { + if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) { ARegion *ar = data->region; rcti rect; int x = event->x, y = event->y; @@ -3713,7 +3721,8 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, break; default: - assert(!"invalid hsv type"); + BLI_assert(0); + break; } hsv_to_rgb_v(hsv, rgb); @@ -3783,8 +3792,10 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF hsv[2] += ndof->rx * sensitivity; CLAMP(hsv[2], but->softmin, but->softmax); + break; default: assert(!"invalid hsv type"); + break; } hsv_to_rgb_v(hsv, rgb); @@ -4933,7 +4944,6 @@ static bool ui_but_menu(bContext *C, uiBut *but) uiPopupMenu *pup; uiLayout *layout; bool is_array, is_array_component; - const char *name; uiStringInfo label = {BUT_GET_LABEL, NULL}; /* if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)*/ @@ -4946,12 +4956,11 @@ static bool ui_but_menu(bContext *C, uiBut *but) button_timers_tooltip_remove(C, but); + /* highly unlikely getting the label ever fails */ uiButGetStrInfo(C, but, &label, NULL); - name = label.strinfo; - pup = uiPupMenuBegin(C, name, ICON_NONE); + pup = uiPupMenuBegin(C, label.strinfo ? label.strinfo : "", ICON_NONE); layout = uiPupMenuLayout(pup); - if (label.strinfo) MEM_freeN(label.strinfo); @@ -6184,7 +6193,7 @@ void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but) button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); - event = *(win->eventstate); /* XXX huh huh? make api call */ + wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; @@ -6291,11 +6300,11 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) case MIDDLEMOUSE: case MOUSEPAN: button_timers_tooltip_remove(C, but); - - /* pass on purposedly */ + /* fall-through */ default: /* handle button type specific events */ retval = ui_do_button(C, block, but, event); + break; } } else if (data->state == BUTTON_STATE_WAIT_RELEASE) { @@ -6345,6 +6354,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) if (event->customdata == data->flashtimer) { button_activate_state(C, but, BUTTON_STATE_EXIT); } + break; } } @@ -6415,7 +6425,6 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar) { uiBut *but = ui_list_find_mouse_over(ar, event->x, event->y); int retval = WM_UI_HANDLER_CONTINUE; - int value, min, max; int type = event->type, val = event->val; if (but) { @@ -6438,8 +6447,11 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar) if (ELEM(type, UPARROWKEY, DOWNARROWKEY) || ((ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt))) { + const int value_orig = RNA_property_int_get(&but->rnapoin, but->rnaprop); + int value, min, max; + /* activate up/down the list */ - value = RNA_property_int_get(&but->rnapoin, but->rnaprop); + value = value_orig; if (ELEM(type, UPARROWKEY, WHEELUPMOUSE)) value--; @@ -6456,9 +6468,13 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar) RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max); value = CLAMPIS(value, min, max); - RNA_property_int_set(&but->rnapoin, but->rnaprop, value); - RNA_property_update(C, &but->rnapoin, but->rnaprop); - ED_region_tag_redraw(ar); + if (value != value_orig) { + RNA_property_int_set(&but->rnapoin, but->rnaprop, value); + RNA_property_update(C, &but->rnapoin, but->rnaprop); + + ui_apply_undo(but); + ED_region_tag_redraw(ar); + } retval = WM_UI_HANDLER_BREAK; } @@ -6563,6 +6579,8 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u static void ui_mouse_motion_towards_init_ex(uiPopupBlockHandle *menu, const int xy[2], const bool force) { + BLI_assert(((uiBlock *)menu->region->uiblocks.first)->flag & UI_BLOCK_MOVEMOUSE_QUIT); + if (!menu->dotowards || force) { menu->dotowards = true; menu->towards_xy[0] = xy[0]; @@ -6595,6 +6613,25 @@ static bool ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *me const float margin = MENU_TOWARDS_MARGIN; rctf rect_px; + BLI_assert(block->flag & UI_BLOCK_MOVEMOUSE_QUIT); + + + /* annoying fix for [#36269], this is a bit odd but in fact works quite well + * don't mouse-out of a menu if another menu has been created after it. + * if this causes problems we could remove it and check on a different fix - campbell */ + if (menu->region->next) { + /* am I the last menu (test) */ + ARegion *ar = menu->region->next; + do { + uiBlock *block = ar->uiblocks.first; + if (block && ui_block_is_menu(block)) { + return true; + } + } while ((ar = ar->next)); + } + /* annoying fix end! */ + + if (!menu->dotowards) { return false; } @@ -6819,10 +6856,12 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH but = ui_but_find_activated(ar); if (but && button_modal_state(but->active->state)) { - /* if a button is activated modal, always reset the start mouse - * position of the towards mechanism to avoid loosing focus, - * and don't handle events */ - ui_mouse_motion_towards_reinit(menu, &event->x); + if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) { + /* if a button is activated modal, always reset the start mouse + * position of the towards mechanism to avoid loosing focus, + * and don't handle events */ + ui_mouse_motion_towards_reinit(menu, &event->x); + } } else if (event->type == TIMER) { if (event->customdata == menu->scrolltimer) @@ -6831,7 +6870,9 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH else { /* for ui_mouse_motion_towards_block */ if (event->type == MOUSEMOVE) { - ui_mouse_motion_towards_init(menu, &event->x); + if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) { + ui_mouse_motion_towards_init(menu, &event->x); + } /* add menu scroll timer, if needed */ if (ui_menu_scroll_test(block, my)) @@ -7136,11 +7177,12 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH menu->menuretval = UI_RETURN_CANCEL | UI_RETURN_POPUP_OK; } else { - ui_mouse_motion_towards_check(block, menu, &event->x, is_parent_inside == false); /* check mouse moving outside of the menu */ if (inside == 0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) { uiSafetyRct *saferct; + + ui_mouse_motion_towards_check(block, menu, &event->x, is_parent_inside == false); /* check for all parent rects, enables arrowkeys to be used */ for (saferct = block->saferct.first; saferct; saferct = saferct->next) { @@ -7229,9 +7271,11 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo submenu->menuretval = 0; } - /* for cases where close does not cascade, allow the user to - * move the mouse back towards the menu without closing */ - ui_mouse_motion_towards_reinit(menu, &event->x); + if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) { + /* for cases where close does not cascade, allow the user to + * move the mouse back towards the menu without closing */ + ui_mouse_motion_towards_reinit(menu, &event->x); + } if (menu->menuretval) return WM_UI_HANDLER_CONTINUE; @@ -7286,12 +7330,16 @@ static int ui_handle_menus_recursive(bContext *C, const wmEvent *event, uiPopupB } if (do_but_search) { + uiBlock *block = menu->region->uiblocks.first; + retval = ui_handle_menu_button(C, event, menu); - /* when there is a active search button and we close it, - * we need to reinit the mouse coords [#35346] */ - if (ui_but_find_activated(menu->region) != but) { - do_towards_reinit = true; + if (block->flag & UI_BLOCK_MOVEMOUSE_QUIT) { + /* when there is a active search button and we close it, + * we need to reinit the mouse coords [#35346] */ + if (ui_but_find_activated(menu->region) != but) { + do_towards_reinit = true; + } } } else { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 82352cee05e..d2a8c47b347 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -427,6 +427,8 @@ struct uiKeyNavLock { struct uiPopupBlockHandle { /* internal */ struct ARegion *region; + + /* use only for 'UI_BLOCK_MOVEMOUSE_QUIT' popups */ float towards_xy[2]; double towardstime; bool dotowards; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2a6a9600582..2e80af1b3ad 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2429,6 +2429,11 @@ uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr, Pr but->rnapoin = *actptr; but->rnaprop = actprop; + /* only for the undo string */ + if (but->flag & UI_BUT_UNDO) { + but->tip = RNA_property_description(actprop); + } + return (uiLayout *)box; } @@ -3077,12 +3082,14 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, /* no undo for buttons for operator redo panels */ uiButClearFlag(but, UI_BUT_UNDO); +#if 0 /* broken, causes freedback loop, see [#36109] */ /* if button is operator's default property, and a text-field, enable focus for it * - this is used for allowing operators with popups to rename stuff with fewer clicks */ if ((but->rnaprop == op->type->prop) && (but->type == TEX)) { uiButSetFocusOnEnter(CTX_wm_window(C), but); } +#endif } } } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 9f7d1435195..5910909142c 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -148,7 +148,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int if (BLI_rcti_isect_pt(&sa->totrct, mx, my)) { if (sa->spacetype == SPACE_IMAGE) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { SpaceImage *sima = sa->spacedata.first; int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; @@ -160,7 +160,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int } else if (sa->spacetype == SPACE_NODE) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { SpaceNode *snode = sa->spacedata.first; int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; @@ -172,7 +172,7 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int } else if (sa->spacetype == SPACE_CLIP) { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if (BLI_rcti_isect_pt(&ar->winrct, mx, my)) { + if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) { SpaceClip *sc = sa->spacedata.first; int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin}; @@ -917,7 +917,7 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch /* First, full lang code. */ BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng); BLI_join_dirfile(path, maxlen, root, uilng); - BLI_join_dirfile(path, maxlen, path, tstr); + BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) return; @@ -941,7 +941,7 @@ static void edittranslation_find_po_file(const char *root, const char *uilng, ch BLI_join_dirfile(path, maxlen, root, tstr); strcat(tstr, ".po"); - BLI_join_dirfile(path, maxlen, path, tstr); + BLI_path_append(path, maxlen, tstr); if (BLI_is_file(path)) return; } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index b13de64d0c7..3fe11ad3a6b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -255,7 +255,7 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int pa->sizey = 0; } - BLI_strncpy(pa->drawname, drawname, UI_MAX_NAME_STR); + BLI_strncpy(pa->drawname, drawname, sizeof(pa->drawname)); /* if a new panel is added, we insert it right after the panel * that was last added. this way new panels are inserted in the diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index fbe23b1a1ed..95f47be0b70 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -439,6 +439,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL}; uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL}; uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL}; + uiStringInfo prop_keymap = {BUT_GET_PROP_KEYMAP, NULL}; uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL}; uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL}; @@ -448,7 +449,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* create tooltip data */ data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); - uiButGetStrInfo(C, but, &but_tip, &enum_label, &enum_tip, &op_keymap, &rna_struct, &rna_prop, NULL); + uiButGetStrInfo(C, but, &but_tip, &enum_label, &enum_tip, &op_keymap, &prop_keymap, &rna_struct, &rna_prop, NULL); /* special case, enum rna buttons only have enum item description, * use general enum description too before the specific one */ @@ -480,6 +481,13 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->color_id[data->totline] = UI_TIP_LC_NORMAL; data->totline++; } + + /* Property context-toggle shortcut */ + if (prop_keymap.strinfo) { + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), prop_keymap.strinfo); + data->color_id[data->totline] = UI_TIP_LC_NORMAL; + data->totline++; + } if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) { /* full string */ @@ -516,7 +524,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) if (but->rnapoin.id.data) { ID *id = but->rnapoin.id.data; - if (id->lib && id->lib->name) { + if (id->lib) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Library: %s"), id->lib->name); data->color_id[data->totline] = UI_TIP_LC_NORMAL; data->totline++; @@ -582,7 +590,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* never fails */ id_path = RNA_path_full_ID_py(id); - if (ptr->id.data && ptr->data && prop) { + if (ptr->data && prop) { data_path = RNA_path_from_ID_to_property(ptr, prop); } @@ -614,6 +622,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) MEM_freeN(enum_tip.strinfo); if (op_keymap.strinfo) MEM_freeN(op_keymap.strinfo); + if (prop_keymap.strinfo) + MEM_freeN(prop_keymap.strinfo); if (rna_struct.strinfo) MEM_freeN(rna_struct.strinfo); if (rna_prop.strinfo) @@ -2106,7 +2116,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper static char tip[50]; static char hexcol[128]; float rgb_gamma[3]; - float min, max, step, precision; + float softmin, softmax, hardmin, hardmax, step, precision; float *hsv = ui_block_hsv_get(block); int yco; @@ -2132,7 +2142,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper /* sneaky way to check for alpha */ rgba[3] = FLT_MAX; - RNA_property_float_ui_range(ptr, prop, &min, &max, &step, &precision); + RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); + RNA_property_float_range(ptr, prop, &hardmin, &hardmax); RNA_property_float_get_array(ptr, prop, rgba); switch (U.color_picker_type) { @@ -2186,7 +2197,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); bt = uiDefButF(block, NUMSLI, 0, IFACE_("S "), 0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 1, 0.0, 1.0, 10, 3, TIP_("Saturation")); uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); - bt = uiDefButF(block, NUMSLI, 0, IFACE_("V "), 0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 2, 0.0, max, 10, 3, TIP_("Value")); + bt = uiDefButF(block, NUMSLI, 0, IFACE_("V "), 0, yco -= UI_UNIT_Y, butwidth, UI_UNIT_Y, hsv + 2, 0.0, softmax, 10, 3, TIP_("Value")); + bt->hardmax = hardmax; /* not common but rgb may be over 1.0 */ uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); uiBlockEndAlign(block); @@ -2256,10 +2268,8 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_ block = uiBeginBlock(C, handle->region, __func__, UI_EMBOSS); - if (but->rnaprop) { - if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { - block->color_profile = FALSE; - } + if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { + block->color_profile = false; } if (but->block) { @@ -2516,7 +2526,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) uiStyle *style = UI_GetStyleDraw(); uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; - + pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash = ui_popup_menu_hash(title); @@ -2530,7 +2540,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) pup->block->handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); /* create title button */ - if (title && title[0]) { + if (title[0]) { char titlestr[256]; if (icon) { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 57392c60f80..f45bd1c3463 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2646,7 +2646,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co sub = uiLayoutRow(overlap, FALSE); but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, - active_dataptr, activeprop, 0, 0, i, 0, 0, ""); + active_dataptr, activeprop, 0, 0, i, 0, 0, NULL); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); @@ -2660,6 +2660,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co if (i == activei) { ui_layout_list_set_labels_active(sub); } + + uiBlockClearFlag(subblock, UI_BLOCK_LIST_ITEM); } i++; } @@ -2734,7 +2736,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co sub = uiLayoutRow(overlap, FALSE); but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, - active_dataptr, activeprop, 0, 0, i, 0, 0, ""); + active_dataptr, activeprop, 0, 0, i, 0, 0, NULL); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); @@ -2747,6 +2749,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co ui_layout_list_set_labels_active(sub); } + uiBlockClearFlag(subblock, UI_BLOCK_LIST_ITEM); + i++; } RNA_PROP_END; @@ -3018,16 +3022,16 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, /* recurse for nested properties */ if (RNA_property_type(prop) == PROP_POINTER) { PointerRNA propptr = RNA_property_pointer_get(ptr, prop); - const char *name = RNA_property_ui_name(prop); if (propptr.data && RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) { + const char *name = RNA_property_ui_name(prop); template_keymap_item_properties(layout, name, &propptr); continue; } } /* add property */ - uiItemR(flow, ptr, RNA_property_identifier(prop), 0, NULL, ICON_NONE); + uiItemFullR(flow, ptr, prop, -1, 0, 0, NULL, ICON_NONE); } RNA_STRUCT_END; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 9b736eb1bf4..594d3e40dcd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -96,8 +96,7 @@ typedef struct uiWidgetBase { float inner_v[WIDGET_SIZE_MAX][2]; float inner_uv[WIDGET_SIZE_MAX][2]; - short inner, outline, emboss; /* set on/off */ - short shadedir; + bool inner, outline, emboss, shadedir; uiWidgetTrias tria1; uiWidgetTrias tria2; @@ -209,9 +208,9 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y /* for each AA step */ for (j = 0; j < WIDGET_AA_JITTER; j++) { - glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); + glTranslatef(jit[j][0], jit[j][1], 0.0f); glDrawArrays(GL_TRIANGLES, 0, 3); - glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); + glTranslatef(-jit[j][0], -jit[j][1], 0.0f); } glDisableClientState(GL_VERTEX_ARRAY); @@ -232,9 +231,9 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m glColor4fv(color); for (j = 0; j < WIDGET_AA_JITTER; j++) { - glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); + glTranslatef(jit[j][0], jit[j][1], 0.0f); uiDrawBox(mode, minx, miny, maxx, maxy, rad); - glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); + glTranslatef(-jit[j][0], -jit[j][1], 0.0f); } glDisable(GL_BLEND); @@ -778,7 +777,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glEnableClientState(GL_VERTEX_ARRAY); for (j = 0; j < WIDGET_AA_JITTER; j++) { - glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); + glTranslatef(jit[j][0], jit[j][1], 0.0f); /* outline */ glColor4ubv(tcol); @@ -794,7 +793,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2); } - glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); + glTranslatef(-jit[j][0], -jit[j][1], 0.0f); } glDisableClientState(GL_VERTEX_ARRAY); @@ -808,7 +807,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) (unsigned char)((float)wcol->item[3] / WIDGET_AA_JITTER)}; /* for each AA step */ for (j = 0; j < WIDGET_AA_JITTER; j++) { - glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); + glTranslatef(jit[j][0], jit[j][1], 0.0f); if (wtb->tria1.tot) { glColor4ubv(tcol); @@ -819,7 +818,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) widget_trias_draw(&wtb->tria2); } - glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); + glTranslatef(-jit[j][0], -jit[j][1], 0.0f); } } @@ -2061,6 +2060,7 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons copy_v3_v3(col1[0], col1[2]); copy_v3_v3(col1[1], col1[2]); copy_v3_v3(col1[3], col1[2]); + break; } /* old below */ @@ -2365,7 +2365,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, const rcti *rect, const rcti *slid uiWidgetBase wtb; int horizontal; float rad; - short outline = 0; + bool outline = false; widget_init(&wtb); @@ -2409,8 +2409,9 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, const rcti *rect, const rcti *slid wtb.emboss = 0; /* only emboss once */ /* exception for progress bar */ - if (state & UI_SCROLL_NO_OUTLINE) - SWAP(short, outline, wtb.outline); + if (state & UI_SCROLL_NO_OUTLINE) { + SWAP(bool, outline, wtb.outline); + } round_box_edges(&wtb, UI_CNR_ALL, slider, rad); @@ -2431,8 +2432,9 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, const rcti *rect, const rcti *slid } widgetbase_draw(&wtb, wcol); - if (state & UI_SCROLL_NO_OUTLINE) - SWAP(short, outline, wtb.outline); + if (state & UI_SCROLL_NO_OUTLINE) { + SWAP(bool, outline, wtb.outline); + } } } @@ -2968,7 +2970,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) case UI_WTYPE_LISTLABEL: wt.wcol_theme = &btheme->tui.wcol_list_item; - /* No break, we use usual label code too. */ + /* fall-through */ /* we use usual label code too. */ case UI_WTYPE_LABEL: wt.draw = NULL; break; @@ -3197,9 +3199,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case SEPR: ui_draw_separator(rect, &tui->wcol_menu_item); break; - default: wt = widget_type(UI_WTYPE_MENU_ITEM); + break; } } else if (but->dt == UI_EMBOSSN) { @@ -3384,6 +3386,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct default: wt = widget_type(UI_WTYPE_REGULAR); + break; } } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index becffb64ae6..dc780d6a4f1 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1353,7 +1353,8 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3] UI_GetColorPtrBlendShade3ubv(src_col, col, dst_col, 0.5f, -10); break; default: - BLI_assert(!"invalid axis arg"); + BLI_assert(0); + break; } } @@ -2094,8 +2095,7 @@ void init_userdef_do_versions(void) if (U.ndof_sensitivity == 0.0f) { U.ndof_sensitivity = 1.0f; - U.ndof_flag = NDOF_LOCK_HORIZON | - NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; + U.ndof_flag = (NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE); } if (U.ndof_orbit_sensitivity == 0.0f) { diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index fe5b129e938..f656d22fc64 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -209,9 +209,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) } /* scrollers - should we have these by default? */ /* XXX for now, we don't override this, or set it either! */ + break; } - break; - /* 'list/channel view' - zoom, aspect ratio, and alignment restrictions are set here */ case V2D_COMMONVIEW_LIST: { @@ -225,9 +224,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) tot_changed = do_init; /* scroller settings are currently not set here... that is left for regions... */ + break; } - break; - /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead. * zoom, aspect ratio, and alignment restrictions are set here */ case V2D_COMMONVIEW_STACK: @@ -242,9 +240,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) tot_changed = do_init; /* scroller settings are currently not set here... that is left for regions... */ + break; } - break; - /* 'header' regions - zoom, aspect ratio, alignment, and panning restrictions are set here */ case V2D_COMMONVIEW_HEADER: { @@ -272,10 +269,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* absolutely no scrollers allowed */ v2d->scroll = 0; - + break; } - break; - /* panels view, with horizontal/vertical align */ case V2D_COMMONVIEW_PANELS_UI: { @@ -308,9 +303,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->cur.ymax = 0.0f; v2d->cur.ymin = (-winy) * panelzoom; } + break; } - break; - /* other view types are completely defined using their own settings already */ default: /* we don't do anything here, as settings should be fine, but just make sure that rect */ @@ -1739,9 +1733,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v fac2 = fac2 - time; scroll_printstr(scene, fac, h, time + (float)FPS * fac2 / 100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h'); + break; } - break; - case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */ /* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */ scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v'); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index e12817262f8..929b7ae2a5d 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -247,8 +247,8 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event) vpd->lasty = event->y; view_pan_apply(op); + break; } - break; /* XXX - Mode switching isn't implemented. See comments in 36818. * switch to zoom */ #if 0 @@ -1288,7 +1288,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar, fac = smooth_view_rect_to_fac(&v2d->cur, cur); } - if (C && U.smooth_viewtx && fac > FLT_EPSILON) { + if (U.smooth_viewtx && fac > FLT_EPSILON) { int changed = FALSE; if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == FALSE) @@ -1674,9 +1674,8 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *e vsm->lasty = event->y; scroller_activate_apply(C, op); + break; } - break; - case LEFTMOUSE: case MIDDLEMOUSE: if (event->val == KM_RELEASE) { |