2.5 - Giving shapekeys UI a bit of attention
authorJoshua Leung <aligorith@gmail.com>
Sat, 1 Aug 2009 06:03:08 +0000 (06:03 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 1 Aug 2009 06:03:08 +0000 (06:03 +0000)
* Separated value and range sliders for the value into two separate rows. Value comes before the range settings since it's used more often, and is drawn as a slider instead.

* Tweaked ranges for the sliders so that they will work sanely.

release/ui/buttons_data_mesh.py
source/blender/editors/object/editkey.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_generics.c
source/blender/makesrna/intern/rna_key.c

index 87c4a596b4dd7ae82f11419b20c904c54236e5eb..882a4ad639e2bfee9f65bde198e9915c7c5d9995 100644 (file)
@@ -125,7 +125,11 @@ class DATA_PT_shape_keys(DataButtonsPanel):
                                if ob.active_shape_key_index != 0:
                                        if not ob.shape_key_lock:
                                                row = layout.row(align=True)
-                                               row.itemR(kb, "value", text="")
+                                               row.itemL(text="Value:")
+                                               row.itemR(kb, "value", text="", slider=True)
+                                               
+                                               row = layout.row(align=True);
+                                               row.itemL(text="Range:")
                                                row.itemR(kb, "slider_min", text="Min")
                                                row.itemR(kb, "slider_max", text="Max")
 
index f38c03fb284873025266ef789afe997a3a11d195..82194a4c3b4c96b00cc2768a90f29b9606d21fdb 100644 (file)
@@ -164,14 +164,20 @@ static KeyBlock *add_keyblock(Scene *scene, Key *key)
        kb= MEM_callocN(sizeof(KeyBlock), "Keyblock");
        BLI_addtail(&key->block, kb);
        kb->type= KEY_CARDINAL;
+       
        tot= BLI_countlist(&key->block);
        if(tot==1) strcpy(kb->name, "Basis");
        else sprintf(kb->name, "Key %d", tot-1);
+       
+               // XXX this is old anim system stuff? (i.e. the 'index' of the shapekey)
        kb->adrcode= tot-1;
        
        key->totkey++;
        if(key->totkey==1) key->refkey= kb;
        
+       kb->slidermin= 0.0f;
+       kb->slidermax= 1.0f;
+       
        // XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor...
        if(key->type == KEY_RELATIVE) 
                kb->pos= curpos+0.1;
index e3e4822b383c71fb5d0b01cb4abd1f52436817df..510193fdade96ff1c3b3daed1f4c0597af5ab9ab 100644 (file)
@@ -93,6 +93,7 @@
 //#include "BSE_view.h"
 
 #include "ED_image.h"
+#include "ED_keyframing.h"
 #include "ED_screen.h"
 #include "ED_space_api.h"
 #include "ED_markers.h"
@@ -298,6 +299,10 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
        {
                /* Do we need more refined tags? */
                WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+               
+               /* for realtime animation record - send notifiers recognised by animation editors */
+               if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
+                       WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
        }
        else if (t->spacetype == SPACE_ACTION) {
                //SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
index 2279bf4dff5728be4c923aaeec7bbe47e4124ed8..6622d82545d0d363fdb0491a59e07fec3425e744 100644 (file)
@@ -758,8 +758,7 @@ void recalcData(TransInfo *t)
                 * (i.e. uneditable animation values)
                 */
                // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
-               // TODO: maybe the ob->adt check isn't really needed? makes it too difficult to use...
-               if (/*(ob->adt) && */(t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
+               if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
                        short targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
                        
                        animrecord_check_state(t->scene, &ob->id, t->animtimer);
@@ -790,8 +789,7 @@ void recalcData(TransInfo *t)
                                 * (i.e. uneditable animation values)
                                 */
                                // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes?
-                               // TODO: maybe the ob->adt check isn't really needed? makes it too difficult to use...
-                               if (/*(ob->adt) && */(t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
+                               if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
                                        animrecord_check_state(t->scene, &ob->id, t->animtimer);
                                        autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
                                }
index 7297ee8cb975d8a453bb6d170ea8596856cbac9f..216a1d05079169fd5d26b8e527692560978db849 100644 (file)
 #include "WM_api.h"
 #include "WM_types.h"
 
+static void rna_ShapeKey_value_set(PointerRNA *ptr, float value)
+{
+       KeyBlock *data= (KeyBlock*)ptr->data;
+       CLAMP(value, data->slidermin, data->slidermax);
+       data->curval= value;
+}
+
+static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max)
+{
+       KeyBlock *data= (KeyBlock*)ptr->data;
+
+       *min= data->slidermin;
+       *max= data->slidermax;
+}
+
 static Key *rna_ShapeKey_find_key(ID *id)
 {
        switch(GS(id->name)) {
@@ -345,6 +360,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
        /* for now, this is editable directly, as users can set this even if they're not animating them (to test results) */
        prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "curval");
+       RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_value_set", "rna_ShapeKey_value_range");
        RNA_def_property_ui_text(prop, "Value", "Value of shape key at the current frame.");
        RNA_def_property_update(prop, 0, "rna_Key_update_data");
 
@@ -380,6 +396,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
        prop= RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "slidermax");
        RNA_def_property_range(prop, -10.0f, 10.0f);
+       RNA_def_property_float_default(prop, 1.0f);
        RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider.");
 
        prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);