Skip to main content

ShellConfig

Struct ShellConfig 

Source
#[non_exhaustive]
pub struct ShellConfig {
Show 14 fields pub title: String, pub size: WindowSize, pub min_size: Option<WindowSize>, pub icon: Option<WindowIcon>, pub maximized: bool, pub fullscreen: bool, pub redraw_policy: RedrawPolicy, pub copy_src: CopySrc, pub present_mode: PresentMode, pub device_label: &'static str, pub optional_features: Features, pub screenshot: Option<ScreenshotConfig>, pub os_tooltip_timings: bool, pub bounds_store: Option<Box<dyn WindowBoundsStore>>,
}
Expand description

Everything crate::run needs before the app exists.

Build one with ShellConfig::new and the with_* setters rather than a struct literal — the struct is #[non_exhaustive] so new knobs can be added without a breaking release.

use agg_gui_shell::{RedrawPolicy, ShellConfig};
let cfg = ShellConfig::new("My App")
    .with_logical_size(1280.0, 720.0)
    .with_min_logical_size(800.0, 600.0)
    .with_redraw_policy(RedrawPolicy::Reactive);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§title: String

OS window title. An owned String because a title is routinely built at runtime (document name, version, profile).

§size: WindowSize

Initial inner size, used when no WindowBoundsStore returns a saved size. Defaults to 1280x720 logical.

§min_size: Option<WindowSize>

Minimum inner size enforced by the window system. None = unconstrained.

§icon: Option<WindowIcon>

Taskbar / title-bar icon.

§maximized: bool

Start maximized. A WindowBoundsStore that returns a maximized state overrides this.

§fullscreen: bool

Start in borderless fullscreen. The app can toggle later through agg_gui::fullscreen::request_toggle.

§redraw_policy: RedrawPolicy

Reactive (default) or continuous redraw. The host can change this at runtime through crate::ShellControl::set_redraw_policy.

§copy_src: CopySrc

Surface read-back requirement, passed through to agg_gui_wgpu::Gpu. Forced to CopySrc::Required when a screenshot is configured.

§present_mode: PresentMode

Swap-chain present mode, passed through to agg_gui_wgpu::Gpu (which falls back to Fifo if the surface does not support it).

§device_label: &'static str

wgpu::DeviceDescriptor label — shows up in backend validation messages and GPU captures.

§optional_features: Features

Device features requested when the adapter offers them, passed through to agg_gui_wgpu::GpuConfig (which masks them against adapter.features() so an adapter lacking one still yields a device).

§screenshot: Option<ScreenshotConfig>

Deterministic capture, see ScreenshotConfig.

§os_tooltip_timings: bool

Seed agg_gui’s tooltip timings from the OS (Windows: SPI_GETMOUSEHOVERTIME). On by default; other platforms keep the library defaults regardless.

§bounds_store: Option<Box<dyn WindowBoundsStore>>

Where the window size / maximized state is restored from and saved to. None = no persistence.

Implementations§

Source§

impl ShellConfig

Source

pub fn new(title: impl Into<String>) -> Self

Default configuration under a window title.

Source

pub fn with_logical_size(self, w: f64, h: f64) -> Self

Initial inner size in DPI-independent pixels.

Source

pub fn with_physical_size(self, w: u32, h: u32) -> Self

Initial inner size in device pixels — the unit a restored size uses.

Source

pub fn with_min_logical_size(self, w: f64, h: f64) -> Self

Refuse to let the user shrink the window below (w, h) logical pixels.

Source

pub fn with_min_physical_size(self, w: u32, h: u32) -> Self

Refuse to let the user shrink the window below (w, h) device pixels.

Source

pub fn with_icon_rgba( self, rgba: impl Into<Vec<u8>>, width: u32, height: u32, ) -> Self

Window icon from raw RGBA8 bytes (width * height * 4). An icon that winit rejects is logged and dropped — an app should still open.

Source

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

Source

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

Source

pub fn with_redraw_policy(self, policy: RedrawPolicy) -> Self

Source

pub fn with_copy_src(self, copy_src: CopySrc) -> Self

Source

pub fn with_present_mode(self, present_mode: PresentMode) -> Self

Source

pub fn with_device_label(self, label: &'static str) -> Self

Source

pub fn with_optional_features(self, features: Features) -> Self

Request these device features when — and only when — the adapter offers them. See ShellConfig::optional_features.

Source

pub fn with_screenshot( self, path: impl Into<PathBuf>, settle_frames: u32, ) -> Self

Headless-style capture: after settle_frames painted frames, read the frame back, write it as a PNG to path, and leave the event loop. The shell polls and paints every idle iteration until the capture fires, so the frame count advances without any user input.

The image is in PHYSICAL pixels — on a 2x display that is twice the logical window size. A failed capture ends crate::run with crate::ShellError::Screenshot; the shell never exits the process itself.

Source

pub fn with_os_tooltip_timings(self, enabled: bool) -> Self

Source

pub fn with_bounds_store(self, store: impl WindowBoundsStore + 'static) -> Self

Restore the window size / maximized state from store at startup and save it back as it changes. See WindowBoundsStore.

Trait Implementations§

Source§

impl Default for ShellConfig

Source§

fn default() -> Self

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

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more