window/
lib.rs

1#![deny(
2    rust_2018_compatibility,
3    rust_2018_idioms,
4    future_incompatible,
5    nonstandard_style,
6    unused,
7    clippy::all,
8    clippy::doc_markdown,
9    missing_docs,
10    missing_copy_implementations,
11    missing_debug_implementations
12)]
13
14//! Window storage and interfacing traits.
15//!
16//! The [`Window`](./trait.Window.html) trait is the minimum interface required for event loop.
17//! All backends usually support this trait.
18//!
19//! The [`AdvancedWindow`](./trait.AdvancedWindow.html) trait
20//! is the maximum interface that can be provided,
21//! while still staying consistent between backends. Not all backends implement
22//! `AdvancedWindow`; check your backend's documentation to see whether it implements
23//! this trait.
24//!
25//! The [`WindowSettings`](./struct.WindowSettings.html) structure is the preferred way of building
26//! new windows in Piston. It uses the `BuildFromWindowSettings` trait,
27//! which backends implement to handle window creation and setup.
28//!
29//! The [`OpenGLWindow`](./trait.OpenGLWindow.html) trait is used to provide low-level
30//! access to OpenGL through the abstract Piston API.
31//!
32//! The [`Size`](./struct.Size.html) structure is used throughout Piston to store window sizes.
33//! It implements some conversion traits for convenience.
34
35use std::{convert::From, error::Error, time::Duration};
36
37pub use graphics_api_version::{UnsupportedGraphicsApiError, Version as Api};
38use input::Event;
39pub use no_window::NoWindow;
40
41mod no_window;
42
43/// The type of an OpenGL function address.
44///
45/// Note: This is a raw pointer. It can be null!
46///
47/// See [`OpenGLWindow`](./trait.OpenGLWindow.html) for more information.
48pub type ProcAddress = *const ();
49
50/// Structure to store the window size.
51///
52/// The width and height are in *points*. On most computers, a point
53/// is 1:1 with a pixel. However, this is not universally true. For example,
54/// the Apple Retina Display defines 1 point to be a 2x2 square of pixels.
55///
56/// Normally, the consideration of points vs pixels should be left to the
57/// host operating system.
58#[derive(Debug, Copy, Clone, PartialEq)]
59pub struct Size {
60    /// The width.
61    pub width: f64,
62    /// The height.
63    pub height: f64,
64}
65
66impl From<[u32; 2]> for Size {
67    #[inline(always)]
68    fn from(value: [u32; 2]) -> Size {
69        Size {
70            width: value[0] as f64,
71            height: value[1] as f64,
72        }
73    }
74}
75
76impl From<[f64; 2]> for Size {
77    #[inline(always)]
78    fn from(value: [f64; 2]) -> Size {
79        Size {
80            width: value[0],
81            height: value[1],
82        }
83    }
84}
85
86impl From<(u32, u32)> for Size {
87    #[inline(always)]
88    fn from(value: (u32, u32)) -> Size {
89        Size {
90            width: value.0 as f64,
91            height: value.1 as f64,
92        }
93    }
94}
95
96impl From<(f64, f64)> for Size {
97    #[inline(always)]
98    fn from(value: (f64, f64)) -> Size {
99        Size {
100            width: value.0,
101            height: value.1,
102        }
103    }
104}
105
106impl From<Size> for [u32; 2] {
107    #[inline(always)]
108    fn from(value: Size) -> [u32; 2] {
109        [value.width as u32, value.height as u32]
110    }
111}
112
113impl From<Size> for [f64; 2] {
114    #[inline(always)]
115    fn from(value: Size) -> [f64; 2] {
116        [value.width, value.height]
117    }
118}
119
120impl From<Size> for (u32, u32) {
121    #[inline(always)]
122    fn from(value: Size) -> (u32, u32) {
123        (value.width as u32, value.height as u32)
124    }
125}
126
127impl From<Size> for (f64, f64) {
128    #[inline(always)]
129    fn from(value: Size) -> (f64, f64) {
130        (value.width, value.height)
131    }
132}
133
134/// Structure to store the window position.
135///
136/// The width and height are in *points*. On most computers, a point
137/// is 1:1 with a pixel. However, this is not universally true. For example,
138/// the Apple Retina Display defines 1 point to be a 2x2 square of pixels.
139///
140/// Normally, the consideration of points vs pixels should be left to the
141/// host operating system.
142#[derive(Debug, Copy, Clone, PartialEq, Eq)]
143pub struct Position {
144    /// The x coordinate.
145    pub x: i32,
146    /// The y coordinate.
147    pub y: i32,
148}
149
150impl From<[i32; 2]> for Position {
151    #[inline(always)]
152    fn from(value: [i32; 2]) -> Position {
153        Position {
154            x: value[0],
155            y: value[1],
156        }
157    }
158}
159
160impl From<(i32, i32)> for Position {
161    #[inline(always)]
162    fn from(value: (i32, i32)) -> Position {
163        Position {
164            x: value.0,
165            y: value.1,
166        }
167    }
168}
169
170impl From<Position> for [i32; 2] {
171    #[inline(always)]
172    fn from(value: Position) -> [i32; 2] {
173        [value.x, value.y]
174    }
175}
176
177impl From<Position> for (i32, i32) {
178    #[inline(always)]
179    fn from(value: Position) -> (i32, i32) {
180        (value.x, value.y)
181    }
182}
183
184/// Constructs a window from a [`WindowSettings`](./struct.WindowSettings.html)
185/// object.
186///
187/// It is used by [`WindowSettings::build`](./struct.WindowSettings.html#method.build).
188/// Note that the backend's implementation of this may differ from its implementation
189/// of `::new()`.
190pub trait BuildFromWindowSettings: Sized {
191    /// Builds the window from a `WindowSettings` object.
192    ///
193    /// # Errors
194    ///
195    /// See your backend's documentation for details about what kind of
196    /// error strings can be returned, and the conditions for error.
197    fn build_from_window_settings(settings: &WindowSettings) -> Result<Self, Box<dyn Error>>;
198}
199
200/// Trait representing the minimum requirements for defining a window.
201///
202/// This trait defines all the behavior needed for making an event loop.
203///
204/// An example of a working event loop can be found in the Piston-Tutorials
205/// repository under getting-started, or in the event loop examples.
206///
207/// When implementing the `Window` trait for a custom window backend,
208/// it is not necessary to emit `Event::Loop` variants,
209/// since these are generated by the event loop.
210pub trait Window {
211    /// Tells the window to close or stay open.
212    fn set_should_close(&mut self, value: bool);
213
214    /// Returns true if the window should close.
215    fn should_close(&self) -> bool;
216
217    /// Gets the size of the window.
218    fn size(&self) -> Size;
219
220    /// Swaps render buffers.
221    ///
222    /// When this is set to false, this method must be called manually
223    /// or through the window backend. By default, it is set to true, so
224    /// usually it is not needed in application code.
225    fn swap_buffers(&mut self);
226
227    /// Wait indefinitely for an input event to be available from the window.
228    fn wait_event(&mut self) -> Event;
229
230    /// Wait for an input event to be available from the window or for the
231    /// specified timeout to be reached.
232    ///
233    /// Returns `None` only if there is no input event within the timeout.
234    fn wait_event_timeout(&mut self, timeout: Duration) -> Option<Event>;
235
236    /// Polls an input event from the window.
237    ///
238    /// Return `None` if no events available.
239    fn poll_event(&mut self) -> Option<Event>;
240
241    /// Gets the draw size of the window.
242    ///
243    /// This is equal to the size of the frame buffer of the inner window,
244    /// excluding the title bar and borders.
245    ///
246    /// This information is given to the client code through the
247    /// [`Render`](../input/enum.Event.html) event.
248    fn draw_size(&self) -> Size;
249}
250
251/// Trait representing a window with the most features that are still generic.
252///
253/// This trait is implemented by fully featured window back-ends. When possible,
254/// reduce the trait constraint to `Window` to make the code more portable.
255///
256/// The `Sized` trait is required for method chaining.
257pub trait AdvancedWindow: Window + Sized {
258    /// Gets a copy of the title of the window.
259    fn get_title(&self) -> String;
260
261    /// Sets the title of the window.
262    fn set_title(&mut self, value: String);
263
264    /// Sets title on window.
265    ///
266    /// This method moves the current window data,
267    /// unlike [`set_title()`](#tymethod.set_title), so
268    /// that it can be used in method chaining.
269    fn title(mut self, value: String) -> Self {
270        self.set_title(value);
271        self
272    }
273
274    /// Gets whether to exit when pressing esc.
275    ///
276    /// Useful when prototyping.
277    fn get_exit_on_esc(&self) -> bool;
278
279    /// Sets whether to exit when pressing esc.
280    ///
281    /// Useful when prototyping.
282    fn set_exit_on_esc(&mut self, value: bool);
283
284    /// Sets whether to exit when pressing the Esc button.
285    ///
286    /// Useful when prototyping.
287    ///
288    /// This method moves the current window data,
289    /// unlike [`set_exit_on_esc()`](#tymethod.set_exit_on_esc), so
290    /// that it can be used in method chaining.
291    fn exit_on_esc(mut self, value: bool) -> Self {
292        self.set_exit_on_esc(value);
293        self
294    }
295
296    /// Gets whether the window will automatically close when attempting
297    /// to close it.
298    ///
299    /// Useful when prototyping.
300    fn get_automatic_close(&self) -> bool;
301
302    /// Sets whether the window will automatically close when attempting
303    /// to close it. If this is disabled, attempts to close the window
304    /// can be detected via an `Input::Close(..)` event, and
305    /// [`Window::set_should_close()`](trait.Window.html#tymethod.set_should_close)
306    /// can be called to actually close the window.
307    ///
308    /// Useful when prototyping.
309    fn set_automatic_close(&mut self, value: bool);
310
311    /// Sets whether the window will automatically close when attempting
312    /// to close it. If this is disabled, attempts to close the window
313    /// can be detected via an `Input::Close(..)` event, and
314    /// [`Window::set_should_close()`](trait.Window.html#tymethod.set_should_close)
315    /// can be called to actually close the window.
316    ///
317    /// Useful when prototyping.
318    ///
319    /// This method moves the current window data,
320    /// unlike [`set_automatic_close()`](#tymethod.set_automatic_close), so
321    /// that it can be used in method chaining.
322    fn automatic_close(mut self, value: bool) -> Self {
323        self.set_automatic_close(value);
324        self
325    }
326
327    /// Sets whether to capture/grab the cursor.
328    ///
329    /// This is used to lock and hide cursor to the window,
330    /// for example in a first-person shooter game.
331    fn set_capture_cursor(&mut self, value: bool);
332
333    /// Sets whether to capture/grab the cursor.
334    ///
335    /// This method moves the current window data,
336    /// unlike [`set_capture_cursor()`](#tymethod.set_capture_cursor), so
337    /// that it can be used in method chaining.
338    fn capture_cursor(mut self, value: bool) -> Self {
339        self.set_capture_cursor(value);
340        self
341    }
342
343    /// Shows the window.
344    ///
345    /// If the platform does not support this, it will have no effect.
346    fn show(&mut self);
347
348    /// Hides the window.
349    ///
350    /// If the platform does not support this, it will have no effect.
351    fn hide(&mut self);
352
353    /// Gets the position of window.
354    // Returns `None` if the window no longer has a position.
355    fn get_position(&self) -> Option<Position>;
356
357    /// Sets the position of window.
358    ///
359    /// Has no effect if the window no longer has a position.
360    fn set_position<P: Into<Position>>(&mut self, val: P);
361
362    /// Sets the window size.
363    ///
364    /// Has no effect if the window no longer has a size.
365    fn set_size<S: Into<Size>>(&mut self, val: S);
366
367    /// Sets the position of window.
368    ///
369    /// Has no effect if the window no longer has a position.
370    ///
371    /// This method moves the current window data,
372    /// unlike [`set_position()`](#tymethod.set_position), so
373    /// that it can be used in method chaining.
374    fn position<P: Into<Position>>(mut self, val: P) -> Self {
375        self.set_position(val);
376        self
377    }
378}
379
380/// Trait for OpenGL specific operations on a window.
381///
382/// OpenGL uses a strategy called "function pointer loading"
383/// to hook up the higher level graphics APIs with the OpenGL
384/// driver. Which function pointers to load depends on the
385/// hardware capabilities and version of OpenGL. By using the
386/// [`OpenGLWindow`](trait.OpenGLWindow.html)
387/// trait, the higher level graphics API can load
388/// functions from the window backend with the version set up
389/// using the `WindowSettings` structure.
390///
391/// For more information about function pointer loading, see
392/// <https://www.opengl.org/wiki/Load_OpenGL_Functions>
393pub trait OpenGLWindow: Window {
394    /// Returns the address of the specified OpenGL function if it exists.
395    ///
396    /// If the function does not exist, it returns a null pointer.
397    fn get_proc_address(&mut self, proc_name: &str) -> ProcAddress;
398
399    /// Returns true if this window's gl context is the current gl context.
400    fn is_current(&self) -> bool;
401
402    /// Make the window's gl context the current gl context.
403    fn make_current(&mut self);
404}
405
406/// Settings structure for window behavior.
407///
408/// This structure stores everything that needs to be customized when
409/// constructing most windows. This structure makes it easy to create multiple
410/// windows with the same settings, and it also makes piston's multiple backends
411/// easier to implement for piston devs.
412#[derive(Clone, Debug)]
413pub struct WindowSettings {
414    title: String,
415    size: Size,
416    samples: u8,
417    fullscreen: bool,
418    exit_on_esc: bool,
419    automatic_close: bool,
420    vsync: bool,
421    graphics_api: Option<Api>,
422    srgb: bool,
423    resizable: bool,
424    decorated: bool,
425    controllers: bool,
426    transparent: bool,
427}
428
429impl WindowSettings {
430    /// Creates window settings with defaults.
431    ///
432    /// - samples: 0
433    /// - fullscreen: false
434    /// - exit_on_esc: false
435    /// - automatic_close: true
436    /// - vsync: false
437    /// - graphics_api: None
438    /// - srgb: true
439    /// - resizable: true
440    /// - decorated: true
441    /// - controllers: true
442    /// - transparent: false
443    pub fn new<T: Into<String>, S: Into<Size>>(title: T, size: S) -> WindowSettings {
444        WindowSettings {
445            title: title.into(),
446            size: size.into(),
447            samples: 0,
448            fullscreen: false,
449            exit_on_esc: false,
450            automatic_close: true,
451            vsync: false,
452            graphics_api: None,
453            srgb: true,
454            resizable: true,
455            decorated: true,
456            controllers: true,
457            transparent: false,
458        }
459    }
460
461    /// Builds window from the given settings.
462    ///
463    /// The return value is ambiguous, to allow for operation on multiple
464    /// backends. Clients should explicitly name the return type. See the
465    /// Guide to using Piston Windows for more info and examples.
466    ///
467    /// # Errors
468    ///
469    /// This function will return an error if your backend returns an error.
470    /// See your backend's documentation on `build_from_window_settings()`
471    /// for more details.
472    pub fn build<W: BuildFromWindowSettings>(&self) -> Result<W, Box<dyn Error>> {
473        BuildFromWindowSettings::build_from_window_settings(self)
474    }
475
476    /// Gets the title of built windows.
477    pub fn get_title(&self) -> String {
478        self.title.clone()
479    }
480
481    /// Sets the title of built windows.
482    pub fn set_title(&mut self, value: String) {
483        self.title = value;
484    }
485
486    /// Sets the title of built windows.
487    ///
488    /// This method moves the current window data,
489    /// unlike [`set_title()`](#method.set_title),
490    /// so that it can be used in method chaining.
491    pub fn title(mut self, value: String) -> Self {
492        self.set_title(value);
493        self
494    }
495
496    /// Gets the size of built windows.
497    pub fn get_size(&self) -> Size {
498        self.size
499    }
500
501    /// Sets the size of built windows.
502    pub fn set_size(&mut self, value: Size) {
503        self.size = value;
504    }
505
506    /// Sets the size of built windows.
507    ///
508    /// This method moves the current window data,
509    /// unlike [`set_size()`](#method.set_size),
510    /// so that it can be used in method chaining.
511    pub fn size(mut self, value: Size) -> Self {
512        self.set_size(value);
513        self
514    }
515
516    /// Gets whether built windows will be fullscreen.
517    pub fn get_fullscreen(&self) -> bool {
518        self.fullscreen
519    }
520
521    /// Sets whether built windows will be fullscreen.
522    pub fn set_fullscreen(&mut self, value: bool) {
523        self.fullscreen = value;
524    }
525
526    /// Sets whether built windows will be fullscreen.
527    ///
528    /// This method moves the current window data,
529    /// unlike [`set_fullscreen()`](#method.set_fullscreen),
530    /// so that it can be used in method chaining.
531    pub fn fullscreen(mut self, value: bool) -> Self {
532        self.set_fullscreen(value);
533        self
534    }
535
536    /// Gets whether built windows should exit when the Esc key is pressed.
537    pub fn get_exit_on_esc(&self) -> bool {
538        self.exit_on_esc
539    }
540
541    /// Sets whether built windows should exit when the Esc key is pressed.
542    pub fn set_exit_on_esc(&mut self, value: bool) {
543        self.exit_on_esc = value;
544    }
545
546    /// Sets whether built windows should exit when the Esc key is pressed.
547    ///
548    /// This method moves the current window data,
549    /// unlike [`set_exit_on_esc()`](#method.set_exit_on_esc),
550    /// so that it can be used in method chaining.
551    pub fn exit_on_esc(mut self, value: bool) -> Self {
552        self.set_exit_on_esc(value);
553        self
554    }
555
556    /// Gets whether built windows should automatically close when the X or
557    /// ALT+F4 are pressed.
558    pub fn get_automatic_close(&self) -> bool {
559        self.automatic_close
560    }
561
562    /// Sets whether built windows should automatically close when the X or
563    /// ALT+F4 are pressed. If this is disabled, attempts to close the window
564    /// can be detected via an `Input::Close(..)` event, and
565    /// [`Window::set_should_close()`](trait.Window.html#tymethod.set_should_close)
566    /// can be called to actually close the window.
567    pub fn set_automatic_close(&mut self, value: bool) {
568        self.automatic_close = value;
569    }
570
571    /// Sets whether built windows should automatically close when the X or
572    /// ALT+F4 are pressed. If this is disabled, attempts to close the window
573    /// can be detected via an `Input::Close(..)` event, and
574    /// [`Window::set_should_close()`](trait.Window.html#tymethod.set_should_close)
575    /// can be called to actually close the window.
576    ///
577    /// This method moves the current window data,
578    /// unlike [`set_automatic_close()`](#method.set_automatic_close),
579    /// so that it can be used in method chaining.
580    pub fn automatic_close(mut self, value: bool) -> Self {
581        self.set_automatic_close(value);
582        self
583    }
584
585    /// Gets the number of samples to use for anti-aliasing.
586    ///
587    /// See <https://en.wikipedia.org/wiki/Multisample_anti-aliasing>
588    /// for more information.
589    pub fn get_samples(&self) -> u8 {
590        self.samples
591    }
592
593    /// Sets the number of samples to use for anti-aliasing.
594    ///
595    /// See <https://en.wikipedia.org/wiki/Multisample_anti-aliasing>
596    /// for more information.
597    pub fn set_samples(&mut self, value: u8) {
598        self.samples = value;
599    }
600
601    /// Sets the number of samples to use for anti-aliasing.
602    ///
603    /// See <https://en.wikipedia.org/wiki/Multisample_anti-aliasing>
604    /// for more information.
605    ///
606    /// This method moves the current window data,
607    /// unlike [`set_samples()`](#method.set_samples)
608    /// so that it can be used in method chaining.
609    pub fn samples(mut self, value: u8) -> Self {
610        self.set_samples(value);
611        self
612    }
613
614    /// Gets whether built windows should use vsync.
615    ///
616    /// See <https://en.wikipedia.org/wiki/Screen_tearing> for more information>
617    /// about vsync.
618    pub fn get_vsync(&self) -> bool {
619        self.vsync
620    }
621
622    /// Sets whether built windows should use vsync.
623    ///
624    /// See <https://en.wikipedia.org/wiki/Screen_tearing> for more information>
625    /// about vsync.
626    pub fn set_vsync(&mut self, value: bool) {
627        self.vsync = value;
628    }
629
630    /// Sets whether built windows should use vsync.
631    ///
632    /// See <https://en.wikipedia.org/wiki/Screen_tearing> for more information>
633    /// about vsync.
634    ///
635    /// This method moves the current window data,
636    /// unlike [`set_vsync()`](#method.set_vsync),
637    /// so that it can be used in method chaining.
638    pub fn vsync(mut self, value: bool) -> Self {
639        self.set_vsync(value);
640        self
641    }
642
643    /// Gets the graphics API version of built windows.
644    ///
645    /// If None is returned, the default graphics API version is being used. This
646    /// is often a forward compatible version of OpenGL 3.2 or
647    /// higher that works with newer versions of graphics libraries.
648    pub fn get_maybe_graphics_api(&self) -> Option<Api> {
649        self.graphics_api.clone()
650    }
651
652    /// Sets graphics API version of built windows.
653    ///
654    /// If None is passed, the default graphics API version is used. This
655    /// is often a forward compatible version of OpenGL 3.2 or
656    /// higher that works with newer versions of graphics libraries.
657    pub fn set_maybe_graphics_api<V: Into<Api>>(&mut self, value: Option<V>) {
658        self.graphics_api = value.map(|v| v.into());
659    }
660
661    /// Sets graphics API version of built windows.
662    ///
663    /// If None is passed, the default graphics API version is used. This
664    /// is often a forward compatible version of OpenGL 3.2 or
665    /// higher that works with newer versions of graphics libraries.
666    ///
667    /// This method moves the current window data,
668    /// unlike [`set_maybe_graphics_api()`](#method.set_maybe_graphics_api),
669    /// so that it can be used in method chaining.
670    pub fn maybe_graphics_api<V: Into<Api>>(mut self, value: Option<V>) -> Self {
671        self.set_maybe_graphics_api(value.map(|v| v.into()));
672        self
673    }
674
675    /// Sets graphics API version of built windows.
676    ///
677    /// For setting the graphics API version back to default, see
678    /// [`set_maybe_graphics_api()`](#method.set_maybe_graphics_api).
679    pub fn set_graphics_api<V: Into<Api>>(&mut self, value: V) {
680        self.graphics_api = Some(value.into());
681    }
682
683    /// Sets the graphics API version of built windows.
684    ///
685    /// For setting the graphics API version back to default, see
686    /// [`maybe_graphics_api()`](#method.maybe_graphics_api).
687    ///
688    /// This method moves the current window data,
689    /// unlike [`set_graphics_api()`](#method.set_graphics_api),
690    /// so that it can be used in method chaining.
691    pub fn graphics_api<V: Into<Api>>(mut self, value: V) -> Self {
692        self.set_graphics_api(value);
693        self
694    }
695
696    /// Gets whether built windows should use hardware accelerated color conversion.
697    ///
698    /// If true, the graphics hardware uses customized circuitry
699    /// to convert colors from `sRGB` to linear color space in graphics
700    /// shaders, and then converts pixel fragments back to `sRGB`
701    /// depending on the color format of the frame buffer. This feature
702    /// is supported by most graphics hardware and set to true by
703    /// default.
704    ///
705    /// See <https://en.wikipedia.org/wiki/SRGB> for more information.
706    pub fn get_srgb(&self) -> bool {
707        self.srgb
708    }
709
710    /// Sets whether built windows should use hardware accelerated color conversion.
711    ///
712    /// See [`get_srgb()`](#method.get_srgb) for more information about
713    /// the srgb setting.
714    pub fn set_srgb(&mut self, value: bool) {
715        self.srgb = value;
716    }
717
718    /// Sets whether built windows should use hardware accelerated color conversion.
719    ///
720    /// See [`get_srgb()`](#method.get_srgb) for more information about
721    /// the srgb setting.
722    ///
723    /// This method moves the current window data,
724    /// unlike [`set_srgb()`](#method.set_srgb),
725    /// so that it can be used in method chaining.
726    pub fn srgb(mut self, value: bool) -> Self {
727        self.set_srgb(value);
728        self
729    }
730
731    /// Gets whether built windows should be resizable.
732    pub fn get_resizable(&self) -> bool {
733        self.resizable
734    }
735
736    /// Sets whether built windows should be resizable.
737    pub fn set_resizable(&mut self, value: bool) {
738        self.resizable = value;
739    }
740
741    /// Sets whether built windows should be resizable.
742    ///
743    /// This method moves the current window data,
744    /// unlike [`set_resizable()`](#method.set_resizable),
745    /// so that it can be used in method chaining.
746    pub fn resizable(mut self, value: bool) -> Self {
747        self.set_resizable(value);
748        self
749    }
750
751    /// Gets whether built windows should be decorated.
752    ///
753    /// Decoration on a window refers to the Operating System's
754    /// header above the window, and the window border.
755    ///
756    /// For more information, see
757    /// <https://en.wikipedia.org/wiki/Window_decoration>
758    pub fn get_decorated(&self) -> bool {
759        self.decorated
760    }
761
762    /// Sets whether built windows should be decorated.
763    ///
764    /// Decoration on a window refers to the Operating System's
765    /// header above the window, and the window border.
766    ///
767    /// For more information, see
768    /// <https://en.wikipedia.org/wiki/Window_decoration>
769    pub fn set_decorated(&mut self, value: bool) {
770        self.decorated = value;
771    }
772
773    /// Sets whether built windows should be decorated.
774    ///
775    /// Decoration on a window refers to the Operating System's
776    /// header above the window, and the window border.
777    ///
778    /// For more information, see
779    /// <https://en.wikipedia.org/wiki/Window_decoration>
780    ///
781    /// This method moves the current window data,
782    /// unlike [`set_decorated()`](#method.set_decorated),
783    /// so that it can be used in method chaining.
784    pub fn decorated(mut self, value: bool) -> Self {
785        self.set_decorated(value);
786        self
787    }
788
789    /// Gets whether built windows should listen to controller input.
790    pub fn get_controllers(&self) -> bool {
791        self.controllers
792    }
793
794    /// Sets whether built windows should listen to controller input.
795    pub fn set_controllers(&mut self, value: bool) {
796        self.controllers = value;
797    }
798
799    /// Sets whether built windows should listen to controller input.
800    ///
801    /// This method moves the current window data,
802    /// unlike [`set_controllers()`](#method.set_controllers),
803    /// so that it can be used in method chaining.
804    pub fn controllers(mut self, value: bool) -> Self {
805        self.set_controllers(value);
806        self
807    }
808
809    /// Gets whether built windows should be transparent.
810    pub fn get_transparent(&self) -> bool {
811        self.transparent
812    }
813
814    /// Sets whether built windows should be transparent.
815    pub fn set_transparent(&mut self, value: bool) {
816        self.transparent = value;
817    }
818
819    /// Sets whether built windows should be transparent.
820    ///
821    /// This method moves the current window data,
822    /// unlike [`set_transparent()`](#method.set_transparent),
823    /// so that it can be used in method chaining.
824    pub fn transparent(mut self, value: bool) -> Self {
825        self.set_transparent(value);
826        self
827    }
828}