[Bf-blender-cvs] [7a88a7742b5] blender2.8: Drivers UI (Part of T55145) - WIP first steps towards getting a floating driver settings panel

Joshua Leung noreply at git.blender.org
Thu May 24 18:10:29 CEST 2018


Commit: 7a88a7742b586c0d1e62cbf1c7089ac125f4ab59
Author: Joshua Leung
Date:   Thu May 24 18:08:32 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7a88a7742b586c0d1e62cbf1c7089ac125f4ab59

Drivers UI (Part of T55145) - WIP first steps towards getting a floating driver settings panel

This commit adds a new menu entry - "Edit Driver" - the RMB menu that
will show a popover panel displaying the settings for the driver you
activated the menu item on. This shows the popover panel defined in
yesterday's commit (GRAPH_PT_drivers_popover).

It is possible to edit the driver settings from this panel now.
However, do be warned that the functionality presented is highly
WIP still. There are some unresolved issues, such as:
 - The popover disappears too easily on any mouse movements/clicks
   on anything, making the panel less useful right now than it should.

 - The layout still needs refining. Currently the layout that's there
   is a bit of a placeholder until we can play around with it a bit
   more to see/feel what feels good/right or what is too much.

 - The "Open Drivers Editor" on the bottom of the panel doesn't work.
   There are some tricky context tricky things that need to happen here
   to make that case work, since the operator button won't have the necessary
   context info.

===================================================================

M	source/blender/editors/animation/anim_intern.h
M	source/blender/editors/animation/anim_ops.c
M	source/blender/editors/animation/drivers.c
M	source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index c571da1ba74..824c1d58f44 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -79,6 +79,7 @@ void ANIM_OT_keying_set_active_set(struct wmOperatorType *ot);
 /* Driver management operators for UI buttons (RMB menu) */
 void ANIM_OT_driver_button_add(struct wmOperatorType *ot);
 void ANIM_OT_driver_button_remove(struct wmOperatorType *ot);
+void ANIM_OT_driver_button_edit(struct wmOperatorType *ot);
 void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
 void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
 
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index eace5af4701..1136dcd129e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -512,6 +512,7 @@ void ED_operatortypes_anim(void)
 	
 	WM_operatortype_append(ANIM_OT_driver_button_add);
 	WM_operatortype_append(ANIM_OT_driver_button_remove);
+	WM_operatortype_append(ANIM_OT_driver_button_edit);
 	WM_operatortype_append(ANIM_OT_copy_driver_button);
 	WM_operatortype_append(ANIM_OT_paste_driver_button);
 
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index f792bd2ea9b..41a72e7b5fd 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -41,6 +41,7 @@
 
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
+#include "DNA_space_types.h"
 #include "DNA_texture_types.h"
 
 #include "BKE_animsys.h"
@@ -967,6 +968,46 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot)
 	RNA_def_boolean(ot->srna, "all", 1, "All", "Delete drivers for all elements of the array");
 }
 
+/* Edit Driver Button Operator ------------------------ */
+
+static int edit_driver_button_exec(bContext *C, wmOperator *op)
+{
+	PointerRNA ptr = {{NULL}};
+	PropertyRNA *prop = NULL;
+	int index;
+	const bool all = 0; // RNA_boolean_get(op->ptr, "all");
+	
+	/* try to find driver using property retrieved from UI */
+	UI_context_active_but_prop_get(C, &ptr, &prop, &index);
+	
+	if (all)
+		index = -1;
+	
+	if (ptr.id.data && ptr.data && prop) {
+		UI_popover_panel_invoke(C, SPACE_IPO, RGN_TYPE_UI, "GRAPH_PT_drivers_popover", op->reports);
+	}
+	
+	return OPERATOR_INTERFACE;
+}
+
+void ANIM_OT_driver_button_edit(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Edit Driver";
+	ot->idname = "ANIM_OT_driver_button_edit";
+	ot->description = "Edit the drivers for the property connected represented by the highlighted button";
+	
+	/* callbacks */
+	ot->exec = edit_driver_button_exec;
+	//op->poll = ??? // TODO: need to have some driver to be able to do this...
+	
+	/* flags */
+	ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL;
+
+	/* properties */
+	//RNA_def_boolean(ot->srna, "all", 1, "All", "Edit drivers for all elements of the array");
+}
+
 /* Copy Driver Button Operator ------------------------ */
 
 static int copy_driver_button_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 70cd53c440f..ce64a7e21a2 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -6783,8 +6783,11 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 				        ICON_NONE, "ANIM_OT_paste_driver_button");
 			}
 
+			uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Edit Driver"),
+			        ICON_DRIVER, "ANIM_OT_driver_button_edit");
+
 			uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"),
-			        ICON_DRIVER, "SCREEN_OT_drivers_editor_show");
+			        ICON_NONE, "SCREEN_OT_drivers_editor_show");
 		}
 		else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) {
 			/* pass */
@@ -6809,7 +6812,7 @@ static bool ui_but_menu(bContext *C, uiBut *but)
 			}
 
 			uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open Drivers Editor"),
-			        ICON_DRIVER, "SCREEN_OT_drivers_editor_show");
+			        ICON_NONE, "SCREEN_OT_drivers_editor_show");
 		}
 
 		/* Keying Sets */



More information about the Bf-blender-cvs mailing list