[Bf-blender-cvs] [2250b5cefee] master: UI: Redesigned data-block selectors

Julian Eisel noreply at git.blender.org
Fri Dec 18 18:28:51 CET 2020


Commit: 2250b5cefee7f7cce31e388cb83515543ffe60f0
Author: Julian Eisel
Date:   Fri Dec 18 18:12:11 2020 +0100
Branches: master
https://developer.blender.org/rB2250b5cefee7f7cce31e388cb83515543ffe60f0

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.

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

M	intern/cycles/blender/addon/ui.py
M	release/scripts/startup/bl_ui/properties_material.py
M	release/scripts/startup/bl_ui/properties_world.py
M	release/scripts/startup/bl_ui/space_dopesheet.py
M	source/blender/editors/include/ED_util.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_context_menu.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_region_tooltip.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/render/render_intern.h
M	source/blender/editors/render/render_ops.c
M	source/blender/editors/render/render_shading.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_action/action_data.c
M	source/blender/editors/space_action/action_intern.h
M	source/blender/editors/space_action/action_ops.c
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_clip/clip_buttons.c
M	source/blender/editors/space_file/file_panels.c
M	source/blender/editors/space_image/image_buttons.c
M	source/blender/editors/space_nla/nla_buttons.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/util/CMakeLists.txt
M	source/blender/editors/util/ed_util.c
A	source/blender/editors/util/ed_util_ops.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/modifiers/intern/MOD_displace.c
M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/modifiers/intern/MOD_volume_displace.cc
M	source/blender/modifiers/intern/MOD_warp.c
M	source/blender/modifiers/intern/MOD_wave.c
M	source/blender/modifiers/intern/MOD_weightvg_util.c
M	source/blender/windowmanager/intern/wm_operator_type.c

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

diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index f24265d256a..eee7d8ec0b8 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1148,7 +1148,7 @@ class CYCLES_PT_context_material(CyclesButtonsPanel, Panel):
         split = layout.split(factor=0.65)
 
         if ob:
-            split.template_ID(ob, "active_material", new="material.new")
+            split.template_ID(ob, "active_material", new="material.new", duplicate="material.duplicate")
             row = split.row()
 
             if slot:
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 47ab98386f4..e1f2862f826 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -133,7 +133,7 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
         row = layout.row()
 
         if ob:
-            row.template_ID(ob, "active_material", new="material.new")
+            row.template_ID(ob, "active_material", new="material.new", duplicate="material.duplicate")
 
             if slot:
                 icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA'
diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py
index 9b61311c2d3..74293e02b60 100644
--- a/release/scripts/startup/bl_ui/properties_world.py
+++ b/release/scripts/startup/bl_ui/properties_world.py
@@ -51,7 +51,7 @@ class WORLD_PT_context_world(WorldButtonsPanel, Panel):
         space = context.space_data
 
         if scene:
-            layout.template_ID(scene, "world", new="world.new")
+            layout.template_ID(scene, "world", new="world.new", duplicate="world.duplicate")
         elif world:
             layout.template_ID(space, "pin_id")
 
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 0c222e8c023..3f43240eaed 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -248,7 +248,7 @@ class DOPESHEET_HT_editor_buttons:
 
             layout.separator_spacer()
 
-            layout.template_ID(st, "action", new="action.new", unlink="action.unlink")
+            layout.template_ID(st, "action", new="action.new", duplicate="action.duplicate_assign", unlink="action.unlink")
 
         # Layer management
         if st.mode == 'GPENCIL':
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index ca6b4bdc618..1e87a940a7d 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -52,10 +52,11 @@ void ED_spacedata_id_remap(struct ScrArea *area,
                            struct ID *old_id,
                            struct ID *new_id);
 
-void ED_OT_flush_edits(struct wmOperatorType *ot);
 void ED_OT_lib_id_load_custom_preview(struct wmOperatorType *ot);
 void ED_OT_lib_id_generate_preview(struct wmOperatorType *ot);
 
+void ED_operatortypes_edutils(void);
+
 /* ************** XXX OLD CRUFT WARNING ************* */
 
 void apply_keyb_grid(
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 7c128cbf1e6..ced411ef75f 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -76,6 +76,7 @@ struct wmWindow;
 
 typedef struct uiBlock uiBlock;
 typedef struct uiBut uiBut;
+typedef struct uiButExtraOpIcon uiButExtraOpIcon;
 typedef struct uiLayout uiLayout;
 typedef struct uiPopupBlockHandle uiPopupBlockHandle;
 
@@ -1381,13 +1382,16 @@ typedef struct uiStringInfo {
 /* Note: Expects pointers to uiStringInfo structs as parameters.
  *       Will fill them with translated strings, when possible.
  *       Strings in uiStringInfo must be MEM_freeN'ed by caller. */
-void UI_but_string_info_get(struct bContext *C, uiBut *but, ...) ATTR_SENTINEL(0);
+void UI_but_string_info_get(struct bContext *C, uiBut *but, uiButExtraOpIcon *extra_icon, ...)
+    ATTR_SENTINEL(0);
 
 /* Edit i18n stuff. */
 /* Name of the main py op from i18n addon. */
 #define EDTSRC_I18N_OP_NAME "UI_OT_edittranslation"
 
 /**
+ * TODO This is old stuff, only used by templateID. Should be cleaned up.
+ *
  * Special Buttons
  *
  * Buttons with a more specific purpose:
@@ -1405,14 +1409,16 @@ enum {
   UI_ID_ALONE = 1 << 4,
   UI_ID_OPEN = 1 << 3,
   UI_ID_DELETE = 1 << 5,
-  UI_ID_LOCAL = 1 << 6,
-  UI_ID_AUTO_NAME = 1 << 7,
-  UI_ID_FAKE_USER = 1 << 8,
+  UI_ID_MAKE_LOCAL = 1 << 6,
+  UI_ID_LIB_OVERRIDE_ADD = 1 << 7,
+  UI_ID_AUTO_NAME = 1 << 8,
   UI_ID_PIN = 1 << 9,
   UI_ID_PREVIEWS = 1 << 10,
-  UI_ID_OVERRIDE = 1 << 11,
+  UI_ID_LIB_OVERRIDE_REMOVE = 1 << 11,
+  UI_ID_LIB_OVERRIDE_RESET = 1 << 12,
   UI_ID_FULL = UI_ID_RENAME | UI_ID_BROWSE | UI_ID_ADD_NEW | UI_ID_OPEN | UI_ID_ALONE |
-               UI_ID_DELETE | UI_ID_LOCAL,
+               UI_ID_DELETE | UI_ID_MAKE_LOCAL | UI_ID_LIB_OVERRIDE_ADD |
+               UI_ID_LIB_OVERRIDE_REMOVE | UI_ID_LIB_OVERRIDE_RESET,
 };
 
 /**
@@ -1658,10 +1664,12 @@ void UI_but_func_hold_set(uiBut *but, uiButHandleHoldFunc func, void *argN);
 
 void UI_but_func_pushed_state_set(uiBut *but, uiButPushedStateFunc func, void *arg);
 
-PointerRNA *UI_but_extra_operator_icon_add(uiBut *but,
-                                           const char *opname,
-                                           short opcontext,
-                                           int icon);
+struct uiButExtraOpIcon *UI_but_extra_operator_icon_add(uiBut *but,
+                                                        const char *opname,
+                                                        short opcontext,
+                                                        int icon);
+struct wmOperatorType *UI_but_extra_operator_icon_optype_get(struct uiButExtraOpIcon *extra_icon);
+PointerRNA *UI_but_extra_operator_icon_opptr_get(struct uiButExtraOpIcon *extra_icon);
 
 /* Autocomplete
  *
@@ -1963,6 +1971,7 @@ void uiTemplateID(uiLayout *layout,
                   struct PointerRNA *ptr,
                   const char *propname,
                   const char *newop,
+                  const char *duplicateop,
                   const char *openop,
                   const char *unlinkop,
                   int filter,
@@ -2567,6 +2576,11 @@ struct ARegion *UI_tooltip_create_from_button(struct bContext *C,
                                               struct ARegion *butregion,
                                               uiBut *but,
                                               bool is_label);
+struct ARegion *UI_tooltip_create_from_button_or_extra_icon(struct bContext *C,
+                                                            struct ARegion *butregion,
+                                                            uiBut *but,
+                                                            uiButExtraOpIcon *extra_icon,
+                                                            bool is_label);
 struct ARegion *UI_tooltip_create_from_gizmo(struct bContext *C, struct wmGizmo *gz);
 void UI_tooltip_free(struct bContext *C, struct bScreen *screen, struct ARegion *region);
 
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c5c2f0e55c4..26fd75cc74c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1167,16 +1167,21 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str
  * \{ */
 
 static bool ui_but_event_operator_string_from_operator(const bContext *C,
-                                                       uiBut *but,
+                                                       wmOperatorCallParams *op_call_params,
                                                        char *buf,
                                                        const size_t buf_len)
 {
-  BLI_assert(but->optype != NULL);
+  BLI_assert(op_call_params->optype != NULL);
   bool found = false;
-  IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
-
-  if (WM_key_event_operator_string(
-          C, but->optype->idname, but->opcontext, prop, true, buf, buf_len)) {
+  IDProperty *prop = (op_call_params->opptr) ? op_call_params->opptr->data : NULL;
+
+  if (WM_key_event_operator_string(C,
+                                   op_call_params->optype->idname,
+                                   op_call_params->opcontext,
+                                   prop,
+                                   true,
+                                   buf,
+                                   buf_len)) {
     found = true;
   }
   return found;
@@ -1253,15 +1258,22 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C,
   return found;
 }
 
-static bool ui_but_event_operator_string(const bContext *C,
-                                         uiBut *but,
-                                         char *buf,
-                                         const size_t buf_len)
+static bool ui_but_event_operator_string(
+    const bContext *C, uiBut *but, uiButExtraOpIcon *extra_icon, char *buf, const size_t buf_len)
 {
   bool found = false;
+  wmOperatorType *extra_icon_optype = UI_but_extra_operator_icon_optype_get(extra_icon);
 
-  if (but->optype != NULL) {
-    found = ui_but_event_operator_string_from_operator(C, but, buf, buf_len);
+  if (extra_icon_optype) {
+    found = ui_but_event_operator_string_from_operator(C, extra_icon->optype_params, buf, buf_len);
+  }
+  else if (but->optype != NULL) {
+    found = ui_but_event_operator_string_from_operator(
+        C,
+        &(wmOperatorCallParams){
+            .optype = but->optype, .opptr = but->opptr, .opcontext = but->opcontext},
+        buf,
+        buf_len);
   }
   else if (UI_but_menutype_get(but) != NULL) {
     found = ui_but_event_operator_string_from_menu(C, but, buf, buf_len);
@@ -1564,7 +1576,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
         continue;
       }
 
-      if (ui_but_event_operator_st

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list