mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Add Window::set_theme
This commit is contained in:
@@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||
|
||||
# Unreleased
|
||||
|
||||
- On Windows, macOS and Wayland, add `Window::set_theme`.
|
||||
- On Windows, fix icons specified on `WindowBuilder` not taking effect for windows created after the first one.
|
||||
- On Windows and macOS, add `Window::title` to query the current window title.
|
||||
- On Windows, fix focusing menubar when pressing `Alt`.
|
||||
|
||||
@@ -853,6 +853,8 @@ impl Window {
|
||||
ndk_glue::content_rect()
|
||||
}
|
||||
|
||||
pub fn set_theme(&self, _theme: Theme) {}
|
||||
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -348,6 +348,11 @@ impl Inner {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_theme(&self, _theme: Theme) {
|
||||
warn!("`Window::set_theme` is ignored on iOS");
|
||||
}
|
||||
|
||||
pub fn title(&self) -> String {
|
||||
warn!("`Window::title` is ignored on iOS");
|
||||
String::new()
|
||||
|
||||
@@ -585,6 +585,11 @@ impl Window {
|
||||
x11_or_wayland!(match self; Window(window) => window.raw_display_handle())
|
||||
}
|
||||
|
||||
#[inlnie]
|
||||
pub fn set_theme(&self, theme: Theme) {
|
||||
x11_or_wayland!(match self; Window(window) => window.set_theme())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
x11_or_wayland!(match self; Window(window) => window.theme())
|
||||
|
||||
@@ -620,6 +620,12 @@ impl Window {
|
||||
self.event_loop_awakener.ping();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_theme(&self, _theme: Theme) {
|
||||
#[cfg(feature = "sctk-adwaita")]
|
||||
window.set_frame_config(theme.into());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
None
|
||||
|
||||
@@ -1547,6 +1547,9 @@ impl UnownedWindow {
|
||||
RawDisplayHandle::Xlib(display_handle)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_theme(&self, _theme: Theme) {}
|
||||
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
None
|
||||
|
||||
@@ -1122,6 +1122,11 @@ impl WinitWindow {
|
||||
state.current_theme
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_theme(&self, theme: Theme) {
|
||||
set_ns_theme(theme);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn title(&self) -> String {
|
||||
self.title_().to_string()
|
||||
|
||||
@@ -374,6 +374,9 @@ impl Window {
|
||||
RawDisplayHandle::Web(WebDisplayHandle::empty())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_theme(&self, _theme: Theme) {}
|
||||
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
None
|
||||
|
||||
@@ -693,6 +693,11 @@ impl Window {
|
||||
});
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_theme(&self, theme: Theme) {
|
||||
try_theme(self.window.0, Some(theme));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
Some(self.window_state_lock().current_theme)
|
||||
|
||||
@@ -943,12 +943,22 @@ impl Window {
|
||||
self.window.request_user_attention(request_type)
|
||||
}
|
||||
|
||||
/// Returns the current window theme.
|
||||
/// Sets the current window theme.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **iOS / Android / Web / x11:** Unsupported.
|
||||
#[inline]
|
||||
pub fn set_theme(&self, theme: Theme) {
|
||||
self.window.set_theme(theme)
|
||||
}
|
||||
|
||||
/// Returns the current window theme.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **iOS / Android / Web / Wayland / x11:** Unsupported.
|
||||
#[inline]
|
||||
pub fn theme(&self) -> Option<Theme> {
|
||||
self.window.theme()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user