Merged changes in the trunk up to revision 46045.
[blender-staging.git] / source / blender / editors / space_nla / nla_buttons.c
index c431f5455edce07b248be64d4bb82393ab38ede0..17be87052c4c696484f50d9741c96cbb5d2957a3 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
 
 #include "BLI_math.h"
 #include "BLI_blenlib.h"
-#include "BLI_editVert.h"
 #include "BLI_rand.h"
 
-#include "BLF_api.h"
+#include "BLF_translation.h"
 
 #include "BKE_nla.h"
 #include "BKE_context.h"
@@ -79,7 +76,7 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event)
 {
        //Scene *scene= CTX_data_scene(C);
        
-       switch(event) {
+       switch (event) {
 
        }
        
@@ -105,7 +102,8 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA
        /* extract list of active channel(s), of which we should only take the first one 
         *      - we need the channels flag to get the active AnimData block when there are no NLA Tracks
         */
-       filter= (ANIMFILTER_VISIBLE|ANIMFILTER_ACTIVE|ANIMFILTER_CHANNELS);
+       // XXX: double-check active!
+       filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_VISIBLE|ANIMFILTER_ACTIVE|ANIMFILTER_LIST_CHANNELS);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        for (ale= anim_data.first; ale; ale= ale->next) {
@@ -147,6 +145,8 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA
                        case ANIMTYPE_DSPART:
                        case ANIMTYPE_DSMBALL:
                        case ANIMTYPE_DSARM:
+                       case ANIMTYPE_DSLINESTYLE:
+                       case ANIMTYPE_DSSPK:
                        {
                                /* for these channels, we only do AnimData */
                                if (ale->id && ale->adt) {
@@ -213,6 +213,24 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt)
        return (strip->type == NLASTRIP_TYPE_CLIP);
 }
 
+static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+       PointerRNA ptr;
+       NlaStrip *strip;
+       
+       if (!nla_panel_context(C, NULL, NULL, &ptr))
+               return 0;
+       if (ptr.data == NULL)
+               return 0;
+       
+       strip= ptr.data;
+       
+       if (strip->type == NLASTRIP_TYPE_SOUND)
+               return 0;
+               
+       return 1;
+}
+
 /* -------------- */
 
 /* active AnimData */
@@ -276,8 +294,9 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
 {
        PointerRNA strip_ptr;
        uiLayout *layout= pa->layout;
-       uiLayout *column, *row, *subcol;
+       uiLayout *column, *row, *sub;
        uiBlock *block;
+       short showEvalProps = 1;
        
        if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
                return;
@@ -297,32 +316,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
                uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE);
                uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE);
        
-       /* extrapolation */
-       row= uiLayoutRow(layout, 1);
-               uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
+       /* Evaluation-Related Strip Properties ------------------ */
        
-       /* blending */
-       row= uiLayoutRow(layout, 1);
-               uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
-               
-       /* blend in/out + autoblending
-        *      - blend in/out can only be set when autoblending is off
-        */
-       column= uiLayoutColumn(layout, 1);
-               uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); 
-               uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle?
-               
-               subcol= uiLayoutColumn(column, 1);
-                       uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); 
-                       uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE);
-                       uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE);
+       /* sound properties strips don't have these settings */
+       if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND)
+               showEvalProps = 0;
+       
+       /* only show if allowed to... */
+       if (showEvalProps) {
+               /* extrapolation */
+               row= uiLayoutRow(layout, 1);
+                       uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE);
                
-       /* settings */
-       column= uiLayoutColumn(layout, 1);
-               uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); 
-               uiItemL(column, "Playback Settings:", ICON_NONE);
-               uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE);
-               uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
+               /* blending */
+               row= uiLayoutRow(layout, 1);
+                       uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE);
+                       
+               /* blend in/out + autoblending
+                *      - blend in/out can only be set when autoblending is off
+                */
+               column= uiLayoutColumn(layout, 1);
+                       uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); 
+                       uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle?
+                       
+                       sub= uiLayoutColumn(column, 1);
+                               uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); 
+                               uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE);
+                               uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE);
+                       
+               /* settings */
+               column= uiLayoutColumn(layout, 1);
+                       uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); 
+                       uiItemL(column, "Playback Settings:", ICON_NONE);
+                       uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE);
+                       uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE);
+       }
 }
 
 
@@ -367,7 +395,7 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
 {
        PointerRNA strip_ptr;
        uiLayout *layout= pa->layout;
-       uiLayout *column, *subcolumn, *subrow;
+       uiLayout *col, *sub;
        uiBlock *block;
 
        /* check context and also validity of pointer */
@@ -377,23 +405,21 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
        block= uiLayoutGetBlock(layout);
        uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL);
                
-       column= uiLayoutColumn(layout, 1);
-               uiItemR(column, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE);
-               
-               subcolumn= uiLayoutColumn(column, 1);
-               uiLayoutSetEnabled(subcolumn, RNA_boolean_get(&strip_ptr, "use_animated_influence"));   
-                       uiItemR(subcolumn, &strip_ptr, "influence", 0, NULL, ICON_NONE);
-               
+       col= uiLayoutColumn(layout, 1);
+       uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE);
        
-       column= uiLayoutColumn(layout, 1);
-               subrow= uiLayoutRow(column, 0);
-               uiItemR(subrow, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE);
-               uiItemR(subrow, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE);
-
-               subcolumn= uiLayoutColumn(column, 1);
-               subrow= uiLayoutRow(subcolumn, 0);
-               uiLayoutSetEnabled(subrow, RNA_boolean_get(&strip_ptr, "use_animated_time"));
-                       uiItemR(subcolumn, &strip_ptr, "strip_time", 0, NULL, ICON_NONE);
+       sub= uiLayoutColumn(col, 1);
+       uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); 
+       uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE);
+
+       col= uiLayoutColumn(layout, 1);
+       sub= uiLayoutRow(col, 0);
+       uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE);
+       uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE);
+
+       sub= uiLayoutRow(col, 0);
+       uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time"));
+       uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE);
 }
 
 /* F-Modifiers for active NLA-Strip */
@@ -420,7 +446,8 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
                
                // XXX for now, this will be a operator button which calls a temporary 'add modifier' operator
                // FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected)
-               uiDefButO(block, BUT, "NLA_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, "Add Modifier", 10, 0, 150, 20, "Adds a new F-Modifier for the active NLA Strip");
+               uiDefButO(block, BUT, "NLA_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), 10, 0, 150, 20,
+                               TIP_("Adds a new F-Modifier for the active NLA Strip"));
                
                /* copy/paste (as sub-row)*/
                row= uiLayoutRow(row, 1);
@@ -476,14 +503,14 @@ void nla_buttons_register(ARegionType *art)
        strcpy(pt->idname, "NLA_PT_evaluation");
        strcpy(pt->label, "Evaluation");
        pt->draw= nla_panel_evaluation;
-       pt->poll= nla_strip_panel_poll;
+       pt->poll= nla_strip_eval_panel_poll;
        BLI_addtail(&art->paneltypes, pt);
        
        pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers");
        strcpy(pt->idname, "NLA_PT_modifiers");
        strcpy(pt->label, "Modifiers");
        pt->draw= nla_panel_modifiers;
-       pt->poll= nla_strip_panel_poll;
+       pt->poll= nla_strip_eval_panel_poll;
        BLI_addtail(&art->paneltypes, pt);
 }
 
@@ -492,7 +519,7 @@ static int nla_properties(bContext *C, wmOperator *UNUSED(op))
        ScrArea *sa= CTX_wm_area(C);
        ARegion *ar= nla_has_buttons_region(sa);
        
-       if(ar)
+       if (ar)
                ED_region_toggle_hidden(C, ar);
 
        return OPERATOR_FINISHED;
@@ -500,13 +527,13 @@ static int nla_properties(bContext *C, wmOperator *UNUSED(op))
 
 void NLA_OT_properties(wmOperatorType *ot)
 {
-       ot->name= _("Properties");
-       ot->idname= "NLA_OT_properties";
-       ot->description= _("Toggle display properties panel");
+       ot->name = "Properties";
+       ot->idname = "NLA_OT_properties";
+       ot->description = "Toggle display properties panel";
        
-       ot->exec= nla_properties;
-       ot->poll= ED_operator_nla_active;
+       ot->exec = nla_properties;
+       ot->poll = ED_operator_nla_active;
 
        /* flags */
-       ot->flag= 0;
+       ot->flag = 0;
 }