Replies: 4 comments 5 replies
-
Doing so by default would break compatibility with existing projects, and applying this new approach in new projects could easily be confusing. It would lead to people wondering why their newly set up theme looks different from the same theme configured in an older project. Instead, I think this is something that should be opt-in. There is a Texture2D property that allows overriding the physical size of any texture displayed in 2D, but it's currently not exposed to scripting. (This naturally has no effect in 3D scenes.)
This is already possible if you design your UI for a high base resolution and let it downscale with the There's a Default Theme Scale project setting you can change to adjust the scale at which the default project theme is generated. |
Beta Was this translation helpful? Give feedback.
-
Auto scalable SVG textures are implemented as part of godotengine/godot#86022, for both the editor icons and UI elements (if theme resource are SVG based). |
Beta Was this translation helpful? Give feedback.
-
Is there any updates about this functionality? I tried to use these available options for icons but never achieved a good result as like with fonts. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I've been working a lot with getting UI things to work and render as expected on hiDPI monitors (see #7968 for more general explanation) and when working standard UI controls I've repeatedly run into an issue with built in texture-based components (like icons, grabber handles etc) in controls being sized based on their texture size.
This works fine when you render the control at 100% scale/resolution, and when you do it will automatically make the components larger/smaller if you customize the theme to use a larger or smaller texture. However, if you render the UI in hiDPI (or do any other type of interface scaling) this leads to problems, since you can't configure the theme to use higher resolution textures without this also changing the size of the controls:
So as you can see rendering of text, styleboxes etc is rendered at the correct higher resolution, but texture components of controls are rendered at low resolution and instead just made larger. As far as I can tell the only way to get around this and get the control to render higher resolution components is to make your own subclass and render the higher resolution textures on top of the base control or replace it entirely. This applies to for example Checkbox, Slider, TabBar, Tree, and probably more.
The solution in my mind would be to never use the texture size to set the size of any of these icons, and instead let this be set up size properties (like a
grabber_size
for Slider or using the Checkbox controlsize
to scale the icon). However, since we now have this implementation and don't want to break compatibility we need to implement this in some way that falls back to the current way of working for existing themes.I can imagine specific fixes for different Controls (like again, a new
grabber_size
parameter for Slider, or asize_icon_to_height
option on Checkbox) and could make proposals for such changes, but since this is a more general problem perhaps there's some better way of handling this in the same way in all controls for consistency? Or even implementing something more low-level like how macOS and iOS does it where UI/2D-Textures could have resolution scaling built into them so that the control can still think the icon image size is 16x16 while the texture backing on hiDPI systems actually has 32x32 pixels? What do you think?Beta Was this translation helpful? Give feedback.
All reactions