[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18003] branches/blender2.5/blender/source /blender: 2.5 - Action Editor / Dopesheet
Joshua Leung
aligorith at gmail.com
Mon Dec 22 09:13:26 CET 2008
Revision: 18003
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18003
Author: aligorith
Date: 2008-12-22 09:13:25 +0100 (Mon, 22 Dec 2008)
Log Message:
-----------
2.5 - Action Editor / Dopesheet
Initial commit of drawing code for Action Editor / Dopesheet. By default, the Dopesheet is now enabled (like in AnimSys2). There are still a few unresolved problems (like bad alpha blending for icons, and keyframes still not being drawn). However, these will be resolved in due course.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
branches/blender2.5/blender/source/blender/editors/interface/resources.c
branches/blender2.5/blender/source/blender/editors/space_action/action_intern.h
branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
branches/blender2.5/blender/source/blender/editors/space_view3d/drawarmature.c
branches/blender2.5/blender/source/blender/makesdna/DNA_userdef_types.h
Added Paths:
-----------
branches/blender2.5/blender/source/blender/editors/animation/anim_keyframes_draw.c
branches/blender2.5/blender/source/blender/editors/include/ED_keyframes_draw.h
branches/blender2.5/blender/source/blender/editors/space_action/action_draw.c
Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c 2008-12-22 06:55:24 UTC (rev 18002)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_draw.c 2008-12-22 08:13:25 UTC (rev 18003)
@@ -42,8 +42,10 @@
#include "BLI_blenlib.h"
+#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_ipo.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -177,3 +179,79 @@
}
/* *************************************************** */
+/* KEYFRAME DRAWING UTILITIES */
+
+/* Obtain the Object providing NLA-scaling for the given channel (if applicable) */
+Object *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
+{
+ /* sanity checks */
+ if (ac == NULL)
+ return NULL;
+
+ /* handling depends on the type of animation-context we've got */
+ if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_IPO)) {
+ /* Action Editor (action mode) or Ipo Editor (ipo mode):
+ * Only use if editor is not pinned, and active object has action
+ */
+ if (ac->obact && ac->obact->action) {
+ /* Action Editor */
+ if (ac->datatype == ANIMCONT_ACTION) {
+ SpaceAction *saction= (SpaceAction *)ac->sa->spacedata.first;
+
+ if (saction->pin == 0)
+ return ac->obact;
+ }
+ /* IPO Editor */
+ else if (ac->datatype == ANIMCONT_IPO) {
+ SpaceIpo *sipo= (SpaceIpo *)ac->sa->spacedata.first;
+
+ if (sipo->pin == 0)
+ return ac->obact;
+ }
+ }
+ }
+ else if ((ac->datatype == ANIMCONT_DOPESHEET) && (ale)) {
+ /* Dopesheet:
+ * Only if channel is available, and is owned by an Object with an Action
+ */
+ if ((ale->id) && (GS(ale->id->name) == ID_OB)) {
+ Object *ob= (Object *)ale->id;
+
+ if (ob->action)
+ return ob;
+ }
+ }
+
+ /* no appropriate object found */
+ return NULL;
+}
+
+/* Set/clear temporary mapping of coordinates from 'local-action' time to 'global-nla-scaled' time
+ * - the old mapping is stored in a static var, but that shouldn't be too bad as UI drawing
+ * (where this is called) is single-threaded anyway
+ */
+// XXX was called: map_active_strip()
+void ANIM_nla_mapping_draw(gla2DDrawInfo *di, Object *ob, short restore)
+{
+ static rctf stored;
+
+ if (restore) {
+ /* restore un-mapped coordinates */
+ gla2DSetMap(di, &stored);
+ }
+ else {
+ /* set mapped coordinates */
+ rctf map;
+
+ gla2DGetMap(di, &stored);
+ map= stored;
+
+ map.xmin= get_action_frame(ob, map.xmin);
+ map.xmax= get_action_frame(ob, map.xmax);
+
+ if (map.xmin == map.xmax) map.xmax += 1.0f;
+ gla2DSetMap(di, &map);
+ }
+}
+
+/* *************************************************** */
Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c 2008-12-22 06:55:24 UTC (rev 18002)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c 2008-12-22 08:13:25 UTC (rev 18003)
@@ -140,86 +140,110 @@
}
/* Get data being edited in Action Editor (depending on current 'mode') */
-static void *actedit_get_context (const bContext *C, SpaceAction *saction, short *datatype)
+static short actedit_get_context (const bContext *C, bAnimContext *ac, SpaceAction *saction)
{
- Scene *scene= CTX_data_scene(C);
-
/* sync settings with current view status, then return appropriate data */
switch (saction->mode) {
case SACTCONT_ACTION: /* 'Action Editor' */
/* if not pinned, sync with active object */
if (saction->pin == 0) {
- if (OBACT)
- saction->action = OBACT->action;
+ if (ac->obact)
+ saction->action = ac->obact->action;
else
saction->action= NULL;
}
-
- *datatype= ANIMCONT_ACTION;
- return saction->action;
+ ac->datatype= ANIMCONT_ACTION;
+ ac->data= saction->action;
+
+ ac->mode= saction->mode;
+ return 1;
+
case SACTCONT_SHAPEKEY: /* 'ShapeKey Editor' */
- *datatype= ANIMCONT_SHAPEKEY;
- return actedit_get_shapekeys(C, saction);
+ ac->datatype= ANIMCONT_SHAPEKEY;
+ ac->data= actedit_get_shapekeys(C, saction);
+ ac->mode= saction->mode;
+ return 1;
+
case SACTCONT_GPENCIL: /* Grease Pencil */ // XXX review how this mode is handled...
- *datatype=ANIMCONT_GPENCIL;
- return CTX_wm_screen(C); // FIXME: add that dopesheet type thing here!
- break;
+ ac->datatype=ANIMCONT_GPENCIL;
+ ac->data= CTX_wm_screen(C); // FIXME: add that dopesheet type thing here!
+ ac->mode= saction->mode;
+ return 1;
+
case SACTCONT_DOPESHEET: /* DopeSheet */
/* update scene-pointer (no need to check for pinning yet, as not implemented) */
- saction->ads.source= (ID *)scene;
+ saction->ads.source= (ID *)ac->scene;
- *datatype= ANIMCONT_DOPESHEET;
- return &saction->ads;
+ ac->datatype= ANIMCONT_DOPESHEET;
+ ac->data= &saction->ads;
+
+ ac->mode= saction->mode;
+ return 1;
default: /* unhandled yet */
- *datatype= ANIMCONT_NONE;
- return NULL;
+ ac->datatype= ANIMCONT_NONE;
+ ac->data= NULL;
+
+ ac->mode= -1;
+ return 0;
}
}
/* ----------- Private Stuff - IPO Editor ------------- */
/* Get data being edited in IPO Editor (depending on current 'mode') */
-static void *ipoedit_get_context (const bContext *C, SpaceIpo *sipo, short *datatype)
+static short ipoedit_get_context (const bContext *C, bAnimContext *ac, SpaceIpo *sipo)
{
// XXX FIXME...
- return NULL;
+ return 0;
}
/* ----------- Public API --------------- */
-/* Obtain current anim-data context from Blender Context info */
-void *ANIM_animdata_get_context (const bContext *C, short *datatype)
+/* Obtain current anim-data context from Blender Context info
+ * - AnimContext to write to is provided as pointer to var on stack so that we don't have
+ * allocation/freeing costs (which are not that avoidable with channels).
+ * -
+ */
+short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
{
- ScrArea *sa= CTX_wm_area(C);
+ ScrArea *sa= CTX_wm_area(C); // XXX it is assumed that this will always be valid
+ ARegion *ar= CTX_wm_region(C);
+ Scene *scene= CTX_data_scene(C);
- /* set datatype to 'None' for convenience */
- if (datatype == NULL) return NULL;
- *datatype= ANIMCONT_NONE;
- if (sa == NULL) return NULL; /* highly unlikely to happen, but still! */
+ /* clear old context info */
+ if (ac == NULL) return 0;
+ memset(ac, 0, sizeof(bAnimContext));
+ /* set default context settings */
+ ac->scene= scene;
+ ac->obact= (scene && scene->basact)? scene->basact->object : NULL;
+ ac->sa= sa;
+ ac->spacetype= sa->spacetype;
+ ac->regiontype= ar->regiontype;
+
/* context depends on editor we are currently in */
switch (sa->spacetype) {
case SPACE_ACTION:
{
SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
- return actedit_get_context(C, saction, datatype);
+ return actedit_get_context(C, ac, saction);
}
break;
case SPACE_IPO:
{
SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
- return ipoedit_get_context(C, sipo, datatype);
+ return ipoedit_get_context(C, ac, sipo);
}
break;
}
/* nothing appropriate */
- return NULL;
+ return 0;
}
/* ************************************************************ */
@@ -1208,6 +1232,10 @@
case ANIMCONT_DOPESHEET:
animdata_filter_dopesheet(anim_data, data, filter_mode);
break;
+
+ case ANIMCONT_IPO:
+ // FIXME: this will be used for showing a single IPO-block (not too useful from animator perspective though!)
+ break;
}
/* remove any weedy entries */
Added: branches/blender2.5/blender/source/blender/editors/animation/anim_keyframes_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_keyframes_draw.c (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_keyframes_draw.c 2008-12-22 08:13:25 UTC (rev 18003)
@@ -0,0 +1,701 @@
+/**
+ * $Id: drawaction.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 *****
+ */
+
+/* System includes ----------------------------------------------------- */
+
+#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"
+
+/* Types --------------------------------------------------------------- */
+
+#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 "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_global.h" // XXX remove me!
+#include "BKE_context.h"
+#include "BKE_utildefines.h"
+
+/* Everything from source (BIF, BDR, BSE) ------------------------------ */
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list