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:
authorCampbell Barton <ideasman42@gmail.com>2019-05-09 11:40:42 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-09 11:40:42 +0300
commitdea8fb2beaed6282ec5baef80b3fd735198caff4 (patch)
treeccc43ff4d61208c1d4693c0f28b3f836c9623276 /source/blender/editors/screen
parentf09aead64a7475ba9eb6be7729fe176900d80c81 (diff)
Fix: Nav_bar context menu in preferences
Also merge the keymaps for header/footer/navbar. D4736 by @Gvgeo with edits
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/area.c9
-rw-r--r--source/blender/editors/screen/screen_ops.c165
2 files changed, 72 insertions, 102 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index f3dd25ff20f..1bb7bf2fce7 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1627,14 +1627,19 @@ static void ed_default_handlers(
}
if (flag & ED_KEYMAP_HEADER) {
/* standard keymap for headers regions */
- wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Header", 0, 0);
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Region Context Menu", 0, 0);
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_FOOTER) {
/* standard keymap for footer regions */
- wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Footer", 0, 0);
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Region Context Menu", 0, 0);
WM_event_add_keymap_handler(handlers, keymap);
}
+ if (flag & ED_KEYMAP_NAVBAR) {
+ /* standard keymap for Navigation bar regions */
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Region Context Menu", 0, 0);
+ WM_event_add_keymap_handler(&ar->handlers, keymap);
+ }
/* Keep last because of LMB/RMB handling, see: T57527. */
if (flag & ED_KEYMAP_GPENCIL) {
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index a87660d2cb7..bebab6b3a36 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -3955,10 +3955,10 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Header Tools Operator
+/** \name Region Context Menu Operator (Header/Footer/Navbar)
* \{ */
-static bool header_context_menu_poll(bContext *C)
+static bool screen_region_context_menu_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
return (sa && sa->spacetype != SPACE_STATUSBAR);
@@ -4008,81 +4008,6 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
}
}
-static int header_context_menu_invoke(bContext *C,
- wmOperator *UNUSED(op),
- const wmEvent *UNUSED(event))
-{
- uiPopupMenu *pup;
- uiLayout *layout;
-
- pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
-
- ED_screens_header_tools_menu_create(C, layout, NULL);
-
- UI_popup_menu_end(C, pup);
-
- return OPERATOR_INTERFACE;
-}
-
-static void SCREEN_OT_header_context_menu(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Header Context Menu";
- ot->description = "Display header region context menu";
- ot->idname = "SCREEN_OT_header_context_menu";
-
- /* api callbacks */
- ot->poll = header_context_menu_poll;
- ot->invoke = header_context_menu_invoke;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Footer Toggle Operator
- * \{ */
-
-static int footer_exec(bContext *C, wmOperator *UNUSED(op))
-{
- ARegion *ar = screen_find_region_type(C, RGN_TYPE_FOOTER);
-
- if (ar == NULL) {
- return OPERATOR_CANCELLED;
- }
-
- ar->flag ^= RGN_FLAG_HIDDEN;
-
- 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_footer(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Toggle Footer";
- ot->description = "Toggle footer display";
- ot->idname = "SCREEN_OT_footer";
-
- /* api callbacks */
- ot->exec = footer_exec;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Footer Tools Operator
- * \{ */
-
-static bool footer_context_menu_poll(bContext *C)
-{
- ScrArea *sa = CTX_wm_area(C);
- return sa;
-}
-
void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
{
ScrArea *sa = CTX_wm_area(C);
@@ -4107,51 +4032,92 @@ void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UN
}
}
-static int footer_context_menu_invoke(bContext *C,
+void ED_screens_navigation_bar_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
+{
+ const ARegion *ar = CTX_wm_region(C);
+ const char *but_flip_str = (ar->alignment == RGN_ALIGN_LEFT) ? IFACE_("Flip to Right") :
+ IFACE_("Flip to Left");
+
+ /* 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");
+}
+
+static int screen_context_menu_invoke(bContext *C,
wmOperator *UNUSED(op),
const wmEvent *UNUSED(event))
{
uiPopupMenu *pup;
uiLayout *layout;
+ const ARegion *ar = CTX_wm_region(C);
- pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE);
- layout = UI_popup_menu_layout(pup);
-
- ED_screens_footer_tools_menu_create(C, layout, NULL);
-
- UI_popup_menu_end(C, pup);
+ if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
+ pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
+ layout = UI_popup_menu_layout(pup);
+ ED_screens_header_tools_menu_create(C, layout, NULL);
+ UI_popup_menu_end(C, pup);
+ }
+ else if (ar->regiontype == RGN_TYPE_FOOTER) {
+ pup = UI_popup_menu_begin(C, IFACE_("Footer"), ICON_NONE);
+ layout = UI_popup_menu_layout(pup);
+ ED_screens_footer_tools_menu_create(C, layout, NULL);
+ UI_popup_menu_end(C, pup);
+ }
+ else if (ar->regiontype == RGN_TYPE_NAV_BAR) {
+ pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE);
+ layout = UI_popup_menu_layout(pup);
+ ED_screens_navigation_bar_tools_menu_create(C, layout, NULL);
+ UI_popup_menu_end(C, pup);
+ }
return OPERATOR_INTERFACE;
}
-static void SCREEN_OT_footer_context_menu(wmOperatorType *ot)
+static void SCREEN_OT_region_context_menu(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Footer Context Menu";
- ot->description = "Display footer region context menu";
- ot->idname = "SCREEN_OT_footer_context_menu";
+ ot->name = "Region Context Menu";
+ ot->description = "Display region context menu";
+ ot->idname = "SCREEN_OT_region_context_menu";
/* api callbacks */
- ot->poll = footer_context_menu_poll;
- ot->invoke = footer_context_menu_invoke;
+ ot->poll = screen_region_context_menu_poll;
+ ot->invoke = screen_context_menu_invoke;
}
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Navigation Bar Tools Menu
+/** \name Footer Toggle Operator
* \{ */
-void ED_screens_navigation_bar_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
+static int footer_exec(bContext *C, wmOperator *UNUSED(op))
{
- const ARegion *ar = CTX_wm_region(C);
- const char *but_flip_str = (ar->alignment == RGN_ALIGN_LEFT) ? IFACE_("Flip to Right") :
- IFACE_("Flip to Left");
+ ARegion *ar = screen_find_region_type(C, RGN_TYPE_FOOTER);
- /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */
- uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
+ if (ar == NULL) {
+ return OPERATOR_CANCELLED;
+ }
- uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
+ ar->flag ^= RGN_FLAG_HIDDEN;
+
+ 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_footer(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Toggle Footer";
+ ot->description = "Toggle footer display";
+ ot->idname = "SCREEN_OT_footer";
+
+ /* api callbacks */
+ ot->exec = footer_exec;
}
/** \} */
@@ -5299,9 +5265,8 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(SCREEN_OT_region_scale);
WM_operatortype_append(SCREEN_OT_region_flip);
WM_operatortype_append(SCREEN_OT_header_toggle_menus);
- WM_operatortype_append(SCREEN_OT_header_context_menu);
+ WM_operatortype_append(SCREEN_OT_region_context_menu);
WM_operatortype_append(SCREEN_OT_footer);
- WM_operatortype_append(SCREEN_OT_footer_context_menu);
WM_operatortype_append(SCREEN_OT_screen_set);
WM_operatortype_append(SCREEN_OT_screen_full_area);
WM_operatortype_append(SCREEN_OT_back_to_previous);