diff --git a/druid-shell/src/backend/gtk/window.rs b/druid-shell/src/backend/gtk/window.rs index b82dc93e2..fdff1a348 100644 --- a/druid-shell/src/backend/gtk/window.rs +++ b/druid-shell/src/backend/gtk/window.rs @@ -972,12 +972,30 @@ impl WindowHandle { } } + pub fn is_resizable(&self) -> bool { + self.state + .upgrade() + .map_or(true, |state| state.window.is_resizable()) + } + + pub fn is_transparent(&self) -> bool { + self.state + .upgrade() + .map_or(false, |state| state.is_transparent.get()) + } + pub fn show_titlebar(&self, show_titlebar: bool) { if let Some(state) = self.state.upgrade() { state.window.set_decorated(show_titlebar) } } + pub fn has_titlebar(&self) -> bool { + self.state + .upgrade() + .map_or(true, |state| state.window.is_decorated()) + } + pub fn set_position(&self, mut position: Point) { if let Some(state) = self.state.upgrade() { if let Some(parent_state) = &state.parent { diff --git a/druid-shell/src/backend/mac/window.rs b/druid-shell/src/backend/mac/window.rs index 6e16b870d..7a6280100 100644 --- a/druid-shell/src/backend/mac/window.rs +++ b/druid-shell/src/backend/mac/window.rs @@ -1232,6 +1232,11 @@ impl WindowHandle { // TODO: Implement this pub fn show_titlebar(&self, _show_titlebar: bool) {} + pub fn has_titlebar(&self) -> bool { + tracing::warn!("WindowHandle::has_titlebar is currently unimplemented for Mac."); + true + } + // Need to translate mac y coords, as they start from bottom left pub fn set_position(&self, mut position: Point) { // TODO: Maybe @cmyr can get this into a state where modal windows follow the parent? @@ -1380,6 +1385,16 @@ impl WindowHandle { } } + pub fn is_resizable(&self) -> bool { + tracing::warn!("WindowHandle::is_resizable is currently unimplemented for Mac."); + true + } + + pub fn is_transparent(&self) -> bool { + tracing::warn!("WindowHandle::is_transparent is currently unimplemented for Mac."); + false + } + pub fn set_menu(&self, menu: Menu) { unsafe { NSApp().setMainMenu_(menu.menu); diff --git a/druid-shell/src/backend/wayland/window.rs b/druid-shell/src/backend/wayland/window.rs index 6ad45048e..4606358cd 100644 --- a/druid-shell/src/backend/wayland/window.rs +++ b/druid-shell/src/backend/wayland/window.rs @@ -106,10 +106,24 @@ impl WindowHandle { tracing::warn!("resizable is unimplemented on wayland"); } + pub fn is_resizable(&self) -> bool { + tracing::warn!("is_resizable is unimplemented on wayland"); + true + } + + pub fn is_transparent(&self) -> bool { + true + } + pub fn show_titlebar(&self, _show_titlebar: bool) { tracing::warn!("show_titlebar is unimplemented on wayland"); } + pub fn has_titlebar(&self) -> bool { + tracing::warn!("has_titlebar is unimplemented on wayland"); + true + } + pub fn set_position(&self, _position: Point) { tracing::warn!("set_position is unimplemented on wayland"); } diff --git a/druid-shell/src/backend/web/window.rs b/druid-shell/src/backend/web/window.rs index 042d40061..1da3e9612 100644 --- a/druid-shell/src/backend/web/window.rs +++ b/druid-shell/src/backend/web/window.rs @@ -498,13 +498,27 @@ impl WindowHandle { } pub fn resizable(&self, _resizable: bool) { - warn!("resizable unimplemented for web"); + warn!("WindowHandle::resizable unimplemented for web"); + } + + pub fn is_resizable(&self) -> bool { + warn!("WindowHandle::is_resizable is unimplemented on web"); + true } pub fn show_titlebar(&self, _show_titlebar: bool) { - warn!("show_titlebar unimplemented for web"); + warn!("WindowHandle::show_titlebar unimplemented for web"); } + pub fn has_titlebar(&self) -> bool { + warn!("WindowHandle::has_titlebar is unimplemented on web"); + true + } + + pub fn is_transparent(&self) -> bool { + warn!("WindowHandle::is_transparent is unimplemented on web"); + true + } pub fn set_position(&self, _position: Point) { warn!("WindowHandle::set_position unimplemented for web"); } diff --git a/druid-shell/src/backend/windows/window.rs b/druid-shell/src/backend/windows/window.rs index d6c692d0f..0180bafb4 100644 --- a/druid-shell/src/backend/windows/window.rs +++ b/druid-shell/src/backend/windows/window.rs @@ -1926,6 +1926,13 @@ impl WindowHandle { self.defer(DeferredOp::ShowTitlebar(show_titlebar)); } + pub fn has_titlebar(&self) -> bool { + self.state + .upgrade() + .map(|state| state.has_titlebar.get()) + .unwrap_or_default() + } + pub fn set_position(&self, position: Point) { self.defer(DeferredOp::SetWindowState(window::WindowState::Restored)); if let Some(w) = self.state.upgrade() { @@ -2032,6 +2039,20 @@ impl WindowHandle { self.defer(DeferredOp::SetResizable(resizable)); } + pub fn is_resizable(&self) -> bool { + self.state + .upgrade() + .map(|state| state.is_resizable.get()) + .unwrap_or_default() + } + + pub fn is_transparent(&self) -> bool { + self.state + .upgrade() + .map(|state| state.is_transparent.get()) + .unwrap_or_default() + } + /// Sets the window state. pub fn set_window_state(&self, state: window::WindowState) { self.defer(DeferredOp::SetWindowState(state)); diff --git a/druid-shell/src/backend/x11/window.rs b/druid-shell/src/backend/x11/window.rs index e88709dc3..119ead3bc 100644 --- a/druid-shell/src/backend/x11/window.rs +++ b/druid-shell/src/backend/x11/window.rs @@ -1625,6 +1625,16 @@ impl WindowHandle { } } + pub fn is_resizable(&self) -> bool { + warn!("is_resizable is unimplemented on x11"); + true + } + + pub fn is_transparent(&self) -> bool { + warn!("is_transparent is unimplemented on x11"); + false + } + pub fn show_titlebar(&self, show_titlebar: bool) { if let Some(w) = self.window.upgrade() { w.show_titlebar(show_titlebar); @@ -1633,6 +1643,11 @@ impl WindowHandle { } } + pub fn has_titlebar(&self) -> bool { + warn!("has_titlebar is unimplemented on x11"); + true + } + pub fn set_position(&self, position: Point) { if let Some(w) = self.window.upgrade() { w.set_position(position); diff --git a/druid-shell/src/window.rs b/druid-shell/src/window.rs index 32fde8b9d..d28b40e84 100644 --- a/druid-shell/src/window.rs +++ b/druid-shell/src/window.rs @@ -191,6 +191,16 @@ impl WindowHandle { self.0.resizable(resizable) } + /// Get whether the window is resizable + pub fn is_resizable(&self) -> bool { + self.0.is_resizable() + } + + /// Get whether the window is transparent + pub fn is_transparent(&self) -> bool { + self.0.is_transparent() + } + /// Sets the state of the window. pub fn set_window_state(&mut self, state: WindowState) { self.0.set_window_state(state); @@ -216,6 +226,11 @@ impl WindowHandle { self.0.show_titlebar(show_titlebar) } + /// Get whether the window has titlebar. + pub fn has_titlebar(&self) -> bool { + self.0.has_titlebar() + } + /// Sets the position of the window. /// /// The position is given in [display points], measured relative to the parent window if there