2009-02-21 10:38:58 +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) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation, Joshua Leung
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
#include "DNA_action_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_editVert.h"
|
|
|
|
#include "BLI_rand.h"
|
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2009-09-16 19:36:17 +00:00
|
|
|
#include "BKE_animsys.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
#include "BKE_depsgraph.h"
|
2009-03-15 10:39:02 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2009-09-16 19:36:17 +00:00
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2009-02-21 10:38:58 +00:00
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "ED_anim_api.h"
|
|
|
|
#include "ED_keyframing.h"
|
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_types.h"
|
|
|
|
#include "ED_util.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "graph_intern.h" // own include
|
|
|
|
|
2009-04-19 12:26:31 +00:00
|
|
|
/* XXX */
|
|
|
|
|
|
|
|
/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */
|
|
|
|
#define UI_FLT_MAX 10000.0f
|
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2009-02-22 09:30:18 +00:00
|
|
|
/* ******************* graph editor space & buttons ************** */
|
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
#define B_NOP 1
|
|
|
|
#define B_REDR 2
|
|
|
|
|
2009-02-22 09:30:18 +00:00
|
|
|
/* -------------- */
|
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
static void do_graph_region_buttons(bContext *C, void *arg, int event)
|
|
|
|
{
|
|
|
|
//Scene *scene= CTX_data_scene(C);
|
|
|
|
|
|
|
|
switch(event) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* default for now */
|
|
|
|
//WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
|
|
|
}
|
|
|
|
|
2009-10-27 11:46:46 +00:00
|
|
|
/* -------------- */
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
bAnimContext ac;
|
|
|
|
bAnimListElem *elem= NULL;
|
|
|
|
|
|
|
|
/* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
|
|
|
|
* to work correctly is able to be correctly retrieved. There's no point showing empty panels?
|
|
|
|
*/
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* try to find 'active' F-Curve */
|
|
|
|
elem= get_active_fcurve_channel(&ac);
|
|
|
|
if(elem == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(fcu)
|
|
|
|
*fcu= (FCurve*)elem->data;
|
|
|
|
if(ale)
|
|
|
|
*ale= elem;
|
|
|
|
else
|
|
|
|
MEM_freeN(elem);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int graph_panel_poll(const bContext *C, PanelType *pt)
|
|
|
|
{
|
|
|
|
return graph_panel_context(C, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2009-10-27 11:46:46 +00:00
|
|
|
/* -------------- */
|
|
|
|
|
|
|
|
/* Graph Editor View Settings */
|
|
|
|
static void graph_panel_view(const bContext *C, Panel *pa)
|
|
|
|
{
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
|
|
|
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
PointerRNA spaceptr, sceneptr;
|
|
|
|
uiLayout *col, *subcol;
|
|
|
|
|
|
|
|
/* get RNA pointers for use when creating the UI elements */
|
|
|
|
RNA_id_pointer_create(&scene->id, &sceneptr);
|
|
|
|
RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
|
|
|
|
|
|
|
|
/* 2D-Cursor */
|
|
|
|
col= uiLayoutColumn(pa->layout, 0);
|
|
|
|
uiItemR(col, NULL, 0, &spaceptr, "show_cursor", 0);
|
|
|
|
|
|
|
|
subcol= uiLayoutColumn(col, 1);
|
|
|
|
uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor"));
|
|
|
|
uiItemR(subcol, "Cursor X", 0, &sceneptr, "current_frame", 0);
|
|
|
|
uiItemR(subcol, "Cursor Y", 0, &spaceptr, "cursor_value", 0);
|
|
|
|
|
|
|
|
subcol= uiLayoutColumn(col, 1);
|
|
|
|
uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor"));
|
|
|
|
uiItemO(subcol, "Cursor from Selection", 0, "GRAPH_OT_frame_jump");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ******************* active F-Curve ************** */
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static void graph_panel_properties(const bContext *C, Panel *pa)
|
|
|
|
{
|
|
|
|
bAnimListElem *ale;
|
|
|
|
FCurve *fcu;
|
2009-11-08 06:43:08 +00:00
|
|
|
PointerRNA fcu_ptr;
|
|
|
|
uiLayout *layout = pa->layout;
|
|
|
|
uiLayout *col, *row, *subrow;
|
2009-02-21 10:38:58 +00:00
|
|
|
uiBlock *block;
|
2009-11-08 06:43:08 +00:00
|
|
|
char name[256];
|
|
|
|
int icon = 0;
|
2009-02-21 10:38:58 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
if (!graph_panel_context(C, &ale, &fcu))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
2009-11-08 06:43:08 +00:00
|
|
|
|
|
|
|
block= uiLayoutGetBlock(layout);
|
2009-05-19 17:13:33 +00:00
|
|
|
uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
|
2009-02-21 11:22:06 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
/* F-Curve pointer */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
/* user-friendly 'name' for F-Curve */
|
|
|
|
// TODO: only show the path if this is invalid?
|
|
|
|
col= uiLayoutColumn(layout, 0);
|
|
|
|
icon= getname_anim_fcurve(name, ale->id, fcu);
|
|
|
|
uiItemL(col, name, icon);
|
|
|
|
|
2009-11-17 22:46:42 +00:00
|
|
|
/* RNA-Path Editing - only really should be enabled when things aren't working */
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
|
|
|
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED));
|
2009-12-11 14:16:59 +00:00
|
|
|
uiItemR(col, "", ICON_RNA, &fcu_ptr, "data_path", 0);
|
2009-11-17 22:46:42 +00:00
|
|
|
uiItemR(col, NULL, 0, &fcu_ptr, "array_index", 0);
|
|
|
|
|
2009-11-08 06:43:08 +00:00
|
|
|
/* color settings */
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
|
|
|
uiItemL(col, "Display Color:", 0);
|
|
|
|
|
|
|
|
row= uiLayoutRow(col, 1);
|
|
|
|
uiItemR(row, "", 0, &fcu_ptr, "color_mode", 0);
|
|
|
|
|
|
|
|
subrow= uiLayoutRow(row, 1);
|
|
|
|
uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
|
|
|
|
uiItemR(subrow, "", 0, &fcu_ptr, "color", 0);
|
2009-02-21 11:22:06 +00:00
|
|
|
|
2009-02-22 09:30:18 +00:00
|
|
|
/* TODO: the following settings could be added here
|
|
|
|
* - Access details (ID-block + RNA-Path + Array Index)
|
|
|
|
* - ...
|
|
|
|
*/
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
MEM_freeN(ale);
|
2009-02-21 10:38:58 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 03:49:22 +00:00
|
|
|
/* ******************* drivers ******************************** */
|
2009-02-22 09:30:18 +00:00
|
|
|
|
|
|
|
#define B_IPO_DEPCHANGE 10
|
|
|
|
|
|
|
|
static void do_graph_region_driver_buttons(bContext *C, void *arg, int event)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
2009-04-11 00:29:21 +00:00
|
|
|
switch (event) {
|
2009-02-22 09:30:18 +00:00
|
|
|
case B_IPO_DEPCHANGE:
|
|
|
|
{
|
|
|
|
/* rebuild depsgraph for the new deps */
|
|
|
|
DAG_scene_sort(scene);
|
|
|
|
|
2009-04-13 00:46:32 +00:00
|
|
|
/* force an update of depsgraph */
|
2009-11-24 11:48:16 +00:00
|
|
|
DAG_ids_flush_update(0);
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* default for now */
|
2009-11-24 11:48:16 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); // XXX could use better notifier
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2009-04-11 06:48:39 +00:00
|
|
|
/* callback to remove the active driver */
|
|
|
|
static void driver_remove_cb (bContext *C, void *ale_v, void *dummy_v)
|
|
|
|
{
|
|
|
|
bAnimListElem *ale= (bAnimListElem *)ale_v;
|
|
|
|
ID *id= ale->id;
|
|
|
|
FCurve *fcu= ale->data;
|
|
|
|
|
|
|
|
/* try to get F-Curve that driver lives on, and ID block which has this AnimData */
|
|
|
|
if (ELEM(NULL, id, fcu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* call API method to remove this driver */
|
|
|
|
ANIM_remove_driver(id, fcu->rna_path, fcu->array_index, 0);
|
|
|
|
}
|
|
|
|
|
2009-04-16 12:38:44 +00:00
|
|
|
/* callback to add a target variable to the active driver */
|
|
|
|
static void driver_add_var_cb (bContext *C, void *driver_v, void *dummy_v)
|
|
|
|
{
|
|
|
|
ChannelDriver *driver= (ChannelDriver *)driver_v;
|
|
|
|
|
|
|
|
/* add a new var */
|
|
|
|
driver_add_new_target(driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* callback to remove target variable from active driver */
|
|
|
|
static void driver_delete_var_cb (bContext *C, void *driver_v, void *dtar_v)
|
|
|
|
{
|
|
|
|
ChannelDriver *driver= (ChannelDriver *)driver_v;
|
|
|
|
DriverTarget *dtar= (DriverTarget *)dtar_v;
|
|
|
|
|
2009-11-06 11:09:04 +00:00
|
|
|
/* remove the active target */
|
2009-04-16 12:38:44 +00:00
|
|
|
driver_free_target(driver, dtar);
|
|
|
|
}
|
|
|
|
|
2009-04-11 06:48:39 +00:00
|
|
|
/* callback to reset the driver's flags */
|
|
|
|
static void driver_update_flags_cb (bContext *C, void *fcu_v, void *dummy_v)
|
|
|
|
{
|
|
|
|
FCurve *fcu= (FCurve *)fcu_v;
|
|
|
|
ChannelDriver *driver= fcu->driver;
|
|
|
|
|
|
|
|
/* clear invalid flags */
|
2009-11-13 01:04:01 +00:00
|
|
|
fcu->flag &= ~FCURVE_DISABLED; // XXX?
|
2009-04-11 06:48:39 +00:00
|
|
|
driver->flag &= ~DRIVER_FLAG_INVALID;
|
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* drivers panel poll */
|
|
|
|
static int graph_panel_drivers_poll(const bContext *C, PanelType *pt)
|
|
|
|
{
|
2009-07-28 16:33:02 +00:00
|
|
|
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
if(sipo->mode != SIPO_MODE_DRIVERS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return graph_panel_context(C, NULL, NULL);
|
|
|
|
}
|
Animato - Drivers with Multiple Targets:
Drivers now support multiple targets which act as 'variables'. The targets have a short 'name' (see later), and reference some property (in much the same way as F-Curves do, using RNA-Paths) which acts as the 'value'.
These named variables can then be used in a Python Expression which relates them to each other for more fine-grained control over the result of the driver. By using only the names of these variables in the expressions, we are able to define expressions/relationships in a much more readable way, as data access is separated from data use. This makes the underlying relationships easier to understand.
By default, if no Python Expression is given, the variables are simply averaged together, so old files won't break. :)
For example, check the following diagram (thanks Cessen/Nathan V from Peach team):
http://download.blender.org/ftp/incoming/250_drivers_mockup_cessen.png
TODO List:
* Depsgraph building for new driver relationships doesn't work yet. This needs to be recoded again, but this new system makes this much easier, since the targets are clearly defined (i.e. no need to parse py expressions to get list of objects)
* Graph Editor interface for editing these needs to be rewritten
* Python function for evaluating these expressions is needed (Campbell?)
2009-04-16 07:37:06 +00:00
|
|
|
|
2009-09-16 19:36:17 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* driver settings for active F-Curve (only for 'Drivers' mode) */
|
|
|
|
static void graph_panel_drivers(const bContext *C, Panel *pa)
|
2009-02-22 09:30:18 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
bAnimListElem *ale;
|
|
|
|
FCurve *fcu;
|
|
|
|
ChannelDriver *driver;
|
2009-04-16 12:38:44 +00:00
|
|
|
DriverTarget *dtar;
|
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
PointerRNA driver_ptr;
|
|
|
|
uiLayout *col;
|
2009-02-22 09:30:18 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* Get settings from context */
|
|
|
|
if (!graph_panel_context(C, &ale, &fcu))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
|
|
|
driver= fcu->driver;
|
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* set event handler for panel */
|
|
|
|
block= uiLayoutGetBlock(pa->layout); // xxx?
|
2009-05-19 17:13:33 +00:00
|
|
|
uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* general actions - management */
|
|
|
|
col= uiLayoutColumn(pa->layout, 0);
|
|
|
|
block= uiLayoutGetBlock(col);
|
|
|
|
but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Update Dependencies", 0, 0, 10*UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, "Force updates of dependencies");
|
|
|
|
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
|
|
|
|
|
|
|
|
but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Remove Driver", 0, 0, 10*UI_UNIT_X, 18, NULL, 0.0, 0.0, 0, 0, "Remove this driver");
|
2009-11-16 12:44:33 +00:00
|
|
|
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* driver-level settings - type, expressions, and errors */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
|
2009-04-16 12:38:44 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
col= uiLayoutColumn(pa->layout, 1);
|
|
|
|
block= uiLayoutGetBlock(col);
|
|
|
|
uiItemR(col, NULL, 0, &driver_ptr, "type", 0);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
|
|
|
|
if (driver->type == DRIVER_TYPE_PYTHON) {
|
|
|
|
/* expression */
|
2009-11-24 11:48:16 +00:00
|
|
|
uiItemR(col, "Expr", 0, &driver_ptr, "expression", 0);
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* errors? */
|
|
|
|
if (driver->flag & DRIVER_FLAG_INVALID)
|
|
|
|
uiItemL(col, "ERROR: invalid Python expression", ICON_ERROR);
|
2009-04-16 12:38:44 +00:00
|
|
|
}
|
2009-10-14 11:57:26 +00:00
|
|
|
else {
|
|
|
|
/* errors? */
|
|
|
|
if (driver->flag & DRIVER_FLAG_INVALID)
|
|
|
|
uiItemL(col, "ERROR: invalid target channel(s)", ICON_ERROR);
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
2009-04-16 12:38:44 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* add driver target variables */
|
|
|
|
col= uiLayoutColumn(pa->layout, 0);
|
|
|
|
block= uiLayoutGetBlock(col);
|
2009-11-06 11:09:04 +00:00
|
|
|
but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Add Target", 0, 0, 10*UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "Add a new target variable for this Driver");
|
2009-10-14 11:57:26 +00:00
|
|
|
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
|
2009-04-16 12:38:44 +00:00
|
|
|
|
|
|
|
/* loop over targets, drawing them */
|
|
|
|
for (dtar= driver->targets.first; dtar; dtar= dtar->next) {
|
2009-10-14 11:57:26 +00:00
|
|
|
PointerRNA dtar_ptr;
|
|
|
|
uiLayout *box, *row;
|
2009-04-17 02:13:35 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* panel holding the buttons */
|
|
|
|
box= uiLayoutBox(pa->layout);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* first row context info for driver */
|
|
|
|
RNA_pointer_create(ale->id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
2009-04-11 00:29:21 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
row= uiLayoutRow(box, 0);
|
|
|
|
block= uiLayoutGetBlock(row);
|
|
|
|
/* variable name */
|
|
|
|
uiItemR(row, "", 0, &dtar_ptr, "name", 0);
|
|
|
|
|
|
|
|
/* remove button */
|
2009-11-24 11:48:16 +00:00
|
|
|
but= uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Delete target variable.");
|
2009-10-14 11:57:26 +00:00
|
|
|
uiButSetFunc(but, driver_delete_var_cb, driver, dtar);
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-04-11 06:48:39 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* Target ID */
|
|
|
|
row= uiLayoutRow(box, 0);
|
2009-11-24 04:21:32 +00:00
|
|
|
uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Value:");
|
2009-04-16 12:38:44 +00:00
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
/* Target Property */
|
|
|
|
// TODO: make this less technical...
|
2009-04-16 12:38:44 +00:00
|
|
|
if (dtar->id) {
|
2009-10-15 10:13:59 +00:00
|
|
|
PointerRNA root_ptr;
|
|
|
|
|
|
|
|
/* get pointer for resolving the property selected */
|
|
|
|
RNA_id_pointer_create(dtar->id, &root_ptr);
|
|
|
|
|
2009-10-14 11:57:26 +00:00
|
|
|
col= uiLayoutColumn(box, 1);
|
|
|
|
block= uiLayoutGetBlock(col);
|
|
|
|
/* rna path */
|
2009-12-11 14:16:59 +00:00
|
|
|
uiTemplatePathBuilder(col, (bContext *)C, &dtar_ptr, "data_path", &root_ptr, "Path");
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* array index */
|
|
|
|
// TODO: this needs selector which limits it to ok values
|
2009-11-26 11:13:10 +00:00
|
|
|
// NOTE: for for now, the array index box still gets shown when non-zero (i.e. for tweaking rigs as necessary)
|
|
|
|
if (dtar->array_index)
|
|
|
|
uiItemR(col, "Index", 0, &dtar_ptr, "array_index", 0);
|
2009-04-11 06:48:39 +00:00
|
|
|
}
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
2009-10-14 11:57:26 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2009-05-19 17:13:33 +00:00
|
|
|
MEM_freeN(ale);
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 03:49:22 +00:00
|
|
|
/* ******************* f-modifiers ******************************** */
|
2009-07-02 04:47:36 +00:00
|
|
|
/* all the drawing code is in editors/animation/fmodifier_ui.c */
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
#define B_FMODIFIER_REDRAW 20
|
|
|
|
|
2009-02-22 09:30:18 +00:00
|
|
|
static void do_graph_region_modifier_buttons(bContext *C, void *arg, int event)
|
|
|
|
{
|
2009-03-16 11:11:44 +00:00
|
|
|
switch (event) {
|
2009-03-15 10:39:02 +00:00
|
|
|
case B_REDR:
|
2009-03-16 11:11:44 +00:00
|
|
|
case B_FMODIFIER_REDRAW: // XXX this should send depsgraph updates too
|
2009-10-14 11:57:26 +00:00
|
|
|
WM_event_add_notifier(C, NC_ANIMATION, NULL); // XXX need a notifier specially for F-Modifiers
|
|
|
|
break;
|
2009-03-15 10:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static void graph_panel_modifiers(const bContext *C, Panel *pa)
|
2009-02-22 09:30:18 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
bAnimListElem *ale;
|
|
|
|
FCurve *fcu;
|
2009-03-15 10:39:02 +00:00
|
|
|
FModifier *fcm;
|
2009-07-02 12:41:03 +00:00
|
|
|
uiLayout *col, *row;
|
2009-02-22 09:30:18 +00:00
|
|
|
uiBlock *block;
|
2009-03-16 11:11:44 +00:00
|
|
|
|
2009-07-02 12:41:03 +00:00
|
|
|
if (!graph_panel_context(C, &ale, &fcu))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-07-02 12:41:03 +00:00
|
|
|
block= uiLayoutGetBlock(pa->layout);
|
2009-05-19 17:13:33 +00:00
|
|
|
uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL);
|
2009-03-16 11:11:44 +00:00
|
|
|
|
2009-03-15 10:39:02 +00:00
|
|
|
/* 'add modifier' button at top of panel */
|
2009-07-02 12:41:03 +00:00
|
|
|
{
|
|
|
|
row= uiLayoutRow(pa->layout, 0);
|
|
|
|
block= uiLayoutGetBlock(row);
|
|
|
|
|
|
|
|
// XXX for now, this will be a operator button which calls a temporary 'add modifier' operator
|
|
|
|
uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, "Add Modifier", 10, 0, 150, 20, "Adds a new F-Curve Modifier for the active F-Curve");
|
|
|
|
}
|
2009-03-15 10:39:02 +00:00
|
|
|
|
|
|
|
/* draw each modifier */
|
2009-07-02 12:41:03 +00:00
|
|
|
for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
|
|
|
|
col= uiLayoutColumn(pa->layout, 1);
|
|
|
|
|
2009-12-24 14:01:22 +00:00
|
|
|
ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
|
2009-07-02 12:41:03 +00:00
|
|
|
}
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
MEM_freeN(ale);
|
2009-02-22 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 03:49:22 +00:00
|
|
|
/* ******************* general ******************************** */
|
2009-02-22 09:30:18 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
void graph_buttons_register(ARegionType *art)
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
PanelType *pt;
|
|
|
|
|
2009-10-27 11:46:46 +00:00
|
|
|
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
|
|
|
|
strcpy(pt->idname, "GRAPH_PT_view");
|
2009-11-08 06:43:08 +00:00
|
|
|
strcpy(pt->label, "View Properties");
|
2009-10-27 11:46:46 +00:00
|
|
|
pt->draw= graph_panel_view;
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
|
|
|
strcpy(pt->idname, "GRAPH_PT_properties");
|
2009-11-08 06:43:08 +00:00
|
|
|
strcpy(pt->label, "Active F-Curve");
|
2009-05-19 17:13:33 +00:00
|
|
|
pt->draw= graph_panel_properties;
|
|
|
|
pt->poll= graph_panel_poll;
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
|
|
|
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
|
|
|
|
strcpy(pt->idname, "GRAPH_PT_drivers");
|
|
|
|
strcpy(pt->label, "Drivers");
|
|
|
|
pt->draw= graph_panel_drivers;
|
|
|
|
pt->poll= graph_panel_drivers_poll;
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
|
|
|
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
|
|
|
|
strcpy(pt->idname, "GRAPH_PT_modifiers");
|
|
|
|
strcpy(pt->label, "Modifiers");
|
|
|
|
pt->draw= graph_panel_modifiers;
|
|
|
|
pt->poll= graph_panel_poll;
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
2009-02-21 10:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int graph_properties(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
ARegion *ar= graph_has_buttons_region(sa);
|
|
|
|
|
2009-09-14 19:12:29 +00:00
|
|
|
if(ar)
|
|
|
|
ED_region_toggle_hidden(C, ar);
|
|
|
|
|
2009-02-21 10:38:58 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
2009-06-22 04:23:06 +00:00
|
|
|
void GRAPH_OT_properties(wmOperatorType *ot)
|
2009-02-21 10:38:58 +00:00
|
|
|
{
|
|
|
|
ot->name= "Properties";
|
2009-06-22 04:23:06 +00:00
|
|
|
ot->idname= "GRAPH_OT_properties";
|
2009-02-21 10:38:58 +00:00
|
|
|
|
|
|
|
ot->exec= graph_properties;
|
|
|
|
ot->poll= ED_operator_ipo_active; // xxx
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
ot->flag= 0;
|
|
|
|
}
|