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-11 15:52:23 +0400
committerJoshua Leung <aligorith@gmail.com>2009-08-11 15:52:23 +0400
commitb9584607c57720da9e443a42eff30d758c4075a0 (patch)
treef1eb2e01fb6af22a6c7f908b3e933c897799080e /source/blender/editors/space_action/action_draw.c
parent911078aaaddfab72eeea564f671f7e1a1c392300 (diff)
Animation Editors: Code Cleanup Part 1 - Drawing
Finally started refactoring the drawing code for animation editors so that all the drawing (of the channels/names list) is done using standardised code for all the editors. A little specialised system for this has been made, and is now used for DopeSheet and Graph Editor drawing. This should make it easier to add new channel types with less effort. Protect/mute toggles are now always clamped to the right-hand edge of the channels list. So you can now make the list wider to view longer names fully. However, since the mouse-handling hasn't been fixed yet, this won't always work. TODOs: * make mouse-click handling code use this system too, simplifying things to 1-2 lines of code there. Maybe this could be made to use UI widgets instead at a later date? * NLA still needs to be ported to this system
Diffstat (limited to 'source/blender/editors/space_action/action_draw.c')
-rw-r--r--source/blender/editors/space_action/action_draw.c570
1 files changed, 5 insertions, 565 deletions
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 6e86748adae..f5fa263eee8 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -404,7 +404,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
int filter;
View2D *v2d= &ar->v2d;
- float x= 0.0f, y= 0.0f;
+ float y= 0.0f;
int items, height;
/* build list of channels to draw */
@@ -431,575 +431,15 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
y= (float)ACHANNEL_FIRST;
for (ale= anim_data.first; ale; ale= ale->next) {
- const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
- const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF);
+ float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
+ float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF);
/* check if visible */
if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
{
- bActionGroup *grp = NULL;
- 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_DOWN;
- 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_DOWN;
- else
- expand= ICON_TRIA_RIGHT;
-
- sel = SEL_OBJC(base);
- strcpy(name, ob->id.name+2);
- }
- break;
- case ANIMTYPE_FILLACTD: /* action widget */
- {
- bAction *act= (bAction *)ale->data;
-
- group = 4;
- indent= 1;
- special= ICON_ACTION;
-
- if (EXPANDED_ACTC(act))
- expand= ICON_TRIA_DOWN;
- else
- expand= ICON_TRIA_RIGHT;
-
- sel = SEL_ACTC(act);
- strcpy(name, act->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_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
-
- strcpy(name, "Materials");
- }
- break;
- case ANIMTYPE_FILLPARTD: /* object particles (dopesheet) expand widget */
- {
- Object *ob = (Object *)ale->data;
-
- group = 4;
- indent = 1;
- special = ICON_PARTICLE_DATA;
-
- if (FILTER_PART_OBJC(ob))
- expand = ICON_TRIA_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
-
- strcpy(name, "Particles");
- }
- 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_DOWN;
- 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_DOWN;
- 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_DOWN;
- 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_DOWN;
- 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_DOWN;
- 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_DSPART: /* particle (dopesheet) expand widget */
- {
- ParticleSettings *part= (ParticleSettings*)ale->data;
-
- group = 0;
- indent = 0;
- special = ICON_PARTICLE_DATA;
- offset = 21;
-
- if (FILTER_PART_OBJD(part))
- expand = ICON_TRIA_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
-
- strcpy(name, part->id.name+2);
- }
- break;
- case ANIMTYPE_DSMBALL: /* metaball (dopesheet) expand widget */
- {
- MetaBall *mb = (MetaBall *)ale->data;
-
- group = 4;
- indent = 1;
- special = ICON_META_DATA;
-
- if (FILTER_MBALL_OBJD(mb))
- expand = ICON_TRIA_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
-
- strcpy(name, mb->id.name+2);
- }
- break;
-
-
- case ANIMTYPE_GROUP: /* action group */
- {
- bActionGroup *agrp= (bActionGroup *)ale->data;
-
- group= 2;
- indent= 0;
- special= -1;
-
- if (ale->id) {
- /* special exception for materials */
- if (GS(ale->id->name) == ID_MA)
- offset= 25;
- else
- offset= 14;
- }
- else
- offset= 0;
-
- /* only show expand if there are any channels */
- if (agrp->channels.first) {
- if (EXPANDED_AGRP(agrp))
- expand = ICON_TRIA_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
- }
-
- if (agrp->flag & AGRP_MUTED)
- mute = ICON_MUTE_IPO_ON;
- else
- mute = ICON_MUTE_IPO_OFF;
-
- if (EDITABLE_AGRP(agrp))
- protect = ICON_UNLOCKED;
- else
- protect = ICON_LOCKED;
-
- sel = SEL_AGRP(agrp);
- strcpy(name, agrp->name);
- }
- break;
- case ANIMTYPE_FCURVE: /* F-Curve channel */
- {
- FCurve *fcu = (FCurve *)ale->data;
-
- indent = 0;
-
- group= (fcu->grp) ? 1 : 0;
- grp= fcu->grp;
-
- if (ale->id) {
- /* special exception for materials and particles */
- if (ELEM(GS(ale->id->name),ID_MA,ID_PA)) {
- offset= 21;
- indent= 1;
- }
- else
- offset= 14;
- }
- else
- offset= 0;
-
- if (fcu->flag & FCURVE_MUTED)
- mute = ICON_MUTE_IPO_ON;
- else
- mute = ICON_MUTE_IPO_OFF;
-
- if (fcu->bezt) {
- if (EDITABLE_FCU(fcu))
- protect = ICON_UNLOCKED;
- else
- protect = ICON_LOCKED;
- }
- else
- protect = ICON_ZOOMOUT; // XXX editability is irrelevant here, but this icon is temp...
-
- sel = SEL_FCU(fcu);
-
- getname_anim_fcurve(name, ale->id, fcu);
- }
- break;
-
- case ANIMTYPE_SHAPEKEY: /* shapekey channel */
- {
- KeyBlock *kb = (KeyBlock *)ale->data;
-
- indent = 0;
- special = -1;
-
- offset= (ale->id) ? 21 : 0;
-
- if (kb->name[0] == '\0')
- sprintf(name, "Key %d", ale->index);
- else
- strcpy(name, kb->name);
- }
- break;
-
- case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */
- {
- bGPdata *gpd = (bGPdata *)ale->data;
- ScrArea *sa = (ScrArea *)ale->owner;
-
- indent = 0;
- group= 3;
-
- /* only show expand if there are any channels */
- if (gpd->layers.first) {
- if (gpd->flag & GP_DATA_EXPAND)
- expand = ICON_TRIA_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
- }
-
- switch (sa->spacetype) {
- case SPACE_VIEW3D:
- {
- /* this shouldn't cause any overflow... */
- //sprintf(name, "3DView:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func..
- strcpy(name, "3dView");
- special= ICON_VIEW3D;
- }
- break;
- case SPACE_NODE:
- {
- SpaceNode *snode= sa->spacedata.first;
- char treetype[12];
-
- if (snode->treetype == 1)
- strcpy(treetype, "Composite");
- else
- strcpy(treetype, "Material");
- sprintf(name, "Nodes:%s", treetype);
-
- special= ICON_NODE;
- }
- break;
- case SPACE_SEQ:
- {
- SpaceSeq *sseq= sa->spacedata.first;
- char imgpreview[10];
-
- switch (sseq->mainb) {
- case 1: sprintf(imgpreview, "Image..."); break;
- case 2: sprintf(imgpreview, "Luma..."); break;
- case 3: sprintf(imgpreview, "Chroma..."); break;
- case 4: sprintf(imgpreview, "Histogram"); break;
-
- default: sprintf(imgpreview, "Sequence"); break;
- }
- sprintf(name, "Sequencer:%s", imgpreview);
-
- special= ICON_SEQUENCE;
- }
- break;
- case SPACE_IMAGE:
- {
- SpaceImage *sima= sa->spacedata.first;
-
- if (sima->image)
- sprintf(name, "Image:%s", sima->image->id.name+2);
- else
- strcpy(name, "Image:<None>");
-
- special= ICON_IMAGE_COL;
- }
- break;
-
- default:
- {
- sprintf(name, "<Unknown GP-Data Source>");
- special= -1;
- }
- break;
- }
- }
- break;
- case ANIMTYPE_GPLAYER: /* gpencil layer */
- {
- bGPDlayer *gpl = (bGPDlayer *)ale->data;
-
- indent = 0;
- special = -1;
- expand = -1;
- group = 1;
-
- if (EDITABLE_GPL(gpl))
- protect = ICON_UNLOCKED;
- else
- protect = ICON_LOCKED;
-
- if (gpl->flag & GP_LAYER_HIDE)
- mute = ICON_MUTE_IPO_ON;
- else
- mute = ICON_MUTE_IPO_OFF;
-
- sel = SEL_GPL(gpl);
- BLI_snprintf(name, 32, gpl->info);
- }
- 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_DOWN)? (1):(1|8));
- gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_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 == 3) {
- /* only for gp-data channels */
- UI_ThemeColorShade(TH_GROUP, 20);
- uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8));
- gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8);
- }
- else if (group == 2) {
- /* only for action group channels */
- if (ale->flag & AGRP_ACTIVE)
- UI_ThemeColorShade(TH_GROUP_ACTIVE, 10);
- else
- UI_ThemeColorShade(TH_GROUP, 20);
- uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8));
- gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8);
- }
- else {
- /* for normal channels
- * - use 3 shades of color group/standard color for 3 indention level
- * - only use group colors if allowed to, and if actually feasible
- */
- if ( !(saction->flag & SACTION_NODRAWGCOLORS) &&
- (grp) && (grp->customCol) )
- {
- char cp[3];
-
- if (indent == 2) {
- VECCOPY(cp, grp->cs.solid);
- }
- else if (indent == 1) {
- VECCOPY(cp, grp->cs.select);
- }
- else {
- VECCOPY(cp, grp->cs.active);
- }
-
- glColor3ub(cp[0], cp[1], cp[2]);
- }
- else
- 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)ACHANNEL_NAMEWIDTH, ymaxc);
- glVertex2f((float)ACHANNEL_NAMEWIDTH, yminc);
- glEnd();
- }
-
- /* draw expand/collapse triangle */
- if (expand > 0) {
- UI_icon_draw(x+offset, yminc, expand);
- offset += 17;
- }
-
- /* draw special icon indicating certain data-types */
- if (special > -1) {
- if (ELEM(group, 3, 4)) {
- /* for gpdatablock channels */
- UI_icon_draw(x+offset, yminc, special);
- offset += 17;
- }
- else {
- /* for normal channels */
- UI_icon_draw(x+offset, yminc, 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)ACHANNEL_NAMEWIDTH-offset, yminc, protect);
- }
-
- /* draw mute 'eye' */
- if (mute > -1) {
- offset += 16;
- UI_icon_draw((float)(ACHANNEL_NAMEWIDTH-offset), yminc, mute);
- }
- glDisable(GL_BLEND);
+ /* draw all channels using standard channel-drawing API */
+ ANIM_channel_draw(ac, ale, yminc, ymaxc);
}
/* adjust y-position for next one */