Added menu entry for recursive hierarchy selec in outliner
authorGaia Clary <gaia.clary@machinimatrix.org>
Sun, 10 Mar 2013 17:19:03 +0000 (17:19 +0000)
committerGaia Clary <gaia.clary@machinimatrix.org>
Sun, 10 Mar 2013 17:19:03 +0000 (17:19 +0000)
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tools.c

index 63452de..0b71629 100644 (file)
@@ -167,6 +167,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag);
 /* 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 ---------------------------------------------- */
 
index 8b7486a..03fc795 100644 (file)
@@ -837,18 +837,15 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa
        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 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
        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";
index 0f85ed4..7b28064 100644 (file)
@@ -75,6 +75,7 @@
 
 #include "outliner_intern.h"
 
+
 /* ****************************************************** */
 
 /* ************ SELECTION OPERATIONS ********* */
@@ -266,6 +267,17 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te,
        }
 }
 
+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 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
 
 /* **************************************** */
 
+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 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
        
        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 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
                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 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
                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";
        }