The Wayback Machine - https://web.archive.org/web/20210802165713/https://github.com/godotengine/godot/pull/51159
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

Improve the default project theme #51159

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

@Calinou
Copy link
Member

@Calinou Calinou commented Aug 1, 2021

The new default project theme uses StyleBoxFlat extensively for a more modern design and better scalability to multiple resolutions.

SVG icons are now used in place of PNG icons. While this does not allow for true vector-based icon drawing (icons are still rasterized at load-time), this makes the design work easier for contributors and opens the door to vector drawing in the future (e.g. with polygons or SDFs).

Like for editor icons, the SVG header file is now built automatically when a SVG file is changed. This removing the need for running make_header.py manually.

The Use Hidpi project setting has been removed in favor of a Default Theme Scale project setting, which allows creating the default theme at a higher/lower scale than the default. This can be used when designing GUIs with a high base resolution to ensure crisp visuals.

The new theme has slightly different metrics, which may result in elements being shifted around when porting 3.x projects (hence the breaks compat label).

Note: Unlike LineEdit, TextEdit will appear to have no visible focus outline because its focus outline is clipped by the main StyleBox's area (this is not about drawing order). We need to fix this in the TextEdit node, ideally before this PR is merged. See #32996.

This closes #25349.

Preview

On all screenshots, the first button is focused so that you can see how the focus outline looks.

Default resolution

Before After
Before After

Fullscreen (2d stretch mode)

The new theme scales much better to higher resolutions thanks to its StyleBoxFlat-based design.

Before After
Before After

TODO

  • Finish theming all nodes and remove PNGs.
    • Tree, GraphEdit and WindowDialog and possibly more weren't redesigned yet.
  • Print a warning message when compiling Godot with the NanoSVG module disabled.
    • Generate fallback images when the NanoSVG module is disabled.
    • Alternatively, make NanoSVG a hard requirement for compiling Godot.
  • Remove make_header.py which should no longer be needed.
@pycbouh
Copy link
Contributor

@pycbouh pycbouh commented Aug 1, 2021

Something's wrong with the texture progress control or with its surrounding container?

@Calinou
Copy link
Member Author

@Calinou Calinou commented Aug 2, 2021

Something's wrong with the texture progress control or with its surrounding container?

It looks as intended. It's just that the higher spacing makes it not fit anymore within the container, so its edge looks flush with the panel instead of having some padding. I'm not sure where this addtitional spacing comes from though.

@aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Aug 2, 2021

Overall this is really nice!

I'm not sure I like the scrollbars, and the other corners. Is there any program that has pointy edges on them?

corners

It seems a bit bright. If we have white text we want to ensure the background is dark enough that people can easily read it. Can we make the background a nice even #444? We could potentially go even darker. (This was modified with GIMP)

darker

@Calinou
Copy link
Member Author

@Calinou Calinou commented Aug 2, 2021

I'm not sure I like the scrollbars, and the other corners. Is there any program that has pointy edges on them?

Not that I know of. I'll reduce their radius to make them more square.

It seems a bit bright. If we have white text we want to ensure the background is dark enough that people can easily read it. Can we make the background a nice even #444? We could potentially go even darker. (This was modified with GIMP)

The panel's background is translucent, which is why it appears to be relatively bright against the clear color. I can make it slightly more opaque, which will make it appear darker.

The new default project theme uses StyleBoxFlat extensively for
a more modern design and better scalability to multiple resolutions.

SVG icons are now used in place of PNG icons. While this does not
allow for true vector-based icon drawing (icons are still rasterized
at load-time), this makes the design work easier for contributors
and opens the door to vector drawing in the future (e.g. with polygons
or SDFs).

Like for editor icons, the SVG header file is now built automatically
when a SVG file is changed. This removing the need for running
`make_header.py` manually (TODO).

The "Use Hidpi" project setting has been removed in favor of a
"Default Theme Scale" project setting, which allows creating the
default theme at a higher/lower scale than the default.
This can be used when designing GUIs with a high base resolution
to ensure crisp visuals.

TODO:

- Finish theming all nodes and remove PNGs.
- Generate fallback images when the NanoSVG module is disabled.
- Print a warning message when compiling Godot with the NanoSVG
  module disabled.
  - Alternatively, make NanoSVG a hard requirement for compiling Godot.
@Calinou Calinou force-pushed the Calinou:improve-default-project-theme branch from 4862905 to 4361035 Aug 2, 2021
@aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Aug 2, 2021

The panel's background is translucent,

Shouldn't it be opaque by default?

@Calinou
Copy link
Member Author

@Calinou Calinou commented Aug 2, 2021

Shouldn't it be opaque by default?

I can make it opaque by default, but one reason I made it translucent by default is that it makes multiple overlapping panels distinguishable out of the box (since they don't have borders anymore).

If panels are made opaque by default, the Self Modulate property could be used to adjust their opacity without overriding the stylebox.

PS: I updated the After screenshots in OP to reflect the latest changes:

  • Lower corner radius on scrollbars.
  • More opaque panels and buttons (50% opacity -> 60% opacity).
@ee0pdt
Copy link

@ee0pdt ee0pdt commented Aug 2, 2021

The corners… is it possible to have rounded edges? I can’t think of a modern interface that has anything other these days.

I don’t mean to prevent anyone using this style, but just want to know if it’s possible to create an alternative

@Calinou
Copy link
Member Author

@Calinou Calinou commented Aug 2, 2021

The corners… is it possible to have rounded edges? I can’t think of a modern interface that has anything other these days.

Corners were rounded in an earlier revision of this theme, but there are currently several issues with rounded corners in StyleBoxFlat:

  • When you enable antialiasing, the StyleBoxFlat's edges become blurry due to how StyleBoxFlat antialiasing is implemented. This makes the UI look less well-defined, both at low and high resolutions. This wasn't an issue at some point – it broke during the 3.1 -> 3.2 cycle and we didn't manage to find a good solution for it yet.
  • When you disable antialiasing, rounded corners look bad at higher resolutions. Beleved corners look much better when antialiasing is disabled since there are only 45-degree angles.
  • On particularly slow hardware (IGPs and mobile devices), displaying lots of StyleBoxes with rounded corners is slow. This can have a non-negligible performance impact on UI-heavy games. Beveled corners are much less expensive in this aspect.

If we manage to fix the issue with StyleBoxFlat antialiasing, I'd be OK with making corners rounded again.

In the Godot editor theme, corners are rounded and antialiasing is disabled. This combination works well because the Godot editor uses the disabled stretch mode, which means controls will not get larger as you resize the window (which makes antialiasing artifacts more visible here). However, in most projects, you'll want to use the 2d or viewport stretch mode to ensure the GUI scales well to all resolutions.

@ee0pdt
Copy link

@ee0pdt ee0pdt commented Aug 2, 2021

@Calinou that’s a fantastic reply. Thanks for the info

I guess that this is down to preference - and given the limitations I’d probably go with a one pixel radius and keep it simple.

If we could solve the anti-aliasing problem…

But either way, could we get your answer in the docs with some info on how to change the corner if one wanted to try rounded corners that would be most helpful I feel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment