The theme is the master class that gets asked for style boxes, constants and fonts all the time. The theme is asked multiple times per node and hundreds of times a frame.
It's that simple. However, there is one great additional thing in Godot which makes the dpi addition easy to implement.
There are two ways of accessing values in a theme. theme->get_styebox()
and my_control->get_stylebox()
.
- When asking the theme, it just calls the hash map with styles, and that's it.
- When asking a control, it does some logic:
- font (cached) the next node up to the tree that has a theme assigned.
- check if the theme has the requested style. Yes: return it! No: go to the next Control with a theme.