Improve naming of theme properties throughout GUI code #65437
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I really wanted to introduce some sensible naming scheme for theme items by Godot 4, but ran out of time. So in this, and a couple follow-up PRs I'll try to clean up some names that are the most problematic for one reason or another. This PR also includes a second commit that fixes some random theming issues I've noticed while working on this. Put it in a dedicated commit so that it's clear which changes are not related to renames directly.
The list of changes:
ItemList
:bg
->panel
bg_focus
->focus
The name "bg" is used across several different controls, but is not consistent with other controls which call the main stylebox "panel". Calling it "bg" is a misnomer, as it's not just providing a background, but also adds offsets. Also we frown upon shortened names, and rename those occurrences for 4.0.
As for "bg_focus", here it is technically not too wrong, since it is drawn below the items (unlike
Tree
, where it is drawn above). However, the name doesn't fit the rest of the controls that have a dedicated focus style, and I feel like the order of drawing is an implementation detail that should not be reflected in the name. We may even want to introduce a theme constant to control whether it should be drawn above all or below, since there have been a few issues with that. So anyway, for consistency, this is now called "focus".Tree
:bg
->panel
bg_focus
->focus
Same as
ItemList
, but also here focus is indeed drawn on top of everything, making it a completely wrong name.ProgressBar
:bg
->background
fg
->fill
This should make the semantic meaning clearer, instead of referring to their draw order.
ScrollContainer
:bg
->panel
Same as previous entries, this is more consistent, not a shortened name, etc.
FileDialog
:*_icon_modulate
->*_icon_color
files_disabled
->file_disabled_color
Technically, colors assigned to icons are used for modulation, but we don't call them that in most theme properties, hence the rename. "files_disabled" is just weird and I think is an obvious one.
CheckButton
:on*
/off*
->checked*
/unchecked*
This makes the names consistent with
CheckBox
, and in general less awkward.check_v_adjust
->check_v_offset
A couple of classes have this. We typically call adjustments like that offsets, hence the rename.
As for fixes,
Panel
had an unused style,RichTextLabel
had an extra definition for the text outline which was never actually set, andSplitContainer
had a regression in theme caching from a recent fix-up PR.I've added the necessary conversion rules to the tool, but it will probably misbehave on some "bg" properties which were used elsewhere as well. The ones I've renamed are probably the most relevant cases, so it's better to include a rename, I think.
I also don't know if theme renames should be added to the C# list, as I don't see under what circumstances they would be found in C# code as regular camelCase properties. They should only be found in strings or in scene files, so the already include rules seem wrong to me, and I didn't add the new ones there.