#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.title: StringOS window title. An owned String because a title is routinely built
at runtime (document name, version, profile).
size: WindowSizeInitial 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: boolStart maximized. A WindowBoundsStore that returns a maximized
state overrides this.
fullscreen: boolStart in borderless fullscreen. The app can toggle later through
agg_gui::fullscreen::request_toggle.
redraw_policy: RedrawPolicyReactive (default) or continuous redraw. The host can change this at
runtime through crate::ShellControl::set_redraw_policy.
copy_src: CopySrcSurface read-back requirement, passed through to agg_gui_wgpu::Gpu.
Forced to CopySrc::Required when a screenshot is configured.
present_mode: PresentModeSwap-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 strwgpu::DeviceDescriptor label — shows up in backend validation
messages and GPU captures.
optional_features: FeaturesDevice 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: boolSeed 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
impl ShellConfig
Sourcepub fn with_logical_size(self, w: f64, h: f64) -> Self
pub fn with_logical_size(self, w: f64, h: f64) -> Self
Initial inner size in DPI-independent pixels.
Sourcepub fn with_physical_size(self, w: u32, h: u32) -> Self
pub fn with_physical_size(self, w: u32, h: u32) -> Self
Initial inner size in device pixels — the unit a restored size uses.
Sourcepub fn with_min_logical_size(self, w: f64, h: f64) -> Self
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.
Sourcepub fn with_min_physical_size(self, w: u32, h: u32) -> Self
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.
Sourcepub fn with_icon_rgba(
self,
rgba: impl Into<Vec<u8>>,
width: u32,
height: u32,
) -> Self
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.
pub fn with_maximized(self, maximized: bool) -> Self
pub fn with_fullscreen(self, fullscreen: bool) -> Self
pub fn with_redraw_policy(self, policy: RedrawPolicy) -> Self
pub fn with_copy_src(self, copy_src: CopySrc) -> Self
pub fn with_present_mode(self, present_mode: PresentMode) -> Self
pub fn with_device_label(self, label: &'static str) -> Self
Sourcepub fn with_optional_features(self, features: Features) -> Self
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.
Sourcepub fn with_screenshot(
self,
path: impl Into<PathBuf>,
settle_frames: u32,
) -> Self
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.
pub fn with_os_tooltip_timings(self, enabled: bool) -> Self
Sourcepub fn with_bounds_store(self, store: impl WindowBoundsStore + 'static) -> Self
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§
Auto Trait Implementations§
impl !RefUnwindSafe for ShellConfig
impl !Send for ShellConfig
impl !Sync for ShellConfig
impl !UnwindSafe for ShellConfig
impl Freeze for ShellConfig
impl Unpin for ShellConfig
impl UnsafeUnpin for ShellConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().