UI: Replace list of workspace add-ons with a UIList #112684

Manually merged
Campbell Barton merged 6 commits from guishe/blender:workspace-addons into main 2024-01-22 03:35:06 +01:00
Contributor

Resolves #111272

Resolves https://projects.blender.org/blender/blender/issues/111272
Author
Contributor

I kept using operator to activate and deactivate the add-ons within the UILits, but they do not align well

I kept using operator to activate and deactivate the add-ons within the UILits, but they do not align well <video src="/attachments/3b7bd6a1-77f3-4a17-ad76-48f2e7557018" title="2023-09-21 11-20-52.mp4" controls></video>
Guillermo Venegas requested review from Pablo Vazquez 2023-09-21 19:23:24 +02:00
Member

I kept using operator to activate and deactivate the add-ons within the UILits, but they do not align well

What if you put them on the right like in my mockup?

mockup

Thanks for working on this!

> I kept using operator to activate and deactivate the add-ons within the UILits, but they do not align well What if you put them on the right like in my mockup? ![mockup](/attachments/17e0de2e-cf82-4b68-94c6-0c6c0bb6a43e) Thanks for working on this!
Author
Contributor

Done, although now it can only be activated and deactivated with the checkbox

I also attach tests of what it looks if there are unknown add-ons

Done, although now it can only be activated and deactivated with the checkbox I also attach tests of what it looks if there are unknown add-ons <video src="/attachments/6a8f06d4-30a2-4e2d-b3f5-1768b1d17b1f" title="2023-09-22 13-21-03.mp4" controls></video>
Member

I also attach tests of what it looks if there are unknown add-ons

Not sure I understand, what's an "unknown add-on"? All add-ons should be available at all times just disabled from that particular editor.

> I also attach tests of what it looks if there are unknown add-ons Not sure I understand, what's an "unknown add-on"? All add-ons should be available at all times just disabled from that particular editor.
Author
Contributor

Is a list of add-ons that are supposed to be active in the workspace but are disabled or removed from preferences. This list already exists

image

Is a list of add-ons that are supposed to be active in the workspace but are disabled or removed from preferences. This list already exists ![image](/attachments/8a644b13-d27e-4c5d-8987-386d334e7a74)
484 KiB
Member

Interesting, that's for another patch then.

The only thing left I'd change is to not force the rows to be 10, that's way too tall for a list that can be resized and filtered anyway. Maybe 8 for the regular add-ons and 4 for unknown would be enough?

Interesting, that's for another patch then. The only thing left I'd change is to not force the rows to be 10, that's way too tall for a list that can be resized and filtered anyway. Maybe `8` for the regular add-ons and `4` for unknown would be enough?
Guillermo Venegas force-pushed workspace-addons from 3f0198ef45 to 1b50d55bc9 2023-09-28 19:52:06 +02:00 Compare
Author
Contributor

I changed it to 8.
I update the patch, before I used a temporary property collection to store the add-ons lists, but it didn't convince me too much doing that way

I changed it to 8. I update the patch, before I used a temporary property collection to store the add-ons lists, but it didn't convince me too much doing that way
Member

Thanks! I can't review the code, @ideasman42 could you (or poke someone who could) please have a look at the code for this? IIRC you worked on the first implementation back in 2.8.

The end result is something we want (scrollable list similar to other UILists) but it seems the code is more involved.

Thanks! I can't review the code, @ideasman42 could you (or poke someone who could) please have a look at the code for this? IIRC you worked on the first implementation back in 2.8. The end result is something we want (scrollable list similar to other UILists) but it seems the code is more involved.
Campbell Barton requested changes 2023-11-04 06:59:12 +01:00
Campbell Barton left a comment
Owner

Generally seems fine, requesting minor changes.

Generally seems fine, requesting minor changes.
@ -81,0 +68,4 @@
"addons",
context.workspace,
"active_addon",
rows=8)

*picky* use , & newline for trailing parenthesis.

\*picky\* use `,` & newline for trailing parenthesis.
guishe marked this conversation as resolved
@ -96,0 +93,4 @@
class WORKSPACE_UL_addons_items(bpy.types.UIList):
@classmethod
def filter_addons_by_category_name(cls, pattern, bitflag, addons, reverse=False):

Can be a static method using a _ prefix as it's for internal use only.

Can be a static method using a `_` prefix as it's for internal use only.
guishe marked this conversation as resolved
@ -96,0 +106,4 @@
return []
# Implicitly add heading/trailing wildcards.
pattern = "*" + pattern + "*"

Compile the pattern for faster evaluation, since it doesn't need to compile the expression for every match.

pattern_re = re.compile(fnmatch.translate("*" + pattern.strip("*") + "*"))
...
if pattern_re.match(name): ...

Noticed Blender's UI logic also did this, updated: b177f27e6f

Compile the pattern for faster evaluation, since it doesn't need to compile the expression for every match. ``` pattern_re = re.compile(fnmatch.translate("*" + pattern.strip("*") + "*")) ... if pattern_re.match(name): ... ``` ---- Noticed Blender's UI logic also did this, updated: b177f27e6f50bd1ffa4f5ee7dd13f1ee5ce60021
Author
Contributor

I added re.IGNORECASE to re.compile(...,re.IGNORECASE), most UIList are case-insensitive and without that feels wrong

I added `re.IGNORECASE` to `re.compile(...,re.IGNORECASE)`, most UIList are case-insensitive and without that feels wrong
@ -96,0 +112,4 @@
for i, addon in enumerate(addons):
name = addon_category_name(addon)
# This is similar to a logical xor

End sentences with a full-stop.

End sentences with a full-stop.
guishe marked this conversation as resolved
@ -96,0 +113,4 @@
for i, addon in enumerate(addons):
name = addon_category_name(addon)
# This is similar to a logical xor
if bool(name and fnmatch.fnmatch(name, pattern)) is not bool(reverse):

no need for bool(reverse), can be reverse.

no need for `bool(reverse)`, can be `reverse`.
guishe marked this conversation as resolved
@ -96,0 +118,4 @@
return flags
@classmethod
def sort_addons_by_category_name(cls, addons):
  • As this is an internal method use _ prefix.
  • Since cls isn't used this can be a staticmethod.
- As this is an internal method use `_` prefix. - Since `cls` isn't used this can be a `staticmethod`.
guishe marked this conversation as resolved
@ -96,0 +122,4 @@
"""
Re-order addons using their categories and names (case-insensitive).
return a list mapping org_idx -> new_idx,
or an empty list if no sorting has been done.

odd indentation, can be wrapped onto the previous line.

odd indentation, can be wrapped onto the previous line.
guishe marked this conversation as resolved
Guillermo Venegas added 2 commits 2023-11-07 22:15:38 +01:00
Member

Generally seems fine, requesting minor changes.

Would the latest changes make this patch ready to go?

@guishe if so, could you please update this against the latest main? Thanks!

> Generally seems fine, requesting minor changes. Would the latest changes make this patch ready to go? @guishe if so, could you please update this against the latest `main`? Thanks!
Guillermo Venegas added 3 commits 2024-01-19 18:49:27 +01:00
Campbell Barton manually merged commit d7aa1988d1 into main 2024-01-22 03:35:06 +01:00
Guillermo Venegas deleted branch workspace-addons 2024-03-14 02:09:44 +01:00
Sign in to join this conversation.
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
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#112684
No description provided.