tauri-apps / tao

The TAO of cross-platform windowing. A library in Rust built for Tauri.
Apache License 2.0
1.57k stars 183 forks source link

feat: add a function to set theme dynamically #937

Closed Legend-Master closed 1 week ago

Legend-Master commented 3 months ago

Closes #582 Closes #891

Legend-Master commented 3 months ago

~~I don't quite understand how ThemeChanged works in tao to be honest, when should it be fired? We currently only fires it when the window's theme is set to auto/no preference and the theme is actually changed I think it should be fired whenever the theme changes no matter if the theme is set to None or Some(Theme)~~ Never mind, only auto will can have theme changes

I'm not sure how to send events from set_theme, do we do a RegisterWindowMessage and use PostMessage here?

Legend-Master commented 3 months ago

We probably can just mirror the mac and linux implementations from winit (they should be much more straight forward compared to the Windows one 😂), but I can't test them, so I'll just do the Windows one for now

FabianLars commented 3 months ago

Moving my discord message here: The macos implementation worked on my machine. 👍

github-actions[bot] commented 3 months ago

Package Changes Through 0b1daad1c1d6b88f983fde6d07ea9d21241c4ff2

There are 1 changes which include tao with patch

Planned Package Versions The following package releases are the planned based on the context of changes in this pull request. | package | current | next | |----|----|----| | tao | 0.30.0 | 0.30.1 |

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

FabianLars commented 2 months ago

Linux impl works for me on WSL

pewsheen commented 2 months ago

Looks good on macOS.

Just a note that the ThemeChagned event does not emit, but I think it has broken for a while.

Legend-Master commented 1 week ago

I don't know if sending WM_SETTINGCHANGE ourselves here is fine or not since the wparam and lparam are actually not 0 from the system one, and by the way, if you do this, you need to set redraw_title_bar to true

amrbashir commented 1 week ago

I don't know if sending WM_SETTINGCHANGE ourselves here is fine or not since the wparam and lparam are actually not 0 from the system one

Doesn't matter since we don't read either of them.

and by the way, if you do this, you need to set redraw_title_bar to true

From my testing, this doesn't seem to be needed.

Legend-Master commented 1 week ago

@amrbashir the windows one is not working right now, you need to set redraw_title_bar to true, see my comment above

amrbashir commented 1 week ago

I guess Windows 10, really needs to redraw, just changed it to always redraw then

amrbashir commented 1 week ago

BTW, sorry for hijacking the PR, I was just testing a few things out and thought might as well push it instead of requesting another review.

Legend-Master commented 1 week ago

All good, feel free to make changes 😃