Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / editors / space_nla / nla_header.c
index 11dfc55..e507efb 100644 (file)
@@ -21,7 +21,7 @@
  * All rights reserved.
  *
  * 
- * Contributor(s): Blender Foundation
+ * Contributor(s): Blender Foundation, Joshua Leung
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 #include "ED_util.h"
 
 #include "ED_anim_api.h"
+#include "ED_markers.h"
 #include "ED_space_api.h"
 #include "ED_screen.h"
+#include "ED_transform.h"
 
 #include "BIF_gl.h"
-#include "BIF_transform.h"
 
 #include "RNA_access.h"
 
@@ -68,7 +69,7 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
-#include "ED_markers.h"
+#include "nla_intern.h"
 
 /* button events */
 enum {
@@ -82,15 +83,14 @@ 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);
+       SpaceNla *snla= CTX_wm_space_nla(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");
+       uiItemO(layout, NULL, ICON_MENU_PANEL, "NLA_OT_properties");
        
        uiItemS(layout);
        
@@ -100,13 +100,10 @@ static void nla_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
                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");
+       uiItemR(layout, NULL, 0, &spaceptr, "show_strip_curves", 0, 0, 0);
+       
+       uiItemS(layout);
        
        uiItemS(layout);
        
@@ -125,46 +122,76 @@ static void nla_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
 
 static void nla_selectmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_select_all_toggle");
-       uiItemBooleanO(layout, "Invert All", 0, "NLAEDIT_OT_select_all_toggle", "invert", 1);
+       uiItemO(layout, NULL, 0, "NLA_OT_select_all_toggle");
+       uiItemBooleanO(layout, "Invert All", 0, "NLA_OT_select_all_toggle", "invert", 1);
        
        uiItemS(layout);
        
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_select_border");
-       uiItemBooleanO(layout, "Border Axis Range", 0, "NLAEDIT_OT_select_border", "axis_range", 1);
+       uiItemO(layout, NULL, 0, "NLA_OT_select_border");
+       uiItemBooleanO(layout, "Border Axis Range", 0, "NLA_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, "Grab/Move", 0, "TFM_OT_transform", "mode", TFM_TRANSLATION);
        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_edit_snapmenu(bContext *C, uiLayout *layout, void *arg_unused)
+{
+       uiItemEnumO(layout, NULL, 0, "NLA_OT_snap", "type", NLAEDIT_SNAP_CFRA);
+       uiItemEnumO(layout, NULL, 0, "NLA_OT_snap", "type", NLAEDIT_SNAP_NEAREST_FRAME);
+       uiItemEnumO(layout, NULL, 0, "NLA_OT_snap", "type", NLAEDIT_SNAP_NEAREST_SECOND);
+       uiItemEnumO(layout, NULL, 0, "NLA_OT_snap", "type", NLAEDIT_SNAP_NEAREST_MARKER);
+}
+
 static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu);
+       Scene *scene= CTX_data_scene(C);
+       
+       uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL);
+       uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu, NULL);
+       
+       uiItemS(layout);
+       
+       uiItemO(layout, NULL, 0, "NLA_OT_duplicate");
+       uiItemO(layout, NULL, 0, "NLA_OT_split");
+       uiItemO(layout, NULL, 0, "NLA_OT_delete");
+       
+       uiItemS(layout);
+       
+       uiItemO(layout, NULL, 0, "NLA_OT_mute_toggle");
        
        uiItemS(layout);
        
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_duplicate");
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_split");
+       uiItemO(layout, NULL, 0, "NLA_OT_apply_scale");
+       uiItemO(layout, NULL, 0, "NLA_OT_clear_scale");
        
        uiItemS(layout);
        
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_delete");
+       uiItemO(layout, NULL, 0, "NLA_OT_move_up");
+       uiItemO(layout, NULL, 0, "NLA_OT_move_down");
        
        uiItemS(layout);
        
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_apply_scale");
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_clear_scale");
+       // TODO: names of these tools for 'tweakmode' need changing?
+       if (scene->flag & SCE_NLA_EDIT_ON) 
+               uiItemO(layout, "Stop Tweaking Strip Actions", 0, "NLA_OT_tweakmode_exit");
+       else
+               uiItemO(layout, "Start Tweaking Strip Actions", 0, "NLA_OT_tweakmode_enter");
 }
 
 static void nla_addmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_add_actionclip");
-       uiItemO(layout, NULL, 0, "NLAEDIT_OT_add_transition");
+       uiItemO(layout, NULL, 0, "NLA_OT_add_actionclip");
+       uiItemO(layout, NULL, 0, "NLA_OT_add_transition");
+       
+       uiItemS(layout);
+       
+       uiItemO(layout, NULL, 0, "NLA_OT_add_meta");
+       uiItemO(layout, NULL, 0, "NLA_OT_remove_meta");
        
        uiItemS(layout);
        
@@ -186,7 +213,7 @@ static void do_nla_buttons(bContext *C, void *arg, int event)
 
 void nla_header_buttons(const bContext *C, ARegion *ar)
 {
-       SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(C);
+       SpaceNla *snla= CTX_wm_space_nla(C);
        ScrArea *sa= CTX_wm_area(C);
        uiBlock *block;
        int xco, yco= 3;
@@ -234,12 +261,14 @@ void nla_header_buttons(const bContext *C, ARegion *ar)
                        uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Lamps");
                        uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA,       (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Cameras");
                        uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA,        (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Curves");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display MetaBalls");
+                       uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA,    (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Particles");
                uiBlockEndAlign(block);
                xco += 15;
        }
        else {
                // XXX this case shouldn't happen at all... for now, just pad out same amount of space
-               xco += 7*XIC + 15;
+               xco += 10*XIC + 15;
        }
        xco += (XIC + 8);