UI: Change menu icons of single-choice enums to radio buttons #111796
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111796
Loading…
Reference in New Issue
No description provided.
Delete Branch "Mysteryem/blender:ui_enum_menu_item_radio_icons"
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?
Checkboxes are usually used when multiple choices can be made from
multiple options.
Radio buttons are usually used when only a single choice can be made
from multiple options.
Enum properties that do not have PROP_ENUM_FLAG can only have a single
chosen value, so this patch changes their menu icons from checkboxes to
radio buttons.
Affected UI primarily includes use of UILayout.prop_menu_enum in Python-
defined UI, such as View>Display Size in the Asset Browser and File
Browser, and the menu for changing a Brush's tool in the Brush Specials
menu.
It was questionable whether single-choice enums being displayed as checkboxes was considered a bug (#111768), but it turned out to be a single-line change, so I thought I may as well submit the change myself.
I don't know if there are any places other than UILayout.prop_menu_enum that this is used. The code mentions pie menus too, but I don't know of any enum properties displayed through pie menus that were displaying with checkboxes.
Before
After
Panel script
Such a useful one liner. Thank you!
@Mysteryem
Love this!
However I can think of some ways where our current code could be incorrect regarding this flag. Can you go through each editor with this PR applied looking at each menu for anything that looks wrong? Obviously I am concerned about the possibility of showing a single item alone as a radio button because the ON state just looks like a filled ball.
If you find any errors they would just need to have some
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
sprinkled here and there. I can certainly help if you need it.I think an enum property that only has a single option and only allows a single choice would be a little odd with either checkboxes or radio buttons, mainly because that single option should always be selected and selecting it again will do nothing (technically for custom properties defined by addons, the current index can be set out-of-bounds which deselects that single option, but I'm not sure if that also applies for RNA enum properties).
Though, enabling
PROP_ENUM_FLAG
for enum properties that do not have the flag already would need some care because it would be a breaking Python API change. An enum property withPROP_ENUM_FLAG
being exposed through the Python API as aset
ofstr
strings, and enum property withoutPROP_ENUM_FLAG
being exposed through the Python API as a singlestr
string.I would anticipate that the only RNA enum properties that allow only a single choice and might have only a single option would be dynamic enums. A static enum with only a single choice and a single option would make more sense to be a read-only string property instead.
I've checked every use of
prop_menu_enum
that I could find in Blender's python-defined UI, and those enums all have more than one option.I had a look at the C functions called by
UILayout.prop_menu_enum
too, but I couldn't find any other uses until the UI functions got generic, supporting any kind of property rather than only enums.Oh, sorry that I was not clear. I have no problems with your PR itself. My only concern is that our codebase might contain some errors that could be exposed by this. I'll do a quick check around to make sure.
Thanks for posting this PR. We should be able to discuss it very soon.
Thanks for this!