egui::viewport

Struct ViewportBuilder

Source
pub struct ViewportBuilder {
Show 27 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 clamp_size_to_monitor_size: Option<bool>, 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 fullsize_content_view: Option<bool>, pub title_shown: Option<bool>, pub titlebar_buttons_shown: Option<bool>, pub titlebar_shown: Option<bool>, pub drag_and_drop: Option<bool>, pub taskbar: 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>, pub window_type: Option<X11WindowType>,
}
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>§clamp_size_to_monitor_size: Option<bool>

Whether clamp the window’s size to monitor’s size. The default is true on linux, otherwise it is false.

Note: On some Linux systems, a window size larger than the monitor causes crashes

§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>§fullsize_content_view: Option<bool>§title_shown: Option<bool>§titlebar_buttons_shown: Option<bool>§titlebar_shown: Option<bool>§drag_and_drop: Option<bool>§taskbar: Option<bool>§close_button: Option<bool>§minimize_button: Option<bool>§maximize_button: Option<bool>§window_level: Option<WindowLevel>§mouse_passthrough: Option<bool>§window_type: Option<X11WindowType>

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 IconData::default().

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_taskbar(self, show: bool) -> Self

windows: Whether show or hide the window icon in the taskbar.

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_clamp_size_to_monitor_size(self, value: bool) -> Self

Sets whether clamp the window’s size to monitor’s size. The default is true on linux, otherwise it is false.

Note: On some Linux systems, a window size larger than the monitor causes crashes

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 with_window_type(self, value: X11WindowType) -> Self

§On X11

This sets the window type. Maps directly to _NET_WM_WINDOW_TYPE.

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

Source§

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>,

Source§

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>,

Source§

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,