149
145
col= uiLayoutColumn(pa->layout, 0);
150
uiItemR(col, &spaceptr, "show_cursor", 0, NULL, 0);
152
subcol= uiLayoutColumn(col, 1);
153
uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor"));
154
uiItemO(subcol, "Cursor from Selection", 0, "GRAPH_OT_frame_jump");
156
subcol= uiLayoutColumn(col, 1);
157
uiLayoutSetActive(subcol, RNA_boolean_get(&spaceptr, "show_cursor"));
158
row= uiLayoutSplit(subcol, 0.7, 1);
159
uiItemR(row, &sceneptr, "frame_current", 0, "Cursor X", 0);
160
uiItemEnumO(row, "GRAPH_OT_snap", "To Keys", 0, "type", GRAPHKEYS_SNAP_CFRA);
161
row= uiLayoutSplit(subcol, 0.7, 1);
162
uiItemR(row, &spaceptr, "cursor_value", 0, "Cursor Y", 0);
163
uiItemEnumO(row, "GRAPH_OT_snap", "To Keys", 0, "type", GRAPHKEYS_SNAP_VALUE);
146
uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
148
sub= uiLayoutColumn(col, 1);
149
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
150
uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
152
sub= uiLayoutColumn(col, 1);
153
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
154
row= uiLayoutSplit(sub, 0.7, 1);
155
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
156
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
157
row= uiLayoutSplit(sub, 0.7, 1);
158
uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
159
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
166
162
/* ******************* active F-Curve ************** */
186
182
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
188
184
/* user-friendly 'name' for F-Curve */
189
// TODO: only show the path if this is invalid?
185
/* TODO: only show the path if this is invalid? */
190
186
col= uiLayoutColumn(layout, 0);
191
187
icon= getname_anim_fcurve(name, ale->id, fcu);
192
188
uiItemL(col, name, icon);
194
190
/* RNA-Path Editing - only really should be enabled when things aren't working */
195
191
col= uiLayoutColumn(layout, 1);
196
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED));
192
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED)!=0);
197
193
uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
198
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, 0);
194
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
200
196
/* color settings */
201
197
col= uiLayoutColumn(layout, 1);
202
uiItemL(col, "Display Color:", 0);
198
uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
204
200
row= uiLayoutRow(col, 1);
205
uiItemR(row, &fcu_ptr, "color_mode", 0, "", 0);
201
uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
207
subrow= uiLayoutRow(row, 1);
208
uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
209
uiItemR(subrow, &fcu_ptr, "color", 0, "", 0);
203
sub= uiLayoutRow(row, 1);
204
uiLayoutSetEnabled(sub, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
205
uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
246
/* update callback for active keyframe properties - base updates stuff */
247
static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr))
249
SpaceIpo *sipo= CTX_wm_space_graph(C);
250
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
251
FCurve *fcu = (FCurve *)fcu_ptr;
253
/* make sure F-Curve and its handles are still valid after this editing */
254
sort_time_fcurve(fcu);
255
testhandles_fcurve(fcu, use_handle);
258
/* update callback for active keyframe properties - handle-editing wrapper */
259
static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
261
BezTriple *bezt = (BezTriple *)bezt_ptr;
263
/* since editing the handles, make sure they're set to types which are receptive to editing
264
* see transform_conversions.c :: createTransGraphEditData(), last step in second loop
266
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
267
/* by changing to aligned handles, these can now be moved... */
272
/* now call standard updates */
273
graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
250
276
static void graph_panel_key_properties(const bContext *C, Panel *pa)
252
278
bAnimListElem *ale;
266
292
/* only show this info if there are keyframes to edit */
267
293
if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
294
PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr;
295
PropertyRNA *fcu_prop = NULL;
297
int unit = B_UNIT_NONE;
270
299
/* RNA pointer to keyframe, to allow editing */
271
300
RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr);
302
/* get property that F-Curve affects, for some unit-conversion magic */
303
RNA_id_pointer_create(ale->id, &id_ptr);
304
if (RNA_path_resolve(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop) && fcu_prop) {
305
/* determine the unit for this property */
306
unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
273
309
/* interpolation */
274
310
col= uiLayoutColumn(layout, 0);
275
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, 0);
311
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
277
/* numerical coordinate editing */
313
/* numerical coordinate editing
314
* - we use the button-versions of the calls so that we can attach special update handlers
315
* and unit conversion magic that cannot be achieved using a purely RNA-approach
278
318
col= uiLayoutColumn(layout, 1);
279
319
/* keyframe itself */
280
uiItemR(col, &bezt_ptr, "co", 0, "Key", 0);
321
uiItemL(col, IFACE_("Key:"), ICON_NONE);
323
but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
324
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
325
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
327
but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
328
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
329
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
330
uiButSetUnitType(but, unit);
282
333
/* previous handle - only if previous was Bezier interpolation */
283
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ))
284
uiItemR(col, &bezt_ptr, "handle1", 0, NULL, 0);
334
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
335
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
337
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
338
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
339
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
341
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
342
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
343
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
344
uiButSetUnitType(but, unit);
286
347
/* next handle - only if current is Bezier interpolation */
287
if (bezt->ipo == BEZT_IPO_BEZ)
288
uiItemR(col, &bezt_ptr, "handle2", 0, NULL, 0);
291
uiItemL(layout, "No active keyframe on F-Curve", 0);
348
if (bezt->ipo == BEZT_IPO_BEZ) {
349
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
351
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
352
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
353
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
355
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
356
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
357
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
358
uiButSetUnitType(but, unit);
362
if ((fcu->bezt == NULL) && (fcu->modifiers.first)) {
363
/* modifiers only - so no keyframes to be active */
364
uiItemL(layout, IFACE_("F-Curve only has F-Modifiers"), ICON_NONE);
365
uiItemL(layout, IFACE_("See Modifiers panel below"), ICON_INFO);
369
uiItemL(layout, IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"),
373
uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
365
450
/* drivers panel poll */
366
static int graph_panel_drivers_poll(const bContext *C, PanelType *pt)
451
static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
368
453
SpaceIpo *sipo= CTX_wm_space_graph(C);
370
if(sipo->mode != SIPO_MODE_DRIVERS)
455
if (sipo->mode != SIPO_MODE_DRIVERS)
373
458
return graph_panel_context(C, NULL, NULL);
377
461
/* settings for 'single property' driver variable type */
378
static void graph_panel_driverVar__singleProp(const bContext *C, uiLayout *layout, ID *id, DriverVar *dvar)
462
static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVar *dvar)
380
464
DriverTarget *dtar= &dvar->targets[0];
381
465
PointerRNA dtar_ptr;
382
466
uiLayout *row, *col;
385
/* initialise RNA pointer to the target */
468
/* initialize RNA pointer to the target */
386
469
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
389
472
row= uiLayoutRow(layout, 0);
390
uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Prop:");
473
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
392
475
/* Target Property */
393
476
// TODO: make this less technical...
477
559
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
480
uiItemR(col, &dtar2_ptr, "use_local_space_transforms", 0, NULL, 0);
562
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
483
565
/* settings for 'transform channel' driver variable type */
484
static void graph_panel_driverVar__transChan(const bContext *C, uiLayout *layout, ID *id, DriverVar *dvar)
566
static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar *dvar)
486
568
DriverTarget *dtar= &dvar->targets[0];
487
569
Object *ob = (Object *)dtar->id;
488
570
PointerRNA dtar_ptr;
491
/* initialise RNA pointer to the target */
573
/* initialize RNA pointer to the target */
492
574
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
495
577
col= uiLayoutColumn(layout, 1);
496
uiTemplateAnyID(col, (bContext *)C, &dtar_ptr, "id", "id_type", "Ob/Bone:");
578
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:"));
498
580
if (dtar->id && ob->pose) {
499
581
PointerRNA tar_ptr;
532
614
/* general actions - management */
533
615
col= uiLayoutColumn(pa->layout, 0);
534
616
block= uiLayoutGetBlock(col);
535
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");
617
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10*UI_UNIT_X, 22,
618
NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
536
619
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
538
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");
621
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10*UI_UNIT_X, 18,
622
NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
539
623
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
541
625
/* driver-level settings - type, expressions, and errors */
544
628
col= uiLayoutColumn(pa->layout, 1);
545
629
block= uiLayoutGetBlock(col);
546
uiItemR(col, &driver_ptr, "type", 0, NULL, 0);
630
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
548
632
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
549
633
if (driver->type == DRIVER_TYPE_PYTHON) {
551
uiItemR(col, &driver_ptr, "expression", 0, "Expr", 0);
635
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
554
638
if (driver->flag & DRIVER_FLAG_INVALID)
555
uiItemL(col, "ERROR: invalid Python expression", ICON_ERROR);
639
uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
559
643
if (driver->flag & DRIVER_FLAG_INVALID)
560
uiItemL(col, "ERROR: invalid target channel(s)", ICON_ERROR);
644
uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
563
647
col= uiLayoutColumn(pa->layout, 1);
564
648
/* debug setting */
565
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, 0);
649
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
567
651
/* value of driver */
568
652
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
569
653
uiLayout *row= uiLayoutRow(col, 1);
572
uiItemL(row, "Driver Value:", 0);
656
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
574
sprintf(valBuf, "%.3f", driver->curval);
575
uiItemL(row, valBuf, 0);
658
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
659
uiItemL(row, valBuf, ICON_NONE);
578
662
/* add driver variables */
579
663
col= uiLayoutColumn(pa->layout, 0);
580
664
block= uiLayoutGetBlock(col);
581
but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Add Variable", 0, 0, 10*UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "Add a new target variable for this Driver");
665
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10*UI_UNIT_X, UI_UNIT_Y,
666
NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
582
667
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
584
669
/* loop over targets, drawing them */
597
682
row= uiLayoutRow(box, 0);
598
683
block= uiLayoutGetBlock(row);
599
684
/* variable name */
600
uiItemR(row, &dvar_ptr, "name", 0, "", 0);
685
uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
602
687
/* remove button */
603
688
uiBlockSetEmboss(block, UI_EMBOSSN);
604
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.");
689
but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
690
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
605
691
uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
606
692
uiBlockSetEmboss(block, UI_EMBOSS);
608
694
/* variable type */
609
695
row= uiLayoutRow(box, 0);
610
uiItemR(row, &dvar_ptr, "type", 0, "", 0);
696
uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
612
698
/* variable type settings */
613
699
box= uiLayoutBox(col);
614
700
/* controls to draw depends on the type of variable */
615
701
switch (dvar->type) {
616
702
case DVAR_TYPE_SINGLE_PROP: /* single property */
617
graph_panel_driverVar__singleProp(C, box, ale->id, dvar);
703
graph_panel_driverVar__singleProp(box, ale->id, dvar);
619
705
case DVAR_TYPE_ROT_DIFF: /* rotational difference */
620
graph_panel_driverVar__rotDiff(C, box, ale->id, dvar);
706
graph_panel_driverVar__rotDiff(box, ale->id, dvar);
622
708
case DVAR_TYPE_LOC_DIFF: /* location difference */
623
graph_panel_driverVar__locDiff(C, box, ale->id, dvar);
709
graph_panel_driverVar__locDiff(box, ale->id, dvar);
625
711
case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
626
graph_panel_driverVar__transChan(C, box, ale->id, dvar);
712
graph_panel_driverVar__transChan(box, ale->id, dvar);
630
/* value of variable */
631
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
635
box= uiLayoutBox(col);
636
row= uiLayoutRow(box, 1);
637
uiItemL(row, "Value:", 0);
716
/* value of variable */
717
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
720
box= uiLayoutBox(col);
721
row= uiLayoutRow(box, 1);
722
uiItemL(row, IFACE_("Value:"), ICON_NONE);
639
sprintf(valBuf, "%.3f", dvar->curval);
640
uiItemL(row, valBuf, 0);
724
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
725
uiItemL(row, valBuf, ICON_NONE);
707
792
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
708
793
strcpy(pt->idname, "GRAPH_PT_view");
709
strcpy(pt->label, "View Properties");
794
strcpy(pt->label, N_("View Properties"));
710
795
pt->draw= graph_panel_view;
711
796
pt->flag |= PNL_DEFAULT_CLOSED;
712
797
BLI_addtail(&art->paneltypes, pt);
714
799
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
715
800
strcpy(pt->idname, "GRAPH_PT_properties");
716
strcpy(pt->label, "Active F-Curve");
801
strcpy(pt->label, N_("Active F-Curve"));
717
802
pt->draw= graph_panel_properties;
718
803
pt->poll= graph_panel_poll;
719
804
BLI_addtail(&art->paneltypes, pt);
721
806
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
722
807
strcpy(pt->idname, "GRAPH_PT_key_properties");
723
strcpy(pt->label, "Active Keyframe");
808
strcpy(pt->label, N_("Active Keyframe"));
724
809
pt->draw= graph_panel_key_properties;
725
810
pt->poll= graph_panel_poll;
726
811
BLI_addtail(&art->paneltypes, pt);
729
814
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
730
815
strcpy(pt->idname, "GRAPH_PT_drivers");
731
strcpy(pt->label, "Drivers");
816
strcpy(pt->label, N_("Drivers"));
732
817
pt->draw= graph_panel_drivers;
733
818
pt->poll= graph_panel_drivers_poll;
734
819
BLI_addtail(&art->paneltypes, pt);
736
821
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
737
822
strcpy(pt->idname, "GRAPH_PT_modifiers");
738
strcpy(pt->label, "Modifiers");
823
strcpy(pt->label, N_("Modifiers"));
739
824
pt->draw= graph_panel_modifiers;
740
825
pt->poll= graph_panel_poll;
741
826
BLI_addtail(&art->paneltypes, pt);
744
static int graph_properties(bContext *C, wmOperator *op)
829
static int graph_properties(bContext *C, wmOperator *UNUSED(op))
746
831
ScrArea *sa= CTX_wm_area(C);
747
832
ARegion *ar= graph_has_buttons_region(sa);
750
835
ED_region_toggle_hidden(C, ar);
752
837
return OPERATOR_FINISHED;