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

Further theme work #267

Open
crertel opened this issue May 20, 2022 · 2 comments
Open

Further theme work #267

crertel opened this issue May 20, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@crertel
Copy link
Contributor

crertel commented May 20, 2022

As per conversation with @boydm , inspired by the good work done by #252 , we've found a way forward that's maybe a little simpler.

(this is loose paraphrasing, we'll collect better notes here as we can recall them)

We want a Scenic.Theme (probably replacing Scenic.Styles.Theme) to encapsulate settings for a given theme. Settings for a theme are things like:

  • Colors
  • Fonts
  • Font-sizes
  • Other settings that people might want to customize (tbd, so we'll want the theme container to be flexible in that regard)

A sample theme might be created something like:

hotdog_stand_theme = Theme.create(:hotdog_stand)
                     |> Theme.add_setting( :pallette, %{
                         primary: Scenic.Color.named().red,
                         secondary: Scenic.Color.named().yellow,
                     })
                    |> Theme.add_setting( :font, "comic_sans")

We want to introduce a Scenic.ViewPort.Themes module, which exposes functions for:

  • adding a theme at runtime
  • removing a theme at runtime
  • listing registered themes
  • getting a theme at runtime

We probably don't want to do a full genserver (since we can't have everybody hammering that with messages when drawing), but instead we'll probably let folks do concurrent reads on a named ETS table and then marshal mutating operations through the module API (which may touch a genserver or maybe not). This is similar to how Viewport already works, so it'll be helpful to reuse those concepts for developers.

@boydm Lemme know if this is enough to jog your memory. :)

@boydm
Copy link
Collaborator

boydm commented Jun 9, 2022

Yes. This is a good direction. Any theme manager is going to have a heavy concurrent read pattern, which means if it needs to query a GenServer, then it is going to serialize. So... Ok to write themes to a GenServer that then writes them to an ETS table, but reads come directly out of ETS on the caller's process.

@crertel crertel mentioned this issue Jun 20, 2022
4 tasks
@vacarsu
Copy link
Contributor

vacarsu commented Aug 22, 2022

I like the idea of including fonts into themes, but hope you would still be able to swap fonts out without necessarily having to change the theme. The original reason why I didn't go the GenServer/ETS route is because I was under the impression that an ETS lookup was still going to require sending a message to a process and was trying to avoid that.

@crertel crertel added the enhancement New feature or request label Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants