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

Theme update #138

Merged
merged 18 commits into from
Aug 14, 2023
Merged

Theme update #138

merged 18 commits into from
Aug 14, 2023

Conversation

wash2
Copy link
Contributor

@wash2 wash2 commented Aug 3, 2023

This is an implementation of the new design. It also removes some of the old code which had similar-ish functionality that we don't need anymore.

@wash2 wash2 marked this pull request as ready for review August 4, 2023 17:10
@wash2 wash2 requested a review from a team August 4, 2023 17:10
@wash2
Copy link
Contributor Author

wash2 commented Aug 4, 2023

Oh I guess I need to wait for a new release of the palette crate with the oklch and oklab fix

@wash2 wash2 marked this pull request as draft August 4, 2023 17:15
@ids1024
Copy link
Member

ids1024 commented Aug 9, 2023

So the goal of using a thread_local! RefCell for the theme is so that it can be accessed for things like margins, without having to get a reference to the theme though Iced? (Which doesn't provide the theme where we'd normally need this.)

Are we sure we'd never try to access this from a different thread, even if Iced is using a multi-threaded async executor? If that happened, it would silently use a different instance of the variable local to that thread, which could be confusing.

This would also be a problem if multiple instance of Application are running in a single process, possibly with different themes... but hopefully that isn't an issue.

@mmstick
Copy link
Member

mmstick commented Aug 10, 2023

There isn't a need to access the theme from a different thread because the view methods are always run from the same event loop on the main thread. Elements would otherwise require a static lifetime along with Send. The background threads are used only by commands and subscriptions.

I think we'd support concurrent execution of multiple application instances from the same thread, too. Similar to GTK, we could make a socket that listens for new application requests, and then register additional instances in our iced runtime, with events that are accompanied by an application instance ID.

@ids1024
Copy link
Member

ids1024 commented Aug 10, 2023

Yeah, I guess THEME is also set only from the main thread since it's handled in update, so it should be fine.

@wash2 wash2 marked this pull request as ready for review August 10, 2023 14:54
@ids1024
Copy link
Member

ids1024 commented Aug 14, 2023

If we find a better solution to using a thread local, perhaps with changes to how theming works in upstream Iced, we can change that. But it should be fine for now.

This otherwise looks good.

@wash2 wash2 merged commit fb2fb65 into master Aug 14, 2023
8 checks passed
@wash2 wash2 deleted the theme-update branch August 14, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants