Struct window::WindowSettings

source ·
pub struct WindowSettings { /* private fields */ }
Expand description

Settings structure for window behavior.

This structure stores everything that needs to be customized when constructing most windows. This structure makes it easy to create multiple windows with the same settings, and it also makes piston’s multiple backends easier to implement for piston devs.

Implementations§

source§

impl WindowSettings

source

pub fn new<T: Into<String>, S: Into<Size>>(title: T, size: S) -> WindowSettings

Creates window settings with defaults.

  • samples: 0
  • fullscreen: false
  • exit_on_esc: false
  • automatic_close: true
  • vsync: false
  • graphics_api: None
  • srgb: true
  • resizable: true
  • decorated: true
  • controllers: true
  • transparent: false
source

pub fn build<W: BuildFromWindowSettings>(&self) -> Result<W, Box<dyn Error>>

Builds window from the given settings.

The return value is ambiguous, to allow for operation on multiple backends. Clients should explicitly name the return type. See the Guide to using Piston Windows for more info and examples.

Errors

This function will return an error if your backend returns an error. See your backend’s documentation on build_from_window_settings() for more details.

source

pub fn get_title(&self) -> String

Gets the title of built windows.

source

pub fn set_title(&mut self, value: String)

Sets the title of built windows.

source

pub fn title(self, value: String) -> Self

Sets the title of built windows.

This method moves the current window data, unlike set_title(), so that it can be used in method chaining.

source

pub fn get_size(&self) -> Size

Gets the size of built windows.

source

pub fn set_size(&mut self, value: Size)

Sets the size of built windows.

source

pub fn size(self, value: Size) -> Self

Sets the size of built windows.

This method moves the current window data, unlike set_size(), so that it can be used in method chaining.

source

pub fn get_fullscreen(&self) -> bool

Gets whether built windows will be fullscreen.

source

pub fn set_fullscreen(&mut self, value: bool)

Sets whether built windows will be fullscreen.

source

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

Sets whether built windows will be fullscreen.

This method moves the current window data, unlike set_fullscreen(), so that it can be used in method chaining.

source

pub fn get_exit_on_esc(&self) -> bool

Gets whether built windows should exit when the Esc key is pressed.

source

pub fn set_exit_on_esc(&mut self, value: bool)

Sets whether built windows should exit when the Esc key is pressed.

source

pub fn exit_on_esc(self, value: bool) -> Self

Sets whether built windows should exit when the Esc key is pressed.

This method moves the current window data, unlike set_exit_on_esc(), so that it can be used in method chaining.

source

pub fn get_automatic_close(&self) -> bool

Gets whether built windows should automatically close when the X or ALT+F4 are pressed.

source

pub fn set_automatic_close(&mut self, value: bool)

Sets whether built windows should automatically close when the X or ALT+F4 are pressed. If this is disabled, attempts to close the window can be detected via an Input::Close(..) event, and Window::set_should_close() can be called to actually close the window.

source

pub fn automatic_close(self, value: bool) -> Self

Sets whether built windows should automatically close when the X or ALT+F4 are pressed. If this is disabled, attempts to close the window can be detected via an Input::Close(..) event, and Window::set_should_close() can be called to actually close the window.

This method moves the current window data, unlike set_automatic_close(), so that it can be used in method chaining.

source

pub fn get_samples(&self) -> u8

Gets the number of samples to use for anti-aliasing.

See https://en.wikipedia.org/wiki/Multisample_anti-aliasing for more information.

source

pub fn set_samples(&mut self, value: u8)

Sets the number of samples to use for anti-aliasing.

See https://en.wikipedia.org/wiki/Multisample_anti-aliasing for more information.

source

pub fn samples(self, value: u8) -> Self

Sets the number of samples to use for anti-aliasing.

See https://en.wikipedia.org/wiki/Multisample_anti-aliasing for more information.

This method moves the current window data, unlike set_samples() so that it can be used in method chaining.

source

pub fn get_vsync(&self) -> bool

Gets whether built windows should use vsync.

See https://en.wikipedia.org/wiki/Screen_tearing for more information> about vsync.

source

pub fn set_vsync(&mut self, value: bool)

Sets whether built windows should use vsync.

See https://en.wikipedia.org/wiki/Screen_tearing for more information> about vsync.

source

pub fn vsync(self, value: bool) -> Self

Sets whether built windows should use vsync.

See https://en.wikipedia.org/wiki/Screen_tearing for more information> about vsync.

This method moves the current window data, unlike set_vsync(), so that it can be used in method chaining.

source

pub fn get_maybe_graphics_api(&self) -> Option<Api>

Gets the graphics API version of built windows.

If None is returned, the default graphics API version is being used. This is often a forward compatible version of OpenGL 3.2 or higher that works with newer versions of graphics libraries.

source

pub fn set_maybe_graphics_api<V: Into<Api>>(&mut self, value: Option<V>)

Sets graphics API version of built windows.

If None is passed, the default graphics API version is used. This is often a forward compatible version of OpenGL 3.2 or higher that works with newer versions of graphics libraries.

source

pub fn maybe_graphics_api<V: Into<Api>>(self, value: Option<V>) -> Self

Sets graphics API version of built windows.

If None is passed, the default graphics API version is used. This is often a forward compatible version of OpenGL 3.2 or higher that works with newer versions of graphics libraries.

This method moves the current window data, unlike set_maybe_graphics_api(), so that it can be used in method chaining.

source

pub fn set_graphics_api<V: Into<Api>>(&mut self, value: V)

Sets graphics API version of built windows.

For setting the graphics API version back to default, see set_maybe_graphics_api().

source

pub fn graphics_api<V: Into<Api>>(self, value: V) -> Self

Sets the graphics API version of built windows.

For setting the graphics API version back to default, see maybe_graphics_api().

This method moves the current window data, unlike set_graphics_api(), so that it can be used in method chaining.

source

pub fn get_srgb(&self) -> bool

Gets whether built windows should use hardware accelerated color conversion.

If true, the graphics hardware uses customized circuitry to convert colors from sRGB to linear color space in graphics shaders, and then converts pixel fragments back to sRGB depending on the color format of the frame buffer. This feature is supported by most graphics hardware and set to true by default.

See https://en.wikipedia.org/wiki/SRGB for more information.

source

pub fn set_srgb(&mut self, value: bool)

Sets whether built windows should use hardware accelerated color conversion.

See get_srgb() for more information about the srgb setting.

source

pub fn srgb(self, value: bool) -> Self

Sets whether built windows should use hardware accelerated color conversion.

See get_srgb() for more information about the srgb setting.

This method moves the current window data, unlike set_srgb(), so that it can be used in method chaining.

source

pub fn get_resizable(&self) -> bool

Gets whether built windows should be resizable.

source

pub fn set_resizable(&mut self, value: bool)

Sets whether built windows should be resizable.

source

pub fn resizable(self, value: bool) -> Self

Sets whether built windows should be resizable.

This method moves the current window data, unlike set_resizable(), so that it can be used in method chaining.

source

pub fn get_decorated(&self) -> bool

Gets whether built windows should be decorated.

Decoration on a window refers to the Operating System’s header above the window, and the window border.

For more information, see https://en.wikipedia.org/wiki/Window_decoration

source

pub fn set_decorated(&mut self, value: bool)

Sets whether built windows should be decorated.

Decoration on a window refers to the Operating System’s header above the window, and the window border.

For more information, see https://en.wikipedia.org/wiki/Window_decoration

source

pub fn decorated(self, value: bool) -> Self

Sets whether built windows should be decorated.

Decoration on a window refers to the Operating System’s header above the window, and the window border.

For more information, see https://en.wikipedia.org/wiki/Window_decoration

This method moves the current window data, unlike set_decorated(), so that it can be used in method chaining.

source

pub fn get_controllers(&self) -> bool

Gets whether built windows should listen to controller input.

source

pub fn set_controllers(&mut self, value: bool)

Sets whether built windows should listen to controller input.

source

pub fn controllers(self, value: bool) -> Self

Sets whether built windows should listen to controller input.

This method moves the current window data, unlike set_controllers(), so that it can be used in method chaining.

source

pub fn get_transparent(&self) -> bool

Gets whether built windows should be transparent.

source

pub fn set_transparent(&mut self, value: bool)

Sets whether built windows should be transparent.

source

pub fn transparent(self, value: bool) -> Self

Sets whether built windows should be transparent.

This method moves the current window data, unlike set_transparent(), so that it can be used in method chaining.

Trait Implementations§

source§

impl Clone for WindowSettings

source§

fn clone(&self) -> WindowSettings

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WindowSettings

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.