diff --git a/release/scripts/ui/space_dopesheet.py b/release/scripts/ui/space_dopesheet.py index 2bd0300c465..f0ddc3b4651 100644 --- a/release/scripts/ui/space_dopesheet.py +++ b/release/scripts/ui/space_dopesheet.py @@ -130,6 +130,8 @@ class DOPESHEET_MT_channel(bpy.types.Menu): def draw(self, context): layout = self.layout + layout.operator_context = 'INVOKE_REGION_CHANNELS' + layout.column() layout.operator("anim.channels_setting_toggle") layout.operator("anim.channels_setting_enable") diff --git a/release/scripts/ui/space_graph.py b/release/scripts/ui/space_graph.py index 511ab06d0da..3ee85672f28 100644 --- a/release/scripts/ui/space_graph.py +++ b/release/scripts/ui/space_graph.py @@ -133,6 +133,8 @@ class GRAPH_MT_channel(bpy.types.Menu): def draw(self, context): layout = self.layout + layout.operator_context = 'INVOKE_REGION_CHANNELS' + layout.column() layout.operator("anim.channels_setting_toggle") layout.operator("anim.channels_setting_enable") diff --git a/release/scripts/ui/space_sequencer.py b/release/scripts/ui/space_sequencer.py index 9a63903300e..d1b7affc1be 100644 --- a/release/scripts/ui/space_sequencer.py +++ b/release/scripts/ui/space_sequencer.py @@ -123,7 +123,9 @@ class SEQUENCER_MT_view(bpy.types.Menu): if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'): layout.operator("sequencer.view_all", text='View all Sequences') if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'): + layout.operator_context = 'INVOKE_REGION_PREVIEW' layout.operator("sequencer.view_all_preview", text='Fit preview in window') + layout.operator_context = 'INVOKE_DEFAULT' layout.operator("sequencer.view_selected") layout.prop(st, "draw_frames") diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 3a0cbd9d872..ebf4f09ffd4 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -234,6 +234,8 @@ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar); void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar); void BKE_screen_area_free(struct ScrArea *sa); +struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); + /* screen */ void free_screen(struct bScreen *sc); unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 0dc6bf359f6..b8ac8d99128 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -336,3 +336,19 @@ unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene) return layer; } +/* ***************** Utilities ********************** */ + +/* Find a region of the specified type from the given area */ +ARegion *BKE_area_find_region_type(ScrArea *sa, int type) +{ + if (sa) { + ARegion *ar; + + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == type) + return ar; + } + } + return NULL; +} + diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index f756c5b3158..a1ad79b0658 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1385,7 +1385,7 @@ void ANIM_OT_channels_expand (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); + ot->prop= RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); } /* ********************** Collapse Channels Operator *********************** */ @@ -1427,7 +1427,7 @@ void ANIM_OT_channels_collapse (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)"); + ot->prop= RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)"); } /* ********************** Select All Operator *********************** */ @@ -1467,7 +1467,7 @@ void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); + ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); } /* ******************** Borderselect Operator *********************** */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 22f5989f3aa..d91f2788ecd 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -733,7 +733,7 @@ void ACTION_OT_clean (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); + ot->prop= RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); } /* ******************** Sample Keyframes Operator *********************** */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 1939057b654..c22533f9d45 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -196,7 +196,7 @@ void ACTION_OT_select_all_toggle (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); + ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); } /* ******************** Border Select Operator **************************** */ @@ -362,7 +362,7 @@ void ACTION_OT_select_border(wmOperatorType *ot) /* rna */ WM_operator_properties_gesture_border(ot, FALSE); - RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); + ot->prop= RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } /* ******************** Column Select Operator **************************** */ @@ -571,7 +571,7 @@ void ACTION_OT_select_column (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); + ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } /* ******************** Select More/Less Operators *********************** */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index dca2b2f3b98..40e035759d1 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -924,7 +924,7 @@ void GRAPH_OT_clean (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); + ot->prop= RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); } /* ******************** Bake F-Curve Operator *********************** */ @@ -2013,7 +2013,7 @@ void GRAPH_OT_fmodifier_add (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); RNA_def_boolean(ot->srna, "only_active", 1, "Only Active", "Only add F-Modifier to active F-Curve."); } diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 872b688bea1..d6ac1480985 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -199,7 +199,7 @@ void GRAPH_OT_select_all_toggle (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; /* props */ - RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); + ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); } /* ******************** Border Select Operator **************************** */ @@ -361,7 +361,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot) /* rna */ WM_operator_properties_gesture_border(ot, FALSE); - RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); + ot->prop= RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } /* ******************** Column Select Operator **************************** */ @@ -546,7 +546,7 @@ void GRAPH_OT_select_column (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; /* props */ - RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); + ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } /* ******************** Select More/Less Operators *********************** */ diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 695eb76cb53..c5738b58614 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -522,10 +522,14 @@ static void rna_def_ui_layout(BlenderRNA *brna) static EnumPropertyItem operator_context_items[] = { {WM_OP_INVOKE_DEFAULT, "INVOKE_DEFAULT", 0, "Invoke Default", ""}, {WM_OP_INVOKE_REGION_WIN, "INVOKE_REGION_WIN", 0, "Invoke Region Window", ""}, + {WM_OP_INVOKE_REGION_CHANNELS, "INVOKE_REGION_CHANNELS", 0, "Invoke Region Channels", ""}, + {WM_OP_INVOKE_REGION_PREVIEW, "INVOKE_REGION_PREVIEW", 0, "Invoke Region Preview", ""}, {WM_OP_INVOKE_AREA, "INVOKE_AREA", 0, "Invoke Area", ""}, {WM_OP_INVOKE_SCREEN, "INVOKE_SCREEN", 0, "Invoke Screen", ""}, {WM_OP_EXEC_DEFAULT, "EXEC_DEFAULT", 0, "Exec Default", ""}, {WM_OP_EXEC_REGION_WIN, "EXEC_REGION_WIN", 0, "Exec Region Window", ""}, + {WM_OP_EXEC_REGION_CHANNELS, "EXEC_REGION_CHANNELS", 0, "Exec Region Channels", ""}, + {WM_OP_EXEC_REGION_PREVIEW, "EXEC_REGION_PREVIEW", 0, "Exec Region Preview", ""}, {WM_OP_EXEC_AREA, "EXEC_AREA", 0, "Exec Area", ""}, {WM_OP_EXEC_SCREEN, "EXEC_SCREEN", 0, "Exec Screen", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 3efa2b85174..7a08320cc19 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -58,11 +58,15 @@ enum { /* if there's invoke, call it, otherwise exec */ WM_OP_INVOKE_DEFAULT, WM_OP_INVOKE_REGION_WIN, + WM_OP_INVOKE_REGION_CHANNELS, + WM_OP_INVOKE_REGION_PREVIEW, WM_OP_INVOKE_AREA, WM_OP_INVOKE_SCREEN, /* only call exec */ WM_OP_EXEC_DEFAULT, WM_OP_EXEC_REGION_WIN, + WM_OP_EXEC_REGION_CHANNELS, + WM_OP_EXEC_REGION_PREVIEW, WM_OP_EXEC_AREA, WM_OP_EXEC_SCREEN }; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 7e7dfe7a968..685e671c31a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -48,6 +48,7 @@ #include "BKE_main.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_screen.h" #include "BKE_utildefines.h" #include "ED_fileselect.h" @@ -656,17 +657,37 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, int contex case WM_OP_EXEC_REGION_WIN: case WM_OP_INVOKE_REGION_WIN: + case WM_OP_EXEC_REGION_CHANNELS: + case WM_OP_INVOKE_REGION_CHANNELS: + case WM_OP_EXEC_REGION_PREVIEW: + case WM_OP_INVOKE_REGION_PREVIEW: { - /* forces operator to go to the region window, for header menus - but we stay in the same region if we are already in one */ + /* forces operator to go to the region window/channels/preview, for header menus + * but we stay in the same region if we are already in one + */ ARegion *ar= CTX_wm_region(C); ScrArea *area= CTX_wm_area(C); + int type = RGN_TYPE_WINDOW; - if(!(ar && ar->regiontype == RGN_TYPE_WINDOW) && area) { - ARegion *ar1= area->regionbase.first; - for(; ar1; ar1= ar1->next) - if(ar1->regiontype==RGN_TYPE_WINDOW) - break; + switch (context) { + case WM_OP_EXEC_REGION_CHANNELS: + case WM_OP_INVOKE_REGION_CHANNELS: + type = RGN_TYPE_CHANNELS; + + case WM_OP_EXEC_REGION_PREVIEW: + case WM_OP_INVOKE_REGION_PREVIEW: + type = RGN_TYPE_PREVIEW; + break; + + case WM_OP_EXEC_REGION_WIN: + case WM_OP_INVOKE_REGION_WIN: + default: + type = RGN_TYPE_WINDOW; + break; + } + + if(!(ar && ar->regiontype == type) && area) { + ARegion *ar1= BKE_area_find_region_type(area, type); if(ar1) CTX_wm_region_set(C, ar1); } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 9b0f6823522..e0d4cf13efd 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -43,6 +43,7 @@ #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_screen.h" #include "BKE_utildefines.h" #include "RNA_access.h" @@ -475,16 +476,27 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C, const char *op if(found==NULL) { if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { if(sa) { - if(!(ar && ar->regiontype == RGN_TYPE_WINDOW)) { - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) - break; - } - + if (!(ar && ar->regiontype == RGN_TYPE_WINDOW)) + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if(ar) found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, hotkey, compare_props, keymap_r); } } + else if(ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) { + if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS)) + ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS); + + if(ar) + found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, hotkey, compare_props, keymap_r); + } + else if(ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) { + if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW)) + ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + + if(ar) + found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, hotkey, compare_props, keymap_r); + } else { if(ar) found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, hotkey, compare_props, keymap_r);