UI: Show Selected Tool Item #111939

Merged
Harley Acheson merged 3 commits from Harley/blender:ToolSelected into main 2023-09-06 19:07:35 +02:00
Member

Show Toolbar items with selected highlight and hover highlight.


With prior versions of Blender, opening a list of tools initially highlights the selected item, but then you lose the highlight as soon as you start hovering.

ToolItems36.gif

With this PR we get both hover highlight and selected highlight:

ToolItems.gif

Show Toolbar items with selected highlight and hover highlight. --- With prior versions of Blender, opening a list of tools initially highlights the selected item, but then you lose the highlight as soon as you start hovering. ![ToolItems36.gif](/attachments/ed2e8b0f-d539-4c4d-a3f9-d048ad4737a9) With this PR we get both hover highlight and selected highlight: ![ToolItems.gif](/attachments/38675fe1-6117-48ee-9284-ba436064c2f7)
Harley Acheson added 1 commit 2023-09-04 22:16:20 +02:00
2db37e7b6e UI: Show Selected Tool Item
Show Toolbar items with selected highlight and hover highlight.
Harley Acheson added this to the User Interface project 2023-09-04 22:16:45 +02:00
Harley Acheson requested review from Julian Eisel 2023-09-04 22:16:53 +02:00
Harley Acheson added 1 commit 2023-09-05 04:05:40 +02:00
Harley Acheson added 1 commit 2023-09-06 19:05:21 +02:00
Harley Acheson merged commit d99af958d7 into main 2023-09-06 19:07:35 +02:00
Harley Acheson deleted branch ToolSelected 2023-09-06 19:07:36 +02:00
Member

This seems like the wrong way to implement this, in fact it doesn't work in many cases. Some problems:

  • This only works if the menu was opened before in this Blender instance. For example, when opening a file with a tool active that is not first in its menu, the first tool is still highlighted. Screenshot 2023-09-07 at 16.54.52.png
    Only after changing to a different tool the next time the menu is opened it highlights the correct one. This is because the implementation relies on the feature to remember the last used menu item (static memory).

    I would expect this to be closer to layout definition, where we may know about the active item, not in generic popup code
  • ui_block_func_POPUP is called for many cases, not just the tool menus. So this can have unwanted side-effects in other cases.
  • ui_but_activate_over() is a general function that clearly states that it activates a button. This implementation also makes it draw a button as selected, which is neither clear from the function name nor from the function documentation (not even the context it's called in). This probably wouldn't always be the desired behavior of the function. It's just an arbitrary location that happens to work for what you want to achieve (although it actually doesn't).
  • The comment you added only explains what it does (which is pretty obvious from the code), not why it does this. If I see this code I'm confused.

I'd suggest reverting this and working on a proper implementation, especially since this is causing regressions (#112077).

This seems like the wrong way to implement this, in fact it doesn't work in many cases. Some problems: - This only works if the menu was opened before in this Blender instance. For example, when opening a file with a tool active that is not first in its menu, the first tool is still highlighted. ![Screenshot 2023-09-07 at 16.54.52.png](/attachments/7d9a57aa-5723-47c4-a417-3fa663450403)<br/>Only after changing to a different tool the next time the menu is opened it highlights the correct one. This is because the implementation relies on the feature to remember the last used menu item (static memory). <br/><br/>I would expect this to be closer to layout definition, where we may know about the active item, not in generic popup code - `ui_block_func_POPUP` is called for many cases, not just the tool menus. So this can have unwanted side-effects in other cases. - `ui_but_activate_over()` is a general function that clearly states that it activates a button. This implementation also makes it draw a button as selected, which is neither clear from the function name nor from the function documentation (not even the context it's called in). This probably wouldn't always be the desired behavior of the function. It's just an arbitrary location that happens to work for what you want to achieve (although it actually doesn't). - The comment you added only explains what it does (which is pretty obvious from the code), not why it does this. If I see this code I'm confused. I'd suggest reverting this and working on a proper implementation, especially since this is causing regressions (#112077).
Author
Member

@JulianEisel - when opening a file with a tool active that is not first in its menu, the first tool is still highlighted.

This specific issue exists before my PR. Following is with 3.6.1:

image

I'd suggest reverting this and working on a proper implementation, especially since this is causing regressions (#112077).

Regression is fixed. Was a (dumb) lack of a check for the active region being null.

I would expect this to be closer to layout definition, where we may know about the active item, not in generic popup code

Sounds like a better way to do it. Can you give any further pointers for this?

> @JulianEisel - when opening a file with a tool active that is not first in its menu, the first tool is still highlighted. This specific issue exists before my PR. Following is with 3.6.1: ![image](/attachments/d8be3aab-fc27-4047-bb60-25c5bfc516c5) > I'd suggest reverting this and working on a proper implementation, especially since this is causing regressions (#112077). Regression is fixed. Was a (dumb) lack of a check for the active region being null. > I would expect this to be closer to layout definition, where we may know about the active item, not in generic popup code Sounds like a better way to do it. Can you give any further pointers for this?
Member

This specific issue exists before my PR. Following is with 3.6.1:

image

We're only now introducing the concept of properly highlighting the active item, before the highlight was much more loose. It's important that this works reliably now to not mislead users.

Regression is fixed. Was a (dumb) lack of a check for the active region being null.

Problem is we're adding a bunch of fixes on top of wrongly implemented features. At least this makes reverting harder. But worse, once we revert that or implement it properly, it's easy to forget to revert a specific fix, and then they remain in the code and soon nobody remembers what this is for and if it can be removed. I'm trying to keep track of what changes are being done now, but this is far from optimal.

Sounds like a better way to do it. Can you give any further pointers for this?

Not off the top of my head, this would have to be investigated as part of making a proper technical design for this feature.

> This specific issue exists before my PR. Following is with 3.6.1: > > ![image](/attachments/d8be3aab-fc27-4047-bb60-25c5bfc516c5) We're only now introducing the concept of properly highlighting the active item, before the highlight was much more loose. It's important that this works reliably now to not mislead users. > Regression is fixed. Was a (dumb) lack of a check for the active region being null. Problem is we're adding a bunch of fixes on top of wrongly implemented features. At least this makes reverting harder. But worse, once we revert that or implement it properly, it's easy to forget to revert a specific fix, and then they remain in the code and soon nobody remembers what this is for and if it can be removed. I'm trying to keep track of what changes are being done now, but this is far from optimal. > Sounds like a better way to do it. Can you give any further pointers for this? Not off the top of my head, this would have to be investigated as part of making a proper technical design for this feature.
Sign in to join this conversation.
No reviewers
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
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111939
No description provided.