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
Ability to force a theme on Windows #1666
Merged
Merged
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
486798a
You can now force either dark or light theme no matter the system pre…
VZout c80974e
Clean up and fixed a freeze when switching at runtime
VZout 1d045f3
Update FEATURES.md
VZout fb78110
Update windows.rs
VZout b09b464
Update CHANGELOG.md
VZout 45592dd
cargo fmt
VZout d92a4bd
Merge branch 'force_theme_v1' of github.com:VZout/winit into force_th…
VZout d210aa8
Update CHANGELOG.md
VZout 3e9895b
Merge branch 'master' into force_theme_v1
VZout 4b14626
Incorporated feedback
VZout 34ee46e
fixed a comment
VZout 885e66b
Merge branch 'force_theme_v1' of github.com:VZout/winit into force_th…
VZout 1b6436f
Changelog update
VZout 7ca4bb7
fmt
VZout 2fdfd80
Merge branch 'master' into force_theme_v1
VZout 9d347bb
Incorporated feedback
6762d84
Merge branch 'master' into force_theme_v1
VZout 5a79a2f
Inlined the changed param
e8ff688
Merge branch 'force_theme_v1' of https://github.com/VZout/winit into …
43d3959
Update src/platform/windows.rs
VZout 32ca08b
feedback
VZout 452ebec
merged
VZout 653efc2
kchibisov's suggestion
VZout 3984155
Merge branch 'master' into force_theme_v1
VZout aa1248c
Update CHANGELOG.md
VZout 9c797ad
reordered changelog
VZout d27490d
Update dark_mode.rs
VZout 33ea8f4
renamed try_dark_mode to try_theme and fixed a unused import
VZout 89c8a11
Merge branch 'master' into force_theme_v1
VZout 2d9e151
fmt
VZout bcb41f8
fixed function order
VZout a5dd089
Update windows.rs
VZout 1ef38f0
Merge branch 'master' into force_theme_v1
VZout fe258f6
Update CHANGELOG.md
VZout File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ use crate::{ | |
event_loop::EventLoop, | ||
monitor::MonitorHandle, | ||
platform_impl::{EventLoop as WindowsEventLoop, WinIcon}, | ||
window::{BadIcon, Icon, Window, WindowBuilder}, | ||
window::{BadIcon, Icon, Theme, Window, WindowBuilder}, | ||
}; | ||
|
||
/// Additional methods on `EventLoop` that are specific to Windows. | ||
|
@@ -82,7 +82,7 @@ pub trait WindowExtWindows { | |
fn set_taskbar_icon(&self, taskbar_icon: Option<Icon>); | ||
|
||
/// Whether the system theme is currently Windows 10's "Dark Mode". | ||
fn is_dark_mode(&self) -> bool; | ||
fn theme(&self) -> Theme; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a breaking change, so it should be listed in the changelog There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the changelog |
||
} | ||
|
||
impl WindowExtWindows for Window { | ||
|
@@ -102,8 +102,8 @@ impl WindowExtWindows for Window { | |
} | ||
|
||
#[inline] | ||
fn is_dark_mode(&self) -> bool { | ||
self.window.is_dark_mode() | ||
fn theme(&self) -> Theme { | ||
self.window.theme() | ||
} | ||
} | ||
|
||
|
@@ -125,6 +125,9 @@ pub trait WindowBuilderExtWindows { | |
/// If you need COM API with `COINIT_MULTITHREADED` you must initialize it before calling any winit functions. | ||
/// See https://docs.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize#remarks for more information. | ||
fn with_drag_and_drop(self, flag: bool) -> WindowBuilder; | ||
|
||
/// Forces a theme or uses the system settings if `None` was provided. | ||
fn with_theme(self, theme: Option<Theme>) -> WindowBuilder; | ||
} | ||
|
||
impl WindowBuilderExtWindows for WindowBuilder { | ||
|
@@ -151,6 +154,12 @@ impl WindowBuilderExtWindows for WindowBuilder { | |
self.platform_specific.drag_and_drop = flag; | ||
self | ||
} | ||
|
||
#[inline] | ||
fn with_theme(mut self, theme: Option<Theme>) -> WindowBuilder { | ||
self.platform_specific.preferred_theme = theme; | ||
self | ||
} | ||
} | ||
|
||
/// Additional methods on `MonitorHandle` that are specific to Windows. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation doesn't match anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the comment