Ejemplo n.º 1
0
// TODO: depreceate this code...
static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y)
{
	bAnimListElem *ale;
	float x = 0.0f;
	
	/* 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) ) 
		{
			short indent= 0, offset= 0, sel= 0, group= 0;
			int expand= -1, protect = -1, special= -1, mute = -1;
			char name[128];
			short doDraw=0;
			
			/* determine what needs to be drawn */
			switch (ale->type) {
				case ANIMTYPE_NLATRACK: /* NLA Track */
				{
					NlaTrack *nlt= (NlaTrack *)ale->data;
					
					indent= 0;
					
					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;
					
					/* 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 this track is active and we're tweaking it, don't draw these toggles */
					// TODO: need a special macro for this...
					if ( ((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0 ) 
					{
						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;
					}
						
					sel = SEL_NLT(nlt);
					strcpy(name, nlt->name);
					
					// draw manually still
					doDraw= 1;
				}
					break;
				case ANIMTYPE_NLAACTION: /* NLA Action-Line */
				{
					bAction *act= (bAction *)ale->data;
					
					group = 5;
					
					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;
					
					special = ICON_ACTION;
					
					if (act)
						sprintf(name, "ActAction: <%s>", act->id.name+2);
					else
						sprintf(name, "<No Action>");
						
					// draw manually still
					doDraw= 1;
				}
					break;
					
				default: /* handled by standard channel-drawing API */
					// draw backdrops only...
					ANIM_channel_draw(ac, ale, yminc, ymaxc);
					break;
			}	
			
			/* if special types, draw manually for now... */
			if (doDraw) {
				/* 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 == 5) {
					/* Action Line */
					AnimData *adt= ale->adt;
					
					// TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now)
					if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
						// greenish color (same as tweaking strip) - hardcoded for now
						glColor3f(0.3f, 0.95f, 0.1f);
					}
					else {
						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;
					
					/* only on top two corners, to show that this channel sits on top of the preceeding ones */
					uiSetRoundBox((1|2)); 
					
					/* draw slightly shifted up vertically to look like it has more separtion from other channels,
					 * but we then need to slightly shorten it so that it doesn't look like it overlaps
					 */
					gl_round_box(GL_POLYGON, x+offset,  yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 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)v2d->cur.xmax, ymaxc);
						glVertex2f((float)v2d->cur.xmax, 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)(v2d->cur.xmax-offset), ydatac, protect);
				}
				
				/* draw mute 'eye' */
				if (mute > -1) {
					offset += 16;
					UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute);
				}
				
				/* draw NLA-action line 'status-icons' - only when there's an action */
				if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) {
					AnimData *adt= ale->adt;
					
					offset += 16;
					
					/* now draw some indicator icons  */
					if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
						/* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */
						// for now, use pin icon to symbolise this
						if (adt->flag & ADT_NLA_EDIT_NOMAP)
							UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED);
						else
							UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED);
						
						fdrawline((float)(v2d->cur.xmax-offset), yminc, 
								  (float)(v2d->cur.xmax-offset), ymaxc);
						offset += 16;;
						
						/* 'tweaking action' indicator - not a button */
						UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); 
					}
					else {
						/* XXX firstly draw a little rect to help identify that it's different from the toggles */
						glBegin(GL_LINE_LOOP);
							glVertex2f((float)v2d->cur.xmax-offset-1, y-7);
							glVertex2f((float)v2d->cur.xmax-offset-1, y+9);
							glVertex2f((float)v2d->cur.xmax-1, y+9);
							glVertex2f((float)v2d->cur.xmax-1, y-7);
						glEnd(); // GL_LINES
						
						/* 'push down' icon for normal active-actions */
						UI_icon_draw((float)NLACHANNEL_NAMEWIDTH-offset, ydatac, ICON_FREEZE);
					}
				}
				
				glDisable(GL_BLEND);
			}
		}
		
		/* adjust y-position for next one */
		y -= NLACHANNEL_STEP;
	}
}
Ejemplo n.º 2
0
// TODO: depreceate this code...
static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y)
{
	SpaceNla *snla = (SpaceNla *)ac->sl;
	bAnimListElem *ale;
	float x = 0.0f;
	
	/* 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(snla));
		const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla));
		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) )
		{
			AnimData *adt = ale->adt;
			
			short indent = 0, offset = 0, sel = 0, group = 0, nonSolo = 0;
			int expand = -1, protect = -1, special = -1, mute = -1;
			char name[128];
			short do_draw = FALSE;
			
			/* determine what needs to be drawn */
			switch (ale->type) {
				case ANIMTYPE_NLATRACK: /* NLA Track */
				{
					NlaTrack *nlt = (NlaTrack *)ale->data;
					
					/* 'solo' as the 'special' button? */
					if (nlt->flag & NLATRACK_SOLO)
						special = ICON_SOLO_ON;
					else
						special = ICON_SOLO_OFF;
						
					/* if this track is active and we're tweaking it, don't draw these toggles */
					// TODO: need a special macro for this...
					if (((nlt->flag & NLATRACK_ACTIVE) && (nlt->flag & NLATRACK_DISABLED)) == 0) {
						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;
					}
					
					/* is track enabled for solo drawing? */
					if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) {
						if ((nlt->flag & NLATRACK_SOLO) == 0) {
							/* tag for special non-solo handling; also hide the mute toggles */
							nonSolo = 1;
							mute = 0;
						}
					}
						
					sel = SEL_NLT(nlt);
					BLI_strncpy(name, nlt->name, sizeof(name));
					
					/* draw manually still */
					do_draw = TRUE;
				}
				break;
				case ANIMTYPE_NLAACTION: /* NLA Action-Line */
				{
					bAction *act = (bAction *)ale->data;
					
					group = 5;
					
					special = ICON_ACTION;
					
					if (act)
						BLI_snprintf(name, sizeof(name), "%s", act->id.name + 2);
					else
						BLI_strncpy(name, "<No Action>", sizeof(name));
						
					/* draw manually still */
					do_draw = TRUE;
				}
				break;
					
				default: /* handled by standard channel-drawing API */
					// draw backdrops only...
					ANIM_channel_draw(ac, ale, yminc, ymaxc);
					break;
			}	
			
			/* if special types, draw manually for now... */
			if (do_draw) {
				if (ale->id) {
					/* special exception for textures */
					if (GS(ale->id->name) == ID_TE) {
						offset = 14;
						indent = 1;
					}
					/* special exception for nodetrees */
					else if (GS(ale->id->name) == ID_NT) {
						bNodeTree *ntree = (bNodeTree *)ale->id;
						
						switch (ntree->type) {
							case NTREE_SHADER:
							{
								/* same as for textures */
								offset = 14;
								indent = 1;
							}
							break;
								
							case NTREE_TEXTURE:
							{
								/* even more */
								offset = 21;
								indent = 1;
							}	
							break;
								
							default:
								/* normal will do */
								offset = 14;
								break;
						}
					}
					else {
						offset = 14;
					}
				}
				else {
					offset = 0;
				}
				
				/* 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 */
				// FIXME: hardcoded colors!!!
				if (group == 5) {
					float color[4];
					
					/* Action Line
					 *   The alpha values action_get_color returns are only useful for drawing 
					 *   strips backgrounds but here we're doing channel list backgrounds instead
					 *   so we ignore that and use our own when needed
					 */
					nla_action_get_color(adt, (bAction *)ale->data, color);
					
					if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
						/* Yes, the color vector has 4 components, BUT we only want to be using 3 of them! */
						glColor3fv(color);
					}
					else {
						float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3 : 1.0f;
						glColor4f(color[0], color[1], color[2], alpha);
					}
					
					offset += 7 * indent;
					
					/* only on top two corners, to show that this channel sits on top of the preceding ones */
					uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
					
					/* draw slightly shifted up vertically to look like it has more separation from other channels,
					 * but we then need to slightly shorten it so that it doesn't look like it overlaps
					 */
					uiDrawBox(GL_POLYGON, x + offset,  yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8);
					
					/* clear group value, otherwise we cause errors... */
					group = 0;
				}
				else {
					/* NLA tracks - darker color if not solo track when we're showing solo */
					UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0) ? 20 : -20));
					
					indent += group;
					offset += 7 * indent;
					glBegin(GL_QUADS);
					glVertex2f(x + offset, yminc);
					glVertex2f(x + offset, ymaxc);
					glVertex2f((float)v2d->cur.xmax, ymaxc);
					glVertex2f((float)v2d->cur.xmax, 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)(v2d->cur.xmax - offset), ydatac, protect);
				}
				
				/* draw mute 'eye' */
				if (mute > -1) {
					offset += 16;
					UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, mute);
				}
				
				/* draw NLA-action line 'status-icons' - only when there's an action */
				if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) {
					AnimData *adt = ale->adt;
					
					offset += 16;
					
					/* now draw some indicator icons  */
					if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
						/* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */
						// for now, use pin icon to symbolise this
						if (adt->flag & ADT_NLA_EDIT_NOMAP)
							UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_PINNED);
						else
							UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_UNPINNED);
						
						fdrawline((float)(v2d->cur.xmax - offset), yminc,
						          (float)(v2d->cur.xmax - offset), ymaxc);
						offset += 16;
						
						/* 'tweaking action' indicator - not a button */
						UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_EDIT);
					}
					else {
						/* XXX firstly draw a little rect to help identify that it's different from the toggles */
						glBegin(GL_LINE_LOOP);
						glVertex2f((float)v2d->cur.xmax - offset - 1, y - 7);
						glVertex2f((float)v2d->cur.xmax - offset - 1, y + 9);
						glVertex2f((float)v2d->cur.xmax - 1, y + 9);
						glVertex2f((float)v2d->cur.xmax - 1, y - 7);
						glEnd(); // GL_LINES
						
						/* 'push down' icon for normal active-actions */
						UI_icon_draw((float)v2d->cur.xmax - offset, ydatac, ICON_FREEZE);
					}
				}
				
				glDisable(GL_BLEND);
			}
		}
		
		/* adjust y-position for next one */
		y -= NLACHANNEL_STEP(snla);
	}
}