Skip to main content

ViewportBuilder

Struct ViewportBuilder 

Source
pub struct ViewportBuilder {
Show 29 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 movable_by_window_background: Option<bool>, pub title_shown: Option<bool>, pub titlebar_buttons_shown: Option<bool>, pub titlebar_shown: Option<bool>, pub has_shadow: 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>§movable_by_window_background: Option<bool>§title_shown: Option<bool>§titlebar_buttons_shown: Option<bool>§titlebar_shown: Option<bool>§has_shadow: 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>) -> ViewportBuilder

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) -> ViewportBuilder

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) -> ViewportBuilder

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) -> ViewportBuilder

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) -> ViewportBuilder

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) -> ViewportBuilder

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!

§Platform-specific

macOS: When using this feature to create an overlay-like UI, you likely want to combine this with Self::with_has_shadow set to false in order to avoid ghosting artifacts.

Source

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

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) -> ViewportBuilder

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) -> ViewportBuilder

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) -> ViewportBuilder

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_movable_by_background(self, value: bool) -> ViewportBuilder

macOS: Set to true to allow the window to be moved by dragging the background. Enabling this feature can result in unexpected behavior with draggable UI widgets such as sliders.

Source

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

macOS: Set to false to hide the window title.

Source

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

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

Source

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

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

Source

pub fn with_has_shadow(self, has_shadow: bool) -> ViewportBuilder

macOS: Set to false to make the window render without a drop shadow.

The default is true.

Disabling this feature can solve ghosting issues experienced if using Self::with_transparent.

Look at winit for more details

Source

pub fn with_taskbar(self, show: bool) -> ViewportBuilder

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

Source

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

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>) -> ViewportBuilder

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>) -> ViewportBuilder

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) -> ViewportBuilder

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) -> ViewportBuilder

Does not work on X11.

Source

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

Does not work on X11.

Source

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

Does not work on X11.

Source

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

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>) -> ViewportBuilder

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

eframe notes:

  • iOS: Sets the top left coordinates of the window in the screen space coordinate system.
  • Web: Sets the top-left coordinates relative to the viewport. Doesn’t account for CSS transform.
  • Android / Wayland: Unsupported.
Source

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

§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) -> ViewportBuilder

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

For platform compatibility see crate::viewport::WindowLevel documentation

Source

pub fn with_always_on_top(self) -> ViewportBuilder

This window is always on top

For platform compatibility see crate::viewport::WindowLevel documentation

Source

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

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) -> ViewportBuilder

§On X11

This sets the window type. Maps directly to _NET_WM_WINDOW_TYPE.

Source

pub fn patch( &mut self, new_vp_builder: ViewportBuilder, ) -> (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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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<(), Error>

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 Eq for ViewportBuilder

Source§

impl PartialEq for ViewportBuilder

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.