UI: support operator enums in Quick Favorites #107616
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#107616
Loading…
Reference in New Issue
No description provided.
Delete Branch "lichtwerk/blender:59244"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 beadded to Quick Favorites atm.].
The following are just a small sample from the 3D viewport menus (object
mode), but there are many more.
-- Set Origin
-- Relations >> Make Local...
-- Convert To
-- Grease Pencil
-- Empty
-- Force Field
-- Collection Instance
-- 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 propertyin 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
oruiItemMenuEnumFullO_ptr
inscreen_user_menu_draw
.NOTE: we now also let
uiItemMenuEnumFullO_ptr
take an optionalwmOperatorCallContext
(would always take the layouts root contextotherwise 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)
@ -612,6 +612,7 @@ struct bUserMenu *ED_screen_user_menu_ensure(struct bContext *C);
struct bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(struct ListBase *lb,
const struct wmOperatorType *ot,
struct IDProperty *prop,
const char *op_prop_enum,
Doc-string should note this is to be an empty string when not set.
done
@ -2896,6 +2896,7 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
const char *propname,
const char *name,
int icon,
wmOperatorCallContext *opcontext,
Doc-string should note this is optional (use the layout's when NULL). Realize doc-strings in wide use here, but it's the kind of thing that's useful to include.
removed this completely, seems the roots opcontext is already fine here?
@ -3555,6 +3555,7 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
const char *propname,
const char *name,
int icon,
wmOperatorCallContext *opcontext,
This is awkward, it's using a pointer, for an enum, for the purpose of being able to set it to NULL and use the layout's value.
It's more straightforward to set the context temporarily in
layout->root->opcontext
using accessor functions as is done in Python. While setting temporary values isn't so nice - this is only done fromscreen_user_menu_draw
and avoids an additional non-obvious argument everywhere else.see above
@ -199,2 +206,3 @@
static void screen_user_menu_draw(const bContext *C, Menu *menu)
static void screen_user_menu_draw(const bContext *C_const, Menu *menu)
{
bContext *C = (bContext *)C_const;
Committed update to make
uiItemMenuEnumFullO_ptr
take aconst
context.thx, updated to this
@ -228,0 +237,4 @@
}
else {
uiItemMenuEnumFullO_ptr(menu->layout,
C,
It's possible we want to support assigning additional properties even with
op_prop_enum
set, although I'm not sure if there are practical cases which would use this of hand.Nevertheless, it's worth adding a comment that
umi_op->prop
could be used to set other properties but it's currently unsupported.added that comment
This is great!
Not sure what needs to be approved from my side, since this wouldn't really change the looks of things other than add menus to the Quick Favorites list? If so I think it's okay. The Quick Favorites is not like pie menus where it is preferred to have speed so we avoid enums.
Thanks for working on this.
Works as advertised, which is awesomely!