NLA SoC: Start of UI Drawing Code for NLA Editor
In this commit, I've only setup the drawing code for the channels list. Only the drawing of the 'active action' dummy-line has been tested so far.
This commit is contained in:
@@ -5680,7 +5680,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
||||
ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
|
||||
ar->v2d.align= V2D_ALIGN_NO_POS_Y;
|
||||
ar->v2d.align= V2D_ALIGN_NO_NEG_Y;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ static short nlaedit_get_context (bAnimContext *ac, SpaceNla *snla)
|
||||
{
|
||||
/* init dopesheet data if non-existant (i.e. for old files) */
|
||||
if (snla->ads == NULL)
|
||||
snla->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
|
||||
|
||||
/* sync settings with current view status, then return appropriate data */
|
||||
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
|
||||
@@ -359,6 +359,9 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
|
||||
if (ANIMDATA_HAS_NLA(id)) {\
|
||||
nlaOk\
|
||||
}\
|
||||
else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\
|
||||
nlaOk\
|
||||
}\
|
||||
}\
|
||||
else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\
|
||||
if (ANIMDATA_HAS_DRIVERS(id)) {\
|
||||
@@ -566,6 +569,13 @@ bAnimListElem *make_new_animlistelem (void *data, short datatype, void *owner, s
|
||||
ale->datatype= ALE_NLASTRIP;
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_NLAACTION:
|
||||
{
|
||||
/* nothing to include for now... nothing editable from NLA-perspective here */
|
||||
ale->key_data= NULL;
|
||||
ale->datatype= ALE_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +604,6 @@ static int animdata_filter_fcurves (ListBase *anim_data, FCurve *first, bActionG
|
||||
if ( ANIMCHANNEL_SELOK(SEL_FCU(fcu)) ) {
|
||||
/* only include if this curve is active */
|
||||
if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) {
|
||||
/* owner/ownertype will be either object or action-channel, depending if it was dopesheet or part of an action */
|
||||
ale= make_new_animlistelem(fcu, ANIMTYPE_FCURVE, owner, ownertype, owner_id);
|
||||
|
||||
if (ale) {
|
||||
@@ -682,10 +691,49 @@ static int animdata_filter_action (ListBase *anim_data, bAction *act, int filter
|
||||
return items;
|
||||
}
|
||||
|
||||
static int animdata_filter_nla (ListBase *anim_data, NlaTrack *first, int filter_mode, void *owner, short ownertype, ID *owner_id)
|
||||
static int animdata_filter_nla (ListBase *anim_data, AnimData *adt, int filter_mode, void *owner, short ownertype, ID *owner_id)
|
||||
{
|
||||
// FIXME
|
||||
return 0;
|
||||
bAnimListElem *ale;
|
||||
NlaTrack *nlt;
|
||||
int items = 0;
|
||||
|
||||
/* loop over NLA Tracks - assume that the caller of this has already checked that these should be included */
|
||||
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
|
||||
/* only work with this channel and its subchannels if it is editable */
|
||||
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
|
||||
/* only include this track if selected in a way consistent with the filtering requirements */
|
||||
if ( ANIMCHANNEL_SELOK(SEL_NLT(nlt)) ) {
|
||||
/* only include if this track is active */
|
||||
// XXX keep this?
|
||||
if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) {
|
||||
ale= make_new_animlistelem(nlt, ANIMTYPE_NLATRACK, owner, ownertype, owner_id);
|
||||
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if showing channels, include active action */
|
||||
if (filter_mode & ANIMFILTER_CHANNELS) {
|
||||
/* there isn't really anything editable here, so skip if need editable */
|
||||
// TODO: currently, selection isn't checked since it doesn't matter
|
||||
if ((filter_mode & ANIMFILTER_FOREDIT) == 0) {
|
||||
/* just add the action track now */
|
||||
ale= make_new_animlistelem(adt->action, ANIMTYPE_NLAACTION, owner, ownertype, owner_id);
|
||||
|
||||
if (ale) {
|
||||
BLI_addtail(anim_data, ale);
|
||||
items++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* return the number of items added to the list */
|
||||
return items;
|
||||
}
|
||||
|
||||
static int animdata_filter_shapekey (ListBase *anim_data, Key *key, int filter_mode, void *owner, short ownertype, ID *owner_id)
|
||||
@@ -881,7 +929,7 @@ static int animdata_filter_dopesheet_mats (ListBase *anim_data, bDopeSheet *ads,
|
||||
/* add material's animation data */
|
||||
if (FILTER_MAT_OBJD(ma) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
ANIMDATA_FILTER_CASES(ma,
|
||||
items += animdata_filter_nla(anim_data, ma->adt->nla_tracks.first, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);,
|
||||
items += animdata_filter_nla(anim_data, ma->adt, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);,
|
||||
items += animdata_filter_fcurves(anim_data, ma->adt->drivers.first, NULL, ma, ANIMTYPE_DSMAT, filter_mode, (ID *)ma);,
|
||||
items += animdata_filter_action(anim_data, ma->adt->action, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);)
|
||||
}
|
||||
@@ -946,7 +994,7 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
|
||||
if ((expanded) || (filter_mode & ANIMFILTER_CURVESONLY)) {
|
||||
/* filtering for channels - nla, drivers, keyframes */
|
||||
ANIMDATA_FILTER_CASES(iat,
|
||||
items+= animdata_filter_nla(anim_data, iat->adt->nla_tracks.first, filter_mode, iat, type, (ID *)iat);,
|
||||
items+= animdata_filter_nla(anim_data, iat->adt, filter_mode, iat, type, (ID *)iat);,
|
||||
items+= animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, iat, type, filter_mode, (ID *)iat);,
|
||||
items += animdata_filter_action(anim_data, iat->adt->action, filter_mode, iat, type, (ID *)iat);)
|
||||
}
|
||||
@@ -997,8 +1045,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
|
||||
#endif
|
||||
|
||||
/* add NLA tracks */
|
||||
if (/*EXPANDED_NLTD(adt) ||*/ !(filter_mode & ANIMFILTER_CHANNELS))
|
||||
items += animdata_filter_nla(anim_data, adt->nla_tracks.first, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
items += animdata_filter_nla(anim_data, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
},
|
||||
{ /* drivers */
|
||||
/* include drivers-expand widget? */
|
||||
@@ -1053,8 +1100,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
|
||||
#endif
|
||||
|
||||
/* add NLA tracks */
|
||||
if (/*EXPANDED_NLTD(adt) ||*/ !(filter_mode & ANIMFILTER_CHANNELS))
|
||||
items += animdata_filter_nla(anim_data, adt->nla_tracks.first, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
items += animdata_filter_nla(anim_data, adt, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
|
||||
},
|
||||
{ /* drivers */
|
||||
/* include shapekey-expand widget? */
|
||||
@@ -1179,8 +1225,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
|
||||
#endif
|
||||
|
||||
/* add NLA tracks */
|
||||
if (/*EXPANDED_NLTD(adt) ||*/ !(filter_mode & ANIMFILTER_CHANNELS))
|
||||
items += animdata_filter_nla(anim_data, adt->nla_tracks.first, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
|
||||
items += animdata_filter_nla(anim_data, adt, filter_mode, sce, ANIMTYPE_SCENE, (ID *)sce);
|
||||
},
|
||||
{ /* drivers */
|
||||
/* include drivers-expand widget? */
|
||||
@@ -1233,8 +1278,7 @@ static int animdata_filter_dopesheet_scene (ListBase *anim_data, bDopeSheet *ads
|
||||
#endif
|
||||
|
||||
/* add NLA tracks */
|
||||
if (/*EXPANDED_NLTD(adt) ||*/ !(filter_mode & ANIMFILTER_CHANNELS))
|
||||
items += animdata_filter_nla(anim_data, adt->nla_tracks.first, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
|
||||
items += animdata_filter_nla(anim_data, adt, filter_mode, wo, ANIMTYPE_DSWOR, (ID *)wo);
|
||||
},
|
||||
{ /* drivers */
|
||||
/* include world-expand widget? */
|
||||
@@ -1508,6 +1552,7 @@ int ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_mode
|
||||
case ANIMCONT_DOPESHEET:
|
||||
case ANIMCONT_FCURVES:
|
||||
case ANIMCONT_DRIVERS:
|
||||
case ANIMCONT_NLA:
|
||||
items= animdata_filter_dopesheet(anim_data, data, filter_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -412,8 +412,6 @@ void scene_to_keylist(Scene *sce, ListBase *keys, ListBase *blocks, ActKeysInc *
|
||||
/* get filterflag */
|
||||
if (ads)
|
||||
filterflag= ads->filterflag;
|
||||
else if ((aki) && (aki->actmode == -1)) /* only set like this by NLA */
|
||||
filterflag= ADS_FILTER_NLADUMMY;
|
||||
else
|
||||
filterflag= 0;
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ typedef enum eAnim_ChannelType {
|
||||
ANIMTYPE_GPLAYER,
|
||||
|
||||
ANIMTYPE_NLATRACK,
|
||||
ANIMTYPE_NLAACTION,
|
||||
} eAnim_ChannelType;
|
||||
|
||||
/* types of keyframe data in bAnimListElem */
|
||||
|
||||
@@ -52,6 +52,8 @@ enum {
|
||||
V2D_COMMONVIEW_STANDARD,
|
||||
/* listview (i.e. Outliner) */
|
||||
V2D_COMMONVIEW_LIST,
|
||||
/* stackview (this is basically a list where new items are added at the top) */
|
||||
V2D_COMMONVIEW_STACK,
|
||||
/* headers (this is basically the same as listview, but no y-panning) */
|
||||
V2D_COMMONVIEW_HEADER,
|
||||
/* ui region containing panels */
|
||||
|
||||
@@ -501,7 +501,10 @@ void ui_theme_init_userdef(void)
|
||||
btheme->tact= btheme->tipo;
|
||||
SETCOL(btheme->tact.strip, 12, 10, 10, 128);
|
||||
SETCOL(btheme->tact.strip_select, 255, 140, 0, 255);
|
||||
|
||||
|
||||
/* space nla */
|
||||
btheme->tnla= btheme->tact;
|
||||
|
||||
/* space file */
|
||||
/* to have something initialized */
|
||||
btheme->tfile= btheme->tv3d;
|
||||
@@ -518,20 +521,6 @@ void ui_theme_init_userdef(void)
|
||||
SETCOL(btheme->tfile.scene, 250, 250, 250, 255);
|
||||
|
||||
|
||||
|
||||
|
||||
/* space nla */
|
||||
btheme->tnla= btheme->tv3d;
|
||||
SETCOL(btheme->tnla.back, 116, 116, 116, 255);
|
||||
SETCOL(btheme->tnla.text, 0, 0, 0, 255);
|
||||
SETCOL(btheme->tnla.text_hi, 255, 255, 255, 255);
|
||||
SETCOL(btheme->tnla.grid, 94, 94, 94, 255);
|
||||
SETCOL(btheme->tnla.shade1, 172, 172, 172, 255); // sliders
|
||||
SETCOL(btheme->tnla.shade2, 84, 44, 31, 100); // bar
|
||||
SETCOL(btheme->tnla.hilite, 17, 27, 60, 100); // bar
|
||||
SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
|
||||
SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
|
||||
|
||||
/* space seq */
|
||||
btheme->tseq= btheme->tv3d;
|
||||
SETCOL(btheme->tseq.back, 116, 116, 116, 255);
|
||||
|
||||
@@ -207,6 +207,23 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
}
|
||||
break;
|
||||
|
||||
/* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
|
||||
* zoom, aspect ratio, and alignment restrictions are set here */
|
||||
case V2D_COMMONVIEW_STACK:
|
||||
{
|
||||
/* zoom + aspect ratio are locked */
|
||||
v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT);
|
||||
v2d->minzoom= v2d->maxzoom= 1.0f;
|
||||
|
||||
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
|
||||
v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
|
||||
v2d->keeptot = V2D_KEEPTOT_STRICT;
|
||||
tot_changed= 1;
|
||||
|
||||
/* scroller settings are currently not set here... that is left for regions... */
|
||||
}
|
||||
break;
|
||||
|
||||
/* 'header' regions - zoom, aspect ratio, alignment, and panning restrictions are set here */
|
||||
case V2D_COMMONVIEW_HEADER:
|
||||
{
|
||||
@@ -245,14 +262,14 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
|
||||
v2d->tot.xmin= 0.0f;
|
||||
v2d->tot.xmax= winx;
|
||||
|
||||
|
||||
v2d->tot.ymax= 0.0f;
|
||||
v2d->tot.ymin= -winy;
|
||||
|
||||
|
||||
v2d->cur= v2d->tot;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
/* other view types are completely defined using their own settings already */
|
||||
default:
|
||||
/* we don't do anything here, as settings should be fine, but just make sure that rect */
|
||||
|
||||
@@ -192,7 +192,7 @@ static SpaceLink *graph_duplicate(SpaceLink *sl)
|
||||
SpaceIpo *sipon= MEM_dupallocN(sl);
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
//sipon->ipokey.first= sipon->ipokey.last= NULL;
|
||||
BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves);
|
||||
sipon->ads= MEM_dupallocN(sipon->ads);
|
||||
|
||||
return (SpaceLink *)sipon;
|
||||
|
||||
480
source/blender/editors/space_nla/nla_draw.c
Normal file
480
source/blender/editors/space_nla/nla_draw.c
Normal file
@@ -0,0 +1,480 @@
|
||||
/**
|
||||
* $Id:
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Joshua Leung (major recode)
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_camera_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_constraint_types.h"
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_lamp_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_interface_icons.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "ED_markers.h"
|
||||
|
||||
#include "nla_intern.h" // own include
|
||||
|
||||
/* XXX */
|
||||
extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
/* *********************************************** */
|
||||
/* Channel List */
|
||||
|
||||
void draw_nla_channel_list (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));
|
||||
if (height > (v2d->mask.ymax - v2d->mask.ymin)) {
|
||||
/* don't use totrect set, as the width stays the same
|
||||
* (NOTE: this is ok here, the configuration is pretty straightforward)
|
||||
*/
|
||||
v2d->tot.ymax= (float)(height);
|
||||
}
|
||||
|
||||
/* loop through channels, and set up drawing depending on their type */
|
||||
y= (float)(-NLACHANNEL_FIRST);
|
||||
|
||||
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) )
|
||||
{
|
||||
short indent= 0, offset= 0, sel= 0, group= 0;
|
||||
int expand= -1, protect = -1, special= -1, mute = -1;
|
||||
char name[128];
|
||||
|
||||
/* determine what needs to be drawn */
|
||||
switch (ale->type) {
|
||||
case ANIMTYPE_SCENE: /* scene */
|
||||
{
|
||||
Scene *sce= (Scene *)ale->data;
|
||||
|
||||
group= 4;
|
||||
indent= 0;
|
||||
|
||||
special= ICON_SCENE_DATA;
|
||||
|
||||
/* only show expand if there are any channels */
|
||||
if (EXPANDED_SCEC(sce))
|
||||
expand= ICON_TRIA_UP;
|
||||
else
|
||||
expand= ICON_TRIA_RIGHT;
|
||||
|
||||
sel = SEL_SCEC(sce);
|
||||
strcpy(name, sce->id.name+2);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_OBJECT: /* object */
|
||||
{
|
||||
Base *base= (Base *)ale->data;
|
||||
Object *ob= base->object;
|
||||
|
||||
group= 4;
|
||||
indent= 0;
|
||||
|
||||
/* icon depends on object-type */
|
||||
if (ob->type == OB_ARMATURE)
|
||||
special= ICON_ARMATURE_DATA;
|
||||
else
|
||||
special= ICON_OBJECT_DATA;
|
||||
|
||||
/* only show expand if there are any channels */
|
||||
if (EXPANDED_OBJC(ob))
|
||||
expand= ICON_TRIA_UP;
|
||||
else
|
||||
expand= ICON_TRIA_RIGHT;
|
||||
|
||||
sel = SEL_OBJC(base);
|
||||
strcpy(name, ob->id.name+2);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_FILLMATD: /* object materials (dopesheet) expand widget */
|
||||
{
|
||||
Object *ob = (Object *)ale->data;
|
||||
|
||||
group = 4;
|
||||
indent = 1;
|
||||
special = ICON_MATERIAL_DATA;
|
||||
|
||||
if (FILTER_MAT_OBJC(ob))
|
||||
expand = ICON_TRIA_UP;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
strcpy(name, "Materials");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ANIMTYPE_DSMAT: /* single material (dopesheet) expand widget */
|
||||
{
|
||||
Material *ma = (Material *)ale->data;
|
||||
|
||||
group = 0;
|
||||
indent = 0;
|
||||
special = ICON_MATERIAL_DATA;
|
||||
offset = 21;
|
||||
|
||||
if (FILTER_MAT_OBJD(ma))
|
||||
expand = ICON_TRIA_UP;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
strcpy(name, ma->id.name+2);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_DSLAM: /* lamp (dopesheet) expand widget */
|
||||
{
|
||||
Lamp *la = (Lamp *)ale->data;
|
||||
|
||||
group = 4;
|
||||
indent = 1;
|
||||
special = ICON_LAMP_DATA;
|
||||
|
||||
if (FILTER_LAM_OBJD(la))
|
||||
expand = ICON_TRIA_UP;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
strcpy(name, la->id.name+2);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_DSCAM: /* camera (dopesheet) expand widget */
|
||||
{
|
||||
Camera *ca = (Camera *)ale->data;
|
||||
|
||||
group = 4;
|
||||
indent = 1;
|
||||
special = ICON_CAMERA_DATA;
|
||||
|
||||
if (FILTER_CAM_OBJD(ca))
|
||||
expand = ICON_TRIA_UP;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
strcpy(name, ca->id.name+2);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_DSCUR: /* curve (dopesheet) expand widget */
|
||||
{
|
||||
Curve *cu = (Curve *)ale->data;
|
||||
|
||||
group = 4;
|
||||
indent = 1;
|
||||
special = ICON_CURVE_DATA;
|
||||
|
||||
if (FILTER_CUR_OBJD(cu))
|
||||
expand = ICON_TRIA_UP;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
strcpy(name, cu->id.name+2);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_DSSKEY: /* shapekeys (dopesheet) expand widget */
|
||||
{
|
||||
Key *key= (Key *)ale->data;
|
||||
|
||||
group = 4;
|
||||
indent = 1;
|
||||
special = ICON_SHAPEKEY_DATA; // XXX
|
||||
|
||||
if (FILTER_SKE_OBJD(key))
|
||||
expand = ICON_TRIA_UP;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
//sel = SEL_OBJC(base);
|
||||
strcpy(name, "Shape Keys");
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_DSWOR: /* world (dopesheet) expand widget */
|
||||
{
|
||||
World *wo= (World *)ale->data;
|
||||
|
||||
group = 4;
|
||||
indent = 1;
|
||||
special = ICON_WORLD_DATA;
|
||||
|
||||
if (FILTER_WOR_SCED(wo))
|
||||
expand = ICON_TRIA_DOWN;
|
||||
else
|
||||
expand = ICON_TRIA_RIGHT;
|
||||
|
||||
strcpy(name, wo->id.name+2);
|
||||
}
|
||||
break;
|
||||
|
||||
case ANIMTYPE_NLATRACK: /* NLA Track */
|
||||
{
|
||||
NlaTrack *nlt= (NlaTrack *)ale->data;
|
||||
|
||||
indent= 0;
|
||||
|
||||
if (ale->id) {
|
||||
/* special exception for materials */
|
||||
if (GS(ale->id->name) == ID_MA) {
|
||||
offset= 21;
|
||||
indent= 1;
|
||||
}
|
||||
else
|
||||
offset= 14;
|
||||
}
|
||||
else
|
||||
offset= 0;
|
||||
|
||||
/* FIXME: 'solo' as the 'special' button?
|
||||
* - need special icons for these
|
||||
*/
|
||||
if (nlt->flag & NLATRACK_SOLO)
|
||||
special= ICON_LAYER_ACTIVE;
|
||||
else
|
||||
special= ICON_LAYER_USED;
|
||||
|
||||
if (nlt->flag & NLATRACK_MUTED)
|
||||
mute = ICON_MUTE_IPO_ON;
|
||||
else
|
||||
mute = ICON_MUTE_IPO_OFF;
|
||||
|
||||
if (EDITABLE_NLT(nlt))
|
||||
protect = ICON_UNLOCKED;
|
||||
else
|
||||
protect = ICON_LOCKED;
|
||||
|
||||
strcpy(name, nlt->name);
|
||||
}
|
||||
break;
|
||||
case ANIMTYPE_NLAACTION: /* NLA Action-Line */
|
||||
{
|
||||
bAction *act= (bAction *)ale->data;
|
||||
|
||||
group = 5;
|
||||
|
||||
if (ale->id) {
|
||||
/* special exception for materials */
|
||||
if (GS(ale->id->name) == ID_MA) {
|
||||
offset= 21;
|
||||
indent= 1;
|
||||
}
|
||||
else
|
||||
offset= 14;
|
||||
}
|
||||
else
|
||||
offset= 0;
|
||||
|
||||
special = ICON_ACTION;
|
||||
|
||||
if (act)
|
||||
sprintf(name, "ActAction: <%s>", act->id.name+2);
|
||||
else
|
||||
sprintf(name, "<No Action>");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* now, start drawing based on this information */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* draw backing strip behind channel name */
|
||||
if (group == 4) {
|
||||
/* only used in dopesheet... */
|
||||
if (ELEM(ale->type, ANIMTYPE_SCENE, ANIMTYPE_OBJECT)) {
|
||||
/* object channel - darker */
|
||||
UI_ThemeColor(TH_DOPESHEET_CHANNELOB);
|
||||
uiSetRoundBox((expand == ICON_TRIA_UP)? (8):(1|8));
|
||||
gl_round_box(GL_POLYGON, x+offset, yminc, (float)NLACHANNEL_NAMEWIDTH, ymaxc, 8);
|
||||
}
|
||||
else {
|
||||
/* sub-object folders - lighter */
|
||||
UI_ThemeColor(TH_DOPESHEET_CHANNELSUBOB);
|
||||
|
||||
offset += 7 * indent;
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(x+offset, yminc);
|
||||
glVertex2f(x+offset, ymaxc);
|
||||
glVertex2f((float)ACHANNEL_NAMEWIDTH, ymaxc);
|
||||
glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc);
|
||||
glEnd();
|
||||
|
||||
/* clear group value, otherwise we cause errors... */
|
||||
group = 0;
|
||||
}
|
||||
}
|
||||
else if (group == 5) {
|
||||
/* Action Line */
|
||||
if (ale->data)
|
||||
glColor3f(0.8f, 0.2f, 0.0f); // reddish color - hardcoded for now
|
||||
else
|
||||
glColor3f(0.6f, 0.5f, 0.5f); // greyish-red color - hardcoded for now
|
||||
|
||||
offset += 7 * indent;
|
||||
uiSetRoundBox(15);
|
||||
gl_round_box(GL_POLYGON, x+offset, yminc, (float)NLACHANNEL_NAMEWIDTH, ymaxc, 8);
|
||||
|
||||
/* clear group value, otherwise we cause errors... */
|
||||
group = 0;
|
||||
}
|
||||
else {
|
||||
/* for normal channels
|
||||
* - use 3 shades of color group/standard color for 3 indention level
|
||||
*/
|
||||
UI_ThemeColorShade(TH_HEADER, ((indent==0)?20: (indent==1)?-20: -40));
|
||||
|
||||
indent += group;
|
||||
offset += 7 * indent;
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(x+offset, yminc);
|
||||
glVertex2f(x+offset, ymaxc);
|
||||
glVertex2f((float)NLACHANNEL_NAMEWIDTH, ymaxc);
|
||||
glVertex2f((float)NLACHANNEL_NAMEWIDTH, yminc);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/* draw expand/collapse triangle */
|
||||
if (expand > 0) {
|
||||
UI_icon_draw(x+offset, ydatac, expand);
|
||||
offset += 17;
|
||||
}
|
||||
|
||||
/* draw special icon indicating certain data-types */
|
||||
if (special > -1) {
|
||||
/* for normal channels */
|
||||
UI_icon_draw(x+offset, ydatac, special);
|
||||
offset += 17;
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* draw name */
|
||||
if (sel)
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
else
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
offset += 3;
|
||||
UI_DrawString(x+offset, y-4, name);
|
||||
|
||||
/* reset offset - for RHS of panel */
|
||||
offset = 0;
|
||||
|
||||
/* set blending again, as text drawing may clear it */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* draw protect 'lock' */
|
||||
if (protect > -1) {
|
||||
offset = 16;
|
||||
UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, protect);
|
||||
}
|
||||
|
||||
/* draw mute 'eye' */
|
||||
if (mute > -1) {
|
||||
offset += 16;
|
||||
UI_icon_draw((float)(NLACHANNEL_NAMEWIDTH-offset), ydatac, mute);
|
||||
}
|
||||
|
||||
/* draw action 'push-down' */
|
||||
if (ale->type == ANIMTYPE_NLAACTION) {
|
||||
offset += 16;
|
||||
UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE);
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* adjust y-position for next one */
|
||||
y += NLACHANNEL_STEP;
|
||||
}
|
||||
|
||||
/* free tempolary channels */
|
||||
BLI_freelistN(&anim_data);
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
75
source/blender/editors/space_nla/nla_edit.c
Normal file
75
source/blender/editors/space_nla/nla_edit.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* $Id:
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Contributor(s): Joshua Leung (major recode)
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_nla_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "ED_markers.h"
|
||||
|
||||
#include "nla_intern.h" // own include
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
/* *********************************************** */
|
||||
@@ -29,6 +29,10 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_nla_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
@@ -37,26 +41,36 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_types.h"
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "nla_intern.h"
|
||||
#include "ED_markers.h"
|
||||
|
||||
/* button events */
|
||||
enum {
|
||||
B_REDR = 0,
|
||||
} eActHeader_ButEvents;
|
||||
|
||||
/* ************************ header area region *********************** */
|
||||
|
||||
@@ -93,13 +107,17 @@ static uiBlock *dummy_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
|
||||
static void do_nla_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
switch (event) {
|
||||
case B_REDR:
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nla_header_buttons(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
uiBlock *block;
|
||||
int xco, yco= 3;
|
||||
@@ -109,7 +127,7 @@ void nla_header_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
xco= ED_area_header_standardbuttons(C, block, yco);
|
||||
|
||||
if((sa->flag & HEADER_NO_PULLDOWN)==0) {
|
||||
if ((sa->flag & HEADER_NO_PULLDOWN)==0) {
|
||||
int xmax;
|
||||
|
||||
xmax= GetButStringLength("View");
|
||||
@@ -119,7 +137,47 @@ void nla_header_buttons(const bContext *C, ARegion *ar)
|
||||
}
|
||||
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
|
||||
/* filtering buttons */
|
||||
if (snla->ads) {
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Only display selected Objects");
|
||||
uiDefIconButBitI(block, TOGN, ADS_FILTER_NLA_NOACT, B_REDR, ICON_ACTION, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Include AnimData blocks with no NLA Data");
|
||||
uiBlockEndAlign(block);
|
||||
xco += 5;
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Scene Animation");
|
||||
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display World Animation");
|
||||
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display ShapeKeys");
|
||||
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(snla->ads->filterflag), 0, 0, 0, 0, "Display Materials");
|
||||
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");
|
||||
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 += (XIC + 8);
|
||||
|
||||
/* auto-snap selector */
|
||||
if (snla->flag & SNLA_DRAWTIME) {
|
||||
uiDefButS(block, MENU, B_REDR,
|
||||
"Auto-Snap Keyframes %t|No Time-Snap %x0|Nearest Second %x2|Nearest Marker %x3",
|
||||
xco,yco,90,YIC, &snla->autosnap, 0, 1, 0, 0,
|
||||
"Auto-snapping mode for times when transforming");
|
||||
}
|
||||
else {
|
||||
uiDefButS(block, MENU, B_REDR,
|
||||
"Auto-Snap Keyframes %t|No Time-Snap %x0|Nearest Frame %x2|Nearest Marker %x3",
|
||||
xco,yco,90,YIC, &snla->autosnap, 0, 1, 0, 0,
|
||||
"Auto-snapping mode for times when transforming");
|
||||
}
|
||||
xco += 98;
|
||||
|
||||
/* always as last */
|
||||
UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
|
||||
|
||||
|
||||
@@ -30,8 +30,30 @@
|
||||
|
||||
/* internal exports only */
|
||||
|
||||
/* -------------- NLA Channel Defines -------------- */
|
||||
|
||||
/* NLA channel heights */
|
||||
#define NLACHANNEL_FIRST -16
|
||||
#define NLACHANNEL_HEIGHT 24
|
||||
#define NLACHANNEL_HEIGHT_HALF 12
|
||||
#define NLACHANNEL_SKIP 2
|
||||
#define NLACHANNEL_STEP (NLACHANNEL_HEIGHT + NLACHANNEL_SKIP)
|
||||
|
||||
/* channel widths */
|
||||
#define NLACHANNEL_NAMEWIDTH 200
|
||||
|
||||
/* channel toggle-buttons */
|
||||
#define NLACHANNEL_BUTTON_WIDTH 16
|
||||
|
||||
|
||||
/* **************************************** */
|
||||
/* nla_draw.c */
|
||||
|
||||
void draw_nla_channel_list(bAnimContext *ac, SpaceNla *snla, ARegion *ar);
|
||||
|
||||
/* **************************************** */
|
||||
/* nla_header.c */
|
||||
|
||||
void nla_header_buttons(const bContext *C, ARegion *ar);
|
||||
|
||||
|
||||
|
||||
@@ -42,10 +42,16 @@
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "ED_anim_api.h"
|
||||
#include "ED_markers.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
@@ -58,8 +64,6 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "ED_markers.h"
|
||||
|
||||
#include "nla_intern.h" // own include
|
||||
|
||||
/* ******************** default callbacks for nla space ***************** */
|
||||
@@ -73,7 +77,7 @@ static SpaceLink *nla_new(const bContext *C)
|
||||
snla->spacetype= SPACE_NLA;
|
||||
|
||||
/* allocate DopeSheet data for NLA Editor */
|
||||
snla->ads= MEM_callocN(sizeof(bDopeSheet), "NLAEdit DopeSheet");
|
||||
snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
|
||||
|
||||
/* header */
|
||||
ar= MEM_callocN(sizeof(ARegion), "header for nla");
|
||||
@@ -82,13 +86,15 @@ static SpaceLink *nla_new(const bContext *C)
|
||||
ar->regiontype= RGN_TYPE_HEADER;
|
||||
ar->alignment= RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* channel list region XXX */
|
||||
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
|
||||
/* channel list region */
|
||||
ar= MEM_callocN(sizeof(ARegion), "channel list for nla");
|
||||
BLI_addtail(&snla->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_CHANNELS;
|
||||
ar->alignment= RGN_ALIGN_LEFT;
|
||||
|
||||
ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
|
||||
/* only need to set these settings since this will use the 'stack' configuration */
|
||||
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
|
||||
/* main area */
|
||||
ar= MEM_callocN(sizeof(ARegion), "main area for nla");
|
||||
@@ -115,10 +121,11 @@ static SpaceLink *nla_new(const bContext *C)
|
||||
ar->v2d.minzoom= 0.1f;
|
||||
ar->v2d.maxzoom= 50.0f;
|
||||
|
||||
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
||||
ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
|
||||
|
||||
ar->v2d.align= V2D_ALIGN_NO_NEG_Y;
|
||||
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
||||
|
||||
return (SpaceLink *)snla;
|
||||
}
|
||||
@@ -138,7 +145,13 @@ static void nla_free(SpaceLink *sl)
|
||||
/* spacetype; init callback */
|
||||
static void nla_init(struct wmWindowManager *wm, ScrArea *sa)
|
||||
{
|
||||
SpaceNla *snla= (SpaceNla *)sa->spacedata.first;
|
||||
|
||||
/* init dopesheet data if non-existant (i.e. for old files) */
|
||||
if (snla->ads == NULL)
|
||||
snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
|
||||
|
||||
ED_area_tag_refresh(sa);
|
||||
}
|
||||
|
||||
static SpaceLink *nla_duplicate(SpaceLink *sl)
|
||||
@@ -146,15 +159,31 @@ static SpaceLink *nla_duplicate(SpaceLink *sl)
|
||||
SpaceNla *snlan= MEM_dupallocN(sl);
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
snlan->ads= MEM_dupallocN(snlan->ads);
|
||||
|
||||
return (SpaceLink *)snlan;
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
{
|
||||
//ListBase *keymap;
|
||||
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STACK, ar->winx, ar->winy);
|
||||
|
||||
/* own keymap */
|
||||
// TODO: cannot use generic copy, need special NLA version
|
||||
//keymap= WM_keymap_listbase(wm, "Animation_Channels", 0, 0); /* XXX weak? */
|
||||
//WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
}
|
||||
|
||||
/* draw entirely, view changes should be handled here */
|
||||
static void nla_channel_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
// SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C);
|
||||
// View2D *v2d= &ar->v2d;
|
||||
SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C);
|
||||
bAnimContext ac;
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2DScrollers *scrollers;
|
||||
float col[3];
|
||||
|
||||
/* clear and setup matrix */
|
||||
@@ -162,15 +191,20 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar)
|
||||
glClearColor(col[0], col[1], col[2], 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// UI_view2d_view_ortho(C, v2d);
|
||||
|
||||
/* data... */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
|
||||
/* data */
|
||||
if (ANIM_animdata_get_context(C, &ac)) {
|
||||
draw_nla_channel_list(&ac, snla, ar);
|
||||
}
|
||||
|
||||
/* reset view matrix */
|
||||
//UI_view2d_view_restore(C);
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers? */
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
|
||||
|
||||
@@ -189,9 +223,13 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
static void nla_main_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
// SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C);
|
||||
SpaceNla *snla= (SpaceNla*)CTX_wm_space_data(C);
|
||||
bAnimContext ac;
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2DGrid *grid;
|
||||
View2DScrollers *scrollers;
|
||||
float col[3];
|
||||
short unit=0, flag=0;
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
@@ -199,14 +237,38 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
|
||||
/* data... */
|
||||
|
||||
/* time grid */
|
||||
unit= (snla->flag & SNLA_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
|
||||
grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
|
||||
UI_view2d_grid_draw(C, v2d, grid, V2D_GRIDLINES_ALL);
|
||||
UI_view2d_grid_free(grid);
|
||||
|
||||
/* data */
|
||||
if (ANIM_animdata_get_context(C, &ac)) {
|
||||
//draw_channel_strips(&ac, saction, ar);
|
||||
}
|
||||
|
||||
/* current frame */
|
||||
if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS;
|
||||
if ((snla->flag & SNLA_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX;
|
||||
ANIM_draw_cfra(C, v2d, flag);
|
||||
|
||||
/* markers */
|
||||
UI_view2d_view_orthoSpecial(C, v2d, 1);
|
||||
draw_markers_time(C, 0);
|
||||
|
||||
/* preview range */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
ANIM_draw_previewrange(C, v2d);
|
||||
|
||||
/* reset view matrix */
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers? */
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
|
||||
void nla_operatortypes(void)
|
||||
@@ -250,6 +312,82 @@ static void nla_header_area_draw(const bContext *C, ARegion *ar)
|
||||
static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
switch(wmn->data) {
|
||||
case ND_OB_ACTIVE:
|
||||
case ND_FRAME:
|
||||
case ND_MARKERS:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_OBJECT:
|
||||
switch(wmn->data) {
|
||||
case ND_BONE_ACTIVE:
|
||||
case ND_BONE_SELECT:
|
||||
case ND_KEYS:
|
||||
case ND_TRANSFORM:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
|
||||
static void nla_channel_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
switch(wmn->data) {
|
||||
case ND_OB_ACTIVE:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case NC_OBJECT:
|
||||
switch(wmn->data) {
|
||||
case ND_BONE_ACTIVE:
|
||||
case ND_BONE_SELECT:
|
||||
case ND_KEYS:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(wmn->data==ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
|
||||
/* editor level listener */
|
||||
static void nla_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch (wmn->category) {
|
||||
case NC_SCENE:
|
||||
/*switch (wmn->data) {
|
||||
case ND_OB_ACTIVE:
|
||||
case ND_OB_SELECT:
|
||||
ED_area_tag_refresh(sa);
|
||||
break;
|
||||
}*/
|
||||
ED_area_tag_refresh(sa);
|
||||
break;
|
||||
case NC_OBJECT:
|
||||
/*switch (wmn->data) {
|
||||
case ND_BONE_SELECT:
|
||||
case ND_BONE_ACTIVE:
|
||||
ED_area_tag_refresh(sa);
|
||||
break;
|
||||
}*/
|
||||
ED_area_tag_refresh(sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* only called once, from space/spacetypes.c */
|
||||
@@ -265,6 +403,7 @@ void ED_spacetype_nla(void)
|
||||
st->init= nla_init;
|
||||
st->duplicate= nla_duplicate;
|
||||
st->operatortypes= nla_operatortypes;
|
||||
st->listener= nla_listener;
|
||||
st->keymap= nla_keymap;
|
||||
|
||||
/* regions: main window */
|
||||
@@ -273,7 +412,7 @@ void ED_spacetype_nla(void)
|
||||
art->init= nla_main_area_init;
|
||||
art->draw= nla_main_area_draw;
|
||||
art->listener= nla_main_area_listener;
|
||||
art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
|
||||
art->keymapflag= ED_KEYMAP_VIEW2D/*|ED_KEYMAP_MARKERS*/|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
@@ -294,8 +433,9 @@ void ED_spacetype_nla(void)
|
||||
art->minsizex= 200;
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
|
||||
//art->init= nla_channel_area_init;
|
||||
art->init= nla_channel_area_init;
|
||||
art->draw= nla_channel_area_draw;
|
||||
art->listener= nla_channel_area_listener;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
|
||||
@@ -288,9 +288,10 @@ typedef struct bDopeSheet {
|
||||
/* DopeSheet filter-flag */
|
||||
typedef enum DOPESHEET_FILTERFLAG {
|
||||
/* general filtering */
|
||||
ADS_FILTER_ONLYSEL = (1<<0),
|
||||
ADS_FILTER_ONLYDRIVERS = (1<<1),
|
||||
ADS_FILTER_ONLYNLA = (1<<2),
|
||||
ADS_FILTER_ONLYSEL = (1<<0), /* only include channels relating to selected data */
|
||||
|
||||
ADS_FILTER_ONLYDRIVERS = (1<<1), /* for 'Drivers' editor - only include Driver data from AnimData */
|
||||
ADS_FILTER_ONLYNLA = (1<<2), /* for 'NLA' editor - only include NLA data from AnimData */
|
||||
|
||||
/* datatype-based filtering */
|
||||
ADS_FILTER_NOSHAPEKEYS = (1<<6),
|
||||
@@ -301,9 +302,11 @@ typedef enum DOPESHEET_FILTERFLAG {
|
||||
ADS_FILTER_NOWOR = (1<<14),
|
||||
ADS_FILTER_NOSCE = (1<<15),
|
||||
|
||||
/* NLA-specific filters */
|
||||
ADS_FILTER_NLA_NOACT = (1<<20), /* if the AnimData block has no NLA data, don't include to just show Action-line */
|
||||
|
||||
/* combination filters (some only used at runtime) */
|
||||
ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM|ADS_FILTER_NOMAT|ADS_FILTER_NOLAM|ADS_FILTER_NOCUR),
|
||||
ADS_FILTER_NLADUMMY = (ADS_FILTER_NOSHAPEKEYS|ADS_FILTER_NOOBDATA),
|
||||
} DOPESHEET_FILTERFLAG;
|
||||
|
||||
/* DopeSheet general flags */
|
||||
|
||||
Reference in New Issue
Block a user