diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-23 20:58:54 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-23 21:02:08 +0300 |
commit | 34ebf6f82c4a375feb3c5260597042ff41adc7b5 (patch) | |
tree | d19e93daad6b4ab67e3c8a08e6544ab839e7340e /source/blender/editors/interface | |
parent | 1de3ae7e427eace696b760fe6fa298157ee7c544 (diff) |
Workspaces: move delete to right click menu, instead of X on tab.
These are not intended to be closed as often as e.g. browser tabs, they are
intended to be more persistent and accidental closing should be avoided.
Diffstat (limited to 'source/blender/editors/interface')
5 files changed, 32 insertions, 36 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 37c56d454bb..edb0928c57e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2075,7 +2075,7 @@ static bool ui_but_icon_extra_is_visible_text_clear(const uiBut *but) static bool ui_but_icon_extra_is_visible_search_unlink(const uiBut *but) { - BLI_assert(ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB)); + BLI_assert(ELEM(but->type, UI_BTYPE_SEARCH_MENU)); return ((but->editstr == NULL) && (but->drawstr[0] != '\0') && (but->flag & UI_BUT_VALUE_CLEAR)); @@ -2118,11 +2118,6 @@ uiButExtraIconType ui_but_icon_extra_get(uiBut *but) return UI_BUT_ICONEXTRA_EYEDROPPER; } break; - case UI_BTYPE_TAB: - if (ui_but_icon_extra_is_visible_search_unlink(but)) { - return UI_BUT_ICONEXTRA_CLEAR; - } - break; default: break; } @@ -3095,7 +3090,6 @@ void ui_but_update_ex(uiBut *but, const bool validate) case UI_BTYPE_TEXT: case UI_BTYPE_SEARCH_MENU: - case UI_BTYPE_TAB: if (!but->editstr) { char str[UI_MAX_DRAW_STR]; diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 8d4f8594a90..281c2fb7104 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -361,7 +361,14 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); } - if (but->rnapoin.data && but->rnaprop) { + if (but->type == UI_BTYPE_TAB) { + uiButTab *tab = (uiButTab *)but; + if (tab->menu) { + UI_menutype_draw(C, tab->menu, layout); + uiItemS(layout); + } + } + else if (but->rnapoin.data && but->rnaprop) { PointerRNA *ptr = &but->rnapoin; PropertyRNA *prop = but->rnaprop; const PropertyType type = RNA_property_type(prop); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0ba9261c4bd..4b68be8fa3b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3763,17 +3763,6 @@ static int ui_do_but_TAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButton return WM_UI_HANDLER_BREAK; } else if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && (event->val == KM_CLICK)) { - const bool has_icon_extra = ui_but_icon_extra_get(but) == UI_BUT_ICONEXTRA_CLEAR; - - if (has_icon_extra && ui_but_is_mouse_over_icon_extra(data->region, but, &event->x)) { - uiButTab *tab = (uiButTab *)but; - wmOperatorType *ot_backup = but->optype; - - but->optype = tab->unlink_ot; - /* Force calling unlink/delete operator. */ - ui_apply_but(C, block, but, data, true); - but->optype = ot_backup; - } button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -8910,7 +8899,6 @@ static int ui_handle_menu_event( else { /* check mouse moving outside of the menu */ - //printf("inside %d mm quit %d\n", inside, block->flag & (UI_BLOCK_MOVEMOUSE_QUIT); if (inside == 0 && (block->flag & (UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_POPOVER))) { uiSafetyRct *saferct; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index f7507223f31..863e4b3762a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -322,7 +322,7 @@ struct uiBut { typedef struct uiButTab { uiBut but; - struct wmOperatorType *unlink_ot; + struct MenuType *menu; } uiButTab; typedef struct ColorPicker { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 820b34c1ac4..9c4e7faa73e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -822,38 +822,45 @@ static void template_ID( UI_block_align_end(block); } + +ID *UI_context_active_but_get_tab_ID(bContext *C) +{ + uiBut *but = UI_context_active_but_get(C); + + if (but && but->type == UI_BTYPE_TAB) { + return but->custom_data; + } + else { + return NULL; + } +} + static void template_ID_tabs( bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, - const char *newop, const char *UNUSED(openop), const char *unlinkop) + const char *newop, const char *UNUSED(openop), const char *menu) { const ARegion *region = CTX_wm_region(C); const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop); + MenuType *mt = WM_menutype_find(menu, false); + const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP; const int but_height = UI_UNIT_Y * 1.1; uiBlock *block = uiLayoutGetBlock(layout); uiStyle *style = UI_style_get_dpi(); - for (ID *id = template->idlb->first; id; id = id->next) { - wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false); - const bool is_active = active_ptr.data == id; - const unsigned int but_width = ( - UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X + - (is_active ? ICON_DEFAULT_WIDTH_SCALE : 0)); - uiButTab *tab; - - tab = (uiButTab *)uiDefButR_prop( - block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y * 1.1, + const int name_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2); + const int but_width = name_width + UI_UNIT_X; + + uiButTab *tab = (uiButTab *)uiDefButR_prop( + block, UI_BTYPE_TAB, 0, id->name + 2, 0, 0, but_width, but_height, &template->ptr, template->prop, 0, 0.0f, sizeof(id->name) - 2, 0.0f, 0.0f, ""); UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(template), id); tab->but.custom_data = (void *)id; - tab->unlink_ot = unlink_ot; + tab->menu = mt; - if (is_active) { - UI_but_flag_enable(&tab->but, UI_BUT_VALUE_CLEAR); - } UI_but_drawflag_enable(&tab->but, but_align); } |