Need event for theme change #10

Closed
opened 2024-05-24 18:01:18 +00:00 by sashakoshka · 2 comments
Owner

Something like

box.OnThemeChange(func ()) event.Cookie

Because objects should be able to request a re-application when the theme is changed. Additionally, objects that grab icons from the theme need to be able to reload those.

Whenever theme.SetTheme is called, the backend should recurse through all active boxes and fire this event.

Of course the only problem with this is when a Box isn't inside of a window, it wouldn't have its theme set. Therefore, it might be a good idea for the backend to have some sort of theme change counter that is incremented whenever the theme is changed, and store a copy of that in each Box. When a Box is added as a child, it and its children should be recursively checked to see if the theme has changed while they were orphaned and if it did, the event should be fired. Perhaps the internal method to recursively fire the event should be the thing that updates the Box's theme counter.

Something like ```go box.OnThemeChange(func ()) event.Cookie ``` Because objects should be able to request a re-application when the theme is changed. Additionally, objects that grab icons from the theme need to be able to reload those. Whenever theme.SetTheme is called, the backend should recurse through all active boxes and fire this event. Of course the only problem with this is when a Box isn't inside of a window, it wouldn't have its theme set. Therefore, it might be a good idea for the backend to have some sort of theme change counter that is incremented whenever the theme is changed, and store a copy of that in each Box. When a Box is added as a child, it and its children should be recursively checked to see if the theme has changed while they were orphaned and if it did, the event should be fired. Perhaps the internal method to recursively fire the event should be the thing that updates the Box's theme counter.
Author
Owner

Another thing for consideration:

All of this would require notifying the backend about the theme change. Why not have the backend be in charge of applying themes, and have Box store its Role?

This would move more responsibility away from objects, and we wouldn't have to trust each individual object to implement this logic in a non-fragile manner, because it would be implemented once (in the backend).

Additionally, in the future the theming system could be extended to support advanced, css-like selectors.

Another thing for consideration: All of this would require notifying the backend about the theme change. Why not have the backend be in charge of applying themes, and have Box store its Role? This would move more responsibility away from objects, and we wouldn't have to trust each individual object to implement this logic in a non-fragile manner, because it would be implemented once (in the backend). Additionally, in the future the theming system could be extended to support advanced, css-like selectors.
Author
Owner

backend be in charge of applying themes, and have Box store its Role?

Going this route

> backend be in charge of applying themes, and have Box store its Role? Going this route
sashakoshka referenced this issue from a commit 2024-06-07 22:57:25 +00:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tomo/tomo#10
No description provided.