UI: support operator enums in Quick Favorites #107616

Merged
Philipp Oeser merged 5 commits from lichtwerk/blender:59244 into main 2023-05-08 09:14:52 +02:00

5 Commits

Author SHA1 Message Date
Philipp Oeser 8ae4fa4436 comment, doc-string 2023-05-05 12:19:40 +02:00
Philipp Oeser aa37fbf99b No need for a mutable context anymore
Since 42d3df25f3
2023-05-05 11:54:37 +02:00
Philipp Oeser 15593ab0d5 remove awkward setting of layouts opcontext
In fact, it looks like the root layout opcontext is fine already, so rely
on existing behavior of `uiItemMenuEnumFullO_ptr`.
2023-05-05 11:50:00 +02:00
Philipp Oeser 924ec7f17e Merge branch 'main' into 59244 2023-05-05 09:30:47 +02:00
Philipp Oeser 54bb07d750 UI: support operator enums in Quick Favorites
Part of #59244

This was heavily requested since there are a lot of usages of
`operator_menu_enum` around in our UI [and these menus all cannot be
added to Quick Favorites atm.].

The following are just a small sample from the 3D viewport menus (object
mode), but there are many more.

- Object
-- Set Origin
-- Relations >> Make Local...
-- Convert To
- Add
-- Grease Pencil
-- Empty
-- Force Field
-- Collection Instance
- Select
-- Select All by Type
-- Select Grouped
-- Select Linked
- ...

So in order to make this work, `USER_MENU_TYPE_OPERATOR` /
`bUserMenuItem_Op` is reused (but extended with a string to the property
in question). (Alternatively, a new type could be introduced -- but
would share most of the code with the type that is reused in this
patch).

Depending on being used with an enum or not [detected by the usage of
that new string] we then either call `uiItemFullO_ptr` or
`uiItemMenuEnumFullO_ptr` in `screen_user_menu_draw`.

NOTE: we now also let `uiItemMenuEnumFullO_ptr` take an optional
`wmOperatorCallContext` (would always take the layouts root context
otherwise which is not what we always want for Quick Favorite menus).

NOTE: support for other enums (property enums such as pivot point or
transform orientations) will follow in a separate commit (building upon
6a13b6324b, trying to solve the way these draw as menus)

NOTE: opening User Preferences with such "new" Quick Favorites even
works (just not drawn with a menu)
2023-05-04 14:00:48 +02:00