mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 06:10:07 -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
|
# 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, 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 and macOS, add `Window::title` to query the current window title.
|
||||||
- On Windows, fix focusing menubar when pressing `Alt`.
|
- On Windows, fix focusing menubar when pressing `Alt`.
|
||||||
|
|||||||
@@ -853,6 +853,8 @@ impl Window {
|
|||||||
ndk_glue::content_rect()
|
ndk_glue::content_rect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_theme(&self, _theme: Theme) {}
|
||||||
|
|
||||||
pub fn theme(&self) -> Option<Theme> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,6 +348,11 @@ impl Inner {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_theme(&self, _theme: Theme) {
|
||||||
|
warn!("`Window::set_theme` is ignored on iOS");
|
||||||
|
}
|
||||||
|
|
||||||
pub fn title(&self) -> String {
|
pub fn title(&self) -> String {
|
||||||
warn!("`Window::title` is ignored on iOS");
|
warn!("`Window::title` is ignored on iOS");
|
||||||
String::new()
|
String::new()
|
||||||
|
|||||||
@@ -585,6 +585,11 @@ impl Window {
|
|||||||
x11_or_wayland!(match self; Window(window) => window.raw_display_handle())
|
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]
|
#[inline]
|
||||||
pub fn theme(&self) -> Option<Theme> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
x11_or_wayland!(match self; Window(window) => window.theme())
|
x11_or_wayland!(match self; Window(window) => window.theme())
|
||||||
|
|||||||
@@ -620,6 +620,12 @@ impl Window {
|
|||||||
self.event_loop_awakener.ping();
|
self.event_loop_awakener.ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_theme(&self, _theme: Theme) {
|
||||||
|
#[cfg(feature = "sctk-adwaita")]
|
||||||
|
window.set_frame_config(theme.into());
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn theme(&self) -> Option<Theme> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -1547,6 +1547,9 @@ impl UnownedWindow {
|
|||||||
RawDisplayHandle::Xlib(display_handle)
|
RawDisplayHandle::Xlib(display_handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_theme(&self, _theme: Theme) {}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn theme(&self) -> Option<Theme> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -1122,6 +1122,11 @@ impl WinitWindow {
|
|||||||
state.current_theme
|
state.current_theme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_theme(&self, theme: Theme) {
|
||||||
|
set_ns_theme(theme);
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn title(&self) -> String {
|
pub fn title(&self) -> String {
|
||||||
self.title_().to_string()
|
self.title_().to_string()
|
||||||
|
|||||||
@@ -374,6 +374,9 @@ impl Window {
|
|||||||
RawDisplayHandle::Web(WebDisplayHandle::empty())
|
RawDisplayHandle::Web(WebDisplayHandle::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_theme(&self, _theme: Theme) {}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn theme(&self) -> Option<Theme> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -693,6 +693,11 @@ impl Window {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn set_theme(&self, theme: Theme) {
|
||||||
|
try_theme(self.window.0, Some(theme));
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn theme(&self) -> Option<Theme> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
Some(self.window_state_lock().current_theme)
|
Some(self.window_state_lock().current_theme)
|
||||||
|
|||||||
@@ -943,12 +943,22 @@ impl Window {
|
|||||||
self.window.request_user_attention(request_type)
|
self.window.request_user_attention(request_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current window theme.
|
/// Sets the current window theme.
|
||||||
///
|
///
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
///
|
///
|
||||||
/// - **iOS / Android / Web / x11:** Unsupported.
|
/// - **iOS / Android / Web / x11:** Unsupported.
|
||||||
#[inline]
|
#[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> {
|
pub fn theme(&self) -> Option<Theme> {
|
||||||
self.window.theme()
|
self.window.theme()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user