2.5 Outliner - Restored all the 'toggle' operators
authorJoshua Leung <aligorith@gmail.com>
Tue, 14 Jul 2009 12:23:08 +0000 (12:23 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 14 Jul 2009 12:23:08 +0000 (12:23 +0000)
* AKEY - Toggle Outliner Selection (*1)
* Shift-AKEY - Expand/Collapse All
* RKEY - Toggle Renderability
* SKEY - Toggle Selectability
* VKEY - Toggle Visiblity

(*1) - The keymap-order of these has been swapped from the ones used in 2.4x. The old keys used here were inconsistent with the rest of Blender (at least I found myself always getting annoyed that I'd accidentally collapsed/expanded all items by hitting AKEY many times).

source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_ops.c

index b6d1f31dd5c63159ac1aa86457d33c09c5d99ba1..e99774a8b9f910d403ba8866afd5eec02caa997a 100644 (file)
@@ -98,6 +98,7 @@
 #include "UI_view2d.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
 
 #include "ED_armature.h"
 #include "ED_keyframing.h"
@@ -1445,6 +1446,8 @@ static void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short
        }
 }
 
+/* --- */
+
 void object_toggle_visibility_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        Scene *scene= NULL;             // XXX
@@ -1456,15 +1459,36 @@ void object_toggle_visibility_cb(TreeElement *te, TreeStoreElem *tsep, TreeStore
        }
 }
 
-void outliner_toggle_visibility(Scene *scene, SpaceOops *soops)
+static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op)
 {
-
+       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       Scene *scene= CTX_data_scene(C);
+       ARegion *ar= CTX_wm_region(C);
+       
        outliner_do_object_operation(scene, soops, &soops->tree, object_toggle_visibility_cb);
        
-       BIF_undo_push("Outliner toggle selectability");
+       // XXX need proper notifiers here instead
+       ED_region_tag_redraw(ar);
+       
+       return OPERATOR_FINISHED;
+}
 
+void OUTLINER_OT_visibility_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Toggle Visability";
+       ot->idname= "OUTLINER_OT_visibility_toggle";
+       ot->description= "Toggle the visibility of selected items.";
+       
+       /* callbacks */
+       ot->exec= outliner_toggle_visibility_exec;
+       ot->poll= ED_operator_outliner_active;
+       
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/* --- */
+
 static void object_toggle_selectability_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        Scene *scene= NULL; // XXX
@@ -1476,15 +1500,36 @@ static void object_toggle_selectability_cb(TreeElement *te, TreeStoreElem *tsep,
        }
 }
 
-void outliner_toggle_selectability(Scene *scene, SpaceOops *soops)
+static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op)
 {
+       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       Scene *scene= CTX_data_scene(C);
+       ARegion *ar= CTX_wm_region(C);
        
        outliner_do_object_operation(scene, soops, &soops->tree, object_toggle_selectability_cb);
        
-       BIF_undo_push("Outliner toggle selectability");
+       // XXX need proper notifiers here instead
+       ED_region_tag_redraw(ar);
+       
+       return OPERATOR_FINISHED;
+}
 
+void OUTLINER_OT_selectability_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Toggle Selectability";
+       ot->idname= "OUTLINER_OT_selectability_toggle";
+       ot->description= "Toggle the selectability";
+       
+       /* callbacks */
+       ot->exec= outliner_toggle_selectability_exec;
+       ot->poll= ED_operator_outliner_active;
+       
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/* --- */
+
 void object_toggle_renderability_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
 {
        Scene *scene= NULL;     // XXX
@@ -1496,38 +1541,102 @@ void object_toggle_renderability_cb(TreeElement *te, TreeStoreElem *tsep, TreeSt
        }
 }
 
-void outliner_toggle_renderability(Scene *scene, SpaceOops *soops)
+static int outliner_toggle_renderability_exec(bContext *C, wmOperator *op)
 {
-
+       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       Scene *scene= CTX_data_scene(C);
+       ARegion *ar= CTX_wm_region(C);
+       
        outliner_do_object_operation(scene, soops, &soops->tree, object_toggle_renderability_cb);
        
-       BIF_undo_push("Outliner toggle renderability");
+       // XXX need proper notifiers here instead
+       ED_region_tag_redraw(ar);
+       
+       return OPERATOR_FINISHED;
+}
 
+void OUTLINER_OT_renderability_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Toggle Renderability";
+       ot->idname= "OUTLINER_OT_renederability_toggle";
+       ot->description= "Toggle the renderbility of selected items.";
+       
+       /* callbacks */
+       ot->exec= outliner_toggle_renderability_exec;
+       ot->poll= ED_operator_outliner_active;
+       
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-void outliner_toggle_visible(SpaceOops *soops)
+/* --- */
+
+static int outliner_toggle_expanded_exec(bContext *C, wmOperator *op)
 {
+       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       ARegion *ar= CTX_wm_region(C);
        
-       ifoutliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1))
+       if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1))
                outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 0);
        else 
                outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 1);
+       
+       // XXX need proper notifiers here instead
+       ED_region_tag_redraw(ar);
+       
+       return OPERATOR_FINISHED;
+}
 
-       BIF_undo_push("Outliner toggle visible");
+void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Expand/Collapse All";
+       ot->idname= "OUTLINER_OT_expanded_toggle";
+       ot->description= "Expand/Collapse all items.";
+       
+       /* callbacks */
+       ot->exec= outliner_toggle_expanded_exec;
+       ot->poll= ED_operator_outliner_active;
+       
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-void outliner_toggle_selected(ARegion *ar, SpaceOops *soops)
+/* --- */
+
+static int outliner_toggle_selected_exec(bContext *C, wmOperator *op)
 {
+       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       ARegion *ar= CTX_wm_region(C);
        
-       ifoutliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1))
+       if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1))
                outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0);
        else 
                outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 1);
        
-       BIF_undo_push("Outliner toggle selected");
        soops->storeflag |= SO_TREESTORE_REDRAW;
+       
+       // XXX need proper notifiers here instead
+       ED_region_tag_redraw(ar);
+       
+       return OPERATOR_FINISHED;
 }
 
+void OUTLINER_OT_selected_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Toggle Selected";
+       ot->idname= "OUTLINER_OT_selected_toggle";
+       ot->description= "Toggle the Outliner selection of items.";
+       
+       /* callbacks */
+       ot->exec= outliner_toggle_selected_exec;
+       ot->poll= ED_operator_outliner_active;
+       
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* --- */
+
 /* helper function for Show/Hide one level operator */
 static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curlevel, int level, int open)
 {
index 263de4efc5bd77531f90a32eadace512f3823a49..69f88fbcca7803f870d6efbc0217d21619f1f0c2 100644 (file)
@@ -120,10 +120,18 @@ void outliner_select(struct SpaceOops *soops, struct ListBase *lb, int *index, s
 void draw_outliner(const struct bContext *C);
 
 void OUTLINER_OT_activate_click(struct wmOperatorType *ot);
+
 void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
 void OUTLINER_OT_show_active(struct wmOperatorType *ot);
 void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
 
+void OUTLINER_OT_selected_toggle(struct wmOperatorType *ot);
+void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
+
+void OUTLINER_OT_renderability_toggle(struct wmOperatorType *ot);
+void OUTLINER_OT_selectability_toggle(struct wmOperatorType *ot);
+void OUTLINER_OT_visibility_toggle(struct wmOperatorType *ot);
+
 void OUTLINER_OT_keyingset_add_selected(struct wmOperatorType *ot);
 void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot);
 
index d07a3ea299e3fa208b80b60ff865f5e595606d98..36ee64f10fdba3b7ada8c84876318beb2947ff90 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "WM_api.h"
 #include "WM_types.h"
+#include "RNA_define.h"
 #include "ED_screen.h"
 
 #include "outliner_intern.h"
@@ -49,6 +50,13 @@ void outliner_operatortypes(void)
        WM_operatortype_append(OUTLINER_OT_show_active);
        WM_operatortype_append(OUTLINER_OT_show_hierarchy);
        
+       WM_operatortype_append(OUTLINER_OT_selected_toggle);
+       WM_operatortype_append(OUTLINER_OT_expanded_toggle);
+       
+       WM_operatortype_append(OUTLINER_OT_renderability_toggle);
+       WM_operatortype_append(OUTLINER_OT_selectability_toggle);
+       WM_operatortype_append(OUTLINER_OT_visibility_toggle);
+       
        WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
        WM_operatortype_append(OUTLINER_OT_keyingset_remove_selected);
        
@@ -70,6 +78,13 @@ void outliner_keymap(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADPLUSKEY, KM_PRESS, 0, 0); /* open */
        RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0)->ptr, "open", 0); /* close */
        
+       WM_keymap_verify_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0);
+       WM_keymap_verify_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0);
+       
+       WM_keymap_verify_item(keymap, "OUTLINER_OT_renderability_toggle", RKEY, KM_PRESS, 0, 0);
+       WM_keymap_verify_item(keymap, "OUTLINER_OT_selectability_toggle", SKEY, KM_PRESS, 0, 0);
+       WM_keymap_verify_item(keymap, "OUTLINER_OT_visibility_toggle", VKEY, KM_PRESS, 0, 0);
+       
        
        /* keying sets - only for databrowse */
        WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0);