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
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-01-01 03:18:23 +0300
committerJoshua Leung <aligorith@gmail.com>2009-01-01 03:18:23 +0300
commitc2de1373d1c61815e3030f88c196e6c42cb1c5fc (patch)
treea5947fea741d57578066e3e7623bfccd67638b3e /source
parentea42e70cb98713571704b2a48fd88cffc7bcbfb8 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/animation/anim_channels.c502
-rw-r--r--source/blender/editors/animation/anim_ops.c2
-rw-r--r--source/blender/editors/include/ED_anim_api.h12
-rw-r--r--source/blender/editors/interface/view2d.c54
-rw-r--r--source/blender/editors/space_action/action_draw.c3
-rw-r--r--source/blender/editors/space_action/action_edit.c (renamed from source/blender/editors/space_action/action_edit_keyframes.c)4
-rw-r--r--source/blender/editors/space_action/action_intern.h2
-rw-r--r--source/blender/editors/space_action/action_ops.c7
-rw-r--r--source/blender/editors/space_action/action_select.c67
-rw-r--r--source/blender/editors/space_action/space_action.c25
-rw-r--r--source/blender/editors/space_api/spacetypes.c2
-rw-r--r--source/blender/editors/transform/transform.c60
12 files changed, 570 insertions, 170 deletions
diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c
new file mode 100644
index 00000000000..c213e2d9a10
--- /dev/null
+++ b/source/blender/editors/animation/anim_channels.c
@@ -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;
+ }
+ }
+ break;
+ case ANIMTYPE_GPDATABLOCK:
+ {
+ bGPdata *gpd= (bGPdata *)ale->data;
+
+ /* toggle expand */
+ gpd->flag ^= GP_DATA_EXPAND;
+ }
+ break;
+ case ANIMTYPE_GPLAYER:
+ {
+#if 0 // XXX future of this is unclear
+ bGPdata *gpd= (bGPdata *)ale->owner;
+ bGPDlayer *gpl= (bGPDlayer *)ale->data;
+
+ if (x >= (ACHANNEL_NAMEWIDTH-16)) {
+ /* toggle lock */
+ gpl->flag ^= GP_LAYER_LOCKED;
+ }
+ else if (x >= (ACHANNEL_NAMEWIDTH-32)) {
+ /* toggle hide */
+ gpl->flag ^= GP_LAYER_HIDE;
+ }
+ else {
+ /* select/deselect */
+ //if (G.qual & LR_SHIFTKEY) {
+ //select_gplayer_channel(gpd, gpl, SELECT_INVERT);
+ //}
+ //else {
+ //deselect_gpencil_layers(data, 0);
+ //select_gplayer_channel(gpd, gpl, SELECT_INVERT);
+ //}
+ }
+#endif // XXX future of this is unclear
+ }
+ break;
+ case ANIMTYPE_SHAPEKEY:
+ /* TODO: shapekey channels cannot be selected atm... */
+ break;
+ default:
+ printf("Error: Invalid channel type in mouse_anim_channels() \n");
+ }
+
+ /* free channels */
+ BLI_freelistN(&anim_data);
+}
+
+/* ------------------- */
+
+/* handle clicking */
+static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ bAnimContext ac;
+ Scene *scene;
+ ARegion *ar;
+ View2D *v2d;
+ int mval[2], channel_index;
+ short selectmode;
+ float x, y;
+
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* get useful pointers from animation context data */
+ scene= ac.scene;
+ ar= ac.ar;
+ v2d= &ar->v2d;
+
+ /* get mouse coordinates (in region coordinates) */
+ mval[0]= (event->x - ar->winrct.xmin);
+ mval[1]= (event->y - ar->winrct.ymin);
+
+ /* select mode is either replace (deselect all, then add) or add/extend */
+ if (RNA_boolean_get(op->ptr, "extend_select"))
+ selectmode= SELECT_INVERT;
+ else
+ selectmode= SELECT_REPLACE;
+
+ /* figure out which channel user clicked in
+ * Note: although channels technically start at y= ACHANNEL_FIRST, we need to adjust by half a channel's height
+ * so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use
+ * ACHANNEL_HEIGHT_HALF.
+ */
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
+ UI_view2d_listview_get_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index);
+
+ /* handle mouse-click in the relevant channel then */
+ mouse_anim_channels(&ac, x, channel_index, selectmode);
+
+ /* set notifier tha things have changed */
+ ED_area_tag_redraw(CTX_wm_area(C)); // FIXME... should be updating 'keyframes' data context or so instead!
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_channels_mouseclick (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Mouse Click on Channels";
+ ot->idname= "ANIM_OT_channels_mouseclick";
+
+ /* api callbacks */
+ ot->invoke= animchannels_mouseclick_invoke;
+ ot->poll= ED_operator_areaactive;
+
+ /* id-props */
+ RNA_def_property(ot->srna, "extend_select", PROP_BOOLEAN, PROP_NONE); // SHIFTKEY
+}
+
+/* ************************************************************************** */
+/* Operator Registration */
+
+void ED_operatortypes_animchannels(void)
+{
+ WM_operatortype_append(ANIM_OT_channels_mouseclick);
+}
+
+void ED_keymap_animchannels(wmWindowManager *wm)
+{
+ ListBase *keymap = WM_keymap_listbase(wm, "Animation_Channels", 0, 0);
+
+ /* click-select */
+ // XXX for now, only leftmouse....
+ WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, 0, 0);
+ RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_mouseclick", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend_select", 1);
+}
+
+/* ************************************************************************** */
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index f9247579c06..9e99be49419 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -367,6 +367,7 @@ void ED_keymap_anim(wmWindowManager *wm)
{
ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
+ /* frame management */
WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_toggle_time", TKEY, KM_PRESS, KM_CTRL, 0);
@@ -374,4 +375,3 @@ void ED_keymap_anim(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_define", PKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_clear", PKEY, KM_PRESS, KM_ALT, 0);
}
-
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index f5cd576c8a3..27079c7aa63 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -211,6 +211,7 @@ typedef enum eAnimFilter_Flags {
/* -------------- Channel Defines -------------- */
/* channel heights */
+#define ACHANNEL_FIRST -16
#define ACHANNEL_HEIGHT 16
#define ACHANNEL_HEIGHT_HALF 8
#define ACHANNEL_SKIP 2
@@ -236,8 +237,12 @@ short ANIM_animdata_get_context(const struct bContext *C, bAnimContext *ac);
short ANIM_animdata_context_getdata(bAnimContext *ac);
/* ************************************************ */
+/* ANIMATION CHANNELS LIST */
+
+
+
+/* ************************************************ */
/* DRAWING API */
-// XXX should this get its own header file?
/* ---------- Current Frame Drawing ---------------- */
@@ -296,7 +301,12 @@ void ED_update_for_newframe(const struct bContext *C, int mute);
/* ************************************************* */
/* OPERATORS */
+
+ /* generic animation channels */
+void ED_operatortypes_animchannels(void);
+void ED_keymap_animchannels(struct wmWindowManager *wm);
+ /* generic time editing */
void ED_operatortypes_anim(void);
void ED_keymap_anim(struct wmWindowManager *wm);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index ffacbab0ff6..4d6068a97ae 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1576,8 +1576,9 @@ void UI_view2d_scrollers_free(View2DScrollers *scrollers)
void UI_view2d_listview_get_cell(View2D *v2d, short columnwidth, short rowheight, float startx, float starty,
float viewx, float viewy, int *column, int *row)
{
- const int x= (int)(floor(viewx + 0.5f) - startx);
- const int y= (int)(floor(viewy + 0.5f) - starty);
+ /* adjust view coordinates to be all positive ints, corrected for the start offset */
+ const int x= (int)(floor(fabs(viewx) + 0.5f) - startx);
+ const int y= (int)(floor(fabs(viewy) + 0.5f) - starty);
/* sizes must not be negative */
if ( (v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0)) ) {
@@ -1589,28 +1590,10 @@ void UI_view2d_listview_get_cell(View2D *v2d, short columnwidth, short rowheight
/* get column */
if ((column) && (columnwidth > 0)) {
- /* which way to get column depends on the alignment of the 'tot' rect
- * - we favour positive-x here, as that's the recommended configuration for listviews
- */
- if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
- /* contents are in positive-x half */
- if (x > 0)
- *column= x % columnwidth;
- else
- *column= 0;
- }
- else if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
- /* contents are in negative-x half */
- if (x < 0)
- *column= (-x) % columnwidth;
- else
- *column= 0;
- }
- else {
- /* contents are centered around x==0 */
- // temp case for now...
+ if (x > 0)
+ *column= x / columnwidth;
+ else
*column= 0;
- }
}
else if (column) {
/* we want the column, but column width is undefined */
@@ -1619,29 +1602,10 @@ void UI_view2d_listview_get_cell(View2D *v2d, short columnwidth, short rowheight
/* get row */
if ((row) && (rowheight > 0)) {
- /* which way to get column depends on the alignment of the 'tot' rect
- * - we favour negative-y here, as that's the recommended configuration for listviews
- */
- if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
- /* contents are in negative-y half */
- if (y < 0)
- *row= (-y) % rowheight;
- else
- *row= 0;
- }
- else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
- /* contents are in positive-y half */
- if (y > 0)
- *row= y % rowheight;
- else
- *row= 0;
- }
- else {
- /* contents are centered around y==0 */
- // temp case for now...
+ if (y > 0)
+ *row= y / rowheight;
+ else
*row= 0;
-
- }
}
else if (row) {
/* we want the row, but row height is undefined */
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 696188dada4..cb392a14eb7 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -402,6 +402,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
+
View2D *v2d= &ar->v2d;
float x= 0.0f, y= 0.0f;
int items, height;
@@ -425,7 +426,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
/* loop through channels, and set up drawing depending on their type */
- y= (float)(-ACHANNEL_HEIGHT);
+ y= (float)ACHANNEL_FIRST;
for (ale= anim_data.first; ale; ale= ale->next) {
const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
diff --git a/source/blender/editors/space_action/action_edit_keyframes.c b/source/blender/editors/space_action/action_edit.c
index d9f333b4ddb..958c79167bb 100644
--- a/source/blender/editors/space_action/action_edit_keyframes.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -378,8 +378,6 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
void ACT_OT_keyframes_copy (wmOperatorType *ot)
{
- PropertyRNA *prop;
-
/* identifiers */
ot->name= "Copy Keyframes";
ot->idname= "ACT_OT_keyframes_copy";
@@ -424,8 +422,6 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
void ACT_OT_keyframes_paste (wmOperatorType *ot)
{
- PropertyRNA *prop;
-
/* identifiers */
ot->name= "Paste Keyframes";
ot->idname= "ACT_OT_keyframes_paste";
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index d70cbb3f4c2..572a7aa0ae5 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -71,7 +71,7 @@ enum {
} eActKeys_ColumnSelect_Mode;
/* ***************************************** */
-/* action_edit_keyframes.c */
+/* action_edit.c */
void ACT_OT_keyframes_copy(struct wmOperatorType *ot);
void ACT_OT_keyframes_paste(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index b9c3b711da5..b68cd145e1c 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -61,8 +61,6 @@
void action_operatortypes(void)
{
- /* channels */
-
/* keyframes */
/* selection */
WM_operatortype_append(ACT_OT_keyframes_clickselect);
@@ -145,7 +143,10 @@ void action_keymap(wmWindowManager *wm)
ListBase *keymap;
/* channels */
- keymap= WM_keymap_listbase(wm, "Action_Channels", SPACE_ACTION, 0);
+ /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module.
+ * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
+ * are all used for the IPO-Editor too.
+ */
/* keyframes */
keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index d356d7a7f42..652d19c3ebf 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -88,74 +88,10 @@
/* ************************************************************************** */
/* GENERAL STUFF */
-/* this function finds the channel that mouse is floating over */
-void *get_nearest_act_channel (bAnimContext *ac, int mval[2], short *ret_type, void **owner)
-{
- ListBase anim_data = {NULL, NULL};
- bAnimListElem *ale;
- int filter;
-
- View2D *v2d= &ac->ar->v2d;
- int clickmin, clickmax;
- float x, y;
- void *data= NULL;
-
- /* init 'owner' return val */
- *owner= NULL;
-
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
- clickmin = (int) ((ACHANNEL_HEIGHT_HALF - y) / (ACHANNEL_STEP));
- clickmax = clickmin;
-
- if (clickmax < 0) {
- *ret_type= ANIMTYPE_NONE;
- return NULL;
- }
-
- /* filter data */
- filter= (ANIMFILTER_FORDRAWING | ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
- ANIM_animdata_filter(&anim_data, filter, ac->data, ac->datatype);
-
- for (ale= anim_data.first; ale; ale= ale->next) {
- if (clickmax < 0)
- break;
- if (clickmin <= 0) {
- /* found match */
- *ret_type= ale->type;
- data= ale->data;
-
- /* if an 'ID' has been set, this takes presidence as owner (for dopesheet) */
- if (ac->datatype == ANIMCONT_DOPESHEET) {
- /* return pointer to ID as owner instead */
- if (ale->id)
- *owner= ale->id;
- else
- *owner= ale->owner;
- }
- else {
- /* just use own owner */
- *owner= ale->owner;
- }
-
- BLI_freelistN(&anim_data);
-
- return data;
- }
- --clickmin;
- --clickmax;
- }
-
- /* cleanup */
- BLI_freelistN(&anim_data);
-
- *ret_type= ANIMTYPE_NONE;
- return NULL;
-}
-
-
/* used only by mouse_action. It is used to find the location of the nearest
* keyframe to where the mouse clicked,
*/
+// XXX port this to new listview code...
static void *get_nearest_action_key (bAnimContext *ac, int mval[2], float *selx, short *sel, short *ret_type, bActionChannel **par)
{
ListBase anim_data = {NULL, NULL};
@@ -1195,6 +1131,7 @@ void ACT_OT_keyframes_clickselect (wmOperatorType *ot)
ot->poll= ED_operator_areaactive;
/* id-props */
+ // XXX should we make this into separate operators?
prop= RNA_def_property(ot->srna, "left_right", PROP_ENUM, PROP_NONE); // ALTKEY
//RNA_def_property_enum_items(prop, prop_actkeys_clickselect_items);
prop= RNA_def_property(ot->srna, "extend_select", PROP_BOOLEAN, PROP_NONE); // SHIFTKEY
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 9545421b7ef..f304367724b 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -223,7 +223,7 @@ static void action_channel_area_init(wmWindowManager *wm, ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
/* own keymap */
- keymap= WM_keymap_listbase(wm, "Action_Channels", SPACE_ACTION, 0); /* XXX weak? */
+ keymap= WM_keymap_listbase(wm, "Animation_Channels", 0, 0); /* XXX weak? */
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
@@ -257,6 +257,28 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar)
UI_view2d_scrollers_free(scrollers);
}
+static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
+{
+ /* context changes */
+ switch(wmn->category) {
+ case NC_SCENE:
+ switch(wmn->data) {
+ case ND_OB_ACTIVE:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ case NC_OBJECT:
+ switch(wmn->data) {
+ case ND_BONE_ACTIVE:
+ case ND_BONE_SELECT:
+ ED_region_tag_redraw(ar);
+ break;
+ }
+ break;
+ }
+}
+
/* add handlers, stuff you only do once or on area/region changes */
static void action_header_area_init(wmWindowManager *wm, ARegion *ar)
@@ -354,6 +376,7 @@ void ED_spacetype_action(void)
art->init= action_channel_area_init;
art->draw= action_channel_area_draw;
+ art->listener= action_main_area_listener;
BLI_addhead(&st->regiontypes, art);
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 3547e201012..a40659cfe1b 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -83,6 +83,7 @@ void ED_spacetypes_init(void)
/* register operator types for screen and all spaces */
ED_operatortypes_screen();
ED_operatortypes_anim();
+ ED_operatortypes_animchannels(); // XXX have this as part of anim() ones instead?
ED_operatortypes_object();
ui_view2d_operatortypes();
@@ -102,6 +103,7 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
ED_keymap_screen(wm);
ED_keymap_anim(wm);
+ ED_keymap_animchannels(wm);
ED_keymap_object(wm);
UI_view2d_keymap(wm);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index b6212751c61..d1917d460d1 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -237,8 +237,7 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
else if(t->spacetype==SPACE_IPO) {
short out[2] = {0.0f, 0.0f};
- // TRANSFORM_FIX_ME
- //ipoco_to_areaco(G.v2d, vec, out);
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
adr[0]= out[0];
adr[1]= out[1];
}
@@ -3979,58 +3978,23 @@ static short getAnimEdit_SnapMode(TransInfo *t)
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
- if (saction) {
- switch (saction->autosnap) {
- case SACTSNAP_OFF:
- if (t->event->ctrl)
- autosnap= SACTSNAP_STEP;
- else if (t->event->shift)
- autosnap= SACTSNAP_FRAME;
- else if (t->event->alt)
- autosnap= SACTSNAP_MARKER;
- else
- autosnap= SACTSNAP_OFF;
- break;
- case SACTSNAP_STEP:
- autosnap= (t->event->ctrl)? SACTSNAP_OFF: SACTSNAP_STEP;
- break;
- case SACTSNAP_FRAME:
- autosnap= (t->event->shift)? SACTSNAP_OFF: SACTSNAP_FRAME;
- break;
- case SACTSNAP_MARKER:
- autosnap= (t->event->alt)? SACTSNAP_OFF: SACTSNAP_MARKER;
- break;
- }
- }
+ if (saction)
+ autosnap= saction->autosnap;
+ }
+ else if (t->spacetype == SPACE_IPO) {
+ SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
+
+ if (sipo)
+ autosnap= sipo->autosnap;
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
- if (snla) {
- switch (snla->autosnap) {
- case SACTSNAP_OFF:
- if (t->event->ctrl)
- autosnap= SACTSNAP_STEP;
- else if (t->event->shift)
- autosnap= SACTSNAP_FRAME;
- else if (t->event->alt)
- autosnap= SACTSNAP_MARKER;
- else
- autosnap= SACTSNAP_OFF;
- break;
- case SACTSNAP_STEP:
- autosnap= (t->event->ctrl)? SACTSNAP_OFF: SACTSNAP_STEP;
- break;
- case SACTSNAP_FRAME:
- autosnap= (t->event->shift)? SACTSNAP_OFF: SACTSNAP_FRAME;
- break;
- case SACTSNAP_MARKER:
- autosnap= (t->event->alt)? SACTSNAP_OFF: SACTSNAP_MARKER;
- break;
- }
- }
+ if (snla)
+ autosnap= snla->autosnap;
}
else {
+ // FIXME: this still toggles the modes...
if (t->event->ctrl)
autosnap= SACTSNAP_STEP;
else if (t->event->shift)