NLA SoC: Added menus including the operators coded already
authorJoshua Leung <aligorith@gmail.com>
Fri, 12 Jun 2009 06:44:49 +0000 (06:44 +0000)
committerJoshua Leung <aligorith@gmail.com>
Fri, 12 Jun 2009 06:44:49 +0000 (06:44 +0000)
source/blender/editors/space_nla/nla_header.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_space.c

index 7ce7536878bc8cfb7db43adcba4132f79f473665..0d42c544a3f16c31ad076e710f0fbff47dc0c615 100644 (file)
@@ -57,6 +57,9 @@
 #include "ED_screen.h"
 
 #include "BIF_gl.h"
+#include "BIF_transform.h"
+
+#include "RNA_access.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -74,37 +77,84 @@ enum {
 
 /* ************************ header area region *********************** */
 
-static void do_viewmenu(bContext *C, void *arg, int event)
+
+static void nla_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa= CTX_wm_area(C);
+       Scene *scene= CTX_data_scene(C);
+       SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C);
+       PointerRNA spaceptr;
+       
+       /* retrieve state */
+       RNA_pointer_create(&sc->id, &RNA_SpaceNLA, snla, &spaceptr);
+       
+       /* create menu */
+       uiItemO(layout, NULL, ICON_MENU_PANEL, "NLAEDIT_OT_properties");
+       
+       uiItemS(layout);
+       
+       uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0, 0, 0);
        
+       if (snla->flag & SNLA_DRAWTIME)
+               uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle");
+       else
+               uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle");
+
+       uiItemS(layout);
+       
+       if (scene->flag & SCE_NLA_EDIT_ON) 
+               uiItemO(layout, NULL, 0, "NLAEDIT_OT_tweakmode_exit");
+       else
+               uiItemO(layout, NULL, 0, "NLAEDIT_OT_tweakmode_enter");
+       
+       uiItemS(layout);
+       
+       uiItemO(layout, NULL, 0, "NLA_OT_view_all");
+       
+       if (sa->full) 
+               uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
+       else 
+               uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctr DownArrow
 }
 
-static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
+static void nla_selectmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
+       uiItemO(layout, NULL, 0, "NLAEDIT_OT_select_all_toggle");
+       uiItemBooleanO(layout, "Invert All", 0, "NLAEDIT_OT_select_all_toggle", "invert", 1);
        
-       block= uiBeginBlock(C, ar, "dummy_viewmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_viewmenu, NULL);
+       uiItemS(layout);
        
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, 
-                                        menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+       uiItemO(layout, NULL, 0, "NLAEDIT_OT_select_border");
+       uiItemBooleanO(layout, "Border Axis Range", 0, "NLAEDIT_OT_select_border", "axis_range", 1);
+}
+
+static void nla_edit_transformmenu(bContext *C, uiLayout *layout, void *arg_unused)
+{
+       // XXX these operators may change for NLA...
+       uiItemEnumO(layout, "Grab/Move", 0, "TFM_OT_transform", "mode", TFM_TIME_TRANSLATE);
+       uiItemEnumO(layout, "Extend", 0, "TFM_OT_transform", "mode", TFM_TIME_EXTEND);
+       uiItemEnumO(layout, "Scale", 0, "TFM_OT_transform", "mode", TFM_TIME_SCALE);
+}
+
+static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
+{
+       uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu);
        
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
+       uiItemS(layout);
        
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
+       uiItemO(layout, NULL, 0, "NLA_OT_add_tracks");
+       uiItemBooleanO(layout, "Add Tracks Above Selected", 0, "NLA_OT_add_tracks", "above_selected", 1);
+       
+       uiItemO(layout, NULL, 0, "NLAEDIT_OT_split");
        
-       return block;
+       uiItemS(layout);
+       
+       uiItemO(layout, NULL, 0, "NLAEDIT_OT_delete");
 }
 
+/* ------------------ */
+
 static void do_nla_buttons(bContext *C, void *arg, int event)
 {
        switch (event) {
@@ -132,9 +182,17 @@ void nla_header_buttons(const bContext *C, ARegion *ar)
                int xmax;
                
                xmax= GetButStringLength("View");
-               uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), 
-                                                "View", xco, yco-2, xmax-3, 24, "");
-               xco+=XIC+xmax;
+               uiDefMenuBut(block, nla_viewmenu, NULL, "View", xco, yco, xmax-3, 20, "");
+               xco+= xmax;
+               
+               xmax= GetButStringLength("Select");
+               uiDefMenuBut(block, nla_selectmenu, NULL, "Select", xco, yco, xmax-3, 20, "");
+               xco+= xmax;
+               
+               xmax= GetButStringLength("Edit");
+               uiDefMenuBut(block, nla_editmenu, NULL, "Edit", xco, yco, xmax-3, 20, "");
+               xco+= xmax;
+               
        }
        
        uiBlockSetEmboss(block, UI_EMBOSS);
index c7abd8f7f83e346c40c1a64fc4bdf4383754e086..3740633b576de379b4de390c2f15f78f957be285 100644 (file)
@@ -696,8 +696,11 @@ enum {
 #define IMS_INFILESLI          4
 
 /* nla->flag */
+       // depreceated
 #define SNLA_ALLKEYED          (1<<0)
+       // depreceated
 #define SNLA_ACTIVELAYERS      (1<<1)
+
 #define SNLA_DRAWTIME          (1<<2)
 #define SNLA_NOTRANSKEYCULL    (1<<3)
 #define SNLA_NODRAWCFRANUM     (1<<4)
index 1a8bf88d1cc04e5efc4d97f3650f3da48ea836d7..d1fd3d780742618651833be990795d05990d5ad7 100644 (file)
@@ -365,6 +365,7 @@ extern StructRNA RNA_Space;
 extern StructRNA RNA_Space3DView;
 extern StructRNA RNA_SpaceButtonsWindow;
 extern StructRNA RNA_SpaceImageEditor;
+extern StructRNA RNA_SpaceNLA;
 extern StructRNA RNA_SpaceOutliner;
 extern StructRNA RNA_SpaceSequenceEditor;
 extern StructRNA RNA_SpaceTextEditor;
index 5de80cce2b58d7230d262ac60834a71940b28310..1b776b727ce50f941c284dacad5bfb6dc350574e 100644 (file)
@@ -92,10 +92,10 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
                /*case SPACE_SOUND:
                        return &RNA_SpaceAudioWindow;
                case SPACE_ACTION:
-                       return &RNA_SpaceDopeSheetEditor;
+                       return &RNA_SpaceDopeSheetEditor;*/
                case SPACE_NLA:
-                       return &RNA_SpaceNLAEditor;
-               case SPACE_SCRIPT:
+                       return &RNA_SpaceNLA;
+               /*case SPACE_SCRIPT:
                        return &RNA_SpaceScriptsWindow;
                case SPACE_TIME:
                        return &RNA_SpaceTimeline;
@@ -757,6 +757,27 @@ static void rna_def_space_text(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool.");
 }
 
+static void rna_def_space_nla(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+       
+       srna= RNA_def_struct(brna, "SpaceNLA", "Space");
+       RNA_def_struct_sdna(srna, "SpaceNla");
+       RNA_def_struct_ui_text(srna, "Space Nla Editor", "NLA editor space data.");
+       
+       /* display */
+       prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SNLA_DRAWTIME);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator
+       RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames.");
+       
+       prop= RNA_def_property(srna, "show_cframe_indicator", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SNLA_NODRAWCFRANUM);
+       RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line.");
+
+}
+
 void RNA_def_space(BlenderRNA *brna)
 {
        rna_def_space(brna);
@@ -767,6 +788,7 @@ void RNA_def_space(BlenderRNA *brna)
        rna_def_background_image(brna);
        rna_def_space_3dview(brna);
        rna_def_space_buttons(brna);
+       rna_def_space_nla(brna);
 }
 
 #endif