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

Bind remaining theme properties to their respective classes #81551

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

YuriSizov
Copy link
Contributor

Follow-up to #81312 and #79311 et al.

This PR adds binds for GraphEdit/GraphElement/GraphNode, which were skipped before due to a rework. Mostly this is straight-forward implementation of the theme cache and the new binds. But I changed one thing. I noticed that GraphEdit uses the port icon of the GraphNode type, but it doesn't fetch it through specific graph nodes, instead it only reads it from the theme. This means that if individual graph nodes have overrides or themes applied directly to them, we don't account for that. That is despite all related code operating in a context of specific graph nodes. So I adjusted these parts to use the port icon relevant to each node. (cc @Geometror).

This also adds binds for Window, which was skipped before due to a complicated code organization. I've used the power of friendship 🌈🙌 to access the cache directly from Viewport, which should do it for now. I still want to move embedded window drawing code back into Window at some point.

Finally, this adds theme cache entries/direct cache access to a few places that previously missed it. Some theme properties are now exposed to other classes via friendships or public getters for convenience. (cc @KoBeWi for ColorPicker/ColorMode related changes).

This removes all string-based theme access from scene/ classes. Everything is cached and statically typed now.

@YuriSizov YuriSizov added this to the 4.2 milestone Sep 11, 2023
@YuriSizov YuriSizov requested review from a team as code owners September 11, 2023 19:50
@YuriSizov YuriSizov force-pushed the gui-cache-all-the-theme branch 3 times, most recently from 22722a9 to f40364a Compare September 12, 2023 13:09
@YuriSizov
Copy link
Contributor Author

Added some fixes for TextEdit/CodeEdit. I made a typo when adding the new macros and one of the properties was bound with an incorrect type.

There was also a weird bit of code that I ignored before, that fetched theme properties of CodeEdit in TextEdit. The idea seems to be that TextEdit handles some CodeEdit-specific stuff internally, so it needs some of the theme items from its extending class. So some properties weren't even bound on CodeEdit, and I also suspect the way it was coded doesn't work with local theme overrides. #74843 recently added to the confusing code too.

So I reworked it to bind properties on the correct class, and then fetch the values using virtual methods that the extending class implements. Should be safe and properly separated now.

scene/main/window.h Outdated Show resolved Hide resolved
scene/gui/graph_node.h Outdated Show resolved Hide resolved
scene/gui/graph_edit.cpp Outdated Show resolved Hide resolved
This adds binds for GraphEdit/GraphElement/GraphNode, which were
skipped before due to a rework. This also adds binds for Window,
which was skipped before due to a complicated code organization.

Also adds theme cache entries/direct cache access to a few places
that previously missed it. Some theme properties are now exposed
to other classes via friendships or public getters for convenience.

This removes all string-based theme access from scene/ classes.
Copy link
Member

@Geometror Geometror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primarily reviewed the GraphEdit related stuff. The changes beyond the theme caching make sense to me. Nice work!

@YuriSizov YuriSizov merged commit 56e54b4 into godotengine:master Sep 14, 2023
15 checks passed
@YuriSizov
Copy link
Contributor Author

Thanks for reviews!

@YuriSizov YuriSizov deleted the gui-cache-all-the-theme branch September 14, 2023 13:31
scene/gui/code_edit.cpp Show resolved Hide resolved
scene/gui/text_edit.h Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants