Page MenuHome

WIP: Edit Menu Item Descriptions
Needs RevisionPublic

Authored by Harley Acheson (harley) on Apr 14 2020, 1:32 AM.

Details

Summary

Something to play with and see if you like. Once applied (and rebuilt) you will see changes to the Edit menu...

Instead of just saying "Undo" and "Redo" it shows what action you are doing. I moved "Undo History" into the same section.

Instead of saying "Adjust Last Operation" it now includes the actual operation. And similar for the "Repeat" operation item. I have reordered these items slightly as well:

Taken together the menu seems a lot clearer, less obscure, more helpful.

It is "Work in Progress" because there are some implementation issues. I'm not sure where to store the needed string resources so they are in dumb places. And I haven't really thought through any translation issues yet. But it works well enough to try it anyway.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Apr 14 2020, 1:32 AM
Harley Acheson (harley) created this revision.
William Reynish (billreynish) requested changes to this revision.Apr 14 2020, 8:25 AM

This is great. But disagree with using ‘Action History’ - this is a way to undo to a specific point in the undo history. Previous name was clearer in that regard.

This revision now requires changes to proceed.Apr 14 2020, 8:25 AM
Harley Acheson (harley) edited the summary of this revision. (Show Details)

Trying "Undo/Redo History" to see how it fits.

William Reynish (billreynish) requested changes to this revision.Apr 15 2020, 7:12 AM

I would still opt for Undo History. We call it the 'undo stack', not the 'undo/redo stack'. Technically yes, it can also be used for redo, but I think it's best to simply leave this as Undo History.

This revision now requires changes to proceed.Apr 15 2020, 7:12 AM
Campbell Barton (campbellbarton) requested changes to this revision.EditedApr 15 2020, 8:20 AM

Regarding: Rename "Suzzane"

I don't think it's good to include data-block names in the menu entries.

Visual Noise

To take this to some logical extreme, imagine we could do this everywhere:

  • Delete "Cube"
  • Parent to "Sphere.001"
  • Save "my_filename.blend"
  • Revert "my_filename.blend"

... etc.

This adds more information in the interface in a way that's not very helpful.

When using an interface users learn to quickly identify unique terms.
Having the text changed based on data-block names means you have the hint that something is changing when you visually scan the menu, when the changes are only based on the selection.

Aside from the distraction of changing text, some names are already quite long, adding data / operator names as part of other actions means we will end up with awkwardly cramped text in some cases.

Unpredictable Menu Search

If data-block names are included in menu item labels, search will give less predictable results as the names of data in the scene will be included in the search too.

So if you know searching for a short combination of letters can activate a tool, this change means there would be a chance that typing in this sequence will perform a different action based on the current selection.

Complicates Documentation

If you have to clearly describe steps which include dynamic names, it means you need to

Edit -> Rename "{active object or bone name}"

Complicates Translations

We need to take care to handle translations properly, currently this patch doesn't account for this (translating the operator names but not the data-names).

Complicates Menu Memory

Currently popup menus remember the last action based on the text,
with dynamic changing text, our menu hashing function ui_popup_menu_memory would need to somehow support this too, at least if this is used for menu items in popup menus.


More general note, while some applications may adjust menu text based on the application state, quite a few don't - where they clearly have the resources to do this if they thought it was a good idea.

In fact none of the applications I checked do this, even for undo/redo (firefox/chrome/qt-creator/ms-word).

release/scripts/startup/bl_ui/space_topbar.py
605

This doesn't account for pose bones or edit bones.

Currently fails to build on Linux:

/src/blender/source/blender/editors/undo/ed_undo.c: In function ‘ed_undo_get_name’:
/src/blender/source/blender/editors/undo/ed_undo.c:483:12: error: returning ‘char (*)[128]’ from a function with incompatible return type ‘const char *’ [-Werror=incompatible-pointer-types]
  483 |     return &undo_stack->ui_undo_text;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
/src/blender/source/blender/editors/undo/ed_undo.c:478:69: warning: unused parameter ‘ptr’ [-Wunused-parameter]
  478 | static const char *ed_undo_get_name(wmOperatorType *ot, PointerRNA *ptr)
      |                                                         ~~~~~~~~~~~~^~~
/src/blender/source/blender/editors/undo/ed_undo.c: In function ‘ed_redo_get_name’:
/src/blender/source/blender/editors/undo/ed_undo.c:539:12: error: returning ‘char (*)[128]’ from a function with incompatible return type ‘const char *’ [-Werror=incompatible-pointer-types]
  539 |     return &undo_stack->ui_redo_text;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
/src/blender/source/blender/editors/undo/ed_undo.c:534:69: warning: unused parameter ‘ptr’ [-Wunused-parameter]
  534 | static const char *ed_redo_get_name(wmOperatorType *ot, PointerRNA *ptr)
      |                                                         ~~~~~~~~~~~~^~~
cc1: some warnings being treated as errors
[ 40%: -3] Building C object source/blender/editors/screen/CMakeFiles/bf_editor_screen.dir/screen_ops.c.o
FAILED: source/blender/editors/screen/CMakeFiles/bf_editor_screen.dir/screen_ops.c.o

/src/blender/source/blender/editors/screen/screen_ops.c: In function ‘repeat_last_get_name’:
/src/blender/source/blender/editors/screen/screen_ops.c:3695:12: error: returning ‘char (*)[128]’ from a function with incompatible return type ‘const char *’ [-Werror=incompatible-pointer-types]
 3695 |     return &wm->ui_repeat_text;
      |            ^~~~~~~~~~~~~~~~~~~
/src/blender/source/blender/editors/screen/screen_ops.c:3689:73: warning: unused parameter ‘ptr’ [-Wunused-parameter]
 3689 | static const char *repeat_last_get_name(wmOperatorType *ot, PointerRNA *ptr)
      |                                                             ~~~~~~~~~~~~^~~
/src/blender/source/blender/editors/screen/screen_ops.c: In function ‘redo_last_get_name’:
/src/blender/source/blender/editors/screen/screen_ops.c:3821:10: error: returning ‘char (*)[128]’ from a function with incompatible return type ‘const char *’ [-Werror=incompatible-pointer-types]
 3821 |   return &wm->ui_adjust_text;
      |          ^~~~~~~~~~~~~~~~~~~
/src/blender/source/blender/editors/screen/screen_ops.c:3801:55: warning: unused parameter ‘ot’ [-Wunused-parameter]
 3801 | static const char *redo_last_get_name(wmOperatorType *ot, PointerRNA *ptr)
      |                                       ~~~~~~~~~~~~~~~~^~
/src/blender/source/blender/editors/screen/screen_ops.c:3801:71: warning: unused parameter ‘ptr’ [-Wunused-parameter]
 3801 | static const char *redo_last_get_name(wmOperatorType *ot, PointerRNA *ptr)
      |                                                           ~~~~~~~~~~~~^~~

Indeed, for Rename it's not necessary to include the data block name. It could be added after any operator entry really, which indeed would be silly. Ie: Delete Suzanne, Duplicate Suzanne etc.

But, for Undo/Redo it really helps to include the operator. Users then know *what* they are undoing or redoing, which really helps. I would very much prefer if we could include the operator names in the Undo & Redo menu entries.

Harley Acheson (harley) edited the summary of this revision. (Show Details)Apr 15 2020, 5:20 PM

@Campbell Barton (campbellbarton) - I don't think it's good to include data-block names in the menu entries.

I agree with you completely. Thank you for such a detailed answer.

This doesn't account for pose bones or edit bones.

That part is removed so no longer applicable.

Currently fails to build on Linux:

Bloody hell. I think I have fixed all those warnings/errors. Sorry about that.

We need to take care to handle translations properly

Yes, this patch is doing nothing right with translations. And the locations of the allocated strings seems dumb to me too.

none of the applications I checked do this, even for undo/redo (firefox/chrome/qt-creator/ms-word).

I can't see a reason for a web browser to need this. But my Word does have this:

none of the applications I checked do this, even for undo/redo (firefox/chrome/qt-creator/ms-word).

I can't see a reason for a web browser to need this. But my Word does have this:

From what I can see this is a history of actions, not a typical drop-down edit-menu with a fixed set of menu items.

Just to be clear, having more communicative Undo & Redo menu items is something most graphics apps do. I could mention them and post hundreds of screenshots, but will refrain from doing that here. We should remove the parts that include datablock names and only amend the Undo/Redo menus.

@William Reynish (billreynish) - We should remove the parts that include datablock names and only amend the Undo/Redo menus.

Current state of this patch no longer uses object name in Rename. It currently only changes undo, redo, adjust, and repeat. Although any dynamic changes to menu items would pose the same problems for things like “search from menu items” so I can understand that this idea could be a no-go. But always fun to explore.

The undo/redo menu items still contain the words undo and redo, so will still appear in the search.

The operator names should be removed from adjust and repeat I think, or they could simply be amended at the end so the full menu item text string is still searchable.

@William Reynish (billreynish) - The undo/redo menu items still contain the words undo and redo, so will still appear in the search.

My concern isn't really that they wouldn't be searchable. More that you would search for "undo" but then see "Undo Move".

It's all a matter of whether the new "search from menu items" is done in way that operatorType.get_name() is called. If the search results are going through that then we'll have problems with this and a few other operators that use it. If it is done in a way where get_name is bypassed then it would never contain dynamic info and all is fine. So searching for "undo" would show "undo".

Note that our overriding of the operator names, and the translations, do not go through get_name. get_name is only for the very few operators we have that dynamically change their own UI display names.

Updated to current state of master.

And as an experiment the dynamic part of the menu items are shown in round brackets. so "Undo (Rotate)" and "Adjust Last (Add Monkey)..." to see how it looks and feels.

Fixing error where Repeat could show wrong operation.

Campbell Barton (campbellbarton) requested changes to this revision.Apr 17 2020, 5:43 AM

I'd rather we restrict these names overrides to the edit menu (instead of using get_name callback), then check of this is using menu search so they can be named "Undo / Redo" when using menu search and not cause searches to be unpredictable.

eg:

Something like this:

if self.is_search:
    layout.operator("ed.undo")
    layout.operator("ed.redo")
else:
    layout.operator("ed.undo", text=iface_("Undo %s") % wm.undo_state_undo_text())
    layout.operator("ed.redo", text=iface_("Redo %s") % wm.undo_state_redo_text())
This revision now requires changes to proceed.Apr 17 2020, 5:43 AM

@Campbell Barton (campbellbarton) - Something like this:

Interesting. Thanks!

But if we assume that we never want dynamic content in the menu names for the search results, couldn't we just (somehow LOL) have WM_operatortype_name() NOT run get_name() if we are in a search? It seems like the only point of get_name is for dynamic names so it would make sense to not allow that in this case. I'm guessing at the moment we couldn't search for operator "call_menu" for example.

Or perhaps I'm just not thinking about this correctly.

@Campbell Barton (campbellbarton) - Something like this:

Interesting. Thanks!

But if we assume that we never want dynamic content in the menu names for the search results, couldn't we just (somehow LOL) have WM_operatortype_name() NOT run get_name() if we are in a search? It seems like the only point of get_name is for dynamic names so it would make sense to not allow that in this case. I'm guessing at the moment we couldn't search for operator "call_menu" for example.

As long as the name from get_name is created based on the operator properties (which the menu sets), this wont be a problem.