Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2018-06-11 08:35:13 +0300
committerJoshua Leung <aligorith@gmail.com>2018-06-11 08:35:13 +0300
commit4605e57b0f60fef282afeae3756211fe6ac1c572 (patch)
treec1ba134f97f0134bf58f09b12623c3fe521e2c2d /source/blender/editors/animation/drivers.c
parentf1e3e50294689350b08f2a4ea26c311273a37b8a (diff)
Drivers Workflow (T55145): Improvements to "Add Driver" workflow
This commit implements a new behaviour for the "Add Driver" functionality (invoked from the RMB menu on a property, or by pressing Ctrl-D). Instead of spawning a context menu asking you to pick the way you want to create a driver, it will now just create a driver on the property under the mouse and then show the "Edit Drivers" popover so that you can immediately start editing the properties of this driver. This way, the whole process is more visual and feels less blocking / constrained, with less upfront decisions needed immediately. Notes: * The new behaviour is equivalent to choosing the "Manually Create (Single)" and then doing a "Edit Driver" on the property * Renamed the old "ANIM_OT_driver_button_add" operator to "ANIM_OT_driver_button_add_menu". It will probably go away in the near future, but it's better to keep it around for a while longer still until the new workflow settles down.
Diffstat (limited to 'source/blender/editors/animation/drivers.c')
-rw-r--r--source/blender/editors/animation/drivers.c74
1 files changed, 62 insertions, 12 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 03639b0ad77..28933f0e135 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -806,7 +806,7 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN
}
-/* Add Driver Button Operator ------------------------ */
+/* Add Driver (With Menu) Button Operator ------------------------ */
static int add_driver_button_poll(bContext *C)
{
@@ -855,7 +855,7 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
}
}
-static int add_driver_button_exec(bContext *C, wmOperator *op)
+static int add_driver_button_menu_exec(bContext *C, wmOperator *op)
{
short mapping_type = RNA_enum_get(op->ptr, "mapping_type");
if (ELEM(mapping_type, CREATEDRIVER_MAPPING_NONE, CREATEDRIVER_MAPPING_NONE_ALL)) {
@@ -874,13 +874,13 @@ static int add_driver_button_exec(bContext *C, wmOperator *op)
}
/* Show menu or create drivers */
-static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+static int add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
PropertyRNA *prop;
if ((prop = RNA_struct_find_property(op->ptr, "mapping_type")) && RNA_property_is_set(op->ptr, prop)) {
/* Mapping Type is Set - Directly go into creating drivers */
- return add_driver_button_exec(C, op);
+ return add_driver_button_menu_exec(C, op);
}
else {
/* Show menu */
@@ -890,19 +890,16 @@ static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *
}
}
-void ANIM_OT_driver_button_add(wmOperatorType *ot)
+void ANIM_OT_driver_button_add_menu(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Add Driver";
- ot->idname = "ANIM_OT_driver_button_add";
+ ot->name = "Add Driver Menu";
+ ot->idname = "ANIM_OT_driver_button_add_menu";
ot->description = "Add driver(s) for the property(s) represented by the highlighted button";
/* callbacks */
- /* NOTE: No exec, as we need all these to use the current context info
- * (especially the eyedropper, which is interactive)
- */
- ot->invoke = add_driver_button_invoke;
- ot->exec = add_driver_button_exec;
+ ot->invoke = add_driver_button_menu_invoke;
+ ot->exec = add_driver_button_menu_exec;
ot->poll = add_driver_button_poll;
/* flags */
@@ -914,6 +911,59 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot)
RNA_def_enum_funcs(ot->prop, driver_mapping_type_itemsf);
}
+/* Add Driver Button Operator ------------------------ */
+
+static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ PointerRNA ptr = {{NULL}};
+ PropertyRNA *prop = NULL;
+ int index;
+
+ /* try to find driver using property retrieved from UI */
+ UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+
+ if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
+ /* 1) Create a new "empty" driver for this property */
+ char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
+ short flags = CREATEDRIVER_WITH_DEFAULT_DVAR;
+ short success = 0;
+
+ if (path) {
+ success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON);
+ MEM_freeN(path);
+ }
+
+ if (success) {
+ /* send updates */
+ UI_context_update_anim_flag(C);
+ DEG_relations_tag_update(CTX_data_main(C));
+ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL);
+ }
+
+ /* 2) Show editing panel for setting up this driver */
+ /* TODO: Use a different one from the editing popever, so we can have the single/all toggle? */
+ UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", true, op->reports);
+ }
+
+ return OPERATOR_INTERFACE;
+}
+
+void ANIM_OT_driver_button_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Driver";
+ ot->idname = "ANIM_OT_driver_button_add";
+ ot->description = "Add driver for the property under the cursor";
+
+ /* callbacks */
+ /* NOTE: No exec, as we need all these to use the current context info */
+ ot->invoke = add_driver_button_invoke;
+ ot->poll = add_driver_button_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
+}
+
/* Remove Driver Button Operator ------------------------ */
static int remove_driver_button_exec(bContext *C, wmOperator *op)