pub struct WindowOptions {Show 18 fields
pub window_bounds: Option<WindowBounds>,
pub titlebar: Option<TitlebarOptions>,
pub focus: bool,
pub show: bool,
pub kind: WindowKind,
pub is_movable: bool,
pub app_owns_titlebar_drag: bool,
pub inactive_frame_interval: Option<Duration>,
pub is_resizable: bool,
pub is_minimizable: bool,
pub display_id: Option<DisplayId>,
pub linux_window_background: LinuxWindowBackground,
pub app_id: Option<String>,
pub window_min_size: Option<Size<Pixels>>,
pub window_decorations: Option<WindowDecorations>,
pub icon: Option<Arc<RgbaImage>>,
pub tabbing_identifier: Option<String>,
pub use_display_p3: bool,
}Expand description
Options for creating a window, passed to App::open_window.
Start from WindowOptions::default (or WindowOptions::new, which is the same)
and chain setters for the fields you want to change. Each setter takes the value
itself, or an Option to clear the field. The defaults give a focused, shown,
resizable, movable normal window with a titlebar, at the platform’s default size
and position.
Not every platform reads every field. The web backend uses WindowOptions::kind,
WindowOptions::show, and web_window_background. The page’s canvas is
the window, so bounds, the titlebar, the minimum size and the resize options are ignored.
Each field’s docs say which
platforms use it. See platforms.
§Examples
Start from the defaults and change only what you need:
use gpui::{Bounds, WindowBounds, WindowOptions, point, px, size};
let bounds = Bounds::new(point(px(100.), px(100.)), size(px(800.), px(600.)));
let options = WindowOptions::default()
.window_bounds(WindowBounds::Windowed(bounds))
.is_resizable(false)
.titlebar(None);
assert_eq!(options.window_bounds, Some(WindowBounds::Windowed(bounds)));
assert!(!options.is_resizable);
assert!(options.titlebar.is_none());
assert!(options.focus);Create a window that doesn’t take focus and opens hidden, so you can show it later:
use gpui::WindowOptions;
let options = WindowOptions::new().focus(false).show(false);
assert!(!options.focus);
assert!(!options.show);Fields§
§window_bounds: Option<WindowBounds>The window’s state and bounds in screen coordinates, in logical pixels.
None inherits the bounds from the platform, and Some opens the window in the
given state. A Windowed window opens at the rectangle, and Maximized and
Fullscreen restore to the rectangle when left. Ignored on the web.
titlebar: Option<TitlebarOptions>The titlebar, or None for a window without one. Ignored on the web.
The default is TitlebarOptions::default, which shows the platform’s titlebar with no title.
focus: boolWhether the window takes keyboard focus when it opens. Defaults to true.
show: boolWhether the window appears when it opens. Set it to false to show the window later
with PlatformWindow::set_visible.
kind: WindowKindThe kind of window to create. Defaults to WindowKind::Normal. On the web, only Normal works.
is_movable: boolWhether the user can drag the window. Defaults to true. macOS and Windows use this
value. Linux and the web ignore it. Programmatic moves still work.
app_owns_titlebar_drag: boolWhether the application owns dragging of the (custom) titlebar, rather than AppKit. Only has an effect on macOS.
Set this to true for windows that draw their own titlebar and move the window
themselves via Window::start_window_move. It marks the whole content view as
app-owned titlebar content, so AppKit neither drags the window from the titlebar
nor delays titlebar clicks while disambiguating double-clicks (a delay first
observed on macOS 27). It is independent of is_movable, so such windows stay
user-movable (via their own drag) and keep the Window-menu tiling items enabled.
Leave this false for windows that rely on AppKit’s native titlebar dragging.
inactive_frame_interval: Option<Duration>The minimum time between animation frames while the window is inactive.
Defaults to about 30 frames per second. Set None to draw inactive windows at the
full frame rate.
is_resizable: boolWhether the user can resize the window. Defaults to true. Ignored on the web.
is_minimizable: boolWhether the user can minimize the window. Defaults to true. Ignored on the web.
display_id: Option<DisplayId>The display to open the window on, or None for the primary display. Ignored on the web.
linux_window_background: LinuxWindowBackgroundThe background appearance of a Linux window.
app_id: Option<String>The application id that desktop environments use to group windows and find the desktop entry.
Linux only. Other platforms ignore it.
window_min_size: Option<Size<Pixels>>The smallest size the user can resize the window to, in logical pixels. None sets no minimum.
Ignored on the web.
window_decorations: Option<WindowDecorations>Whether the window draws its own decorations (client-side) or the window server does (server-side).
None uses the server’s default. Linux’s Wayland and X11 backends honor it, and
the other backends ignore it. The platform may ignore requests it can’t satisfy.
icon: Option<Arc<RgbaImage>>The window’s icon, from an RGBA image. Linux only, and Wayland needs the
xdg-toplevel-icon protocol to show it.
tabbing_identifier: Option<String>The name of the native tab group. Windows with the same identifier open as tabs of one window. macOS only.
use_display_p3: boolWhether to render the window using the Display P3 color space on macOS.
Implementations§
Source§impl WindowOptions
impl WindowOptions
Sourcepub fn window_bounds(self, value: impl Into<Option<WindowBounds>>) -> Self
pub fn window_bounds(self, value: impl Into<Option<WindowBounds>>) -> Self
Sets the window_bounds field of this struct.
Sourcepub fn titlebar(self, value: impl Into<Option<TitlebarOptions>>) -> Self
pub fn titlebar(self, value: impl Into<Option<TitlebarOptions>>) -> Self
Sets the titlebar field of this struct.
Sourcepub fn kind(self, value: impl Into<WindowKind>) -> Self
pub fn kind(self, value: impl Into<WindowKind>) -> Self
Sets the kind field of this struct.
Sourcepub fn is_movable(self, value: impl Into<bool>) -> Self
pub fn is_movable(self, value: impl Into<bool>) -> Self
Sets the is_movable field of this struct.
Sourcepub fn app_owns_titlebar_drag(self, value: impl Into<bool>) -> Self
pub fn app_owns_titlebar_drag(self, value: impl Into<bool>) -> Self
Sets the app_owns_titlebar_drag field of this struct.
Sourcepub fn inactive_frame_interval(self, value: impl Into<Option<Duration>>) -> Self
pub fn inactive_frame_interval(self, value: impl Into<Option<Duration>>) -> Self
Sets the inactive_frame_interval field of this struct.
Sourcepub fn is_resizable(self, value: impl Into<bool>) -> Self
pub fn is_resizable(self, value: impl Into<bool>) -> Self
Sets the is_resizable field of this struct.
Sourcepub fn is_minimizable(self, value: impl Into<bool>) -> Self
pub fn is_minimizable(self, value: impl Into<bool>) -> Self
Sets the is_minimizable field of this struct.
Sourcepub fn display_id(self, value: impl Into<Option<DisplayId>>) -> Self
pub fn display_id(self, value: impl Into<Option<DisplayId>>) -> Self
Sets the display_id field of this struct.
Sourcepub fn linux_window_background(
self,
value: impl Into<LinuxWindowBackground>,
) -> Self
pub fn linux_window_background( self, value: impl Into<LinuxWindowBackground>, ) -> Self
Sets the linux_window_background field of this struct.
Sourcepub fn app_id(self, value: impl Into<Option<String>>) -> Self
pub fn app_id(self, value: impl Into<Option<String>>) -> Self
Sets the app_id field of this struct.
Sourcepub fn window_min_size(self, value: impl Into<Option<Size<Pixels>>>) -> Self
pub fn window_min_size(self, value: impl Into<Option<Size<Pixels>>>) -> Self
Sets the window_min_size field of this struct.
Sourcepub fn window_decorations(
self,
value: impl Into<Option<WindowDecorations>>,
) -> Self
pub fn window_decorations( self, value: impl Into<Option<WindowDecorations>>, ) -> Self
Sets the window_decorations field of this struct.
Sourcepub fn icon(self, value: impl Into<Option<Arc<RgbaImage>>>) -> Self
pub fn icon(self, value: impl Into<Option<Arc<RgbaImage>>>) -> Self
Sets the icon field of this struct.
Sourcepub fn tabbing_identifier(self, value: impl Into<Option<String>>) -> Self
pub fn tabbing_identifier(self, value: impl Into<Option<String>>) -> Self
Sets the tabbing_identifier field of this struct.
Sourcepub fn use_display_p3(self, value: impl Into<bool>) -> Self
pub fn use_display_p3(self, value: impl Into<bool>) -> Self
Sets the use_display_p3 field of this struct.
Source§impl WindowOptions
impl WindowOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns window options with the platform’s defaults: a focused, shown, resizable, minimizable, movable normal window with a titlebar.
Sourcepub fn background_appearance(&self) -> WindowBackgroundAppearance
pub fn background_appearance(&self) -> WindowBackgroundAppearance
Returns the window’s background appearance for the current platform,
erased into the renderer-facing WindowBackgroundAppearance.
Trait Implementations§
Source§impl Debug for WindowOptions
impl Debug for WindowOptions
Source§impl Default for WindowOptions
impl Default for WindowOptions
Source§impl FluentBuilder for WindowOptions
impl FluentBuilder for WindowOptions
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
self to f, and returns the result. Use it to continue a chain with a
closure.Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
then with self if condition is true. Otherwise returns self
unchanged.Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
then with self if condition is true, and else_fn with self
otherwise.Auto Trait Implementations§
impl Freeze for WindowOptions
impl RefUnwindSafe for WindowOptions
impl Send for WindowOptions
impl Sync for WindowOptions
impl Unpin for WindowOptions
impl UnsafeUnpin for WindowOptions
impl UnwindSafe for WindowOptions
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more