2009-01-26 23:18:27 +00:00
|
|
|
/**
|
|
|
|
* $Id:
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_listBase.h"
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
2009-01-28 06:32:47 +00:00
|
|
|
#include "ED_screen.h"
|
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
#include "BIF_transform.h"
|
|
|
|
|
2009-02-03 12:04:05 +00:00
|
|
|
#include "graph_intern.h"
|
2009-01-26 23:18:27 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2009-01-28 06:32:47 +00:00
|
|
|
/* ************************** view-based operators **********************************/
|
|
|
|
// XXX this probably shouldn't be here..
|
|
|
|
|
|
|
|
/* Toggle Handles ----------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int view_toggle_handles_exec (bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
|
|
|
if (sipo == NULL)
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
/* toggle flag to hide handles */
|
|
|
|
sipo->flag ^= SIPO_NOHANDLES;
|
|
|
|
|
|
|
|
/* request refresh of keys area */
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GRAPHEDIT_OT_view_togglehandles (wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
/* identification */
|
|
|
|
ot->name= "Show/Hide All Handles";
|
|
|
|
ot->idname= "GRAPHEDIT_OT_view_toggle_handles";
|
|
|
|
|
|
|
|
/* callbacks */
|
|
|
|
ot->exec= view_toggle_handles_exec;
|
|
|
|
ot->poll= ED_operator_areaactive;
|
|
|
|
}
|
2009-01-26 23:18:27 +00:00
|
|
|
|
|
|
|
/* ************************** registration - operator types **********************************/
|
|
|
|
|
|
|
|
void graphedit_operatortypes(void)
|
|
|
|
{
|
2009-01-28 06:32:47 +00:00
|
|
|
/* view */
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_view_togglehandles);
|
2009-02-10 10:42:04 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_set_previewrange);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_view_all);
|
2009-02-21 10:38:58 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_properties);
|
2009-01-28 06:32:47 +00:00
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
/* keyframes */
|
|
|
|
/* selection */
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_clickselect);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_deselectall);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_borderselect);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_columnselect);
|
|
|
|
|
|
|
|
/* editing */
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_snap);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_mirror);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_cfrasnap);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_handletype);
|
2009-01-28 06:32:47 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_interpolation_type);
|
2009-01-28 09:55:36 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_extrapolation_type);
|
2009-01-26 23:18:27 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_sample);
|
2009-01-28 09:55:36 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_smooth);
|
2009-01-26 23:18:27 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_clean);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_delete);
|
2009-02-20 11:17:33 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_duplicate);
|
2009-02-24 11:18:24 +00:00
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_copy);
|
|
|
|
WM_operatortype_append(GRAPHEDIT_OT_keyframes_paste);
|
2009-02-24 11:18:24 +00:00
|
|
|
|
|
|
|
//TODO: insertkey...
|
2009-01-26 23:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************** registration - keymaps **********************************/
|
|
|
|
|
|
|
|
static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
|
|
|
|
{
|
2009-01-28 06:32:47 +00:00
|
|
|
/* view */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_toggle_handles", HKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
|
2009-02-20 11:17:33 +00:00
|
|
|
/* graph_select.c - selection tools */
|
2009-01-26 23:18:27 +00:00
|
|
|
/* click-select */
|
|
|
|
// TODO: column to alt, left-right to ctrl (for select-linked consistency)
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "column_select", 1);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend_select", 1);
|
2009-01-27 05:04:23 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "left_right", GRAPHKEYS_LRSEL_TEST);
|
2009-01-26 23:18:27 +00:00
|
|
|
|
|
|
|
/* deselect all */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_deselectall", AKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_deselectall", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
|
|
|
|
|
|
|
|
/* borderselect */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_borderselect", BKEY, KM_PRESS, 0, 0);
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_borderselect", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
|
|
|
|
|
|
|
|
/* column select */
|
2009-01-28 00:50:56 +00:00
|
|
|
// XXX KKEY would be nice to keep for 'keyframe' lines
|
2009-01-27 05:04:23 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_columnselect", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN);
|
2009-01-28 06:32:47 +00:00
|
|
|
|
|
|
|
|
2009-02-20 11:17:33 +00:00
|
|
|
/* graph_edit.c */
|
2009-01-26 23:18:27 +00:00
|
|
|
/* snap - current frame to selected keys */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_cfrasnap", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
|
|
|
|
|
|
|
/* menu + single-step transform */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_handletype", HKEY, KM_PRESS, 0, 0);
|
2009-01-28 06:32:47 +00:00
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_interpolation_type", TKEY, KM_PRESS, KM_SHIFT, 0);
|
2009-01-28 09:55:36 +00:00
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
|
|
|
|
/* destructive */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_clean", OKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
|
2009-01-28 09:55:36 +00:00
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_smooth", OKEY, KM_PRESS, KM_ALT, 0);
|
2009-01-26 23:18:27 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_delete", XKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_delete", DELKEY, KM_PRESS, 0, 0);
|
|
|
|
|
2009-02-20 11:17:33 +00:00
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
|
|
|
|
|
2009-02-24 11:18:24 +00:00
|
|
|
/* insertkey */
|
|
|
|
// TODO..
|
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
/* copy/paste */
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_keyframes_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
|
|
|
|
|
|
|
/* auto-set range */
|
2009-02-10 10:42:04 +00:00
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
2009-01-28 06:32:47 +00:00
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
/* transform system */
|
2009-01-28 00:50:56 +00:00
|
|
|
transform_keymap_for_space(wm, keymap, SPACE_IPO);
|
2009-01-26 23:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------- */
|
|
|
|
|
|
|
|
void graphedit_keymap(wmWindowManager *wm)
|
|
|
|
{
|
|
|
|
ListBase *keymap;
|
|
|
|
|
2009-02-20 19:11:35 +00:00
|
|
|
/* keymap for all regions */
|
|
|
|
keymap= WM_keymap_listbase(wm, "GraphEdit Generic", SPACE_IPO, 0);
|
2009-02-21 10:38:58 +00:00
|
|
|
WM_keymap_add_item(keymap, "GRAPHEDIT_OT_properties", NKEY, KM_PRESS, 0, 0);
|
2009-02-20 19:11:35 +00:00
|
|
|
|
2009-01-26 23:18:27 +00:00
|
|
|
/* channels */
|
|
|
|
/* Channels are not directly handled by the Graph 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
|
2009-01-28 06:32:47 +00:00
|
|
|
* are all used for the Graph Editor too.
|
2009-01-26 23:18:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* keyframes */
|
|
|
|
keymap= WM_keymap_listbase(wm, "GraphEdit Keys", SPACE_IPO, 0);
|
|
|
|
graphedit_keymap_keyframes(wm, keymap);
|
|
|
|
}
|
|
|
|
|