Struct nannou::window::Builder[][src]

pub struct Builder<'app> { /* fields omitted */ }

A context for building a window.

Implementations

impl<'app> Builder<'app>[src]

pub const DEFAULT_POWER_PREFERENCE: PowerPreference[src]

The default power preference used to request the WGPU adapter.

pub fn new(app: &'app App) -> Self[src]

Begin building a new window.

pub fn window(self, window: WindowBuilder) -> Self[src]

Build the window with some custom window parameters.

pub fn swap_chain_builder(self, swap_chain_builder: SwapChainBuilder) -> Self[src]

Specify a set of parameters for building the window surface swap chain.

pub fn power_preference(self, pref: PowerPreference) -> Self[src]

Specify the power preference desired for the WGPU adapter.

By default, this is wgpu::PowerPreference::HighPerformance.

pub fn device_descriptor(self, device_desc: DeviceDescriptor<'static>) -> Self[src]

Specify a device descriptor to use when requesting the logical device from the adapter. This allows for specifying custom wgpu device extensions.

pub fn msaa_samples(self, msaa_samples: u32) -> Self[src]

Specify the number of samples per pixel for the multisample anti-aliasing render pass.

If msaa_samples is unspecified, the first default value that nannou will attempt to use can be found via the Frame::DEFAULT_MSAA_SAMPLES constant.

Note: This parameter has no meaning if the window uses a raw_view function for rendering graphics to the window rather than a view function. This is because the raw_view function provides a RawFrame with direct access to the swap chain image itself and thus must manage their own MSAA pass.

On the other hand, the view function provides the Frame type which allows the user to render to a multisampled intermediary image allowing Nannou to take care of resolving the multisampled image to the swap chain image. In order to avoid confusion, The Window::build method will panic! if the user tries to specify msaa_samples as well as a raw_view method.

TODO: Perhaps it would be worth adding two separate methods for specifying msaa samples. One for forcing a certain number of samples and returning an error otherwise, and another for attempting to use the given number of samples but falling back to a supported value in the case that the specified number is not supported.

pub fn sketch(self, sketch_fn: SketchFn) -> Self[src]

Provide a simple function for drawing to the window.

This is similar to view but does not provide access to user data via a Model type. This is useful for sketches where you don’t require tracking any state.

pub fn view<M>(self, view_fn: ViewFn<M>) -> Self where
    M: 'static, 
[src]

The view function that the app will call to allow you to present your Model to the surface of the window on your display.

pub fn raw_view<M>(self, raw_view_fn: RawViewFn<M>) -> Self where
    M: 'static, 
[src]

The view function that the app will call to allow you to present your Model to the surface of the window on your display.

Unlike the ViewFn, the RawViewFn provides a RawFrame that is designed for drawing directly to a window’s swap chain images, rather than to a convenient intermediary image.

pub fn event<M>(self, event_fn: EventFn<M>) -> Self where
    M: 'static, 
[src]

A function for updating your model on WindowEvents associated with this window.

These include events such as key presses, mouse movement, clicks, resizing, etc.

Event Function Call Order

In nannou, if multiple functions require being called for a single kind of event, the more general event function will always be called before the more specific event function.

If an event function was also submitted to the App, that function will always be called immediately before window-specific event functions. Similarly, if a function associated with a more specific event type (e.g. key_pressed) was given, that function will be called after this function will be called.

Specific Events Variants

Note that if you only care about a certain kind of event, you can submit a function that only gets called for that specific event instead. For example, if you only care about key presses, you may wish to use the key_pressed method instead.

pub fn raw_event<M>(self, raw_event_fn: RawEventFn<M>) -> Self where
    M: 'static, 
[src]

The same as the event method, but allows for processing raw winit::event::WindowEvents rather than Nannou’s simplified event::WindowEvents.

Event Function Call Order

If both raw_event and event functions have been provided, the given raw_event function will always be called immediately before the given event function.

pub fn key_pressed<M>(self, f: KeyPressedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing key press events associated with this window.

pub fn key_released<M>(self, f: KeyReleasedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing key release events associated with this window.

pub fn mouse_moved<M>(self, f: MouseMovedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing mouse moved events associated with this window.

pub fn mouse_pressed<M>(self, f: MousePressedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing mouse pressed events associated with this window.

pub fn mouse_released<M>(self, f: MouseReleasedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing mouse released events associated with this window.

pub fn mouse_wheel<M>(self, f: MouseWheelFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing mouse wheel events associated with this window.

pub fn mouse_entered<M>(self, f: MouseEnteredFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing mouse entered events associated with this window.

pub fn mouse_exited<M>(self, f: MouseExitedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing mouse exited events associated with this window.

pub fn touch<M>(self, f: TouchFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing touch events associated with this window.

pub fn touchpad_pressure<M>(self, f: TouchpadPressureFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing touchpad pressure events associated with this window.

pub fn moved<M>(self, f: MovedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing window moved events associated with this window.

pub fn resized<M>(self, f: ResizedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing window resized events associated with this window.

pub fn hovered_file<M>(self, f: HoveredFileFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing hovered file events associated with this window.

pub fn hovered_file_cancelled<M>(self, f: HoveredFileCancelledFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing hovered file cancelled events associated with this window.

pub fn dropped_file<M>(self, f: DroppedFileFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing dropped file events associated with this window.

pub fn focused<M>(self, f: FocusedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing the focused event associated with this window.

pub fn unfocused<M>(self, f: UnfocusedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing the unfocused event associated with this window.

pub fn closed<M>(self, f: ClosedFn<M>) -> Self where
    M: 'static, 
[src]

A function for processing the window closed event associated with this window.

pub fn max_capture_frame_jobs(self, max_jobs: u32) -> Self[src]

The maximum number of simultaneous capture frame jobs that can be run for this window before we block and wait for the existing jobs to complete.

A “capture frame job” refers to the combind process of waiting to read a frame from the GPU and then writing that frame to an image file on the disk. Each call to window.capture_frame(path) spawns a new “capture frame job” on an internal thread pool.

By default, this value is equal to the number of physical cpu threads available on the system. However, keep in mind that this means there must be room in both RAM and VRAM for this number of textures to exist at any moment in time. If you run into an “out of memory” error, try reducing the number of max jobs to a lower value, though never lower than 1.

Panics if the specified value is less than 1.

pub fn capture_frame_timeout(self, timeout: Option<Duration>) -> Self[src]

In the case that max_capture_frame_jobs is reached and the main thread must block, this specifies how long to wait for a running capture job to complete. See the max_capture_frame_jobs docs for more details.

By default, the timeout used is equal to app::Builder::DEFAULT_CAPTURE_FRAME_TIMEOUT.

If None is specified, the capture process will never time out. This may be necessary on extremely low-powered machines that take a long time to write each frame to disk.

pub fn build(self) -> Result<Id, BuildError>[src]

Builds the window, inserts it into the App’s display map and returns the unique ID.

pub fn size(self, width: u32, height: u32) -> Self[src]

Requests the window to be a specific size in points.

This describes to the “inner” part of the window, not including desktop decorations like the title bar.

pub fn min_size(self, width: u32, height: u32) -> Self[src]

Set the minimum size in points for the window.

pub fn max_size(self, width: u32, height: u32) -> Self[src]

Set the maximum size in points for the window.

pub fn size_pixels(self, width: u32, height: u32) -> Self[src]

Requests the window to be a specific size in points.

This describes to the “inner” part of the window, not including desktop decorations like the title bar.

pub fn resizable(self, resizable: bool) -> Self[src]

Whether or not the window should be resizable after creation.

pub fn title<T>(self, title: T) -> Self where
    T: Into<String>, 
[src]

Requests a specific title for the window.

pub fn fullscreen(self) -> Self[src]

Create the window fullscreened on the current monitor.

pub fn fullscreen_with(self, fullscreen: Option<Fullscreen>) -> Self[src]

Set the window fullscreen state with the given settings.

  • None indicates a normal window. This is the default case.
  • Some(Fullscreen) means fullscreen with the desired settings.

pub fn maximized(self, maximized: bool) -> Self[src]

Requests maximized mode.

pub fn visible(self, visible: bool) -> Self[src]

Sets whether the window will be initially hidden or visible.

pub fn transparent(self, transparent: bool) -> Self[src]

Sets whether the background of the window should be transparent.

pub fn decorations(self, decorations: bool) -> Self[src]

Sets whether the window should have a border, a title bar, etc.

pub fn always_on_top(self, always_on_top: bool) -> Self[src]

Sets whether or not the window will always be on top of other windows.

pub fn window_icon(self, window_icon: Option<Icon>) -> Self[src]

Sets the window icon.

Auto Trait Implementations

impl<'app> !RefUnwindSafe for Builder<'app>

impl<'app> !Send for Builder<'app>

impl<'app> !Sync for Builder<'app>

impl<'app> Unpin for Builder<'app>

impl<'app> !UnwindSafe for Builder<'app>

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    T: Component + Float,
    D: AdaptFrom<S, Swp, Dwp, T>,
    Swp: WhitePoint,
    Dwp: WhitePoint
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> Downcast<T> for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Upcast<T> for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,