Blender V5.3
graph_buttons.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <cfloat>
12#include <cstring>
13
14#include "DNA_anim_enums.h"
15#include "DNA_anim_types.h"
16#include "DNA_object_types.h"
17#include "DNA_scene_types.h"
18
19#include "MEM_guardedalloc.h"
20
21#include "BLI_listbase.hh"
23#include "BLI_string.hh"
24#include "BLI_string_utf8.hh"
25#include "BLI_utildefines.hh"
26
27#include "BLT_translation.hh"
28
29#include "BKE_anim_data.hh"
30#include "BKE_context.hh"
31#include "BKE_curve.hh"
32#include "BKE_fcurve.hh"
33#include "BKE_fcurve_driver.h"
34#include "BKE_global.hh"
35#include "BKE_screen.hh"
36#include "BKE_unit.hh"
37
38#include "DEG_depsgraph.hh"
40
41#include "WM_api.hh"
42#include "WM_types.hh"
43
44#include "RNA_access.hh"
45#include "RNA_path.hh"
46#include "RNA_prototypes.hh"
47
48#include "ED_anim_api.hh"
49#include "ED_screen.hh"
50#include "ED_undo.hh"
51
52#include "UI_interface.hh"
54#include "UI_resources.hh"
55
56#include "graph_intern.hh" /* own include */
57
58namespace blender {
59
60/* -------------------------------------------------------------------- */
63
64static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
65{
66 bAnimContext ac;
67 bAnimListElem *elem = nullptr;
68
69 /* For now, only draw if we could init the anim-context info
70 * (necessary for all animation-related tools)
71 * to work correctly is able to be correctly retrieved.
72 * There's no point showing empty panels?
73 */
74 if (ANIM_animdata_get_context(C, &ac) == 0) {
75 return false;
76 }
77
78 /* try to find 'active' F-Curve */
79 elem = get_active_fcurve_channel(&ac);
80 if (elem == nullptr) {
81 return false;
82 }
83
84 if (fcu) {
85 *fcu = static_cast<FCurve *>(elem->data);
86 }
87 if (ale) {
88 *ale = elem;
89 }
90 else {
91 MEM_delete(elem);
92 }
93
94 return true;
95}
96
98{
99 FCurve *fcu;
100 if (!graph_panel_context(C, nullptr, &fcu)) {
101 return nullptr;
102 }
103
104 return fcu;
105}
106
107static bool graph_panel_poll(const bContext *C, PanelType * /*pt*/)
108{
109 return graph_panel_context(C, nullptr, nullptr);
110}
111
113
114/* -------------------------------------------------------------------- */
117
118static void graph_panel_cursor_header(const bContext *C, Panel *panel)
119{
120 bScreen *screen = CTX_wm_screen(C);
122
123 /* get RNA pointers for use when creating the UI elements */
124 PointerRNA spaceptr = RNA_pointer_create_discrete(&screen->id, RNA_SpaceGraphEditor, sipo);
125
126 /* 2D-Cursor */
127 ui::Layout &col = panel->layout->column(false);
128 col.prop(&spaceptr, "show_cursor", UI_ITEM_NONE, "", ICON_NONE);
129}
130
131static void graph_panel_cursor(const bContext *C, Panel *panel)
132{
133 bScreen *screen = CTX_wm_screen(C);
135 Scene *scene = CTX_data_scene(C);
136 ui::Layout &layout = *panel->layout;
137
138 /* get RNA pointers for use when creating the UI elements */
139 PointerRNA sceneptr = RNA_id_pointer_create(&scene->id);
140 PointerRNA spaceptr = RNA_pointer_create_discrete(&screen->id, RNA_SpaceGraphEditor, sipo);
141
142 layout.use_property_split_set(true);
143 layout.use_property_decorate_set(false);
144
145 /* 2D-Cursor */
146 ui::Layout &col = layout.column(false);
147 col.active_set(RNA_boolean_get(&spaceptr, "show_cursor"));
148
149 ui::Layout &pos_sub = col.column(true);
150 if (sipo->mode == SIPO_MODE_DRIVERS) {
151 pos_sub.prop(&spaceptr, "cursor_position_x", UI_ITEM_NONE, IFACE_("Cursor X"), ICON_NONE);
152 }
153 else {
154 pos_sub.prop(&sceneptr, "frame_current", UI_ITEM_NONE, IFACE_("Cursor X"), ICON_NONE);
155 }
156
157 pos_sub.prop(&spaceptr, "cursor_position_y", UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
158
159 ui::Layout &sub = col.column(true);
160 sub.op("GRAPH_OT_frame_jump", IFACE_("Cursor to Selection"), ICON_NONE);
161 sub.op("GRAPH_OT_snap_cursor_value", IFACE_("Cursor Value to Selection"), ICON_NONE);
162}
163
165
166/* -------------------------------------------------------------------- */
169
170static void graph_panel_properties(const bContext *C, Panel *panel)
171{
172 bAnimListElem *ale;
173 FCurve *fcu;
174 ui::Layout &layout = *panel->layout;
175 char name[256];
176 int icon = 0;
177
178 if (!graph_panel_context(C, &ale, &fcu)) {
179 return;
180 }
181
182 /* F-Curve pointer */
183 PointerRNA fcu_ptr = RNA_pointer_create_discrete(ale->fcurve_owner_id, RNA_FCurve, fcu);
184
185 /* user-friendly 'name' for F-Curve */
186 ui::Layout &name_col = layout.column(false);
187 if (ale->type == ANIMTYPE_FCURVE) {
188 /* get user-friendly name for F-Curve */
189 const std::optional<int> optional_icon = getname_anim_fcurve(name, ale->id, fcu);
190 if (optional_icon) {
191 icon = *optional_icon;
192 }
193 else if (ale->id) {
195 }
196 else {
197 icon = ICON_NONE;
198 }
199 }
200 else {
201 /* NLA Control Curve, etc. */
203
204 /* get name */
205 if (acf && acf->name) {
206 acf->name(ale, name);
207 }
208 else {
209 STRNCPY_UTF8(name, IFACE_("<invalid>"));
210 icon = ICON_STATUS_ERROR;
211 }
212
213 /* icon */
214 if (ale->type == ANIMTYPE_NLACURVE) {
215 icon = ICON_NLA;
216 }
217 }
218 name_col.label(name, icon);
219
220 layout.use_property_split_set(true);
221 layout.use_property_decorate_set(false);
222
223 /* RNA-Path Editing - only really should be enabled when things aren't working */
224 ui::Layout &rna_col = layout.column(false);
225 rna_col.enabled_set((fcu->flag & FCURVE_DISABLED) != 0);
226 rna_col.prop(&fcu_ptr, "data_path", UI_ITEM_NONE, "", ICON_RNA);
227 rna_col.prop(&fcu_ptr, "array_index", UI_ITEM_NONE, std::nullopt, ICON_NONE);
228
229 /* color settings */
230 ui::Layout &color_col = layout.column(true);
231 color_col.prop(&fcu_ptr, "color_mode", UI_ITEM_NONE, IFACE_("Display Color"), ICON_NONE);
232
233 if (fcu->color_mode == FCURVE_COLOR_CUSTOM) {
234 color_col.prop(&fcu_ptr, "color", UI_ITEM_NONE, IFACE_("Color"), ICON_NONE);
235 }
236
237 /* smoothing setting */
238 ui::Layout &smooth_col = layout.column(true);
239 smooth_col.prop(&fcu_ptr, "auto_smoothing", UI_ITEM_NONE, IFACE_("Handle Smoothing"), ICON_NONE);
240
241 MEM_delete(ale);
242}
243
245
246/* -------------------------------------------------------------------- */
249
250/* get 'active' keyframe for panel editing */
252 BezTriple **r_bezt,
253 BezTriple **r_prevbezt)
254{
255 /* zero the pointers */
256 *r_bezt = *r_prevbezt = nullptr;
257
258 const int active_keyframe_index = BKE_fcurve_active_keyframe_index(fcu);
259 if (active_keyframe_index == FCURVE_ACTIVE_KEYFRAME_NONE) {
260 return false;
261 }
262
263 /* The active keyframe should be selected. */
264 BLI_assert(BEZT_ISSEL_ANY(&fcu->bezt[active_keyframe_index]));
265
266 *r_bezt = &fcu->bezt[active_keyframe_index];
267 /* Previous is either one before the active, or the point itself if it's the first. */
268 const int prev_index = max_ii(active_keyframe_index - 1, 0);
269 *r_prevbezt = &fcu->bezt[prev_index];
270
271 return true;
272}
273
274/* update callback for active keyframe properties - base updates stuff */
275static void graphedit_activekey_update_cb(bContext * /*C*/, void *fcu_ptr, void * /*bezt_ptr*/)
276{
277 FCurve *fcu = static_cast<FCurve *>(fcu_ptr);
278
279 /* make sure F-Curve and its handles are still valid after this editing */
280 sort_time_fcurve(*fcu);
282}
283
284/* update callback for active keyframe properties - handle-editing wrapper */
285static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
286{
287 BezTriple *bezt = static_cast<BezTriple *>(bezt_ptr);
288
289 /* since editing the handles, make sure they're set to types which are receptive to editing
290 * see transform_conversions.c :: createTransGraphEditData(), last step in second loop
291 */
292 if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
293 /* by changing to aligned handles, these can now be moved... */
294 bezt->h1 = HD_ALIGN;
295 bezt->h2 = HD_ALIGN;
296 }
297 else {
299 }
300
301 /* now call standard updates */
302 graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
303}
304
305static void graphedit_activekey_handle_left_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
306{
309 graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
310}
311
312static void graphedit_activekey_handle_right_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
313{
316 graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr);
317}
318
319/* update callback for editing coordinates of right handle in active keyframe properties
320 * NOTE: we cannot just do graphedit_activekey_handles_cb() due to "order of computation"
321 * weirdness (see calchandleNurb_intern() and #39911)
322 */
323static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
324{
325 BezTriple *bezt = static_cast<BezTriple *>(bezt_ptr);
326
327 const eBezTriple_Flag f1 = bezt->f1;
328 const eBezTriple_Flag f3 = bezt->f3;
329
330 bezt->f1 |= BEZT_FLAG_SELECT;
331 bezt->f3 &= ~BEZT_FLAG_SELECT;
332
333 /* perform normal updates NOW */
334 graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
335
336 /* restore selection state so that no one notices this hack */
337 bezt->f1 = f1;
338 bezt->f3 = f3;
339}
340
341static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
342{
343 BezTriple *bezt = static_cast<BezTriple *>(bezt_ptr);
344
345 /* original state of handle selection - to be restored after performing the recalculation */
346 const eBezTriple_Flag f1 = bezt->f1;
347 const eBezTriple_Flag f3 = bezt->f3;
348
349 /* temporarily make it so that only the right handle is selected, so that updates go correctly
350 * (i.e. it now acts as if we've just transforming the vert when it is selected by itself)
351 */
352 bezt->f1 &= ~BEZT_FLAG_SELECT;
353 bezt->f3 |= BEZT_FLAG_SELECT;
354
355 /* perform normal updates NOW */
356 graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr);
357
358 /* restore selection state so that no one notices this hack */
359 bezt->f1 = f1;
360 bezt->f3 = f3;
361}
362
363static void graph_panel_key_properties(const bContext *C, Panel *panel)
364{
365 bAnimListElem *ale;
366 FCurve *fcu;
367 BezTriple *bezt, *prevbezt;
368
369 ui::Layout &layout = *panel->layout;
370 const ARegion *region = CTX_wm_region(C);
371 /* Just a width big enough so buttons use entire layout width (will be clamped by it then). */
372 const int but_max_width = region->winx;
373
374 if (!graph_panel_context(C, &ale, &fcu)) {
375 return;
376 }
377
378 ui::Block *block = layout.block();
379 layout.use_property_split_set(true);
380 layout.use_property_decorate_set(false);
381
382 /* only show this info if there are keyframes to edit */
383 if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
384 PointerRNA fcu_prop_ptr;
385 PropertyRNA *fcu_prop = nullptr;
386 ui::Button *but;
387 int unit = B_UNIT_NONE;
388
389 /* RNA pointer to keyframe, to allow editing */
390 PointerRNA bezt_ptr = RNA_pointer_create_discrete(ale->fcurve_owner_id, RNA_Keyframe, bezt);
391
392 /* get property that F-Curve affects, for some unit-conversion magic */
393 PointerRNA id_ptr = RNA_id_pointer_create(ale->id);
394 if (RNA_path_resolve_property(&id_ptr, fcu->rna_path_parsed(), &fcu_prop_ptr, &fcu_prop)) {
395 /* determine the unit for this property */
396 unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
397 }
398
399 /* interpolation */
400 ui::Layout &interpolation_col = layout.column(false);
401 if (fcu->flag & FCURVE_DISCRETE_VALUES) {
402 ui::Layout &split = interpolation_col.split(0.33f, true);
403 split.label(IFACE_("Interpolation:"), ICON_NONE);
404 split.label(IFACE_("None for Enum/Boolean"), ICON_IPO_CONSTANT);
405 }
406 else {
407 interpolation_col.prop(&bezt_ptr, "interpolation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
408 }
409
410 /* easing type */
411 if (bezt->ipo > BEZT_IPO_BEZ) {
412 interpolation_col.prop(&bezt_ptr, "easing", UI_ITEM_NONE, std::nullopt, ICON_NONE);
413 }
414
415 /* easing extra */
416 switch (bezt->ipo) {
417 case BEZT_IPO_BACK: {
418 ui::Layout &col = layout.column(true);
419 col.prop(&bezt_ptr, "back", UI_ITEM_NONE, std::nullopt, ICON_NONE);
420 break;
421 }
422 case BEZT_IPO_ELASTIC: {
423 ui::Layout &col = layout.column(true);
424 col.prop(&bezt_ptr, "amplitude", UI_ITEM_NONE, std::nullopt, ICON_NONE);
425 col.prop(&bezt_ptr, "period", UI_ITEM_NONE, std::nullopt, ICON_NONE);
426 break;
427 }
428 default:
429 break;
430 }
431
432 /* numerical coordinate editing
433 * - we use the button-versions of the calls so that we can attach special update handlers
434 * and unit conversion magic that cannot be achieved using a purely RNA-approach
435 */
436 /* keyframe itself */
437 {
438 ui::Layout &col = layout.column(true);
439 uiItemL_respect_property_split(&col, IFACE_("Key Frame"), ICON_NONE);
440 but = uiDefButR(block,
442 "",
443 0,
444 0,
445 but_max_width,
446 UI_UNIT_Y,
447 &bezt_ptr,
448 "co_ui",
449 0,
450 0,
451 0,
452 std::nullopt);
453 button_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
454
455 uiItemL_respect_property_split(&col, IFACE_("Value"), ICON_NONE);
456 but = uiDefButR(block,
458 "",
459 0,
460 0,
461 but_max_width,
462 UI_UNIT_Y,
463 &bezt_ptr,
464 "co_ui",
465 1,
466 0,
467 0,
468 std::nullopt);
469 button_func_set(but, graphedit_activekey_update_cb, fcu, bezt);
470 button_unit_type_set(but, unit);
471 }
472
473 /* previous handle - only if previous was Bezier interpolation */
474 if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
475
476 ui::Layout &col = layout.column(true);
477 uiItemL_respect_property_split(&col, IFACE_("Left Handle Type"), ICON_NONE);
478 but = uiDefButR(block,
480 std::nullopt,
481 0,
482 0,
483 but_max_width,
484 UI_UNIT_Y,
485 &bezt_ptr,
486 "handle_left_type",
487 0,
488 0,
489 0,
490 "Type of left handle");
491 button_func_set(but, graphedit_activekey_handle_left_cb, fcu, bezt);
492
493 uiItemL_respect_property_split(&col, IFACE_("Frame"), ICON_NONE);
494 but = uiDefButR(block,
496 "",
497 0,
498 0,
499 but_max_width,
500 UI_UNIT_Y,
501 &bezt_ptr,
502 "handle_left",
503 0,
504 0,
505 0,
506 std::nullopt);
507 button_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
508
509 uiItemL_respect_property_split(&col, IFACE_("Value"), ICON_NONE);
510 but = uiDefButR(block,
512 "",
513 0,
514 0,
515 but_max_width,
516 UI_UNIT_Y,
517 &bezt_ptr,
518 "handle_left",
519 1,
520 0,
521 0,
522 std::nullopt);
523 button_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt);
524 button_unit_type_set(but, unit);
525 }
526
527 /* next handle - only if current is Bezier interpolation */
528 if (bezt->ipo == BEZT_IPO_BEZ) {
529 /* NOTE: special update callbacks are needed on the coords here due to #39911 */
530
531 ui::Layout &col = layout.column(true);
532 uiItemL_respect_property_split(&col, IFACE_("Right Handle Type"), ICON_NONE);
533 but = uiDefButR(block,
535 std::nullopt,
536 0,
537 0,
538 but_max_width,
539 UI_UNIT_Y,
540 &bezt_ptr,
541 "handle_right_type",
542 0,
543 0,
544 0,
545 "Type of right handle");
546 button_func_set(but, graphedit_activekey_handle_right_cb, fcu, bezt);
547
548 uiItemL_respect_property_split(&col, IFACE_("Frame"), ICON_NONE);
549 but = uiDefButR(block,
551 "",
552 0,
553 0,
554 but_max_width,
555 UI_UNIT_Y,
556 &bezt_ptr,
557 "handle_right",
558 0,
559 0,
560 0,
561 std::nullopt);
562 button_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
563
564 uiItemL_respect_property_split(&col, IFACE_("Value"), ICON_NONE);
565 but = uiDefButR(block,
567 "",
568 0,
569 0,
570 but_max_width,
571 UI_UNIT_Y,
572 &bezt_ptr,
573 "handle_right",
574 1,
575 0,
576 0,
577 std::nullopt);
578 button_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt);
579 button_unit_type_set(but, unit);
580 }
581 }
582 else {
583 if ((fcu->bezt == nullptr) && (fcu->modifiers.first_)) {
584 /* modifiers only - so no keyframes to be active */
585 layout.label(RPT_("F-Curve only has F-Modifiers"), ICON_NONE);
586 layout.label(RPT_("See Modifiers panel below"), ICON_STATUS_INFO);
587 }
588 else if (fcu->fpt) {
589 /* samples only */
590 layout.label(RPT_("F-Curve does not have any keyframes as it only contains sampled points"),
591 ICON_NONE);
592 }
593 else {
594 layout.label(RPT_("No active keyframe on F-Curve"), ICON_NONE);
595 }
596 }
597
598 MEM_delete(ale);
599}
600
602
603/* -------------------------------------------------------------------- */
606
607static void do_graph_region_driver_buttons(bContext *C, void * /*id_p*/, int /*event*/)
608{
609 /* default for now */
611 C, NC_SCENE | ND_FRAME, CTX_data_scene(C)); /* XXX could use better notifier */
612}
613
615{
616 Main *bmain = CTX_data_main(C);
618
619 /* Rebuild depsgraph for the new dependencies, and ensure evaluated copies get flushed. */
622 if (adt != nullptr) {
623 if (adt->action != nullptr) {
625 }
626 if (adt->tmpact != nullptr) {
628 }
629 }
630}
631
632/* callback to add a target variable to the active driver */
634{
635 /* add a new variable */
637 ED_undo_push(C, "Add Driver Variable");
638}
639
640/* callback to remove target variable from active driver */
642{
643 /* remove the active variable */
644 driver_free_variable_ex(driver, dvar);
645 ED_undo_push(C, "Delete Driver Variable");
646}
647
648/* callback to report why a driver variable is invalid */
650{
652 C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Invalid Variable Name"), ICON_NONE);
653 ui::Layout &layout = *popup_menu_layout(pup);
654
655 if (dvar->flag & DVAR_FLAG_INVALID_EMPTY) {
656 layout.label(RPT_("It cannot be left blank"), ICON_STATUS_ERROR);
657 }
658 if (dvar->flag & DVAR_FLAG_INVALID_START_NUM) {
659 layout.label(RPT_("It cannot start with a number"), ICON_STATUS_ERROR);
660 }
662 layout.label(RPT_("It cannot start with a special character,"
663 " including '$', '@', '!', '~', '+', '-', '_', '.', or ' '"),
664 ICON_NONE);
665 }
666 if (dvar->flag & DVAR_FLAG_INVALID_HAS_SPACE) {
667 layout.label(RPT_("It cannot contain spaces (e.g. 'a space')"), ICON_STATUS_ERROR);
668 }
669 if (dvar->flag & DVAR_FLAG_INVALID_HAS_DOT) {
670 layout.label(RPT_("It cannot contain dots (e.g. 'a.dot')"), ICON_STATUS_ERROR);
671 }
673 layout.label(RPT_("It cannot contain special (non-alphabetical/numeric) characters"),
674 ICON_STATUS_ERROR);
675 }
677 layout.label(RPT_("It cannot be a reserved keyword in Python"), ICON_STATUS_ERROR);
678 }
679
680 popup_menu_end(C, pup);
681}
682
683/* callback to reset the driver's flags */
685{
686 ChannelDriver *driver = fcu->driver;
687
688 /* clear invalid flags */
689 fcu->flag &= ~FCURVE_DISABLED;
690 driver->flag &= ~DRIVER_FLAG_INVALID;
691}
692
693/* drivers panel poll */
694static bool graph_panel_drivers_poll(const bContext *C, PanelType * /*pt*/)
695{
697
698 if (sipo->mode != SIPO_MODE_DRIVERS) {
699 return false;
700 }
701
702 return graph_panel_context(C, nullptr, nullptr);
703}
704
706 const DriverTarget *dtar,
707 PointerRNA *dtar_ptr)
708{
709 if (dtar->options & DTAR_OPTION_USE_FALLBACK) {
710 ui::Layout &row = layout.row(true);
711 row.prop(dtar_ptr, "use_fallback_value", UI_ITEM_NONE, "", ICON_NONE);
712 row.prop(dtar_ptr, "fallback_value", UI_ITEM_NONE, std::nullopt, ICON_NONE);
713 }
714 else {
715 layout.prop(dtar_ptr, "use_fallback_value", UI_ITEM_NONE, std::nullopt, ICON_NONE);
716 }
717}
718
719/* settings for 'single property' driver variable type */
721{
722 DriverTarget *dtar = &dvar->targets[0];
723
724 /* initialize RNA pointer to the target */
725 PointerRNA dtar_ptr = RNA_pointer_create_discrete(id, RNA_DriverTarget, dtar);
726
727 /* Target ID */
728 ui::Layout &row = layout.row(false);
729 row.red_alert_set((dtar->flag & DTAR_FLAG_INVALID) && !dtar->id);
730 template_any_id(&row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
731
732 /* Target Property */
733 if (dtar->id) {
734 /* get pointer for resolving the property selected */
735 PointerRNA root_ptr = RNA_id_pointer_create(dtar->id);
736
737 /* rna path */
738 ui::Layout &col = layout.column(true);
740 template_path_builder(&col,
741 &dtar_ptr,
742 "data_path",
743 &root_ptr,
745
746 /* Default value. */
747 graph_panel_driverVar_fallback(layout, dtar, &dtar_ptr);
748 }
749}
750
751/* settings for 'rotation difference' driver variable type */
752/* FIXME: 1) Must be same armature for both dtars, 2) Alignment issues... */
754{
755 for (int i : IndexRange(2)) {
756 DriverTarget *dtar = &dvar->targets[i];
757 /* Initialize RNA pointer to the target */
758 PointerRNA ptr = RNA_pointer_create_discrete(id, RNA_DriverTarget, dtar);
759
760 ui::Layout &col = layout.column(true);
761 col.red_alert_set(dtar->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
762 StringRef name = i == 1 ? IFACE_("Object 1") : IFACE_("Object 2");
763 col.prop(&ptr, "id", UI_ITEM_NONE, name, ICON_NONE);
764
765 Object *ob = id_cast<Object *>(dtar->id);
766 if (dtar->id && GS(dtar->id->name) == ID_OB && ob->pose) {
767 PointerRNA tar_ptr = RNA_pointer_create_discrete(dtar->id, RNA_Pose, ob->pose);
768 col.prop_search(&ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
769 }
770 }
771}
772
773/* settings for 'location difference' driver variable type */
774
776{
777
778 for (int i : IndexRange(2)) {
779 DriverTarget *dtar = &dvar->targets[i];
780 /* Initialize RNA pointer to the target */
781 PointerRNA ptr = RNA_pointer_create_discrete(id, RNA_DriverTarget, dtar);
782
783 ui::Layout &col = layout.column(true);
784 col.red_alert_set(dtar->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
785 StringRef name = i == 1 ? IFACE_("Object 1") : IFACE_("Object 2");
786 col.prop(&ptr, "id", UI_ITEM_NONE, name, ICON_NONE);
787
788 Object *ob = id_cast<Object *>(dtar->id);
789
790 if (dtar->id && GS(dtar->id->name) == ID_OB && ob->pose) {
791 PointerRNA tar_ptr = RNA_pointer_create_discrete(dtar->id, RNA_Pose, ob->pose);
792 col.prop_search(&ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA);
793 }
794
795 /* We can clear it again now - it's only needed when creating the ID/Bone fields */
796 col.red_alert_set(false);
797
798 col.prop(&ptr, "transform_space", UI_ITEM_NONE, std::nullopt, ICON_NONE);
799 }
800}
801
802/* settings for 'transform channel' driver variable type */
804{
805 DriverTarget *dtar = &dvar->targets[0];
806 Object *ob = id_cast<Object *>(dtar->id);
807
808 /* initialize RNA pointer to the target */
809 PointerRNA dtar_ptr = RNA_pointer_create_discrete(id, RNA_DriverTarget, dtar);
810
811 /* properties */
812 ui::Layout &col = layout.column(true);
813 col.red_alert_set(dtar->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
814 col.prop(&dtar_ptr, "id", UI_ITEM_NONE, IFACE_("Object"), ICON_NONE);
815
816 if (dtar->id && GS(dtar->id->name) == ID_OB && ob->pose) {
817 PointerRNA tar_ptr = RNA_pointer_create_discrete(dtar->id, RNA_Pose, ob->pose);
818 col.prop_search(&dtar_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA);
819 }
820
821 ui::Layout &sub = layout.column(true);
822 sub.prop(&dtar_ptr, "transform_type", UI_ITEM_NONE, std::nullopt, ICON_NONE);
823
824 if (ELEM(dtar->transChan,
829 {
830 sub.prop(&dtar_ptr, "rotation_mode", UI_ITEM_NONE, IFACE_("Mode"), ICON_NONE);
831 }
832
833 sub.prop(&dtar_ptr, "transform_space", UI_ITEM_NONE, IFACE_("Space"), ICON_NONE);
834}
835
836/* Settings for 'Context Property' driver variable type. */
838{
839 DriverTarget *dtar = &dvar->targets[0];
840
841 /* Initialize RNA pointer to the target. */
842 PointerRNA dtar_ptr = RNA_pointer_create_discrete(id, RNA_DriverTarget, dtar);
843
844 /* Target Property. */
845 {
846 ui::Layout &row = layout.row(false);
847 row.prop(&dtar_ptr, "context_property", UI_ITEM_NONE, std::nullopt, ICON_NONE);
848 }
849
850 /* Target Path */
851 {
852 ui::Layout &col = layout.column(true);
854 template_path_builder(&col,
855 &dtar_ptr,
856 "data_path",
857 nullptr,
859 }
860
861 /* Default value. */
862 graph_panel_driverVar_fallback(layout, dtar, &dtar_ptr);
863}
864
865/* ----------------------------------------------------------------- */
866
867/* property driven by the driver - duplicates Active FCurve, but useful for clarity */
868
870 ID *id,
871 FCurve *fcu,
872 const char *label)
873{
874 PointerRNA fcurve_ptr = RNA_pointer_create_discrete(id, RNA_FCurve, fcu);
875
876 ui::Block *block = layout.block();
877 uiDefButR(block,
879 label,
880 0,
881 0,
882 UI_UNIT_X,
883 UI_UNIT_Y,
884 &fcurve_ptr,
885 "mute",
886 0,
887 0,
888 0,
889 TIP_("Let the driver determine this property's value"));
890}
891
892static void graph_panel_drivers_header(const bContext *C, Panel *panel)
893{
894 bAnimListElem *ale;
895 FCurve *fcu;
896 if (!graph_panel_context(C, &ale, &fcu)) {
897 return;
898 }
899
900 graph_draw_driven_property_enabled_btn(*panel->layout, ale->id, fcu, IFACE_("Driver"));
901 MEM_delete(ale);
902}
903
905{
906 char name[256];
907 int icon = 0;
908
909 /* get user-friendly 'name' for F-Curve */
910 const std::optional<int> optional_icon = getname_anim_fcurve(name, id, fcu);
911 if (optional_icon) {
912 icon = *optional_icon;
913 }
914 else {
916 }
917
918 /* panel layout... */
919 ui::Layout &row = layout.row(true);
921
922 /* -> user friendly 'name' for datablock that owns F-Curve */
923 /* XXX: Actually, we may need the datablock icons only...
924 * (e.g. right now will show bone for bone props). */
925 row.label(id->name + 2, icon);
926
927 /* -> user friendly 'name' for F-Curve/driver target */
928 row.label("", ICON_RIGHTARROW);
929 row.label(name, ICON_RNA);
930}
931
932/* UI properties panel layout for driver settings - shared for Drivers Editor and for */
934 ID *id,
935 FCurve *fcu,
936 const bool is_popover)
937{
938 ChannelDriver *driver = fcu->driver;
939 ui::Block *block = layout.block();
940
941 ui::Button *but;
942
943 /* set event handler for panel */
944 block_func_handle_set(block, do_graph_region_driver_buttons, id);
945
946 /* driver-level settings - type, expressions, and errors */
947 PointerRNA driver_ptr = RNA_pointer_create_discrete(id, RNA_Driver, driver);
948
949 {
950 ui::Layout &col = layout.column(true);
951 col.prop(&driver_ptr, "type", UI_ITEM_NONE, std::nullopt, ICON_NONE);
952
953 char valBuf[32];
954
955 /* value of driver */
956 ui::Layout &row = col.row(true);
957 row.label(IFACE_("Driver Value:"), ICON_NONE);
958 SNPRINTF_UTF8(valBuf, "%.3f", driver->curval);
959 row.label(valBuf, ICON_NONE);
960 }
961
962 layout.separator();
963 layout.separator();
964
965 /* show expression box if doing scripted drivers,
966 * and/or error messages when invalid drivers exist */
967 if (driver->type == DRIVER_TYPE_PYTHON) {
968 bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != nullptr);
969 bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != nullptr);
970
971 /* expression */
972 /* TODO: "Show syntax hints" button */
973 ui::Layout &expr_col = layout.column(true);
974
975 expr_col.label(IFACE_("Expression:"), ICON_NONE);
976 expr_col.prop(&driver_ptr, "expression", UI_ITEM_NONE, "", ICON_NONE);
977 expr_col.prop(&driver_ptr, "use_self", UI_ITEM_NONE, std::nullopt, ICON_NONE);
978
979 /* errors? */
980 ui::Layout &error_col = layout.column(true);
981
982 if (driver->flag & DRIVER_FLAG_PYTHON_BLOCKED) {
983 /* TODO: Add button to enable? */
984 error_col.label(RPT_("Python restricted for security"), ICON_STATUS_ERROR);
985 error_col.label(RPT_("Slow Python expression"), ICON_STATUS_INFO);
986 }
987 else if (driver->flag & DRIVER_FLAG_INVALID) {
988 error_col.label(RPT_("ERROR: Invalid Python expression"), ICON_STATUS_ERROR);
989 }
990 else if (!BKE_driver_has_simple_expression(driver)) {
991 error_col.label(RPT_("Slow Python expression"), ICON_STATUS_INFO);
992 }
993
994 /* Explicit bpy-references are evil. Warn about these to prevent errors */
995 /* TODO: put these in a box? */
996 if (bpy_data_expr_error || bpy_ctx_expr_error) {
997 error_col.label(RPT_("WARNING: Driver expression may not work correctly"), ICON_HELP);
998
999 if (bpy_data_expr_error) {
1000 error_col.label(RPT_("TIP: Use variables instead of bpy.data paths (see below)"),
1001 ICON_STATUS_WARNING);
1002 }
1003 if (bpy_ctx_expr_error) {
1004 error_col.label(RPT_("TIP: bpy.context is not safe for renderfarm usage"),
1005 ICON_STATUS_WARNING);
1006 }
1007 }
1008 }
1009 else {
1010 /* errors? */
1011 ui::Layout &col = layout.column(true);
1012
1013 if (driver->flag & DRIVER_FLAG_INVALID) {
1014 col.label(RPT_("ERROR: Invalid target channel(s)"), ICON_STATUS_ERROR);
1015 }
1016
1017 /* Warnings about a lack of variables
1018 * NOTE: The lack of variables is generally a bad thing, since it indicates
1019 * that the driver doesn't work at all. This particular scenario arises
1020 * primarily when users mistakenly try to use drivers for procedural
1021 * property animation
1022 */
1023 if (driver->variables.is_empty()) {
1024 col.label(RPT_("ERROR: Driver is useless without any inputs"), ICON_STATUS_ERROR);
1025
1026 if (!fcu->modifiers.is_empty()) {
1027 col.label(RPT_("TIP: Use F-Curves for procedural animation instead"), ICON_STATUS_INFO);
1028 col.label(RPT_("F-Modifiers can generate curves for those too"), ICON_STATUS_INFO);
1029 }
1030 }
1031 }
1032
1033 layout.separator();
1034
1035 /* add/copy/paste driver variables */
1036 ui::Layout &row = layout.row(false);
1037
1038 {
1039 /* Add driver variable - add blank. */
1040 ui::Layout &sub = row.row(true);
1041 but = uiDefIconTextBut(
1042 block,
1044 ICON_ADD,
1045 IFACE_("Add Input Variable"),
1046 0,
1047 0,
1048 10 * UI_UNIT_X,
1049 UI_UNIT_Y,
1050 nullptr,
1051 TIP_("Add a Driver Variable to keep track of an input used by the driver"));
1052 button_func_set(but, [id, driver](bContext &C) {
1053 driver_add_var_cb(&C, driver);
1055 });
1056
1057 if (is_popover) {
1058 /* add driver variable - add using eyedropper */
1059 /* XXX: will this operator work like this? */
1060 sub.op("UI_OT_eyedropper_driver", "", ICON_EYEDROPPER);
1061 }
1062 }
1063
1064 {
1065 /* copy/paste (as sub-row) */
1066 ui::Layout &sub = row.row(true);
1067
1068 sub.op("GRAPH_OT_driver_variables_copy", "", ICON_COPYDOWN);
1069 sub.op("GRAPH_OT_driver_variables_paste", "", ICON_PASTEDOWN);
1070 }
1071
1072 /* loop over targets, drawing them */
1073 for (DriverVar &dvar : driver->variables) {
1074
1075 /* sub-layout column for this variable's settings */
1076 ui::Layout &col = layout.column(true);
1077
1078 /* 1) header panel */
1079 ui::Layout &header_box = col.box();
1080 PointerRNA dvar_ptr = RNA_pointer_create_discrete(id, RNA_DriverVariable, &dvar);
1081
1082 /* 1.1) variable type and name */
1083 ui::Layout &sub = header_box.row(false).row(true);
1084
1085 /* 1.1.1) variable type */
1086
1087 /* HACK: special group just for the enum,
1088 * otherwise we get ugly layout with text included too... */
1089 ui::Layout &type_sub = sub.row(true);
1090
1092
1093 type_sub.prop(&dvar_ptr, "type", ui::ITEM_R_ICON_ONLY, "", ICON_NONE);
1094
1095 /* 1.1.2) variable name */
1096
1097 /* HACK: special group to counteract the effects of the previous enum,
1098 * which now pushes everything too far right */
1099 ui::Layout &name_sub = sub.row(true);
1100
1102
1103 name_sub.prop(&dvar_ptr, "name", UI_ITEM_NONE, "", ICON_NONE);
1104
1105 /* 1.2) invalid name? */
1106 block_emboss_set(block, ui::EmbossType::None);
1107
1108 if (dvar.flag & DVAR_FLAG_INVALID_NAME) {
1109 but = uiDefIconBut(block,
1111 ICON_STATUS_ERROR,
1112 290,
1113 0,
1114 UI_UNIT_X,
1115 UI_UNIT_Y,
1116 nullptr,
1117 0.0,
1118 0.0,
1119 TIP_("Invalid variable name, click here for details"));
1120 button_func_set(
1121 but, [dvar = &dvar](bContext &C) { driver_dvar_invalid_name_query_cb(&C, dvar); });
1122 }
1123
1124 /* 1.3) remove button */
1125 but = uiDefIconBut(block,
1127 ICON_X,
1128 290,
1129 0,
1130 UI_UNIT_X,
1131 UI_UNIT_Y,
1132 nullptr,
1133 0.0,
1134 0.0,
1135 TIP_("Delete target variable"));
1136 button_func_set(but, [id, driver, dvar = &dvar](bContext &C) {
1137 driver_delete_var_cb(&C, driver, dvar);
1139 });
1140 block_emboss_set(block, ui::EmbossType::Emboss);
1141
1142 /* 2) variable type settings */
1143 ui::Layout &box = col.box();
1144 /* controls to draw depends on the type of variable */
1145 switch (dvar.type) {
1146 case DVAR_TYPE_SINGLE_PROP: /* single property */
1147 graph_panel_driverVar__singleProp(box, id, &dvar);
1148 break;
1149 case DVAR_TYPE_ROT_DIFF: /* rotational difference */
1150 graph_panel_driverVar__rotDiff(box, id, &dvar);
1151 break;
1152 case DVAR_TYPE_LOC_DIFF: /* location difference */
1153 graph_panel_driverVar__locDiff(box, id, &dvar);
1154 break;
1155 case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
1156 graph_panel_driverVar__transChan(box, id, &dvar);
1157 break;
1158 case DVAR_TYPE_CONTEXT_PROP: /* context property */
1159 graph_panel_driverVar__contextProp(box, id, &dvar);
1160 break;
1161 case MAX_DVAR_TYPES:
1162 break;
1163 }
1164
1165 /* 3) value of variable */
1166 {
1167 char valBuf[32];
1168
1169 ui::Layout &sub = col.box().row(true);
1170 sub.label(IFACE_("Value:"), ICON_NONE);
1171
1172 if ((dvar.type == DVAR_TYPE_ROT_DIFF) ||
1173 (dvar.type == DVAR_TYPE_TRANSFORM_CHAN &&
1174 ELEM(dvar.targets[0].transChan,
1180 {
1181 SNPRINTF_UTF8(valBuf,
1182 "%.3f (%4.1f" BLI_STR_UTF8_DEGREE_SIGN ")",
1183 dvar.curval,
1184 RAD2DEGF(dvar.curval));
1185 }
1186 else {
1187 SNPRINTF_UTF8(valBuf, "%.3f", dvar.curval);
1188 }
1189
1190 sub.label(valBuf, ICON_NONE);
1191 }
1192 }
1193
1194 layout.separator();
1195 layout.separator();
1196
1197 /* XXX: This should become redundant. But sometimes the flushing fails,
1198 * so keep this around for a while longer as a "last resort" */
1199 layout.row(true);
1200 but = uiDefIconTextBut(block,
1202 ICON_FILE_REFRESH,
1203 IFACE_("Update Dependencies"),
1204 0,
1205 0,
1206 10 * UI_UNIT_X,
1207 UI_UNIT_Y,
1208 nullptr,
1209 TIP_("Force updates of dependencies - Only use this if drivers are not "
1210 "updating correctly"));
1211 button_func_set(but, [id, fcu](bContext &C) {
1214 });
1215}
1216
1217/* ----------------------------------------------------------------- */
1218
1219/* Panel to show property driven by the driver (in Drivers Editor) - duplicates Active FCurve,
1220 * but useful for clarity. */
1221static void graph_panel_driven_property(const bContext *C, Panel *panel)
1222{
1223 bAnimListElem *ale;
1224 FCurve *fcu;
1225
1226 if (!graph_panel_context(C, &ale, &fcu)) {
1227 return;
1228 }
1229
1230 graph_draw_driven_property_panel(*panel->layout, ale->id, fcu);
1231
1232 MEM_delete(ale);
1233}
1234
1235/* driver settings for active F-Curve
1236 * (only for 'Drivers' mode in Graph Editor, i.e. the full "Drivers Editor") */
1237static void graph_panel_drivers(const bContext *C, Panel *panel)
1238{
1239 bAnimListElem *ale;
1240 FCurve *fcu;
1241
1242 /* Get settings from context */
1243 if (!graph_panel_context(C, &ale, &fcu)) {
1244 return;
1245 }
1246
1247 graph_draw_driver_settings_panel(*panel->layout, ale->id, fcu, false);
1248
1249 /* cleanup */
1250 MEM_delete(ale);
1251}
1252
1253/* ----------------------------------------------------------------- */
1254
1255/* Poll to make this not show up in the graph editor,
1256 * as this is only to be used as a popup elsewhere. */
1258{
1259 return ED_operator_graphedit_active(const_cast<bContext *>(C)) == false;
1260}
1261
1262/* popover panel for driver editing anywhere in ui */
1263static void graph_panel_drivers_popover(const bContext *C, Panel *panel)
1264{
1265 ui::Layout &layout = *panel->layout;
1266
1267 PointerRNA ptr = {};
1268 PropertyRNA *prop = nullptr;
1269 int index = -1;
1270 ui::Button *but = nullptr;
1271
1272 /* Get active property to show driver properties for */
1273 but = ui::region_active_but_prop_get(CTX_wm_region(C), &ptr, &prop, &index);
1274 if (but) {
1275 FCurve *fcu;
1276 bool driven, special;
1277
1279 const_cast<bContext *>(C), &ptr, prop, index, nullptr, nullptr, &driven, &special);
1280
1281 /* Hack: Force all buttons in this panel to be able to know the driver button
1282 * this panel is getting spawned from, so that things like the "Open Drivers Editor"
1283 * button will work.
1284 */
1285 layout.context_set_from_but(but);
1286
1287 /* Populate Panel - With a combination of the contents of the Driven and Driver panels */
1288 if (fcu && fcu->driver) {
1289 ID *id = ptr.owner_id;
1290
1291 PointerRNA ptr_fcurve = RNA_pointer_create_discrete(id, RNA_FCurve, fcu);
1292 layout.context_ptr_set("active_editable_fcurve", &ptr_fcurve);
1293
1294 /* Driven Property Settings */
1295 layout.label(IFACE_("Driven Property:"), ICON_NONE);
1296 graph_draw_driven_property_panel(*panel->layout, id, fcu);
1297 /* TODO: All vs Single */
1298
1299 layout.separator();
1300 layout.separator();
1301
1302 /* Drivers Settings */
1303 graph_draw_driven_property_enabled_btn(*panel->layout, id, fcu, IFACE_("Driver:"));
1304 graph_draw_driver_settings_panel(*panel->layout, id, fcu, true);
1305 }
1306 }
1307
1308 /* Show drivers editor is always visible */
1309 layout.op("SCREEN_OT_drivers_editor_show", IFACE_("Show in Drivers Editor"), ICON_DRIVER);
1310}
1311
1313
1314/* -------------------------------------------------------------------- */
1319
1321#define GRAPH_FMODIFIER_PANEL_PREFIX "GRAPH"
1322
1323static void graph_fmodifier_panel_id(void *fcm_link, char *r_name)
1324{
1325 FModifier *fcm = static_cast<FModifier *>(fcm_link);
1327 const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type);
1328
1329 if (!fmi) {
1330 /* This can happen when the blend file has data for a modifier that doesn't exist in this
1331 * Blender version (when the blend file is newer). */
1332 r_name[0] = '\0';
1333 return;
1334 }
1335
1337}
1338
1339static void graph_panel_modifiers(const bContext *C, Panel *panel)
1340{
1341 bAnimListElem *ale;
1342 FCurve *fcu;
1343
1344 if (!graph_panel_context(C, &ale, &fcu)) {
1345 return;
1346 }
1347
1348 /* 'add modifier' button at top of panel */
1349 {
1350 ui::Layout &row = panel->layout->row(false);
1351
1352 /* this is an operator button which calls a 'add modifier' operator...
1353 * a menu might be nicer but would be tricky as we need some custom filtering
1354 */
1355 row.op_menu_enum(C, "GRAPH_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE);
1356
1357 /* copy/paste (as sub-row) */
1358 ui::Layout &sub = row.row(true);
1359 sub.op("GRAPH_OT_fmodifier_copy", "", ICON_COPYDOWN);
1360 sub.op("GRAPH_OT_fmodifier_paste", "", ICON_PASTEDOWN);
1361 }
1362
1364
1365 MEM_delete(ale);
1366}
1367
1369
1370/* -------------------------------------------------------------------- */
1373
1375{
1376 PanelType *pt;
1377
1378 pt = MEM_new_zeroed<PanelType>("spacetype graph panel properties");
1379 STRNCPY_UTF8(pt->idname, "GRAPH_PT_properties");
1380 STRNCPY_UTF8(pt->label, N_("Active F-Curve"));
1381 STRNCPY_UTF8(pt->category, "F-Curve");
1384 pt->poll = graph_panel_poll;
1385 BLI_addtail(&art->paneltypes, pt);
1386
1387 pt = MEM_new_zeroed<PanelType>("spacetype graph panel properties");
1388 STRNCPY_UTF8(pt->idname, "GRAPH_PT_key_properties");
1389 STRNCPY_UTF8(pt->label, N_("Active Keyframe"));
1390 STRNCPY_UTF8(pt->category, "F-Curve");
1393 pt->poll = graph_panel_poll;
1394 BLI_addtail(&art->paneltypes, pt);
1395
1396 pt = MEM_new_zeroed<PanelType>("spacetype graph panel drivers driven");
1397 STRNCPY_UTF8(pt->idname, "GRAPH_PT_driven_property");
1398 STRNCPY_UTF8(pt->label, N_("Driven Property"));
1399 STRNCPY_UTF8(pt->category, "Drivers");
1403 BLI_addtail(&art->paneltypes, pt);
1404
1405 pt = MEM_new_zeroed<PanelType>("spacetype graph panel drivers");
1406 STRNCPY_UTF8(pt->idname, "GRAPH_PT_drivers");
1407 STRNCPY_UTF8(pt->label, N_("Driver"));
1408 STRNCPY_UTF8(pt->category, "Drivers");
1413 BLI_addtail(&art->paneltypes, pt);
1414
1415 pt = MEM_new_zeroed<PanelType>("spacetype graph panel drivers popover");
1416 STRNCPY_UTF8(pt->idname, "GRAPH_PT_drivers_popover");
1417 STRNCPY_UTF8(pt->label, N_("Add/Edit Driver"));
1418 STRNCPY_UTF8(pt->category, "Drivers");
1422 BLI_addtail(&art->paneltypes, pt);
1423 /* This panel isn't used in this region.
1424 * Add explicitly to global list (so popovers work). */
1425 WM_paneltype_add(pt);
1426
1427 pt = MEM_new_zeroed<PanelType>("spacetype graph panel modifiers");
1428 STRNCPY_UTF8(pt->idname, "GRAPH_PT_modifiers");
1429 STRNCPY_UTF8(pt->label, N_("Modifiers"));
1430 STRNCPY_UTF8(pt->category, "Modifiers");
1434 pt->poll = graph_panel_poll;
1435 BLI_addtail(&art->paneltypes, pt);
1436
1439
1440 pt = MEM_new_zeroed<PanelType>("spacetype graph panel view");
1441 STRNCPY_UTF8(pt->idname, "GRAPH_PT_view");
1442 STRNCPY_UTF8(pt->label, N_("Show Cursor"));
1443 STRNCPY_UTF8(pt->category, "View");
1447 BLI_addtail(&art->paneltypes, pt);
1448}
1449
1451
1452} // namespace blender
#define SELECT
Definition BKE_mask.hh:19
#define BKE_ST_MAXNAME
Definition BKE_screen.hh:91
#define RAD2DEGF(_rad)
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define BLI_STR_UTF8_DEGREE_SIGN
#define RPT_(msgid)
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
#define BLT_I18NCONTEXT_EDITOR_FILEBROWSER
#define FCURVE_ACTIVE_KEYFRAME_NONE
#define BEZT_ISSEL_ANY(bezt)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define RNA_SUBTYPE_UNIT(subtype)
Definition RNA_types.hh:266
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_UNIT_X
#define UI_ITEM_NONE
#define NC_SCENE
Definition WM_types.hh:391
#define ND_FRAME
Definition WM_types.hh:453
#define ELEM(...)
constexpr IndexRange()=default
#define GRAPH_FMODIFIER_PANEL_PREFIX
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition abc_util.cc:68
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
Button * region_active_but_prop_get(const ARegion *region, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
@ DVAR_TYPE_TRANSFORM_CHAN
@ DVAR_TYPE_SINGLE_PROP
@ DVAR_TYPE_CONTEXT_PROP
static bool graph_panel_poll(const bContext *C, PanelType *)
static void do_graph_dependency_change_cb(bContext *C, ID *id)
@ DRIVER_FLAG_PYTHON_BLOCKED
@ DRIVER_FLAG_INVALID
static void graph_panel_drivers_header(const bContext *C, Panel *panel)
static void graph_fmodifier_panel_id(void *fcm_link, char *r_name)
bool ED_operator_graphedit_active(bContext *C)
bool WM_paneltype_add(PanelType *pt)
static void graph_panel_driven_property(const bContext *C, Panel *panel)
const bAnimChannelType * ANIM_channel_get_typeinfo(const bAnimListElem *ale)
static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
static void graph_panel_driverVar__transChan(ui::Layout &layout, ID *id, DriverVar *dvar)
void BKE_nurb_bezt_handle_test(BezTriple *bezt, eBezTriple_Flag__Alias sel_flag, const eNurbHandleTest_Mode handle_mode, bool use_around_local)
Definition curve.cc:4083
PointerRNA RNA_id_pointer_create(ID *id)
void BKE_fcurve_update_handle_flag_from_opposite(BezTriple &key, HandleSide source_side)
StructRNA * ID_code_to_RNA_type(short idcode)
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
void driver_free_variable_ex(struct ChannelDriver *driver, struct DriverVar *dvar)
void ANIM_modifier_panels_register_graph_only(ARegionType *region_type, const char *modifier_panel_prefix, PanelTypePollFn poll_function)
static void graphedit_activekey_handle_right_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
MINLINE int max_ii(int a, int b)
@ NURB_HANDLE_TEST_EACH
Definition BKE_curve.hh:65
@ DTAR_ROTMODE_QUATERNION
@ ANIMTYPE_NLACURVE
@ ANIMTYPE_FCURVE
static void driver_add_var_cb(bContext *C, ChannelDriver *driver)
static void driver_dvar_invalid_name_query_cb(bContext *C, DriverVar *dvar)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
static void graph_panel_cursor_header(const bContext *C, Panel *panel)
static void do_graph_region_driver_buttons(bContext *C, void *, int)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
static bool graph_panel_drivers_popover_poll(const bContext *C, PanelType *)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static void graph_panel_driverVar__contextProp(ui::Layout &layout, ID *id, DriverVar *dvar)
void BKE_fcurve_handles_recalc(FCurve &fcu)
static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
static void driver_update_flags_cb(FCurve *fcu)
void ANIM_fmodifier_panels(const bContext *C, ID *owner_id, ListBaseT< FModifier > *fmodifiers, uiListPanelIDFromDataFunc panel_id_fn)
@ DTAR_OPTION_USE_FALLBACK
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:103
@ FCURVE_DISCRETE_VALUES
static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
void graph_buttons_register(ARegionType *art)
static void graph_draw_driven_property_panel(ui::Layout &layout, ID *id, FCurve *fcu)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
static void graph_draw_driven_property_enabled_btn(ui::Layout &layout, ID *id, FCurve *fcu, const char *label)
static void graphedit_activekey_handle_left_cb(bContext *C, void *fcu_ptr, void *bezt_ptr)
SpaceGraph * CTX_wm_space_graph(const bContext *C)
bAnimListElem * get_active_fcurve_channel(bAnimContext *ac)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static void graph_panel_properties(const bContext *C, Panel *panel)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int RNA_struct_ui_icon(const StructRNA *type)
static void graphedit_activekey_update_cb(bContext *, void *fcu_ptr, void *)
static bool get_active_fcurve_keyframe_edit(const FCurve *fcu, BezTriple **r_bezt, BezTriple **r_prevbezt)
@ DTAR_TRANSCHAN_ROTY
@ DTAR_TRANSCHAN_ROTW
@ DTAR_TRANSCHAN_ROTX
@ DTAR_TRANSCHAN_ROTZ
static void graph_panel_key_properties(const bContext *C, Panel *panel)
static void graph_draw_driver_settings_panel(ui::Layout &layout, ID *id, FCurve *fcu, const bool is_popover)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
@ PANEL_TYPE_NO_HEADER
FCurve * ANIM_graph_context_fcurve(const bContext *C)
std::optional< int > getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
ID_Type GS(const char *name)
Definition DNA_ID.h:410
static void graph_panel_modifiers(const bContext *C, Panel *panel)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
void ANIM_modifier_panels_register_graph_and_NLA(ARegionType *region_type, const char *modifier_panel_prefix, PanelTypePollFn poll_function)
static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
static void graph_panel_drivers_popover(const bContext *C, Panel *panel)
FCurve * BKE_fcurve_find_by_rna_context_ui(bContext *C, const PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_animdata, bAction **r_action, bool *r_driven, bool *r_special)
static bool graph_panel_drivers_poll(const bContext *C, PanelType *)
@ FCURVE_COLOR_CUSTOM
static void graph_panel_cursor(const bContext *C, Panel *panel)
static void graph_panel_driverVar__locDiff(ui::Layout &layout, ID *id, DriverVar *dvar)
@ DTAR_FLAG_FALLBACK_USED
@ DVAR_FLAG_INVALID_HAS_DOT
@ DVAR_FLAG_INVALID_EMPTY
@ DVAR_FLAG_INVALID_NAME
@ DVAR_FLAG_INVALID_HAS_SPECIAL
@ DVAR_FLAG_INVALID_PY_KEYWORD
@ DVAR_FLAG_INVALID_HAS_SPACE
@ DVAR_FLAG_INVALID_START_NUM
@ DVAR_FLAG_INVALID_START_CHAR
bool BKE_driver_has_simple_expression(struct ChannelDriver *driver)
@ B_UNIT_NONE
Definition BKE_unit.hh:165
static void driver_delete_var_cb(bContext *C, ChannelDriver *driver, DriverVar *dvar)
static void graph_panel_drivers(const bContext *C, Panel *panel)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:578
ARegion * CTX_wm_region(const bContext *C)
const FModifierTypeInfo * get_fmodifier_typeinfo(int type)
static void graph_panel_driverVar__singleProp(ui::Layout &layout, ID *id, DriverVar *dvar)
struct DriverVar * driver_add_new_variable(struct ChannelDriver *driver)
void sort_time_fcurve(FCurve &fcu)
static void graph_panel_driverVar__rotDiff(ui::Layout &layout, ID *id, DriverVar *dvar)
static void graph_panel_driverVar_fallback(ui::Layout &layout, const DriverTarget *dtar, PointerRNA *dtar_ptr)
ListBaseT< PanelType > paneltypes
eBezTriple_Handle h2
eBezTriple_Flag f3
eBezTriple_Flag f1
eBezTriple_Interpolation ipo
eBezTriple_Handle h1
ListBaseT< DriverVar > variables
eDriverTarget_Options options
eDriverTarget_Flag flag
eDriverTarget_RotationMode rotation_mode
eDriverTarget_TransformChannels transChan
eDriverVar_Flags flag
eDriverVar_Types type
DriverTarget targets[8]
eFCurve_Flags flag
ListBaseT< FModifier > modifiers
ChannelDriver * driver
eFCurve_Coloring color_mode
eFModifier_Types type
char name[258]
Definition DNA_ID.h:433
struct bPose * pose
char translation_context[BKE_ST_MAXNAME]
void(*) draw(const bContext *C, Panel *panel)
char category[BKE_ST_MAXNAME]
bool(*) poll(const bContext *C, PanelType *pt)
void(*) draw_header(const bContext *C, Panel *panel)
char idname[BKE_ST_MAXNAME]
char label[BKE_ST_MAXNAME]
ui::Layout * layout
eGraphEdit_Mode mode
void(*) name(bAnimListElem *ale, char *name)
eAnim_ChannelType type
void enabled_set(bool enabled)
void alignment_set(LayoutAlign alignment)
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< StringRefNull > name, int icon, bool results_are_suggestions)
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
PointerRNA op_menu_enum(const bContext *C, wmOperatorType *ot, StringRefNull propname, std::optional< StringRefNull > name, int icon)
void label(StringRef name, int icon)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
void context_set_from_but(const Button *but)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void red_alert_set(bool red_alert)
void active_set(bool active)
Layout & split(float percentage, bool align)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & row(bool align)
void context_ptr_set(StringRef name, const PointerRNA *ptr)
#define N_(msgid)