2.5:
authorJoshua Leung <aligorith@gmail.com>
Thu, 1 Jan 2009 00:18:23 +0000 (00:18 +0000)
committerJoshua Leung <aligorith@gmail.com>
Thu, 1 Jan 2009 00:18:23 +0000 (00:18 +0000)
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.

12 files changed:
source/blender/editors/animation/anim_channels.c [new file with mode: 0644]
source/blender/editors/animation/anim_ops.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/interface/view2d.c
source/blender/editors/space_action/action_draw.c
source/blender/editors/space_action/action_edit.c [moved from source/blender/editors/space_action/action_edit_keyframes.c with 99% similarity]
source/blender/editors/space_action/action_intern.h
source/blender/editors/space_action/action_ops.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/transform/transform.c

diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c
new file mode 100644 (file)
index 0000000..c213e2d
--- /dev/null
@@ -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);
+}
+
+/* ************************************************************************** */
index f9247579c06a7d305f1eb660c4411b38f8f56d38..9e99be4941961b3193bd5116075f8e151418d69c 100644 (file)
@@ -367,6 +367,7 @@ void ED_keymap_anim(wmWindowManager *wm)
 {
        ListBase *keymap= WM_keymap_listbase(wm, "Animation", 0, 0);
        
 {
        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);
        
        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);
 }
        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);
 }
-
index f5cd576c8a36943403692ed7b405d03475c889dd..27079c7aa633cb1f757b50889e5f03b70667efef 100644 (file)
@@ -211,6 +211,7 @@ typedef enum eAnimFilter_Flags {
 /* -------------- Channel Defines -------------- */
 
 /* channel heights */
 /* -------------- Channel Defines -------------- */
 
 /* channel heights */
+#define ACHANNEL_FIRST                 -16
 #define        ACHANNEL_HEIGHT                 16
 #define ACHANNEL_HEIGHT_HALF   8
 #define        ACHANNEL_SKIP                   2
 #define        ACHANNEL_HEIGHT                 16
 #define ACHANNEL_HEIGHT_HALF   8
 #define        ACHANNEL_SKIP                   2
@@ -235,9 +236,13 @@ short ANIM_animdata_get_context(const struct bContext *C, bAnimContext *ac);
  */
 short ANIM_animdata_context_getdata(bAnimContext *ac);
 
  */
 short ANIM_animdata_context_getdata(bAnimContext *ac);
 
+/* ************************************************ */
+/* ANIMATION CHANNELS LIST */
+
+
+
 /* ************************************************ */
 /* DRAWING API */
 /* ************************************************ */
 /* DRAWING API */
-// XXX should this get its own header file?
 
 /* ---------- Current Frame Drawing ---------------- */
 
 
 /* ---------- Current Frame Drawing ---------------- */
 
@@ -296,7 +301,12 @@ void ED_update_for_newframe(const struct bContext *C, int mute);
 
 /* ************************************************* */
 /* OPERATORS */
 
 /* ************************************************* */
 /* 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);
 
 void ED_operatortypes_anim(void);
 void ED_keymap_anim(struct wmWindowManager *wm);
 
index ffacbab0ff68001bd1e3c000c6583beeadcb1f2c..4d6068a97ae510e11f2f1353cd8c697578d896d0 100644 (file)
@@ -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)
 {
 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)) ) {
        
        /* 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)) {
        
        /* 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;
                        *column= 0;
-               }
        }
        else if (column) {
                /* we want the column, but column width is undefined */
        }
        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)) {
        
        /* 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;
                        *row= 0;
-                       
-               }
        }
        else if (row) {
                /* we want the row, but row height is undefined */
        }
        else if (row) {
                /* we want the row, but row height is undefined */
index 696188dada4e8e2539a0260ea97f11e5ef1df1c1..cb392a14eb780dc8efba9f2db15219990dafa388 100644 (file)
@@ -402,6 +402,7 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
        ListBase anim_data = {NULL, NULL};
        bAnimListElem *ale;
        int filter;
+       
        View2D *v2d= &ar->v2d;
        float x= 0.0f, y= 0.0f;
        int items, height;
        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  */        
        }
        
        /* 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);
        
        for (ale= anim_data.first; ale; ale= ale->next) {
                const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
similarity index 99%
rename from source/blender/editors/space_action/action_edit_keyframes.c
rename to source/blender/editors/space_action/action_edit.c
index d9f333b4ddbd8ef9ac058aebe38d85088dc6a15b..958c79167bb036099ee2391c986f886ec05c766b 100644 (file)
@@ -378,8 +378,6 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
  
 void ACT_OT_keyframes_copy (wmOperatorType *ot)
 {
  
 void ACT_OT_keyframes_copy (wmOperatorType *ot)
 {
-       PropertyRNA *prop;
-       
        /* identifiers */
        ot->name= "Copy Keyframes";
        ot->idname= "ACT_OT_keyframes_copy";
        /* 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)
 {
  
 void ACT_OT_keyframes_paste (wmOperatorType *ot)
 {
-       PropertyRNA *prop;
-       
        /* identifiers */
        ot->name= "Paste Keyframes";
        ot->idname= "ACT_OT_keyframes_paste";
        /* identifiers */
        ot->name= "Paste Keyframes";
        ot->idname= "ACT_OT_keyframes_paste";
index d70cbb3f4c2b6a6dac28cd84d628e7e3457e3528..572a7aa0ae509ddc4d4c546e4e8610a76b886cea 100644 (file)
@@ -71,7 +71,7 @@ enum {
 } eActKeys_ColumnSelect_Mode;
 
 /* ***************************************** */
 } 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);
 
 void ACT_OT_keyframes_copy(struct wmOperatorType *ot);
 void ACT_OT_keyframes_paste(struct wmOperatorType *ot);
index b9c3b711da59e4a607dd87e7d380e71cbc3bfe72..b68cd145e1c9b72a3ee518b1002ac7e4f9e20176 100644 (file)
@@ -61,8 +61,6 @@
 
 void action_operatortypes(void)
 {
 
 void action_operatortypes(void)
 {
-       /* channels */
-       
        /* keyframes */
                /* selection */
        WM_operatortype_append(ACT_OT_keyframes_clickselect);
        /* keyframes */
                /* selection */
        WM_operatortype_append(ACT_OT_keyframes_clickselect);
@@ -145,7 +143,10 @@ void action_keymap(wmWindowManager *wm)
        ListBase *keymap;
        
        /* channels */
        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);
        
        /* keyframes */
        keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0);
index d356d7a7f42aafde1fd6c4cbb53fed539957c57b..652d19c3ebf74c180c6d7a877af338e1dd7b650d 100644 (file)
 /* ************************************************************************** */
 /* GENERAL STUFF */
 
 /* ************************************************************************** */
 /* 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, 
  */
 /* 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};
 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 */
        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
        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
index 9545421b7ef84085305c9745037d7042d2dfb403..f304367724b653511298a891e853789fc223d542 100644 (file)
@@ -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 */
        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);
 }
 
        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);
 }
 
        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)
 
 /* 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->init= action_channel_area_init;
        art->draw= action_channel_area_draw;
+       art->listener= action_main_area_listener;
        
        BLI_addhead(&st->regiontypes, art);
        
        
        BLI_addhead(&st->regiontypes, art);
        
index 3547e201012a09acfc0b4ce4a5a9a277147a9ba4..a40659cfe1b7bbd46f04ad3824b61b939a49cf2c 100644 (file)
@@ -83,6 +83,7 @@ void ED_spacetypes_init(void)
        /* register operator types for screen and all spaces */
        ED_operatortypes_screen();
        ED_operatortypes_anim();
        /* 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();
        
        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_screen(wm);
        ED_keymap_anim(wm);
+       ED_keymap_animchannels(wm);
        ED_keymap_object(wm);
        UI_view2d_keymap(wm);
 
        ED_keymap_object(wm);
        UI_view2d_keymap(wm);
 
index b6212751c611357ac77f3d72fa3c285824871983..d1917d460d1c82b1916ca2cfee5f55cffaa73ea5 100644 (file)
@@ -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};
                
        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];
        }
                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 (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;
                
        }
        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 {
        }
        else {
+               // FIXME: this still toggles the modes...
                if (t->event->ctrl) 
                        autosnap= SACTSNAP_STEP;
                else if (t->event->shift)
                if (t->event->ctrl) 
                        autosnap= SACTSNAP_STEP;
                else if (t->event->shift)