pub struct ViewportBuilder {
Show 24 fields pub title: Option<String>, pub app_id: Option<String>, pub position: Option<Pos2>, pub inner_size: Option<Vec2>, pub min_inner_size: Option<Vec2>, pub max_inner_size: Option<Vec2>, pub fullscreen: Option<bool>, pub maximized: Option<bool>, pub resizable: Option<bool>, pub transparent: Option<bool>, pub decorations: Option<bool>, pub icon: Option<Arc<IconData>>, pub active: Option<bool>, pub visible: Option<bool>, pub drag_and_drop: Option<bool>, pub fullsize_content_view: Option<bool>, pub title_shown: Option<bool>, pub titlebar_buttons_shown: Option<bool>, pub titlebar_shown: Option<bool>, pub close_button: Option<bool>, pub minimize_button: Option<bool>, pub maximize_button: Option<bool>, pub window_level: Option<WindowLevel>, pub mouse_passthrough: Option<bool>,
}
Expand description

Control the building of a new egui viewport (i.e. native window).

See crate::viewport for how to build new viewports (native windows).

The fields are public, but you should use the builder pattern to set them, and that’s where you’ll find the documentation too.

Since egui is immediate mode, ViewportBuilder is accumulative in nature. Setting any option to None means “keep the current value”, or “Use the default” if it is the first call.

The default values are implementation defined, so you may want to explicitly configure the size of the window, and what buttons are shown.

Fields§

§title: Option<String>

The title of the viewport. eframe will use this as the title of the native window.

§app_id: Option<String>

This is wayland only. See Self::with_app_id.

§position: Option<Pos2>

The desired outer position of the window.

§inner_size: Option<Vec2>§min_inner_size: Option<Vec2>§max_inner_size: Option<Vec2>§fullscreen: Option<bool>§maximized: Option<bool>§resizable: Option<bool>§transparent: Option<bool>§decorations: Option<bool>§icon: Option<Arc<IconData>>§active: Option<bool>§visible: Option<bool>§drag_and_drop: Option<bool>§fullsize_content_view: Option<bool>§title_shown: Option<bool>§titlebar_buttons_shown: Option<bool>§titlebar_shown: Option<bool>§close_button: Option<bool>§minimize_button: Option<bool>§maximize_button: Option<bool>§window_level: Option<WindowLevel>§mouse_passthrough: Option<bool>

Implementations§

source§

impl ViewportBuilder

source

pub fn with_title(self, title: impl Into<String>) -> Self

Sets the initial title of the window in the title bar.

Look at winit for more details

source

pub fn with_decorations(self, decorations: bool) -> Self

Sets whether the window should have a border, a title bar, etc.

The default is true.

Look at winit for more details

source

pub fn with_fullscreen(self, fullscreen: bool) -> Self

Sets whether the window should be put into fullscreen upon creation.

The default is None.

Look at winit for more details This will use borderless

source

pub fn with_maximized(self, maximized: bool) -> Self

Request that the window is maximized upon creation.

The default is false.

Look at winit for more details

source

pub fn with_resizable(self, resizable: bool) -> Self

Sets whether the window is resizable or not.

The default is true.

Look at winit for more details

source

pub fn with_transparent(self, transparent: bool) -> Self

Sets whether the background of the window should be transparent.

You should avoid having a crate::CentralPanel, or make sure its frame is also transparent.

In eframe you control the transparency with eframe::App::clear_color().

If this is true, writing colors with alpha values different than 1.0 will produce a transparent window. On some platforms this is more of a hint for the system and you’d still have the alpha buffer.

The default is false. If this is not working, it’s because the graphic context doesn’t support transparency, you will need to set the transparency in the eframe!

source

pub fn with_icon(self, icon: impl Into<Arc<IconData>>) -> Self

The application icon, e.g. in the Windows task bar or the alt-tab menu.

The default icon is a white e on a black background (for “egui” or “eframe”). If you prefer the OS default, set this to None.

source

pub fn with_active(self, active: bool) -> Self

Whether the window will be initially focused or not.

The window should be assumed as not focused by default

Platform-specific:

Android / iOS / X11 / Wayland / Orbital: Unsupported.

Look at winit for more details

source

pub fn with_visible(self, visible: bool) -> Self

Sets whether the window will be initially visible or hidden.

The default is to show the window.

Look at winit for more details

source

pub fn with_fullsize_content_view(self, value: bool) -> Self

macOS: Makes the window content appear behind the titlebar.

You often want to combine this with Self::with_titlebar_shown and Self::with_title_shown.

source

pub fn with_title_shown(self, title_shown: bool) -> Self

macOS: Set to false to hide the window title.

source

pub fn with_titlebar_buttons_shown(self, titlebar_buttons_shown: bool) -> Self

macOS: Set to false to hide the titlebar button (close, minimize, maximize)

source

pub fn with_titlebar_shown(self, shown: bool) -> Self

macOS: Set to false to make the titlebar transparent, allowing the content to appear behind it.

source

pub fn with_inner_size(self, size: impl Into<Vec2>) -> Self

Requests the window to be of specific dimensions.

If this is not set, some platform-specific dimensions will be used.

Should be bigger than 0 Look at winit for more details

source

pub fn with_min_inner_size(self, size: impl Into<Vec2>) -> Self

Sets the minimum dimensions a window can have.

If this is not set, the window will have no minimum dimensions (aside from reserved).

Should be bigger than 0 Look at winit for more details

source

pub fn with_max_inner_size(self, size: impl Into<Vec2>) -> Self

Sets the maximum dimensions a window can have.

If this is not set, the window will have no maximum or will be set to the primary monitor’s dimensions by the platform.

Should be bigger than 0 Look at winit for more details

source

pub fn with_close_button(self, value: bool) -> Self

Does not work on X11.

source

pub fn with_minimize_button(self, value: bool) -> Self

Does not work on X11.

source

pub fn with_maximize_button(self, value: bool) -> Self

Does not work on X11.

source

pub fn with_drag_and_drop(self, value: bool) -> Self

On Windows: enable drag and drop support. Drag and drop can not be disabled on other platforms.

See winit’s documentation for information on why you might want to disable this on windows.

source

pub fn with_position(self, pos: impl Into<Pos2>) -> Self

The initial “outer” position of the window, i.e. where the top-left corner of the frame/chrome should be.

source

pub fn with_app_id(self, app_id: impl Into<String>) -> Self

On Wayland

On Wayland this sets the Application ID for the window.

The application ID is used in several places of the compositor, e.g. for grouping windows of the same application. It is also important for connecting the configuration of a .desktop file with the window, by using the application ID as file name. This allows e.g. a proper icon handling under Wayland.

See Waylands XDG shell documentation for more information on this Wayland-specific option.

The app_id should match the .desktop file distributed with your program.

For details about application ID conventions, see the Desktop Entry Spec

eframe

On eframe, the app_id of the root window is also used to determine the storage location of persistence files.

source

pub fn with_window_level(self, level: WindowLevel) -> Self

Control if window is always-on-top, always-on-bottom, or neither.

source

pub fn with_always_on_top(self) -> Self

This window is always on top

source

pub fn with_mouse_passthrough(self, value: bool) -> Self

On desktop: mouse clicks pass through the window, used for non-interactable overlays.

Generally you would use this in conjunction with Self::with_transparent and Self::with_always_on_top.

source

pub fn patch(&mut self, new_vp_builder: Self) -> (Vec<ViewportCommand>, bool)

Update this ViewportBuilder with a delta, returning a list of commands and a bool indicating if the window needs to be recreated.

Trait Implementations§

source§

impl Clone for ViewportBuilder

source§

fn clone(&self) -> ViewportBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ViewportBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ViewportBuilder

source§

fn default() -> ViewportBuilder

Returns the “default value” for a type. Read more
source§

impl PartialEq for ViewportBuilder

source§

fn eq(&self, other: &ViewportBuilder) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ViewportBuilder

source§

impl StructuralEq for ViewportBuilder

source§

impl StructuralPartialEq for ViewportBuilder

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,