From 48d7cf680ebe8ea7c09ef3e0e4abd1dc93d3fa5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jul 2018 15:44:56 +0200 Subject: Keymap: Select/De-Select support for anim-editors Also update menu items, adding select/de-select. --- .../startup/bl_ui/properties_mask_common.py | 8 +- release/scripts/startup/bl_ui/space_dopesheet.py | 6 +- release/scripts/startup/bl_ui/space_graph.py | 7 +- release/scripts/startup/bl_ui/space_image.py | 15 +-- release/scripts/startup/bl_ui/space_nla.py | 6 +- release/scripts/startup/bl_ui/space_sequencer.py | 8 +- release/scripts/startup/bl_ui/space_view3d.py | 115 +++++++++++++-------- .../blender/editors/animation/anim_channels_edit.c | 40 +++++-- .../blender/editors/space_action/action_intern.h | 2 +- source/blender/editors/space_action/action_ops.c | 12 ++- .../blender/editors/space_action/action_select.c | 31 ++++-- source/blender/editors/space_file/file_intern.h | 2 +- source/blender/editors/space_file/file_ops.c | 4 +- source/blender/editors/space_file/space_file.c | 4 +- source/blender/editors/space_graph/graph_intern.h | 2 +- source/blender/editors/space_graph/graph_ops.c | 12 ++- source/blender/editors/space_graph/graph_select.c | 30 ++++-- source/blender/editors/space_nla/nla_intern.h | 2 +- source/blender/editors/space_nla/nla_ops.c | 14 +-- source/blender/editors/space_nla/nla_select.c | 31 ++++-- 20 files changed, 226 insertions(+), 125 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py index 450ca80bbc2..c766c8dedbc 100644 --- a/release/scripts/startup/bl_ui/properties_mask_common.py +++ b/release/scripts/startup/bl_ui/properties_mask_common.py @@ -378,6 +378,12 @@ class MASK_MT_select(Menu): def draw(self, context): layout = self.layout + layout.operator("mask.select_all", text="All").action = 'SELECT' + layout.operator("mask.select_all", text="None").action = 'DESELECT' + layout.operator("mask.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("mask.select_border") layout.operator("mask.select_circle") @@ -388,8 +394,6 @@ class MASK_MT_select(Menu): layout.separator() - layout.operator("mask.select_all").action = 'TOGGLE' - layout.operator("mask.select_all", text="Inverse").action = 'INVERT' layout.operator("mask.select_linked", text="Select Linked") diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index aeda521ba04..93fbc7799bf 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -358,9 +358,9 @@ class DOPESHEET_MT_select(Menu): def draw(self, context): layout = self.layout - # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None - layout.operator("action.select_all_toggle").invert = False - layout.operator("action.select_all_toggle", text="Invert Selection").invert = True + layout.operator("action.select_all", text="All").action = 'SELECT' + layout.operator("action.select_all", text="None").action = 'DESELECT' + layout.operator("action.select_all", text="Invert").action = 'INVERT' layout.separator() layout.operator("action.select_border").axis_range = False diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index 0a6077e6b57..de5dcdbc36d 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -165,11 +165,12 @@ class GRAPH_MT_select(Menu): def draw(self, context): layout = self.layout - # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None - layout.operator("graph.select_all_toggle").invert = False - layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True + layout.operator("graph.select_all", text="All").action = 'SELECT' + layout.operator("graph.select_all", text="None").action = 'DESELECT' + layout.operator("graph.select_all", text="Invert").action = 'INVERT' layout.separator() + props = layout.operator("graph.select_border") props.axis_range = False props.include_handles = False diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index ba63b2b216e..e20c3ccd7f5 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -139,14 +139,20 @@ class IMAGE_MT_select(Menu): def draw(self, context): layout = self.layout + layout.operator("uv.select_all", text="All").action = 'SELECT' + layout.operator("uv.select_all", text="None").action = 'DESELECT' + layout.operator("uv.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("uv.select_border").pinned = False layout.operator("uv.select_border", text="Border Select Pinned").pinned = True layout.operator("uv.circle_select") layout.separator() - layout.operator("uv.select_all").action = 'TOGGLE' - layout.operator("uv.select_all", text="Inverse").action = 'INVERT' + layout.operator("uv.select_less", text="Less") + layout.operator("uv.select_more", text="More") layout.separator() @@ -155,11 +161,6 @@ class IMAGE_MT_select(Menu): layout.separator() - layout.operator("uv.select_less", text="Less") - layout.operator("uv.select_more", text="More") - - layout.separator() - layout.operator("uv.select_split") diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 304fc799fea..4bf338b89d6 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -126,9 +126,9 @@ class NLA_MT_select(Menu): def draw(self, context): layout = self.layout - # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None - layout.operator("nla.select_all_toggle").invert = False - layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True + layout.operator("nla.select_all", text="All").action = 'SELECT' + layout.operator("nla.select_all", text="None").action = 'DESELECT' + layout.operator("nla.select_all", text="Invert").action = 'INVERT' layout.separator() layout.operator("nla.select_border").axis_range = False diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index dc966850b69..0bdfcc39ed9 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -249,6 +249,12 @@ class SEQUENCER_MT_select(Menu): def draw(self, context): layout = self.layout + layout.operator("sequencer.select_all", text="All").action = 'SELECT' + layout.operator("sequencer.select_all", text="None").action = 'DESELECT' + layout.operator("sequencer.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("sequencer.select_active_side", text="Strips to the Left").side = 'LEFT' layout.operator("sequencer.select_active_side", text="Strips to the Right").side = 'RIGHT' props = layout.operator("sequencer.select", text="All Strips to the Left") @@ -267,8 +273,6 @@ class SEQUENCER_MT_select(Menu): layout.operator("sequencer.select_linked") layout.operator("sequencer.select_less") layout.operator("sequencer.select_more") - layout.operator("sequencer.select_all").action = 'TOGGLE' - layout.operator("sequencer.select_all", text="Inverse").action = 'INVERT' class SEQUENCER_MT_marker(Menu): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 672a5d081bf..f5d451a1189 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -739,15 +739,19 @@ class VIEW3D_MT_select_object(Menu): def draw(self, context): layout = self.layout + layout.operator("object.select_all", text="All").action = 'SELECT' + layout.operator("object.select_all", text="None").action = 'DESELECT' + layout.operator("object.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("object.select_all", text="Select/Deselect All").action = 'TOGGLE' layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...") layout.operator("object.select_camera", text="Select Active Camera") - layout.operator("object.select_all", text="Inverse Selection").action = 'INVERT' layout.operator("object.select_mirror", text="Mirror Selection") layout.operator("object.select_random", text="Select Random") @@ -795,13 +799,17 @@ class VIEW3D_MT_select_pose(Menu): def draw(self, context): layout = self.layout + layout.operator("pose.select_all", text="All").action = 'SELECT' + layout.operator("pose.select_all", text="None").action = 'DESELECT' + layout.operator("pose.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("pose.select_all").action = 'TOGGLE' - layout.operator("pose.select_all", text="Inverse").action = 'INVERT' layout.operator("pose.select_mirror", text="Flip Active") layout.separator() @@ -825,14 +833,18 @@ class VIEW3D_MT_select_particle(Menu): def draw(self, context): layout = self.layout + layout.operator("particle.select_all", text="All").action = 'SELECT' + layout.operator("particle.select_all", text="None").action = 'DESELECT' + layout.operator("particle.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("particle.select_all").action = 'TOGGLE' layout.operator("particle.select_linked") - layout.operator("particle.select_all", text="Inverse").action = 'INVERT' layout.separator() @@ -926,14 +938,15 @@ class VIEW3D_MT_select_edit_mesh(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + # primitive + layout.operator("mesh.select_all", text="All").action = 'SELECT' + layout.operator("mesh.select_all", text="None").action = 'DESELECT' + layout.operator("mesh.select_all", text="Invert").action = 'INVERT' layout.separator() - # primitive - layout.operator("mesh.select_all", text="Select/Deselect All").action = 'TOGGLE' - layout.operator("mesh.select_all", text="Inverse Selection").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -979,13 +992,14 @@ class VIEW3D_MT_select_edit_curve(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("curve.select_all", text="All").action = 'SELECT' + layout.operator("curve.select_all", text="None").action = 'DESELECT' + layout.operator("curve.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("curve.select_all").action = 'TOGGLE' - layout.operator("curve.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1013,13 +1027,14 @@ class VIEW3D_MT_select_edit_surface(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("curve.select_all", text="All").action = 'SELECT' + layout.operator("curve.select_all", text="None").action = 'DESELECT' + layout.operator("curve.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("curve.select_all").action = 'TOGGLE' - layout.operator("curve.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1065,13 +1080,14 @@ class VIEW3D_MT_select_edit_metaball(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("mball.select_all", text="All").action = 'SELECT' + layout.operator("mball.select_all", text="None").action = 'DESELECT' + layout.operator("mball.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("mball.select_all").action = 'TOGGLE' - layout.operator("mball.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1088,13 +1104,14 @@ class VIEW3D_MT_select_edit_lattice(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("lattice.select_all", text="All").action = 'SELECT' + layout.operator("lattice.select_all", text="None").action = 'DESELECT' + layout.operator("lattice.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("lattice.select_all").action = 'TOGGLE' - layout.operator("lattice.select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1112,13 +1129,17 @@ class VIEW3D_MT_select_edit_armature(Menu): def draw(self, context): layout = self.layout + layout.operator("armature.select_all", text="All").action = 'SELECT' + layout.operator("armature.select_all", text="None").action = 'DESELECT' + layout.operator("armature.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("view3d.select_border") layout.operator("view3d.select_circle") layout.separator() - layout.operator("armature.select_all").action = 'TOGGLE' - layout.operator("armature.select_all", text="Inverse").action = 'INVERT' layout.operator("armature.select_mirror", text="Mirror").extend = False layout.separator() @@ -1156,13 +1177,14 @@ class VIEW3D_MT_select_gpencil(Menu): def draw(self, context): layout = self.layout - layout.operator("gpencil.select_border") - layout.operator("gpencil.select_circle") + layout.operator("gpencil.select_all", text="All").action = 'SELECT' + layout.operator("gpencil.select_all", text="None").action = 'DESELECT' + layout.operator("gpencil.select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("gpencil.select_all", text="(De)select All").action = 'TOGGLE' - layout.operator("gpencil.select_all", text="Inverse").action = 'INVERT' + layout.operator("gpencil.select_border") + layout.operator("gpencil.select_circle") layout.separator() @@ -1186,13 +1208,14 @@ class VIEW3D_MT_select_paint_mask(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("paint.face_select_all", text="All").action = 'SELECT' + layout.operator("paint.face_select_all", text="None").action = 'DESELECT' + layout.operator("paint.face_select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("paint.face_select_all").action = 'TOGGLE' - layout.operator("paint.face_select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -1205,13 +1228,14 @@ class VIEW3D_MT_select_paint_mask_vertex(Menu): def draw(self, context): layout = self.layout - layout.operator("view3d.select_border") - layout.operator("view3d.select_circle") + layout.operator("paint.vert_select_all", text="All").action = 'SELECT' + layout.operator("paint.vert_select_all", text="None").action = 'DESELECT' + layout.operator("paint.vert_select_all", text="Invert").action = 'INVERT' layout.separator() - layout.operator("paint.vert_select_all").action = 'TOGGLE' - layout.operator("paint.vert_select_all", text="Inverse").action = 'INVERT' + layout.operator("view3d.select_border") + layout.operator("view3d.select_circle") layout.separator() @@ -2278,6 +2302,13 @@ class VIEW3D_MT_particle_specials(Menu): if particle_edit.select_mode == 'POINT': layout.separator() + + layout.operator("particle.select_all", text="All").action = 'SELECT' + layout.operator("particle.select_all", text="None").action = 'DESELECT' + layout.operator("particle.select_all", text="Invert").action = 'INVERT' + + layout.separator() + layout.operator("particle.select_roots") layout.operator("particle.select_tips") @@ -2292,9 +2323,7 @@ class VIEW3D_MT_particle_specials(Menu): layout.separator() - layout.operator("particle.select_all").action = 'TOGGLE' layout.operator("particle.select_linked") - layout.operator("particle.select_all", text="Inverse").action = 'INVERT' class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu): diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index f629c20b04a..f11c850a12b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2339,10 +2339,24 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT); - else - ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD); + break; + case SEL_SELECT: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_ADD); + break; + case SEL_DESELECT: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_CLEAR); + break; + case SEL_INVERT: + ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT); + break; + default: + BLI_assert(0); + break; + } /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); @@ -2350,11 +2364,11 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) +static void ANIM_OT_channels_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; - ot->idname = "ANIM_OT_channels_select_all_toggle"; + ot->idname = "ANIM_OT_channels_select_all"; ot->description = "Toggle selection of all animation channels"; /* api callbacks */ @@ -2364,8 +2378,8 @@ static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", ""); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Borderselect Operator *********************** */ @@ -3146,7 +3160,7 @@ static void ANIM_OT_channel_select_keys(wmOperatorType *ot) void ED_operatortypes_animchannels(void) { - WM_operatortype_append(ANIM_OT_channels_select_all_toggle); + WM_operatortype_append(ANIM_OT_channels_select_all); WM_operatortype_append(ANIM_OT_channels_select_border); WM_operatortype_append(ANIM_OT_channels_click); @@ -3199,8 +3213,12 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); /* deselect all */ - WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index fc1f40cdb5a..bb8de677b57 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -62,7 +62,7 @@ void timeline_draw_cache(struct SpaceAction *saction, struct Object *ob, struct /* ***************************************** */ /* action_select.c */ -void ACTION_OT_select_all_toggle(struct wmOperatorType *ot); +void ACTION_OT_select_all(struct wmOperatorType *ot); void ACTION_OT_select_border(struct wmOperatorType *ot); void ACTION_OT_select_lasso(struct wmOperatorType *ot); void ACTION_OT_select_circle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index bf7f75db95c..2f2e8c6f49f 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -57,7 +57,7 @@ void action_operatortypes(void) /* keyframes */ /* selection */ WM_operatortype_append(ACTION_OT_clickselect); - WM_operatortype_append(ACTION_OT_select_all_toggle); + WM_operatortype_append(ACTION_OT_select_all); WM_operatortype_append(ACTION_OT_select_border); WM_operatortype_append(ACTION_OT_select_lasso); WM_operatortype_append(ACTION_OT_select_circle); @@ -169,10 +169,12 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); /* deselect all */ - kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", false); - kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 11145e29627..b6431596323 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -157,10 +157,24 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - deselect_action_keys(&ac, 0, SELECT_INVERT); - else - deselect_action_keys(&ac, 1, SELECT_ADD); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + deselect_action_keys(&ac, 1, SELECT_ADD); + break; + case SEL_SELECT: + deselect_action_keys(&ac, 0, SELECT_ADD); + break; + case SEL_DESELECT: + deselect_action_keys(&ac, 0, SELECT_SUBTRACT); + break; + case SEL_INVERT: + deselect_action_keys(&ac, 0, SELECT_INVERT); + break; + default: + BLI_assert(0); + break; + } /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); @@ -168,11 +182,11 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void ACTION_OT_select_all_toggle(wmOperatorType *ot) +void ACTION_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; - ot->idname = "ACTION_OT_select_all_toggle"; + ot->idname = "ACTION_OT_select_all"; ot->description = "Toggle selection of all keyframes"; /* api callbacks */ @@ -182,9 +196,8 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); - RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Border Select Operator **************************** */ diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 6eaf2dda084..48acbdb137d 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -72,7 +72,7 @@ typedef enum WalkSelectDirection { void FILE_OT_highlight(struct wmOperatorType *ot); void FILE_OT_select(struct wmOperatorType *ot); void FILE_OT_select_walk(struct wmOperatorType *ot); -void FILE_OT_select_all_toggle(struct wmOperatorType *ot); +void FILE_OT_select_all(struct wmOperatorType *ot); void FILE_OT_select_border(struct wmOperatorType *ot); void FILE_OT_select_bookmark(struct wmOperatorType *ot); void FILE_OT_bookmark_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7c080044aee..b19b2ff6cd5 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -808,12 +808,12 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void FILE_OT_select_all_toggle(wmOperatorType *ot) +void FILE_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All Files"; ot->description = "Select or deselect all files"; - ot->idname = "FILE_OT_select_all_toggle"; + ot->idname = "FILE_OT_select_all"; /* api callbacks */ ot->exec = file_select_all_exec; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 853d31edebf..0e39ea725ae 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -462,7 +462,7 @@ static void file_operatortypes(void) { WM_operatortype_append(FILE_OT_select); WM_operatortype_append(FILE_OT_select_walk); - WM_operatortype_append(FILE_OT_select_all_toggle); + WM_operatortype_append(FILE_OT_select_all); WM_operatortype_append(FILE_OT_select_border); WM_operatortype_append(FILE_OT_select_bookmark); WM_operatortype_append(FILE_OT_highlight); @@ -588,7 +588,7 @@ static void file_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "FILE_OT_previous", BUTTON4MOUSE, KM_CLICK, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_next", BUTTON5MOUSE, KM_CLICK, 0, 0); - WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "FILE_OT_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index c50e0497519..398561927dd 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -58,7 +58,7 @@ void graph_draw_ghost_curves(struct bAnimContext *ac, struct SpaceIpo *sipo, str void deselect_graph_keys(struct bAnimContext *ac, bool test, short sel, bool do_channels); -void GRAPH_OT_select_all_toggle(struct wmOperatorType *ot); +void GRAPH_OT_select_all(struct wmOperatorType *ot); void GRAPH_OT_select_border(struct wmOperatorType *ot); void GRAPH_OT_select_lasso(struct wmOperatorType *ot); void GRAPH_OT_select_circle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 8ac2c61b8e9..5e269a9c99d 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -427,7 +427,7 @@ void graphedit_operatortypes(void) /* keyframes */ /* selection */ WM_operatortype_append(GRAPH_OT_clickselect); - WM_operatortype_append(GRAPH_OT_select_all_toggle); + WM_operatortype_append(GRAPH_OT_select_all); WM_operatortype_append(GRAPH_OT_select_border); WM_operatortype_append(GRAPH_OT_select_lasso); WM_operatortype_append(GRAPH_OT_select_circle); @@ -550,10 +550,12 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); /* deselect all */ - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", false); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 9a6b733a5ff..e91bb192d3c 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -162,10 +162,24 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) ale_active = get_active_fcurve_channel(&ac); /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - deselect_graph_keys(&ac, 0, SELECT_INVERT, true); - else - deselect_graph_keys(&ac, 1, SELECT_ADD, true); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + deselect_graph_keys(&ac, 1, SELECT_ADD, true); + break; + case SEL_SELECT: + deselect_graph_keys(&ac, 0, SELECT_ADD, true); + break; + case SEL_DESELECT: + deselect_graph_keys(&ac, 0, SELECT_SUBTRACT, true); + break; + case SEL_INVERT: + deselect_graph_keys(&ac, 0, SELECT_INVERT, true); + break; + default: + BLI_assert(0); + break; + } /* restore active F-Curve... */ if (ale_active) { @@ -186,11 +200,11 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void GRAPH_OT_select_all_toggle(wmOperatorType *ot) +void GRAPH_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; - ot->idname = "GRAPH_OT_select_all_toggle"; + ot->idname = "GRAPH_OT_select_all"; ot->description = "Toggle selection of all keyframes"; /* api callbacks */ @@ -200,8 +214,8 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Border Select Operator **************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index a00e71a192d..e59395cac6b 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -65,7 +65,7 @@ enum eNlaEdit_LeftRightSelect_Mode { /* --- */ -void NLA_OT_select_all_toggle(wmOperatorType *ot); +void NLA_OT_select_all(wmOperatorType *ot); void NLA_OT_select_border(wmOperatorType *ot); void NLA_OT_select_leftright(wmOperatorType *ot); void NLA_OT_click_select(wmOperatorType *ot); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 5bfd73b8163..c5dd85b7c4d 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -124,7 +124,7 @@ void nla_operatortypes(void) /* select */ WM_operatortype_append(NLA_OT_click_select); WM_operatortype_append(NLA_OT_select_border); - WM_operatortype_append(NLA_OT_select_all_toggle); + WM_operatortype_append(NLA_OT_select_all); WM_operatortype_append(NLA_OT_select_leftright); /* view */ @@ -223,13 +223,13 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); - /* deselect all */ - /* TODO: uniformize with other select_all ops? */ - kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", false); - kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", true); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", AKEY, KM_PRESS, 0, 0); + RNA_enum_set(kmi->ptr, "action", SEL_SELECT); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "action", SEL_DESELECT); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); /* borderselect */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index f22c211af64..5d32b23ad67 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -167,10 +167,24 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* 'standard' behavior - check if selected, then apply relevant selection */ - if (RNA_boolean_get(op->ptr, "invert")) - deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT); - else - deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); + const int action = RNA_enum_get(op->ptr, "action"); + switch (action) { + case SEL_TOGGLE: + deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); + break; + case SEL_SELECT: + deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_ADD); + break; + case SEL_DESELECT: + deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_SUBTRACT); + break; + case SEL_INVERT: + deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT); + break; + default: + BLI_assert(0); + break; + } /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); @@ -178,11 +192,11 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void NLA_OT_select_all_toggle(wmOperatorType *ot) +void NLA_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All"; - ot->idname = "NLA_OT_select_all_toggle"; + ot->idname = "NLA_OT_select_all"; ot->description = "Select or deselect all NLA-Strips"; /* api callbacks */ @@ -192,9 +206,8 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; - /* props */ - ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); - RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); + /* properties */ + WM_operator_properties_select_all(ot); } /* ******************** Border Select Operator **************************** */ -- cgit v1.2.3