From d245d360746b99abc4bc1c64907d6bd160be120e Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 26 Oct 2017 22:40:24 +0200 Subject: Remove SCREEN_OT_header_flip, use SCREEN_OT_region_flip instead Basically reverts rB65c4149f203610 and fixes the issue in a better way. Keymaps using the removed operator will be affected. Switching header from top to bottom now has the shortcut F5, just like switching other regions. --- source/blender/editors/screen/screen_ops.c | 56 ++++-------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) (limited to 'source') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f6b8e5ba8cf..b48f5dc1432 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3212,6 +3212,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) } /* ************** header operator ***************************** */ + static int header_exec(bContext *C, wmOperator *UNUSED(op)) { ARegion *ar = screen_find_region_type(C, RGN_TYPE_HEADER); @@ -3240,50 +3241,6 @@ static void SCREEN_OT_header(wmOperatorType *ot) ot->exec = header_exec; } -/* ************** header flip operator ***************************** */ - -/* flip a header region alignment */ -static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) -{ - ARegion *ar = screen_find_region_type(C, RGN_TYPE_HEADER); - - if (ar == NULL) { - return OPERATOR_CANCELLED; - } - - /* copied from SCREEN_OT_region_flip */ - if (ar->alignment == RGN_ALIGN_TOP) - ar->alignment = RGN_ALIGN_BOTTOM; - else if (ar->alignment == RGN_ALIGN_BOTTOM) - ar->alignment = RGN_ALIGN_TOP; - else if (ar->alignment == RGN_ALIGN_LEFT) - ar->alignment = RGN_ALIGN_RIGHT; - else if (ar->alignment == RGN_ALIGN_RIGHT) - ar->alignment = RGN_ALIGN_LEFT; - - ED_area_tag_redraw(CTX_wm_area(C)); - - WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - - return OPERATOR_FINISHED; -} - - -static void SCREEN_OT_header_flip(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Flip Header Region"; - ot->idname = "SCREEN_OT_header_flip"; - ot->description = "Toggle the header over/below the main window area"; - - /* api callbacks */ - ot->exec = header_flip_exec; - - ot->poll = ED_operator_areaactive; - ot->flag = 0; -} - - /* ************** show menus operator ***************************** */ @@ -3316,17 +3273,17 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) /* ************** header tools operator ***************************** */ + void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); + const char *but_flip_str = (ar->alignment == RGN_ALIGN_TOP) ? IFACE_("Flip to Bottom") : IFACE_("Flip to Top"); - /* XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator. */ - if (ar->alignment == RGN_ALIGN_TOP) - uiItemO(layout, IFACE_("Flip to Bottom"), ICON_NONE, "SCREEN_OT_header_flip"); - else - uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip"); + /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ + uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); + uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); uiItemO(layout, IFACE_("Collapse Menus"), (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT, "SCREEN_OT_header_toggle_menus"); @@ -4296,7 +4253,6 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_region_quadview); WM_operatortype_append(SCREEN_OT_region_scale); WM_operatortype_append(SCREEN_OT_region_flip); - WM_operatortype_append(SCREEN_OT_header_flip); WM_operatortype_append(SCREEN_OT_header); WM_operatortype_append(SCREEN_OT_header_toggle_menus); WM_operatortype_append(SCREEN_OT_header_toolbox); -- cgit v1.2.3