-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add style inheritance for theme items #850
Comments
While it is possible to make different stylebox classes/resources have a "parent"/"base" property which is the same-typed stylebox they inherit, this might be a bit of a mess. Maybe, a system similar to scene inheritance but for resources could be nice? (edit: bad close, I blame github for interpreting a key press as a click of the "Close and Comment" button) |
As far as I know the current theme system is through a cascading styles system. The parent-most node theme properties are overriden by children nodes. |
@fire I was thinking of the same, but check the issue carefully: The proposal is not to inherit the whole styleboxes, but to be able to override only part of a stylebox in another. |
@fire Yes, you can place new themes on child nodes to change their styles. But still the problem that this proposal addresses is apparent. Say you have 5 StyleBoxFlat's that you use for your buttons. You all have the same border width on them. Now, you want to change it. You have to go to all 5 resources and change it individually - which is annoying to find, and time consuming to do. This proposal would address this by making the system similar to inheritable scenes. All 5 StyleBoxFlats have a "Base" StyleBoxFlat. Now, if you want to change the border thickness, you can just go to the base style and set it there, and the children would update - just like scenes. You would of course be able to override properties in child styles. |
Yeppers, I have something similar in one of my games, several styles that only differ in details. |
This is not true inheritance as this only allows to customize on top of the base class, but I think godotengine/godot#47544 covers this proposal. (Though UX may change a bit as reduz has some additional thoughts on the matter). Oh, and editing related styleboxes is made easier with the new theme editor, where you can pin one stylebox of a type and edit its properties, and the changes would be propagated to the rest of the styleboxes that have the same type. (Can be seen in the last clip from #2505) |
So, @EricEzaM, do you think that godotengine/godot#47544 and godotengine/godot#50169 reasonably cover this proposal or if something crucial is still missing? Unfortunately, this is not portable to 3.x at the moment, so if you want to test it you need to build |
Closing, as the original concern should be reasonably well addressed by godotengine/godot#47544 and godotengine/godot#50169 now. godotengine/godot#57942 also backported type variations to Godot 3.5beta2 and later. godotengine/godot#49487 is a partial backport of godotengine/godot#47544 with breaking changes omitted. |
Unless I'm missing something, this doesn't solve it for styles because you can't actually inherit styles... You still need to make an entirely new variation with a duplicated style just to change 1 thing on the style, and then you get the same problem of it being annoying to edit 1 minor thing on all styles at once (in my case, trying to make a zero-margin version of a panel). Only marginally better than theme overrides since you can edit the style in one place, but that's not relevant to this specific issue of wanting to extend styles themselves. :/ |
Yeah, I just wanted to override the font size for a certain sub-menu, and found no way to do so. I tried Theme > Settings button > Base Type but I get this for Button because it's a native type: There is no Inherited Resource system, but I suppose we could still implement it specifically just for themes, having an (override) theme refer to some base theme as a hardcoded field? Should we reopen an issue for the broader problem of inheriting theme properties (including the "meta properties" of font and font sizes)? |
Yes, I'd say this warrants a separate proposal. |
Describe the project you are working on:
Basic project
Describe the problem or limitation you are having in your project:
I have styles for button normal, pressed, hover, etc. If I want to change 1 shared parameter (e.g. border color), I have to do it all manually on each of them. Kind of a problem if I decide I want a major UI style change for many controls.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Inheritable styles
Style A is the base style (StyleBoxFlat).
Style B (StyleBoxFlat) inherits Style A.
Changing a parameter on Style A also changes it on style B, unless it has been overriden.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
I tried doing this with GD Script with a custom inspector and an exported property. I could get the base style to work, and the child style to 'inherit' it... but the issue was that I could not update the child when the base was updated. There was no easy signal to connect to when the base was changed. I didn't go very far with this trial... Maybe it needs a custom type for both 'base' and 'inheritable' classes, but at this stage I would say it could be easier to implement natively.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Not sure - see above comments. Maybe it could... but useful to have it as native functionality.
Is there a reason why this should be core and not an add-on in the asset library?:
See comments above - this is debatable.
The text was updated successfully, but these errors were encountered: