Skip to content
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

Allow each control to use a specific custom style defined in the assigned theme #20320

Closed
mysticfall opened this issue Jul 21, 2018 · 5 comments

Comments

@mysticfall
Copy link
Contributor

Godot version:
master / cfcb6e1

OS/device including version:
Manjaro Linux 17.1

Issue description: (This issue is a feature request)
When defining an UI theme, sometimes it's needed to make the same type of control to look differently depending on a context.

For example, a Panel can have an opaque background normally, but when they are used as a backdrop of a modal dialog, it's maybe necessary to show them with a translucent background.

With CSS, such a use case would be covered by declaring a style definition for normal panels and an override for backdrop panels, which can be identified by having a specific CSS class, like backdrop:

.panel {
    background-color: black;
}

.panel.backdrop {
    opacity: 0.5;
}

However, in Godot, it seems that there's no clear way to achieve a similar functionality. I can define a theme resource which defines how all panels must look, but if we want to make a certain type of panels to look differently, we need to either create a separate theme, or define a stylebox and set it to individual Panel instances.

It seems that it's possible to define various custom styles for such controls like Button or Panel, but apparently it's not possible currently, to make each control to use one of those custom styles defined in a theme its using rather than the default one.

It'd be better if there is a way to specify that a control belongs to a certain group, i.e. backdrop, so it should be rendered differently according to a custom style defined for that context in its associated theme.

@toger5
Copy link
Contributor

toger5 commented Jul 21, 2018

Intersting though!
I'm thinking a lot about godot themes. And of course there is lot of potwntial for improovement.

To answer your question: you are supposed to use stylebox override for this...

Theming in godot is very simple. It's basically a dicrionary with objects (styleboxes) which know how to draw rectangles ;) ) thats it.
But godot is a game engine. Not gtk or qt ;)
So this simple approach night be the right choice. It's still possible to achieve a lot with it.
It would need quiet a bit of work to make it a fully css themable platform.
But what u can do, is introduce new theme classes. Create a theme in gdscript. Add a stylebox for ("panel/popover","Panel") (first string can be anything) than, mark all the panels you want in that class with add_style_override

@toger5
Copy link
Contributor

toger5 commented Jul 21, 2018

But if you convince me, with a very nice implementatiln, and some good arguments, i might do sone work on theming. Planning to do that anyways. (Shader style boxes, theme based dpi setting with inmediate update, better theme loading withou all svg recreating, auto icon upscaling woth bitmap icons...)

@mysticfall
Copy link
Contributor Author

Thanks for the feedback. I'm planning to revisit this issue soon when I'll try to generalize / reorganize what UIs I've made so far in my project. So I'll share it here, if I come up with some ideas regarding the issue.

@Poobslag
Copy link

Poobslag commented Jun 4, 2020

I'd love to see this implemented. As a workaround I'm using 4 themes in my game h1.theme, h2.theme... and applying them selectively to different components. But, it's a little clumsy and eliminates a lot of the convenience of applying a single theme to a UI component and having it get inherited throughout

Poobslag added a commit to Poobslag/turbofat that referenced this issue Jun 4, 2020
The absence of UI styles as described in Godot issue #20320
(godotengine/godot#20320) prevents using a
universal theme across the entire menu UI. Instead, I've created four
themes for buttons and labels of different sizes.

Also fixed another leftover bug from renaming 'Creature' to 'Customer'.
Poobslag added a commit to Poobslag/turbofat that referenced this issue Jun 4, 2020
The absence of UI styles as described in Godot issue #20320
(godotengine/godot#20320) prevents using a
universal theme across the entire menu UI. Instead, I've created four
themes for buttons and labels of different sizes.

Also fixed another leftover bug from renaming 'Creature' to 'Customer'.
@Calinou
Copy link
Member

Calinou commented Jun 7, 2020

Closing in favor of godotengine/godot-proposals#850, as feature proposals are now tracked on the Godot proposals repository.

@Calinou Calinou closed this as completed Jun 7, 2020
Poobslag added a commit to Poobslag/turbofat that referenced this issue Jul 18, 2020
The absence of UI styles as described in Godot issue #20320
(godotengine/godot#20320) prevents using a
universal theme across the entire menu UI. Instead, I've created four
themes for buttons and labels of different sizes.

Also fixed another leftover bug from renaming 'Creature' to 'Customer'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants