[Bf-blender-cvs] [571e773fbe3] blender2.8: Keymap: outliner now uses A/Alt-A for selection

Campbell Barton noreply at git.blender.org
Fri Jul 6 14:46:18 CEST 2018


Commit: 571e773fbe38b2cc1a6af43e8ed55574d2caadb4
Author: Campbell Barton
Date:   Fri Jul 6 14:45:30 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB571e773fbe38b2cc1a6af43e8ed55574d2caadb4

Keymap: outliner now uses A/Alt-A for selection

===================================================================

M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_ops.c

===================================================================

diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index d8a5ba533c4..d9bcf05fa29 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -880,6 +880,21 @@ bool outliner_flag_set(ListBase *lb, short flag, short set)
 	return changed;
 }
 
+bool outliner_flag_flip(ListBase *lb, short flag)
+{
+	TreeElement *te;
+	TreeStoreElem *tselem;
+	bool changed = false;
+
+	for (te = lb->first; te; te = te->next) {
+		tselem = TREESTORE(te);
+		tselem->flag ^= flag;
+		changed |= outliner_flag_flip(&te->subtree, flag);
+	}
+
+	return changed;
+}
+
 /* Restriction Columns ------------------------------- */
 
 /* same check needed for both object operation and restrict column button func
@@ -940,16 +955,27 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
 
 /* Toggle Selected (Outliner) ---------------------------------------- */
 
-static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
+static int outliner_select_all_exec(bContext *C, wmOperator *op)
 {
 	SpaceOops *soops = CTX_wm_space_outliner(C);
 	ARegion *ar = CTX_wm_region(C);
 	Scene *scene = CTX_data_scene(C);
+	int action = RNA_enum_get(op->ptr, "action");
+	if (action == SEL_TOGGLE) {
+		action = outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1) ? SEL_DESELECT : SEL_SELECT;
+	}
 
-	if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1))
-		outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
-	else
-		outliner_flag_set(&soops->tree, TSE_SELECTED, 1);
+	switch (action) {
+		case SEL_SELECT:
+			outliner_flag_set(&soops->tree, TSE_SELECTED, 1);
+			break;
+		case SEL_DESELECT:
+			outliner_flag_set(&soops->tree, TSE_SELECTED, 0);
+			break;
+		case SEL_INVERT:
+			outliner_flag_flip(&soops->tree, TSE_SELECTED);
+			break;
+	}
 
 	DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
 	WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
@@ -958,18 +984,21 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op))
 	return OPERATOR_FINISHED;
 }
 
-void OUTLINER_OT_selected_toggle(wmOperatorType *ot)
+void OUTLINER_OT_select_all(wmOperatorType *ot)
 {
 	/* identifiers */
 	ot->name = "Toggle Selected";
-	ot->idname = "OUTLINER_OT_selected_toggle";
+	ot->idname = "OUTLINER_OT_select_all";
 	ot->description = "Toggle the Outliner selection of items";
 
 	/* callbacks */
-	ot->exec = outliner_toggle_selected_exec;
+	ot->exec = outliner_select_all_exec;
 	ot->poll = ED_operator_outliner_active;
 
-	/* no undo or registry, UI option */
+	/* no undo or registry */
+
+	/* rna */
+	WM_operator_properties_select_all(ot);
 }
 
 /* ************************************************************** */
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 0763933b102..093ad9361c2 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -247,6 +247,7 @@ int common_restrict_check(struct bContext *C, struct Object *ob);
 
 int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel);
 bool outliner_flag_set(ListBase *lb, short flag, short set);
+bool outliner_flag_flip(ListBase *lb, short flag);
 
 void object_toggle_visibility_cb(
         struct bContext *C, struct ReportList *reports, struct Scene *scene,
@@ -305,7 +306,7 @@ void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
 
 void OUTLINER_OT_select_border(struct wmOperatorType *ot);
 
-void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot);
+void OUTLINER_OT_select_all(struct wmOperatorType *ot);
 void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
 
 void OUTLINER_OT_scroll_page(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 760e2853038..0dd492839c9 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -431,7 +431,7 @@ void outliner_operatortypes(void)
 	WM_operatortype_append(OUTLINER_OT_show_hierarchy);
 	WM_operatortype_append(OUTLINER_OT_scroll_page);
 
-	WM_operatortype_append(OUTLINER_OT_selected_toggle);
+	WM_operatortype_append(OUTLINER_OT_select_all);
 	WM_operatortype_append(OUTLINER_OT_expanded_toggle);
 
 	WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
@@ -542,7 +542,13 @@ void outliner_keymap(wmKeyConfig *keyconf)
 	kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0);
 	RNA_boolean_set(kmi->ptr, "open", false); /* close */
 
-	WM_keymap_add_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0);
+	kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, 0, 0);
+	RNA_enum_set(kmi->ptr, "action", SEL_SELECT);
+	kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", AKEY, KM_PRESS, KM_ALT, 0);
+	RNA_enum_set(kmi->ptr, "action", SEL_DESELECT);
+	kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+	RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
+
 	WM_keymap_add_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0);
 
 	/* keying sets - only for databrowse */



More information about the Bf-blender-cvs mailing list