Outliner: Added recursive select/deselect (CTRL+LMB) and extend (CTRL+SHIFT+LMB)
[blender.git] / source / blender / editors / space_outliner / outliner_edit.c
index 23766d6..78346dc 100644 (file)
@@ -183,8 +183,8 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
 
 static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports)
 {
-       /* can't rename rna datablocks entries */
-       if (ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
+       /* can't rename rna datablocks entries or listbases */
+       if (ELEM4(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM, TSE_ID_BASE)) {
                /* do nothing */;
        }
        else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE,
@@ -222,12 +222,12 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T
        if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
                TreeStoreElem *tselem = TREESTORE(te);
                
-               /* name and first icon */
-               if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) {
-                       
+               /* click on name */
+               if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) {
                        do_item_rename(ar, te, tselem, reports);
+                       return 1;
                }
-               return 1;
+               return 0;
        }
        
        for (te = te->subtree.first; te; te = te->next) {
@@ -242,14 +242,18 @@ static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *ev
        SpaceOops *soops = CTX_wm_space_outliner(C);
        TreeElement *te;
        float fmval[2];
+       int any_renamed = FALSE;
        
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1);
        
        for (te = soops->tree.first; te; te = te->next) {
-               if (do_outliner_item_rename(C, ar, soops, te, fmval)) break;
+               if (do_outliner_item_rename(C, ar, soops, te, fmval)) {
+                       any_renamed = TRUE;
+                       break;
+               }
        }
        
-       return OPERATOR_FINISHED;
+       return any_renamed ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH;
 }
 
 
@@ -836,6 +840,8 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op)
 
 void OUTLINER_OT_show_one_level(wmOperatorType *ot)
 {
+       PropertyRNA *prop;
+
        /* identifiers */
        ot->name = "Show/Hide One Level";
        ot->idname = "OUTLINER_OT_show_one_level";
@@ -848,7 +854,8 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot)
        /* no undo or registry, UI option */
        
        /* properties */
-       RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep");
+       prop = RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep");
+       RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
 /* Show Hierarchy ----------------------------------------------- */
@@ -887,9 +894,13 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase
                                else tselem->flag |= TSE_CLOSED;
                        }
                }
-               else tselem->flag |= TSE_CLOSED;
-               
-               if (TSELEM_OPEN(tselem, soops)) tree_element_show_hierarchy(scene, soops, &te->subtree);
+               else {
+                       tselem->flag |= TSE_CLOSED;
+               }
+
+               if (TSELEM_OPEN(tselem, soops)) {
+                       tree_element_show_hierarchy(scene, soops, &te->subtree);
+               }
        }
 }
 
@@ -1306,8 +1317,8 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
                                                 * for now, we don't supply one, and just let this use the KeyingSet name */
                                                BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode);
                                                ks->active_path = BLI_countlist(&ks->paths);
+                                               break;
                                        }
-                                       break;
                                        case KEYINGSET_EDITMODE_REMOVE:
                                        {
                                                /* find the relevant path, then remove it from the KeyingSet */
@@ -1319,8 +1330,8 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
 
                                                        ks->active_path = 0;
                                                }
+                                               break;
                                        }
-                                       break;
                                }
                                
                                /* free path, since it had to be generated */
@@ -1429,8 +1440,7 @@ static int parent_drop_exec(bContext *C, wmOperator *op)
 
        ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, FALSE, FALSE);
 
-       DAG_scene_sort(bmain, scene);
-       DAG_ids_flush_update(bmain, 0);
+       DAG_relations_tag_update(bmain);
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
        WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
 
@@ -1519,8 +1529,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
                if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) {
                        if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, FALSE, FALSE)) {
-                               DAG_scene_sort(bmain, scene);
-                               DAG_ids_flush_update(bmain, 0);
+                               DAG_relations_tag_update(bmain);
                                WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
                                WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
                        }
@@ -1634,7 +1643,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot)
        ot->poll = ED_operator_outliner_active;
 
        /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 
        /* properties */
        RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object");
@@ -1703,8 +1712,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
 
        ED_object_parent_clear(ob, RNA_enum_get(op->ptr, "type"));
 
-       DAG_scene_sort(bmain, scene);
-       DAG_ids_flush_update(bmain, 0);
+       DAG_relations_tag_update(bmain);
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
        WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL);
        return OPERATOR_FINISHED;
@@ -1723,7 +1731,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot)
        ot->poll = ED_operator_outliner_active;
 
        /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 
        /* properties */
        RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object");
@@ -1792,8 +1800,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        ED_base_object_select(base, BA_SELECT);
                }
 
-               DAG_scene_sort(bmain, scene);
-               DAG_ids_flush_update(bmain, 0);
+               DAG_relations_tag_update(bmain);
 
                WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
 
@@ -1816,7 +1823,7 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot)
        ot->poll = ED_operator_outliner_active;
 
        /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 
        /* properties */
        RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object");
@@ -1825,7 +1832,6 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot)
 
 static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       Main *bmain = CTX_data_main(C);
        Material *ma = NULL;
        Object *ob = NULL;
        SpaceOops *soops = CTX_wm_space_outliner(C);
@@ -1857,9 +1863,8 @@ static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
                assign_material(ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF);
 
-               DAG_ids_flush_update(bmain, 0);
                WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
-               WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, ma);
+               WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
 
                return OPERATOR_FINISHED;
        }
@@ -1880,7 +1885,7 @@ void OUTLINER_OT_material_drop(wmOperatorType *ot)
        ot->poll = ED_operator_outliner_active;
 
        /* flags */
-       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 
        /* properties */
        RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object");