Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-08-16 06:21:43 +0400
committerJoshua Leung <aligorith@gmail.com>2009-08-16 06:21:43 +0400
commitb257acfed11e8d98eb7c86e0908acf80fb9e27af (patch)
treea1b197d8355a6f66df48939627ea814eebf16fdd /source/blender/editors/space_nla
parentebf1c5faca86286aa90ab5ab9fc4d3ddb1f51cdf (diff)
Animation Editors: Code Cleanups (for Channel Lists) Part 2
Now the mute/protect/expand/etc. toggles are drawn using UI widgets. This means that special event handling code to determine when they were clicked on is no longer needed, and also means that there can now be tooltips for these items too. Also, added visibility toggles for ID-block expanders, which will cause all the F-Curves in the linked datablock to not get drawn. The backend filtering code to make this work will come later...
Diffstat (limited to 'source/blender/editors/space_nla')
-rw-r--r--source/blender/editors/space_nla/nla_channels.c187
-rw-r--r--source/blender/editors/space_nla/nla_draw.c92
-rw-r--r--source/blender/editors/space_nla/nla_edit.c52
-rw-r--r--source/blender/editors/space_nla/nla_intern.h2
-rw-r--r--source/blender/editors/space_nla/space_nla.c2
5 files changed, 129 insertions, 206 deletions
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index ab918519ec0..063b329b7a1 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -89,6 +89,7 @@
* part of the channel is relevant.
*
* NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons
+ * --> Most channels are now selection only...
*/
static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode)
@@ -118,32 +119,17 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
case ANIMTYPE_SCENE:
{
Scene *sce= (Scene *)ale->data;
- AnimData *adt= ale->data;
- if (x < 16) {
- /* toggle expand */
- sce->flag ^= SCE_DS_COLLAPSED;
-
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
-
- notifierFlags |= ND_ANIMCHAN_EDIT;
+ /* set selection status */
+ if (selectmode == SELECT_INVERT) {
+ /* swap select */
+ sce->flag ^= SCE_DS_SELECTED;
}
else {
- /* set selection status */
- if (selectmode == SELECT_INVERT) {
- /* swap select */
- sce->flag ^= SCE_DS_SELECTED;
- }
- else {
- sce->flag |= SCE_DS_SELECTED;
- }
-
- notifierFlags |= ND_ANIMCHAN_SELECT;
+ sce->flag |= SCE_DS_SELECTED;
}
+
+ notifierFlags |= ND_ANIMCHAN_SELECT;
}
break;
case ANIMTYPE_OBJECT:
@@ -152,20 +138,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
Scene *sce= (Scene *)ads->source;
Base *base= (Base *)ale->data;
Object *ob= base->object;
- AnimData *adt= ale->adt;
- if (x < 16) {
- /* toggle expand */
- ob->nlaflag ^= OB_ADS_COLLAPSED; // XXX
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- else if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
-
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- else if (nlaedit_is_tweakmode_on(ac) == 0) {
+ if (nlaedit_is_tweakmode_on(ac) == 0) {
/* set selection status */
if (selectmode == SELECT_INVERT) {
/* swap select */
@@ -194,149 +168,6 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
}
}
break;
- case ANIMTYPE_FILLMATD:
- {
- Object *ob= (Object *)ale->data;
- ob->nlaflag ^= OB_ADS_SHOWMATS; // XXX
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_FILLPARTD:
- {
- Object *ob= (Object *)ale->data;
- ob->nlaflag ^= OB_ADS_SHOWPARTS; // XXX
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
-
- case ANIMTYPE_DSMAT:
- {
- Material *ma= (Material *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- ma->flag ^= MA_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSLAM:
- {
- Lamp *la= (Lamp *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- la->flag ^= LA_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSCAM:
- {
- Camera *ca= (Camera *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- ca->flag ^= CAM_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSCUR:
- {
- Curve *cu= (Curve *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- cu->flag ^= CU_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSSKEY:
- {
- Key *key= (Key *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- key->flag ^= KEYBLOCK_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSWOR:
- {
- World *wo= (World *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- wo->flag ^= WO_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSPART:
- {
- ParticleSettings *part= (ParticleSettings *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- part->flag ^= PART_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
- case ANIMTYPE_DSMBALL:
- {
- MetaBall *mb= (MetaBall *)ale->data;
- AnimData *adt= ale->adt;
-
- if ( (adt) && (x >= (NLACHANNEL_NAMEWIDTH-NLACHANNEL_BUTTON_WIDTH)) ) {
- /* toggle mute */
- adt->flag ^= ADT_NLA_EVAL_OFF;
- }
- else {
- /* toggle expand */
- mb->flag2 ^= MB_DS_EXPAND;
- }
- notifierFlags |= ND_ANIMCHAN_EDIT;
- }
- break;
case ANIMTYPE_NLATRACK:
{
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index a4265af71d9..931775f1a6e 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -592,36 +592,15 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* *********************************************** */
/* Channel List */
-void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar)
+/* old code for drawing NLA channels using GL only */
+// TODO: depreceate this code...
+static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y)
{
- ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- int filter;
-
- View2D *v2d= &ar->v2d;
- float x= 0.0f, y= 0.0f;
- int items, height;
-
- /* build list of channels to draw */
- filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
- items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
- /* Update max-extent of channels here (taking into account scrollers):
- * - this is done to allow the channel list to be scrollable, but must be done here
- * to avoid regenerating the list again and/or also because channels list is drawn first
- * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
- * start of list offset, and the second is as a correction for the scrollers.
- */
- height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2));
- /* don't use totrect set, as the width stays the same
- * (NOTE: this is ok here, the configuration is pretty straightforward)
- */
- v2d->tot.ymin= (float)(-height);
+ float x = 0.0f;
/* loop through channels, and set up drawing depending on their type */
- y= (float)(-NLACHANNEL_HEIGHT);
-
- for (ale= anim_data.first; ale; ale= ale->next) {
+ for (ale= anim_data->first; ale; ale= ale->next) {
const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF);
const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF);
const float ydatac= (float)(y - 7);
@@ -716,6 +695,7 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar)
break;
default: /* handled by standard channel-drawing API */
+ // draw backdrops only...
ANIM_channel_draw(ac, ale, yminc, ymaxc);
break;
}
@@ -856,6 +836,66 @@ void draw_nla_channel_list (bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* adjust y-position for next one */
y -= NLACHANNEL_STEP;
}
+}
+
+void draw_nla_channel_list (bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ View2D *v2d= &ar->v2d;
+ float x= 0.0f, y= 0.0f;
+ int items, height;
+
+ /* build list of channels to draw */
+ filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
+ items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* Update max-extent of channels here (taking into account scrollers):
+ * - this is done to allow the channel list to be scrollable, but must be done here
+ * to avoid regenerating the list again and/or also because channels list is drawn first
+ * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
+ * start of list offset, and the second is as a correction for the scrollers.
+ */
+ height= ((items*NLACHANNEL_STEP) + (NLACHANNEL_HEIGHT*2));
+ /* don't use totrect set, as the width stays the same
+ * (NOTE: this is ok here, the configuration is pretty straightforward)
+ */
+ v2d->tot.ymin= (float)(-height);
+
+ /* draw channels */
+ { /* first pass: backdrops + oldstyle drawing */
+ y= (float)(-NLACHANNEL_HEIGHT);
+
+ draw_nla_channel_list_gl(ac, &anim_data, v2d, y);
+ }
+ { /* second pass: UI widgets */
+ uiBlock *block= uiBeginBlock(C, ar, "NLA channel buttons", UI_EMBOSS);
+
+ y= (float)(-NLACHANNEL_HEIGHT);
+
+ /* loop through channels, and set up drawing depending on their type */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF);
+ const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF);
+ const float ydatac= (float)(y - 7);
+
+ /* check if visible */
+ if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
+ IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
+ {
+ /* draw all channels using standard channel-drawing API */
+ ANIM_channel_draw_widgets(ac, ale, block, yminc, ymaxc);
+ }
+
+ /* adjust y-position for next one */
+ y -= NLACHANNEL_STEP;
+ }
+
+ uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+ }
/* free tempolary channels */
BLI_freelistN(&anim_data);
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index d476852ef2d..763f4116416 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -919,6 +919,58 @@ void NLA_OT_split (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/* ******************** Bake Strips Operator ***************************** */
+/* Bakes the NLA Strips for the active AnimData blocks */
+
+static int nlaedit_bake_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* get a list of the editable tracks being shown in the NLA */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* for each AnimData block, bake strips to animdata... */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ // FIXME
+ }
+
+ /* free temp data */
+ BLI_freelistN(&anim_data);
+
+ /* refresh auto strip properties */
+ ED_nla_postop_refresh(&ac);
+
+ /* set notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
+
+ /* done */
+ return OPERATOR_FINISHED;
+}
+
+void NLA_OT_bake (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake Strips";
+ ot->idname= "NLA_OT_bake";
+ ot->description= "Bake all strips of selected AnimData blocks.";
+
+ /* api callbacks */
+ ot->exec= nlaedit_bake_exec;
+ ot->poll= nlaop_poll_tweakmode_off;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* *********************************************** */
/* NLA Editing Operations (Modifying) */
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index 7cc09707ba7..e4557ec878f 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -45,7 +45,7 @@ void NLA_OT_properties(wmOperatorType *ot);
/* nla_draw.c */
void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar);
-void draw_nla_channel_list(bAnimContext *ac, SpaceNla *snla, ARegion *ar);
+void draw_nla_channel_list(bContext *C, bAnimContext *ac, SpaceNla *snla, ARegion *ar);
/* **************************************** */
/* nla_header.c */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 6f377aabd4e..c4f929274c7 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -238,7 +238,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar)
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
- draw_nla_channel_list(&ac, snla, ar);
+ draw_nla_channel_list((bContext *)C, &ac, snla, ar);
}
/* reset view matrix */