Struct egui::viewport::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_shown: Option<bool>
§drag_and_drop: Option<bool>
§taskbar: Option<bool>
§window_level: Option<WindowLevel>
§mouse_passthrough: Option<bool>
§window_type: Option<X11WindowType>
Implementations§
source§impl ViewportBuilder
impl ViewportBuilder
sourcepub fn with_title(self, title: impl Into<String>) -> Self
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
sourcepub fn with_decorations(self, decorations: bool) -> Self
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
sourcepub fn with_fullscreen(self, fullscreen: bool) -> Self
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
sourcepub fn with_maximized(self, maximized: bool) -> Self
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
sourcepub fn with_resizable(self, resizable: bool) -> Self
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
sourcepub fn with_transparent(self, transparent: bool) -> Self
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!
sourcepub fn with_icon(self, icon: impl Into<Arc<IconData>>) -> Self
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()
.
sourcepub fn with_active(self, active: bool) -> Self
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
sourcepub fn with_visible(self, visible: bool) -> Self
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
sourcepub fn with_fullsize_content_view(self, value: bool) -> Self
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
.
sourcepub fn with_title_shown(self, title_shown: bool) -> Self
pub fn with_title_shown(self, title_shown: bool) -> Self
macOS: Set to false
to hide the window title.
macOS: Set to false
to hide the titlebar button (close, minimize, maximize)
sourcepub fn with_titlebar_shown(self, shown: bool) -> Self
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.
sourcepub fn with_taskbar(self, show: bool) -> Self
pub fn with_taskbar(self, show: bool) -> Self
windows: Whether show or hide the window icon in the taskbar.
sourcepub fn with_inner_size(self, size: impl Into<Vec2>) -> Self
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
sourcepub fn with_min_inner_size(self, size: impl Into<Vec2>) -> Self
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
sourcepub fn with_max_inner_size(self, size: impl Into<Vec2>) -> Self
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
sourcepub fn with_clamp_size_to_monitor_size(self, value: bool) -> Self
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
Does not work on X11.
Does not work on X11.
Does not work on X11.
sourcepub fn with_drag_and_drop(self, value: bool) -> Self
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.
sourcepub fn with_position(self, pos: impl Into<Pos2>) -> Self
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.
sourcepub fn with_app_id(self, app_id: impl Into<String>) -> Self
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.
sourcepub fn with_window_level(self, level: WindowLevel) -> Self
pub fn with_window_level(self, level: WindowLevel) -> Self
Control if window is always-on-top, always-on-bottom, or neither.
sourcepub fn with_always_on_top(self) -> Self
pub fn with_always_on_top(self) -> Self
This window is always on top
sourcepub fn with_mouse_passthrough(self, value: bool) -> Self
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
.
sourcepub fn with_window_type(self, value: X11WindowType) -> Self
pub fn with_window_type(self, value: X11WindowType) -> Self
§On X11
This sets the window type.
Maps directly to _NET_WM_WINDOW_TYPE
.
sourcepub fn patch(&mut self, new_vp_builder: Self) -> (Vec<ViewportCommand>, bool)
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
impl Clone for ViewportBuilder
source§fn clone(&self) -> ViewportBuilder
fn clone(&self) -> ViewportBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ViewportBuilder
impl Debug for ViewportBuilder
source§impl Default for ViewportBuilder
impl Default for ViewportBuilder
source§fn default() -> ViewportBuilder
fn default() -> ViewportBuilder
source§impl PartialEq for ViewportBuilder
impl PartialEq for ViewportBuilder
impl Eq for ViewportBuilder
impl StructuralPartialEq for ViewportBuilder
Auto Trait Implementations§
impl Freeze for ViewportBuilder
impl RefUnwindSafe for ViewportBuilder
impl Send for ViewportBuilder
impl Sync for ViewportBuilder
impl Unpin for ViewportBuilder
impl UnwindSafe for ViewportBuilder
Blanket Implementations§
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)