Struct druid::WindowDesc
source · pub struct WindowDesc<T> {
pub id: WindowId,
/* private fields */
}
Expand description
A description of a window to be instantiated.
This struct has builder methods to specify some window properties. Each of
these methods usually corresponds to a platform API call when constructing the
function. Except for title()
, they have no default values and the APIS
won’t be called if the method is not used.
Fields§
§id: WindowId
The WindowId
that will be assigned to this window.
This can be used to track a window from when it is launched and when it actually connects.
Implementations§
source§impl<T: Data> WindowDesc<T>
impl<T: Data> WindowDesc<T>
sourcepub fn new<W>(root: W) -> WindowDesc<T>where
W: Widget<T> + 'static,
pub fn new<W>(root: W) -> WindowDesc<T>where
W: Widget<T> + 'static,
Create a new WindowDesc
, taking the root [Widget
] for this window.
sourcepub fn title(self, title: impl Into<LabelText<T>>) -> Self
pub fn title(self, title: impl Into<LabelText<T>>) -> Self
Set the title for this window. This is a LabelText
; it can be either
a String
, a LocalizedString
, or a closure that computes a string;
it will be kept up to date as the application’s state changes.
If this method isn’t called, the default title will be LocalizedString::new("app-name")
.
Set the menu for this window.
menu
is a callback for creating the menu. Its first argument is the id of the window that
will have the menu, or None
if it’s creating the root application menu for an app with no
menus (which can happen, for example, on macOS).
sourcepub fn window_size_policy(self, size_policy: WindowSizePolicy) -> Self
pub fn window_size_policy(self, size_policy: WindowSizePolicy) -> Self
Set the window size policy
sourcepub fn window_size(self, size: impl Into<Size>) -> Self
pub fn window_size(self, size: impl Into<Size>) -> Self
Set the window’s initial drawing area size in display points.
You can pass in a tuple (width, height)
or a Size
,
e.g. to create a window with a drawing area 1000dp wide and 500dp high:
window.window_size((1000.0, 500.0));
The actual window size in pixels will depend on the platform DPI settings.
This should be considered a request to the platform to set the size of the window. The platform might increase the size a tiny bit due to DPI.
sourcepub fn with_min_size(self, size: impl Into<Size>) -> Self
pub fn with_min_size(self, size: impl Into<Size>) -> Self
Set the window’s minimum drawing area size in display points.
The actual minimum window size in pixels will depend on the platform DPI settings.
This should be considered a request to the platform to set the minimum size of the window. The platform might increase the size a tiny bit due to DPI.
To set the window’s initial drawing area size use window_size
.
sourcepub fn resizable(self, resizable: bool) -> Self
pub fn resizable(self, resizable: bool) -> Self
Builder-style method to set whether this window can be resized.
sourcepub fn show_titlebar(self, show_titlebar: bool) -> Self
pub fn show_titlebar(self, show_titlebar: bool) -> Self
Builder-style method to set whether this window’s titlebar is visible.
sourcepub fn transparent(self, transparent: bool) -> Self
pub fn transparent(self, transparent: bool) -> Self
Builder-style method to set whether this window’s background should be transparent.
sourcepub fn set_position(self, position: impl Into<Point>) -> Self
pub fn set_position(self, position: impl Into<Point>) -> Self
Sets the initial window position in display points, relative to the origin of the virtual screen.
sourcepub fn set_level(self, level: WindowLevel) -> Self
pub fn set_level(self, level: WindowLevel) -> Self
Sets the WindowLevel
of the window
sourcepub fn set_window_state(self, state: WindowState) -> Self
pub fn set_window_state(self, state: WindowState) -> Self
Set initial state for the window.
sourcepub fn with_config(self, config: WindowConfig) -> Self
pub fn with_config(self, config: WindowConfig) -> Self
Set the WindowConfig
of window.