Page MenuHome

Add a filter to the theme preferences
Needs ReviewPublic

Authored by Tobias Langen (Tobl) on Tue, Nov 12, 3:53 PM.
Tokens
"Love" token, awarded by Kronk."Love" token, awarded by franMarz."Love" token, awarded by HooglyBoogly."Love" token, awarded by a.monti."Mountain of Wealth" token, awarded by duarteframos.

Details

Summary

Implemented a filter for the theme preferences based on the proposel "https://blender.community/c/rightclickselect/kSdbbc/".
This can drastically improve theme creation ease.

It can operate on either the properties or a selected color.
The first compares labels and descriptions as well as their translation.
The latter can be used to find the same or similar colors, based on the precision. To not filter out the currently edited color by the user, a freeze-results button is also added.


I saw there is also a general task for searching/filtering within the properties: "https://developer.blender.org/T71185".
So in the future, this theme filtering patch might get obsolete.

In the current implementation, there is a lot of the filtering hard coded.
I would highly appreciate a hint to make the system more automatic.

Diff Detail

Repository
rB Blender

Event Timeline

A filtering system like this would be very helpful, so +1 for the feature itself.

However - and I hate to be a party pooper here - I'm not really happy with this implementation.
An obvious issue is requiring each item to be checked by an if statement. This makes code hard to follow and maintain. The number of possible code execution paths, of which some may cause issues, increases enormously. But further, I'm fairly sure this will break in more complex cases: In more complex layouts, pulling out individual elements can mess up the layout quite badly. Without having checked details, I see you already had to do some tweaks to the layout in some cases, which confirms this suspicion. Even if it works now, it limits what we can do in future.

If we just wanted to remove the if statements, we could wrap the calls to add an item (e.g. uiLayout.prop()), so you would call something like USERPREF_theme_filter.add_prop(layout, ui, "foo_bar") instead. In there you could then perform the conditional check.

Such kind of bandage would improve things a little bit - and I'm not totally rejecting this approach. But I'd prefer something that scales better, and may be applicable to more cases.
So what I would like to see is basically a post-processing step in the C UI definition code: Once all items were added, we check them against the filter and only keep those visible that match. These can then be reinserted into a new, basic layout to avoid the rabbit hole of having to preserve all kinds of layouts. The same system could then be used allover the UI.

Again, I hate to be a party pooper :\ Your effort is appreciated regardless.


As a general note, you should't have to add RNA/DNA properties in cases like this. You should be able to do the same with custom properties.

At first I thought it was only filtering by name, which is something we want to do elsewhere so maybe redundant, but the filtering by color + precision is brilliant!

I think this could fit in a redesign of the theme editor. Expanded to filter by widget type/category.

One note since I can't test the patch right now, except for editor-specific features and the User Interface panel, most editors share this part:

If I search for "Header" would I get both the item in Theme Space and Panel Colors?

Tobias Langen (Tobl) added a comment.EditedTue, Nov 12, 8:21 PM

>>! In D6234#144106, @Julian Eisel (Severin) wrote:

A filtering system like this would be very helpful, so +1 for the feature itself.
However - and I hate to be a party pooper here - I'm not really happy with this implementation.
An obvious issue is requiring each item to be checked by an if statement. This makes code hard to follow and maintain. The number of possible code execution paths, of which some may cause issues, increases enormously. But further, I'm fairly sure this will break in more complex cases: In more complex layouts, pulling out individual elements can mess up the layout quite badly. Without having checked details, I see you already had to do some tweaks to the layout in some cases, which confirms this suspicion. Even if it works now, it limits what we can do in future.
If we just wanted to remove the if statements, we could wrap the calls to add an item (e.g. uiLayout.prop()), so you would call something like USERPREF_theme_filter.add_prop(layout, ui, "foo_bar") instead. In there you could then perform the conditional check.
Such kind of bandage would improve things a little bit - and I'm not totally rejecting this approach. But I'd prefer something that scales better, and may be applicable to more cases.
So what I would like to see is basically a post-processing step in the C UI definition code: Once all items were added, we check them against the filter and only keep those visible that match. These can then be reinserted into a new, basic layout to avoid the rabbit hole of having to preserve all kinds of layouts. The same system could then be used allover the UI.
Again, I hate to be a party pooper :\ Your effort is appreciated regardless.
As a general note, you should't have to add RNA/DNA properties in cases like this. You should be able to do the same with custom properties.

Yeah that was the hard coded part I mentioned.
I was not quite happy with it either.
Will have a look in the drawing code and check what is possible.
Thanks for the new input!

Regarding to an automatic layout, I would mind something like the one of the keymap with the addition of sub-panels.


At first I thought it was only filtering by name, which is something we want to do elsewhere so maybe redundant, but the filtering by color + precision is brilliant!
I think this could fit in a redesign of the theme editor. Expanded to filter by widget type/category.
One note since I can't test the patch right now, except for editor-specific features and the User Interface panel, most editors share this part:


If I search for "Header" would I get both the item in Theme Space and Panel Colors?

Thanks @Pablo Vazquez (pablovazquez)!
First I want to improve the code as mentioned by @Julian Eisel (Severin).
If this works I might have a look at adding a filter by type function.