[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22367] branches/blender2.5/blender/source /blender/editors: Animation Editors: Code Cleanup Part 1 - Drawing

Joshua Leung aligorith at gmail.com
Tue Aug 11 13:52:23 CEST 2009


Revision: 22367
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22367
Author:   aligorith
Date:     2009-08-11 13:52:23 +0200 (Tue, 11 Aug 2009)

Log Message:
-----------
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

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels_defines.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels_edit.c

Removed Paths:
-------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c

Deleted: branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-08-11 11:50:40 UTC (rev 22366)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-08-11 11:52:23 UTC (rev 22367)
@@ -1,2020 +0,0 @@
-/**
- * $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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Joshua Leung
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <float.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.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_particle_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_meta_types.h"
-#include "DNA_userdef_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_windowmanager_types.h"
-#include "DNA_world_types.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "BKE_animsys.h"
-#include "BKE_action.h"
-#include "BKE_depsgraph.h"
-#include "BKE_fcurve.h"
-#include "BKE_key.h"
-#include "BKE_material.h"
-#include "BKE_object.h"
-#include "BKE_context.h"
-#include "BKE_utildefines.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-#include "UI_view2d.h"
-
-#include "ED_anim_api.h"
-#include "ED_keyframes_edit.h" // XXX move the select modes out of there!
-#include "ED_screen.h"
-#include "ED_space_api.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-/* ************************************************************************** */
-/* CHANNELS API */
-
-/* -------------------------- Exposed API ----------------------------------- */
-
-/* Set the given animation-channel as the active one for the active context */
-void ANIM_set_active_channel (bAnimContext *ac, void *data, short datatype, int filter, void *channel_data, short channel_type)
-{
-	ListBase anim_data = {NULL, NULL};
-	bAnimListElem *ale;
-	
-	/* try to build list of filtered items */
-	ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
-	if (anim_data.first == NULL)
-		return;
-		
-	/* only clear the 'active' flag for the channels of the same type */
-	for (ale= anim_data.first; ale; ale= ale->next) {
-		/* skip if types don't match */
-		if (channel_type != ale->type)
-			continue;
-		
-		/* flag to set depends on type */
-		switch (ale->type) {
-			case ANIMTYPE_GROUP:
-			{
-				bActionGroup *agrp= (bActionGroup *)ale->data;
-				
-				ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE);
-			}
-				break;
-			case ANIMTYPE_FCURVE:
-			{
-				FCurve *fcu= (FCurve *)ale->data;
-				
-				ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE);
-			}
-				break;
-			case ANIMTYPE_NLATRACK:
-			{
-				NlaTrack *nlt= (NlaTrack *)ale->data;
-				
-				ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE);
-			}
-				break;
-		}
-	}
-	
-	/* set active flag */
-	if (channel_data != NULL) {
-		switch (channel_type) {
-			case ANIMTYPE_GROUP:
-			{
-				bActionGroup *agrp= (bActionGroup *)channel_data;
-				agrp->flag |= AGRP_ACTIVE;
-			}
-				break;
-			case ANIMTYPE_FCURVE:
-			{
-				FCurve *fcu= (FCurve *)channel_data;
-				fcu->flag |= FCURVE_ACTIVE;
-			}
-				break;
-			case ANIMTYPE_NLATRACK:
-			{
-				NlaTrack *nlt= (NlaTrack *)channel_data;
-				nlt->flag |= NLATRACK_ACTIVE;
-			}
-				break;
-		}
-	}
-	
-	/* clean up */
-	BLI_freelistN(&anim_data);
-}
-
-/* Deselect all animation channels 
- *	- data: pointer to datatype, as contained in bAnimContext
- *	- datatype: the type of data that 'data' represents (eAnimCont_Types)
- *	- test: check if deselecting instead of selecting
- *	- sel: eAnimChannels_SetFlag;
- */
-void ANIM_deselect_anim_channels (void *data, short datatype, short test, short sel)
-{
-	ListBase anim_data = {NULL, NULL};
-	bAnimListElem *ale;
-	int filter;
-	
-	/* filter data */
-	filter= ANIMFILTER_VISIBLE;
-	ANIM_animdata_filter(NULL, &anim_data, filter, data, datatype);
-	
-	/* See if we should be selecting or deselecting */
-	if (test) {
-		for (ale= anim_data.first; ale; ale= ale->next) {
-			if (sel == 0) 
-				break;
-			
-			switch (ale->type) {
-				case ANIMTYPE_SCENE:
-					if (ale->flag & SCE_DS_SELECTED)
-						sel= ACHANNEL_SETFLAG_CLEAR;
-					break;
-				case ANIMTYPE_OBJECT:
-					if (ale->flag & SELECT)
-						sel= ACHANNEL_SETFLAG_CLEAR;
-					break;
-				case ANIMTYPE_FILLACTD:
-					if (ale->flag & ACT_SELECTED)
-						sel= ACHANNEL_SETFLAG_CLEAR;
-					break;
-				case ANIMTYPE_GROUP:
-					if (ale->flag & AGRP_SELECTED)
-						sel= ACHANNEL_SETFLAG_CLEAR;
-					break;
-				case ANIMTYPE_FCURVE:
-					if (ale->flag & FCURVE_SELECTED)
-						sel= ACHANNEL_SETFLAG_CLEAR;
-					break;
-				case ANIMTYPE_NLATRACK:
-					if (ale->flag & NLATRACK_SELECTED)
-						sel= ACHANNEL_SETFLAG_CLEAR;
-					break;
-			}
-		}
-	}
-		
-	/* Now set the flags */
-	for (ale= anim_data.first; ale; ale= ale->next) {
-		switch (ale->type) {
-			case ANIMTYPE_SCENE:
-			{
-				Scene *scene= (Scene *)ale->data;
-				
-				ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED);
-			}
-				break;
-			case ANIMTYPE_OBJECT:
-			{
-				Base *base= (Base *)ale->data;
-				Object *ob= base->object;
-				
-				ACHANNEL_SET_FLAG(base, sel, SELECT);
-				ACHANNEL_SET_FLAG(ob, sel, SELECT);
-			}
-				break;
-			case ANIMTYPE_FILLACTD:
-			{
-				bAction *act= (bAction *)ale->data;
-				
-				ACHANNEL_SET_FLAG(act, sel, ACT_SELECTED);
-			}
-				break;
-			case ANIMTYPE_GROUP:
-			{
-				bActionGroup *agrp= (bActionGroup *)ale->data;
-				
-				ACHANNEL_SET_FLAG(agrp, sel, AGRP_SELECTED);
-				agrp->flag &= ~AGRP_ACTIVE;
-			}
-				break;
-			case ANIMTYPE_FCURVE:
-			{
-				FCurve *fcu= (FCurve *)ale->data;
-				
-				ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED);
-				fcu->flag &= ~FCURVE_ACTIVE;
-			}
-				break;
-			case ANIMTYPE_NLATRACK:
-			{
-				NlaTrack *nlt= (NlaTrack *)ale->data;
-				
-				ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED);
-				nlt->flag &= ~NLATRACK_ACTIVE;
-			}
-				break;
-		}
-	}
-	
-	/* Cleanup */
-	BLI_freelistN(&anim_data);
-}
-
-/* ************************************************************************** */
-/* OPERATORS */
-
-/* ****************** Operator Utilities ********************************** */
-
-/* poll callback for being in an Animation Editor channels list region */
-int animedit_poll_channels_active (bContext *C)
-{
-	ScrArea *sa= CTX_wm_area(C);
-	
-	/* channels region test */
-	// TODO: could enhance with actually testing if channels region?
-	if (ELEM(NULL, sa, CTX_wm_region(C)))
-		return 0;
-	/* animation editor test */
-	if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
-		return 0;
-		
-	return 1;
-}
-
-/* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */
-int animedit_poll_channels_nla_tweakmode_off (bContext *C)
-{
-	ScrArea *sa= CTX_wm_area(C);
-	Scene *scene = CTX_data_scene(C);
-	
-	/* channels region test */
-	// TODO: could enhance with actually testing if channels region?
-	if (ELEM(NULL, sa, CTX_wm_region(C)))
-		return 0;
-	/* animation editor test */
-	if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0)
-		return 0;
-	
-	/* NLA TweakMode test */	
-	if (sa->spacetype == SPACE_NLA) {
-		if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
-			return 0;
-	}
-		
-	return 1;
-}
-
-/* ****************** Rearrange Channels Operator ******************* */
-/* This operator only works for Action Editor mode for now, as having it elsewhere makes things difficult */
-
-#if 0 // XXX old animation system - needs to be updated for new system...
-
-/* constants for channel rearranging */
-/* WARNING: don't change exising ones without modifying rearrange func accordingly */
-enum {
-	REARRANGE_ACTCHAN_TOP= -2,
-	REARRANGE_ACTCHAN_UP= -1,
-	REARRANGE_ACTCHAN_DOWN= 1,
-	REARRANGE_ACTCHAN_BOTTOM= 2
-};
-
-/* make sure all action-channels belong to a group (and clear action's list) */
-static void split_groups_action_temp (bAction *act, bActionGroup *tgrp)
-{
-	bActionChannel *achan;
-	bActionGroup *agrp;
-	
-	/* Separate action-channels into lists per group */
-	for (agrp= act->groups.first; agrp; agrp= agrp->next) {
-		if (agrp->channels.first) {
-			achan= agrp->channels.last;
-			act->chanbase.first= achan->next;
-			
-			achan= agrp->channels.first;
-			achan->prev= NULL;
-			
-			achan= agrp->channels.last;
-			achan->next= NULL;
-		}
-	}
-	
-	/* Initialise memory for temp-group */
-	memset(tgrp, 0, sizeof(bActionGroup));
-	tgrp->flag |= (AGRP_EXPANDED|AGRP_TEMP);
-	strcpy(tgrp->name, "#TempGroup");
-		
-	/* Move any action-channels not already moved, to the temp group */
-	if (act->chanbase.first) {
-		/* start of list */
-		achan= act->chanbase.first;
-		achan->prev= NULL;
-		tgrp->channels.first= achan;
-		act->chanbase.first= NULL;
-		
-		/* end of list */
-		achan= act->chanbase.last;
-		achan->next= NULL;
-		tgrp->channels.last= achan;
-		act->chanbase.last= NULL;
-	}
-	
-	/* Add temp-group to list */
-	BLI_addtail(&act->groups, tgrp);
-}
-
-/* link lists of channels that groups have */
-static void join_groups_action_temp (bAction *act)
-{
-	bActionGroup *agrp;
-	bActionChannel *achan;
-	
-	for (agrp= act->groups.first; agrp; agrp= agrp->next) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list