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:
authorJulian Eisel <julian@blender.org>2020-12-18 20:12:11 +0300
committerJulian Eisel <julian@blender.org>2020-12-18 20:28:04 +0300
commit2250b5cefee7f7cce31e388cb83515543ffe60f0 (patch)
treecbac53205d453f4b1c7ec221b6377a672d9eaa09 /source/blender/editors/space_action
parent7bee1489c1d81ecf2634df96ba039549c64313c3 (diff)
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems: * Scalability: The current solution of adding little icon buttons next to the data-block name field doesn't scale well. It only works if there's a small number of operations. We need to be able to place more items there for better data-block management. Especially with the introduction of library overrides. * Discoverability: It's not obvious what some of the icons do. They appear and disappear, but it's not obvious why some are available at times and others not. * Unclear Status: Currently their library status (linked, indirectly linked, broken link, library override) isn't really clear. * Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to invoke alternative behaviors. This is not a usual pattern in Blender. This patch does the following changes: * Adds a menu to the right of the name button to access all kinds of operations (create, delete, unlink, user management, library overrides, etc). * Make good use of the "disabled hint" for tooltips, to explain why buttons are disabled. The UI team wants to establish this as a good practise. * Use superimposed icons for duplicate and unlink, rather than extra buttons (uses less space, looks less distracting and is a nice + consistent design language). * Remove fake user and user count button, they are available from the menu now. * Support tooltips for superimposed icons (committed mouse hover feedback to master already). * Slightly increase size of the name button - it was already a bit small before, and the move from real buttons to superimposed icons reduces usable space for the name itself. * More clearly differentiate between duplicate and creating a new data-block. The latter is only available in the menu. * Display library status icon on the left (linked, missing library, overridden, asset) * Disables "Make Single User" button - in review we weren't sure if there are good use-cases for it, so better to see if we can remove it. Note that I do expect some aspects of this design to change still. I think some changes are problematic, but others disagreed. I will open a feedback thread on devtalk to see what others think. Differential Revision: https://developer.blender.org/D8554 Reviewed by: Bastien Montagne Design discussed and agreed on with the UI team, also see T79959.
Diffstat (limited to 'source/blender/editors/space_action')
-rw-r--r--source/blender/editors/space_action/action_data.c178
-rw-r--r--source/blender/editors/space_action/action_intern.h1
-rw-r--r--source/blender/editors/space_action/action_ops.c2
3 files changed, 120 insertions, 61 deletions
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index 3a584a7f0cb..4d5a93f75e0 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -158,7 +158,78 @@ static void actedit_change_action(bContext *C, bAction *act)
RNA_property_update(C, &ptr, prop);
}
-/* ******************** New Action Operator *********************** */
+/* ******************** New Action Operators *********************** */
+
+static void action_creation_assign(bContext *C,
+ bAction *action,
+ PointerRNA *ptr,
+ PropertyRNA *prop)
+{
+ PointerRNA idptr;
+ /* Set the new action.
+ * NOTE: we can't use actedit_change_action, as this function is also called from the NLA. */
+ RNA_id_pointer_create(&action->id, &idptr);
+ RNA_property_pointer_set(ptr, prop, idptr, NULL);
+ RNA_property_update(C, ptr, prop);
+}
+
+/**
+ * Stash the previously active action to prevent it from being lost.
+ * \return The old action if any.
+ */
+static bAction *action_creation_stash_old(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
+{
+ bAction *oldact = NULL;
+ AnimData *adt = NULL;
+
+ if (prop) {
+ /* The operator was called from a button. */
+ PointerRNA oldptr;
+
+ oldptr = RNA_property_pointer_get(ptr, prop);
+ oldact = (bAction *)oldptr.owner_id;
+
+ /* stash the old action to prevent it from being lost */
+ if (ptr->type == &RNA_AnimData) {
+ adt = ptr->data;
+ }
+ else if (ptr->type == &RNA_SpaceDopeSheetEditor) {
+ adt = ED_actedit_animdata_from_context(C);
+ }
+ }
+ else {
+ adt = ED_actedit_animdata_from_context(C);
+ oldact = adt->action;
+ }
+
+ if (!adt || !oldact) {
+ /* Found nothing to stash in current context. */
+ return NULL;
+ }
+
+ /* Perform stashing operation. */
+ if (BKE_nla_action_stash(adt, ID_IS_OVERRIDE_LIBRARY(ptr->owner_id))) {
+ /* The stash operation will remove the user already
+ * (and unlink the action from the AnimData action slot).
+ * Hence, we must unset the ref to the action in the
+ * action editor too (if this is where we're being called from)
+ * first before setting the new action once it is created,
+ * or else the user gets decremented twice!
+ */
+ if (ptr->type == &RNA_SpaceDopeSheetEditor) {
+ SpaceAction *saction = ptr->data;
+ saction->action = NULL;
+ }
+ }
+ else {
+#if 0
+ printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n",
+ oldact->id.name);
+#endif
+ }
+
+ return oldact;
+}
/* Criteria:
* 1) There must be an dopesheet/action editor, and it must be in a mode which uses actions...
@@ -207,71 +278,17 @@ static bool action_new_poll(bContext *C)
static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr, idptr;
+ PointerRNA ptr;
PropertyRNA *prop;
- bAction *oldact = NULL;
- AnimData *adt = NULL;
/* hook into UI */
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
- if (prop) {
- /* The operator was called from a button. */
- PointerRNA oldptr;
-
- oldptr = RNA_property_pointer_get(&ptr, prop);
- oldact = (bAction *)oldptr.owner_id;
-
- /* stash the old action to prevent it from being lost */
- if (ptr.type == &RNA_AnimData) {
- adt = ptr.data;
- }
- else if (ptr.type == &RNA_SpaceDopeSheetEditor) {
- adt = ED_actedit_animdata_from_context(C);
- }
- }
- else {
- adt = ED_actedit_animdata_from_context(C);
- oldact = adt->action;
- }
- {
- bAction *action = NULL;
-
- /* Perform stashing operation - But only if there is an action */
- if (adt && oldact) {
- /* stash the action */
- if (BKE_nla_action_stash(adt, ID_IS_OVERRIDE_LIBRARY(ptr.owner_id))) {
- /* The stash operation will remove the user already
- * (and unlink the action from the AnimData action slot).
- * Hence, we must unset the ref to the action in the
- * action editor too (if this is where we're being called from)
- * first before setting the new action once it is created,
- * or else the user gets decremented twice!
- */
- if (ptr.type == &RNA_SpaceDopeSheetEditor) {
- SpaceAction *saction = ptr.data;
- saction->action = NULL;
- }
- }
- else {
-#if 0
- printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n",
- oldact->id.name);
-#endif
- }
- }
-
- /* create action */
- action = action_create_new(C, oldact);
+ action_creation_stash_old(C, &ptr, prop);
- if (prop) {
- /* set this new action
- * NOTE: we can't use actedit_change_action, as this function is also called from the NLA
- */
- RNA_id_pointer_create(&action->id, &idptr);
- RNA_property_pointer_set(&ptr, prop, idptr, NULL);
- RNA_property_update(C, &ptr, prop);
- }
+ bAction *action = action_create_new(C, NULL);
+ if (prop) {
+ action_creation_assign(C, action, &ptr, prop);
}
/* set notifier that keyframes have changed */
@@ -285,7 +302,7 @@ void ACTION_OT_new(wmOperatorType *ot)
/* identifiers */
ot->name = "New Action";
ot->idname = "ACTION_OT_new";
- ot->description = "Create new action";
+ ot->description = "Create a new action";
/* api callbacks */
ot->exec = action_new_exec;
@@ -295,6 +312,45 @@ void ACTION_OT_new(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+static int action_duplicate_assign_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ PointerRNA ptr;
+ PropertyRNA *prop;
+
+ /* hook into UI */
+ UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
+
+ bAction *old_action = action_creation_stash_old(C, &ptr, prop);
+
+ bAction *new_action = action_create_new(C, old_action);
+ if (prop) {
+ action_creation_assign(C, new_action, &ptr, prop);
+ }
+
+ /* set notifier that keyframes have changed */
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+/**
+ * Duplicate an action assigned to a templateID and update it's assignment - based on UI context.
+ */
+void ACTION_OT_duplicate_assign(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Duplicate & Assign Action";
+ ot->idname = "ACTION_OT_duplicate_assign";
+ ot->description = "Create a copy of an existing action and assign it";
+
+ /* api callbacks */
+ ot->exec = action_duplicate_assign_exec;
+ ot->poll = action_new_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+}
+
/* ******************* Action Push-Down Operator ******************** */
/* Criteria:
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index ffe0606c98f..4bce6c62a1a 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -106,6 +106,7 @@ void ACTION_OT_snap(struct wmOperatorType *ot);
void ACTION_OT_mirror(struct wmOperatorType *ot);
void ACTION_OT_new(struct wmOperatorType *ot);
+void ACTION_OT_duplicate_assign(struct wmOperatorType *ot);
void ACTION_OT_unlink(struct wmOperatorType *ot);
void ACTION_OT_push_down(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 7422c05511c..329c3a9f6f6 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -73,7 +73,9 @@ void action_operatortypes(void)
WM_operatortype_append(ACTION_OT_copy);
WM_operatortype_append(ACTION_OT_paste);
+ /* UI-context based operators. */
WM_operatortype_append(ACTION_OT_new);
+ WM_operatortype_append(ACTION_OT_duplicate_assign);
WM_operatortype_append(ACTION_OT_unlink);
WM_operatortype_append(ACTION_OT_push_down);