[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55170] trunk/blender/source/blender/ editors/space_outliner: Added menu entry for recursive hierarchy selec in outliner

Gaia Clary gaia.clary at machinimatrix.org
Sun Mar 10 18:19:03 CET 2013


Revision: 55170
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55170
Author:   gaiaclary
Date:     2013-03-10 17:19:03 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Added menu entry for recursive hierarchy selec in outliner

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
    trunk/blender/source/blender/editors/space_outliner/outliner_select.c
    trunk/blender/source/blender/editors/space_outliner/outliner_tools.c

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_intern.h	2013-03-10 16:55:01 UTC (rev 55169)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_intern.h	2013-03-10 17:19:03 UTC (rev 55170)
@@ -167,6 +167,7 @@
 /* outliner_select.c -------------------------------------------- */
 int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set);
 int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soops, TreeElement *te, int set);
+int outliner_item_do_activate(struct bContext *C, int x, int y, bool extend, bool recursive);
 
 /* outliner_edit.c ---------------------------------------------- */
 

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_select.c	2013-03-10 16:55:01 UTC (rev 55169)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_select.c	2013-03-10 17:19:03 UTC (rev 55170)
@@ -837,18 +837,15 @@
 	return 0;
 }
 
-/* event can enterkey, then it opens/closes */
-static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
+int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recursive)
 {
 	Scene *scene = CTX_data_scene(C);
 	ARegion *ar = CTX_wm_region(C);
 	SpaceOops *soops = CTX_wm_space_outliner(C);
 	TreeElement *te;
 	float fmval[2];
-	bool extend    = RNA_boolean_get(op->ptr, "extend");
-	bool recursive = RNA_boolean_get(op->ptr, "recursive");
 
-	UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1);
+	UI_view2d_region_to_view(&ar->v2d, x, y, fmval, fmval + 1);
 
 	if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) &&
 	    !(soops->flag & SO_HIDE_RESTRICTCOLS) &&
@@ -888,6 +885,16 @@
 	return OPERATOR_FINISHED;
 }
 
+/* event can enterkey, then it opens/closes */
+static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
+{
+	bool extend    = RNA_boolean_get(op->ptr, "extend");
+	bool recursive = RNA_boolean_get(op->ptr, "recursive");
+	int x = event->mval[0];
+	int y = event->mval[1];
+	return outliner_item_do_activate(C, x, y, extend, recursive);
+}
+
 void OUTLINER_OT_item_activate(wmOperatorType *ot)
 {
 	ot->name = "Activate Item";

Modified: trunk/blender/source/blender/editors/space_outliner/outliner_tools.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_tools.c	2013-03-10 16:55:01 UTC (rev 55169)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_tools.c	2013-03-10 17:19:03 UTC (rev 55170)
@@ -75,6 +75,7 @@
 
 #include "outliner_intern.h"
 
+
 /* ****************************************************** */
 
 /* ************ SELECTION OPERATIONS ********* */
@@ -266,6 +267,17 @@
 	}
 }
 
+static void object_select_hierarchy_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
+                             TreeStoreElem *UNUSED(tsep), TreeStoreElem *UNUSED(tselem))
+{
+	/* From where do i get the x,y coordinate of the mouse event ? */
+	wmWindow *win = CTX_wm_window(C);
+	int x = win->eventstate->mval[0];
+	int y = win->eventstate->mval[1];
+	outliner_item_do_activate(C, x, y, true, true);
+}
+
+
 static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
                                TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
@@ -571,15 +583,29 @@
 
 /* **************************************** */
 
+enum {
+	OL_OP_ENDMARKER =0,
+	OL_OP_SELECT,
+	OL_OP_DESELECT,
+	OL_OP_SELECT_HIERARCHY,
+	OL_OP_DELETE,
+	OL_OP_LOCALIZED,  /* disabled, see below */
+	OL_OP_TOGVIS,
+	OL_OP_TOGSEL,
+	OL_OP_TOGREN,
+	OL_OP_RENAME
+};
+
 static EnumPropertyItem prop_object_op_types[] = {
-	{1, "SELECT", 0, "Select", ""},
-	{2, "DESELECT", 0, "Deselect", ""},
-	{4, "DELETE", 0, "Delete", ""},
-	{6, "TOGVIS", 0, "Toggle Visible", ""},
-	{7, "TOGSEL", 0, "Toggle Selectable", ""},
-	{8, "TOGREN", 0, "Toggle Renderable", ""},
-	{9, "RENAME", 0, "Rename", ""},
-	{0, NULL, 0, NULL, NULL}
+	{OL_OP_SELECT, "SELECT", 0, "Select", ""},
+	{OL_OP_DESELECT, "DESELECT", 0, "Deselect", ""},
+	{OL_OP_SELECT_HIERARCHY, "SELECT_HIERARCHY", 0, "Select Hierarchy", ""},
+	{OL_OP_DELETE, "DELETE", 0, "Delete", ""},
+	{OL_OP_TOGVIS, "TOGVIS", 0, "Toggle Visible", ""},
+	{OL_OP_TOGSEL, "TOGSEL", 0, "Toggle Selectable", ""},
+	{OL_OP_TOGREN, "TOGREN", 0, "Toggle Renderable", ""},
+	{OL_OP_RENAME, "RENAME", 0, "Rename", ""},
+	{OL_OP_ENDMARKER, NULL, 0, NULL, NULL}
 };
 
 static int outliner_object_operation_exec(bContext *C, wmOperator *op)
@@ -596,7 +622,7 @@
 	
 	event = RNA_enum_get(op->ptr, "type");
 
-	if (event == 1) {
+	if (event == OL_OP_SELECT) {
 		Scene *sce = scene;  // to be able to delete, scenes are set...
 		outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb);
 		if (scene != sce) {
@@ -606,12 +632,21 @@
 		str = "Select Objects";
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 	}
-	else if (event == 2) {
+	else if (event == OL_OP_SELECT_HIERARCHY) {
+		Scene *sce = scene;  // to be able to delete, scenes are set...
+		outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_hierarchy_cb);
+		if (scene != sce) {
+			ED_screen_set_scene(C, CTX_wm_screen(C), sce);
+		}	
+		str = "Select Object Hierarchy";
+		WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+	}
+	else if (event == OL_OP_DESELECT) {
 		outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb);
 		str = "Deselect Objects";
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 	}
-	else if (event == 4) {
+	else if (event == OL_OP_DELETE) {
 		outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb);
 
 		/* XXX: tree management normally happens from draw_outliner(), but when
@@ -625,26 +660,26 @@
 		str = "Delete Objects";
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
 	}
-	else if (event == 5) {    /* disabled, see above enum (ton) */
+	else if (event == OL_OP_LOCALIZED) {    /* disabled, see above enum (ton) */
 		outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb);
 		str = "Localized Objects";
 	}
-	else if (event == 6) {
+	else if (event == OL_OP_TOGVIS) {
 		outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb);
 		str = "Toggle Visibility";
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
 	}
-	else if (event == 7) {
+	else if (event == OL_OP_TOGSEL) {
 		outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb);
 		str = "Toggle Selectability";
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 	}
-	else if (event == 8) {
+	else if (event == OL_OP_TOGREN) {
 		outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb);
 		str = "Toggle Renderability";
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene);
 	}
-	else if (event == 9) {
+	else if (event == OL_OP_RENAME) {
 		outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb);
 		str = "Rename Object";
 	}




More information about the Bf-blender-cvs mailing list