[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18205] branches/blender2.5/blender/source /blender/editors: 2.5:

Joshua Leung aligorith at gmail.com
Thu Jan 1 01:18:26 CET 2009


Revision: 18205
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18205
Author:   aligorith
Date:     2009-01-01 01:18:23 +0100 (Thu, 01 Jan 2009)

Log Message:
-----------
2.5:

First commit for 2009!

Started of porting of Animation Editor Channels stuff.
This code will be used for both the Action and IPO editors, so any existing code involving this has now been moved to the Animation module.

* Added mouse-click operator for this channels view. Note: the selection stuff currently uses temporary toggling code only (i.e. it only toggles the selection of the channels in the editor, but does not update status of rest of database).
* Fixed bugs in View2D listview functions. Reduced the amount of code needed, and makes the code here simpler.
* Renamed action_edit_keyframes.c to action_edit.c, since channels are not handled there anymore.
* Dopesheet now refreshes correctly when object selection elsewhere changes.
 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/animation/anim_ops.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_select.c
    branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
    branches/blender2.5/blender/source/blender/editors/space_api/spacetypes.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit.c

Removed Paths:
-------------
    branches/blender2.5/blender/source/blender/editors/space_action/action_edit_keyframes.c

Added: branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_channels.c	2009-01-01 00:18:23 UTC (rev 18205)
@@ -0,0 +1,502 @@
+/**
+ * $Id: editaction.c 17746 2008-12-08 11:19:44Z aligorith $
+ *
+ * ***** 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_action_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_ipo_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_gpencil_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "BKE_action.h"
+#include "BKE_depsgraph.h"
+#include "BKE_ipo.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 */
+
+/* -------------------------- Internal Tools -------------------------------- */
+
+/* -------------------------- Exposed API ----------------------------------- */
+
+/* ************************************************************************** */
+/* Channel Drawing */
+// XXX should these get their own file or go in anim_draw instead???
+
+
+/* ************************************************************************** */
+/* Operators */
+
+
+/* ******************** Mouse-Click Operator *********************** */
+/* Depending on the channel that was clicked on, the mouse click will activate whichever
+ * part of the channel is relevant.
+ *
+ * NOTE: eventually, this should probably be phased out when many of these things are replaced with buttons
+ */
+
+static void mouse_anim_channels (bAnimContext *ac, float x, int channel_index, short selectmode)
+{
+	ListBase anim_data = {NULL, NULL};
+	bAnimListElem *ale;
+	int filter;
+	
+	/* get the channel that was clicked on */
+		/* filter channels */
+	filter= (ANIMFILTER_FORDRAWING | ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
+	filter= ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
+	
+		/* get channel from index */
+	ale= BLI_findlink(&anim_data, channel_index);
+	if (ale == NULL) {
+		/* channel not found */
+		printf("Error: animation channel not found in mouse_anim_channels() \n");
+		printf("\t channel index = %d, channels = %d\n", channel_index, filter);
+		
+		BLI_freelistN(&anim_data);
+		return;
+	}
+	
+	/* action to take depends on what channel we've got */
+	switch (ale->type) {
+		case ANIMTYPE_OBJECT:
+			{
+				bDopeSheet *ads= (bDopeSheet *)ac->data;
+				Scene *sce= (Scene *)ads->source;
+				Base *base= (Base *)ale->data;
+				Object *ob= base->object;
+				
+				if (x < 16) {
+					/* toggle expand */
+					ob->nlaflag ^= OB_ADS_COLLAPSED;
+				}
+				else {
+					/* set selection status */
+					// FIXME: this needs to use the new stuff...
+					if (selectmode) {
+						/* swap select */
+						base->flag ^= SELECT;
+						ob->flag= base->flag;
+					}
+					else {
+						Base *b;
+						
+						/* deleselect all */
+						for (b= sce->base.first; b; b= b->next) {
+							b->flag &= ~SELECT;
+							b->object->flag= b->flag;
+						}
+						
+						/* select object now */
+						base->flag |= SELECT;
+						ob->flag |= SELECT;
+					}
+					
+					//set_active_base(base);	/* editview.c */
+				}
+			}
+				break;
+		case ANIMTYPE_FILLIPOD:
+			{
+				Object *ob= (Object *)ale->data;
+				ob->nlaflag ^= OB_ADS_SHOWIPO;
+			}
+				break;
+		case ANIMTYPE_FILLACTD:
+			{
+				bAction *act= (bAction *)ale->data;
+				act->flag ^= ACTC_EXPANDED;
+			}
+				break;
+		case ANIMTYPE_FILLCOND:
+			{
+				Object *ob= (Object *)ale->data;
+				ob->nlaflag ^= OB_ADS_SHOWCONS;
+			}
+				break;
+		case ANIMTYPE_FILLMATD:
+			{
+				Object *ob= (Object *)ale->data;
+				ob->nlaflag ^= OB_ADS_SHOWMATS;
+			}
+				break;
+				
+		case ANIMTYPE_DSMAT:
+			{
+				Material *ma= (Material *)ale->data;
+				ma->flag ^= MA_DS_EXPAND;
+			}
+				break;
+		case ANIMTYPE_DSLAM:
+			{
+				Lamp *la= (Lamp *)ale->data;
+				la->flag ^= LA_DS_EXPAND;
+			}
+				break;
+		case ANIMTYPE_DSCAM:
+			{
+				Camera *ca= (Camera *)ale->data;
+				ca->flag ^= CAM_DS_EXPAND;
+			}
+				break;
+		case ANIMTYPE_DSCUR:
+			{
+				Curve *cu= (Curve *)ale->data;
+				cu->flag ^= CU_DS_EXPAND;
+			}
+				break;
+		case ANIMTYPE_DSSKEY:
+			{
+				Key *key= (Key *)ale->data;
+				key->flag ^= KEYBLOCK_DS_EXPAND;
+			}
+				break;
+			
+		case ANIMTYPE_GROUP: 
+			{
+				bActionGroup *agrp= (bActionGroup *)ale->data;
+				short offset= (ac->datatype == ANIMCONT_DOPESHEET)? 21 : 0;
+				
+				if ((x < (offset+17)) && (agrp->channels.first)) {
+					/* toggle expand */
+					agrp->flag ^= AGRP_EXPANDED;
+				}
+				else if (x >= (ACHANNEL_NAMEWIDTH-16)) {
+					/* toggle protection/locking */
+					agrp->flag ^= AGRP_PROTECTED;
+ 				}
+ 				else {
+					/* select/deselect group */
+					if (selectmode == SELECT_INVERT) {
+						/* inverse selection status of group */
+						//select_action_group(act, agrp, SELECT_INVERT);
+					}
+					else if (/*G.qual == (LR_CTRLKEY|LR_SHIFTKEY)*/0) {
+						// FIXME: need a special case for this!
+						/* select all in group (and deselect everthing else) */	
+						//select_action_group_channels(act, agrp);
+						//select_action_group(act, agrp, SELECT_ADD);
+					}
+					else {
+						/* select group by itself */
+						//deselect_actionchannels(act, ANIMCONT_ACTION, 0);
+						//select_action_group(act, agrp, SELECT_ADD);
+					}
+ 				}
+			}
+			break;
+		case ANIMTYPE_ACHAN:
+			{
+				bActionChannel *achan= (bActionChannel *)ale->data;
+				short offset= (ac->datatype == ANIMCONT_DOPESHEET)? 21 : 0;
+				
+				if (x >= (ACHANNEL_NAMEWIDTH-16)) {
+					/* toggle protect */
+					achan->flag ^= ACHAN_PROTECTED;
+				}
+				else if ((x >= (ACHANNEL_NAMEWIDTH-32)) && (achan->ipo)) {
+					/* toggle mute */
+					achan->ipo->muteipo = (achan->ipo->muteipo)? 0: 1;
+				}
+				else if (x <= (offset+17)) {
+					/* toggle expand */
+					achan->flag ^= ACHAN_EXPANDED;
+				}				
+				else {
+					/* select/deselect achan */		
+					if (selectmode == SELECT_INVERT) {
+						//select_channel(act, achan, SELECT_INVERT);
+					}
+					else {
+						//deselect_actionchannels(act, ACTCONT_ACTION, 0);
+						//select_channel(act, achan, SELECT_ADD);
+					}
+					
+					/* messy... set active bone */
+					//select_poseelement_by_name(achan->name, 2);
+					
+					// XXX for now only
+					achan->flag ^= ACHAN_SELECTED;
+				}
+			}
+				break;
+		case ANIMTYPE_FILLIPO:
+			{
+				bActionChannel *achan= (bActionChannel *)ale->data;
+				
+				achan->flag ^= ACHAN_SHOWIPO;
+				
+				if ((x > 24) && (achan->flag & ACHAN_SHOWIPO)) {
+					/* select+make active achan */		
+					//deselect_actionchannels(act, ACTCONT_ACTION, 0);
+					//select_channel(act, achan, SELECT_ADD);
+					
+					/* messy... set active bone */
+					//select_poseelement_by_name(achan->name, 2);
+					
+					// XXX for now only
+					achan->flag ^= ACHAN_SELECTED;
+				}	
+			}
+			break;
+		case ANIMTYPE_FILLCON:
+			{
+				bActionChannel *achan= (bActionChannel *)ale->data;
+				
+				achan->flag ^= ACHAN_SHOWCONS;
+				
+				if ((x > 24) && (achan->flag & ACHAN_SHOWCONS)) {
+					/* select+make active achan */	
+					//deselect_actionchannels(act, ACTCONT_ACTION, 0);
+					//select_channel(act, achan, SELECT_ADD);
+					
+					/* messy... set active bone */
+					//select_poseelement_by_name(achan->name, 2);
+					
+					// XXX for now only
+					achan->flag ^= ACHAN_SELECTED;
+				}	
+			}
+			break;
+		case ANIMTYPE_ICU: 
+			{
+				IpoCurve *icu= (IpoCurve *)ale->data;
+				
+				if (x >= (ACHANNEL_NAMEWIDTH-16)) {
+					/* toggle protection */
+					icu->flag ^= IPO_PROTECT;
+				}
+				else if (x >= (ACHANNEL_NAMEWIDTH-16)) {
+					/* toggle mute */
+					icu->flag ^= IPO_MUTE;
+				}
+				else {
+					/* select/deselect */
+					//select_icu_channel(act, icu, SELECT_INVERT);
+					
+					// XXX for now only
+					icu->flag ^= IPO_SELECT;
+				}
+			}
+			break;
+		case ANIMTYPE_CONCHAN:
+			{
+				bConstraintChannel *conchan= (bConstraintChannel *)ale->data;
+				
+				if (x >= (ACHANNEL_NAMEWIDTH-16)) {
+					/* toggle protection */
+					conchan->flag ^= CONSTRAINT_CHANNEL_PROTECTED;
+				}
+				else if ((x >= (ACHANNEL_NAMEWIDTH-32)) && (conchan->ipo)) {
+					/* toggle mute */
+					conchan->ipo->muteipo = (conchan->ipo->muteipo)? 0: 1;
+				}
+				else {
+					/* select/deselect */
+					//select_constraint_channel(act, conchan, SELECT_INVERT);
+					
+					// XXX for now only
+					conchan->flag ^= CONSTRAINT_CHANNEL_SELECT;
+				}
+			}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list