diff options
author | 2020-11-06 02:25:56 +0100 | |
---|---|---|
committer | 2020-11-06 02:25:56 +0100 | |
commit | 631c9e4a215d8f044d76ea926117f9a9bdd24d5d (patch) | |
tree | 09ea9710e2f62634aab519836f65cd26b17a8b00 /winit/src/application/state.rs | |
parent | e966cd5b591d8014e53f414014cb49deffef535d (diff) | |
download | iced-631c9e4a215d8f044d76ea926117f9a9bdd24d5d.tar.gz iced-631c9e4a215d8f044d76ea926117f9a9bdd24d5d.tar.bz2 iced-631c9e4a215d8f044d76ea926117f9a9bdd24d5d.zip |
Write missing documentation in `iced_winit`
Diffstat (limited to 'winit/src/application/state.rs')
-rw-r--r-- | winit/src/application/state.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs index 1f3c77a0..4c0bfd34 100644 --- a/winit/src/application/state.rs +++ b/winit/src/application/state.rs @@ -5,6 +5,9 @@ use std::marker::PhantomData; use winit::event::WindowEvent; use winit::window::Window; +/// The state of a windowed [`Application`]. +/// +/// [`Application`]: ../trait.Application.html #[derive(Debug, Clone)] pub struct State<A: Application> { title: String, @@ -19,6 +22,10 @@ pub struct State<A: Application> { } impl<A: Application> State<A> { + /// Creates a new [`State`] for the provided [`Application`] and window. + /// + /// [`State`]: struct.State.html + /// [`Application`]: ../trait.Application.html pub fn new(application: &A, window: &Window) -> Self { let title = application.title(); let mode = application.mode(); @@ -48,30 +55,61 @@ impl<A: Application> State<A> { } } + /// Returns the current background [`Color`] of the [`State`]. + /// + /// [`Color`]: ../struct.Color.html + /// [`State`]: struct.State.html pub fn background_color(&self) -> Color { self.background_color } + /// Returns the current [`Viewport`] of the [`State`]. + /// + /// [`Viewport`]: ../struct.Viewport.html + /// [`State`]: struct.State.html pub fn viewport(&self) -> &Viewport { &self.viewport } + /// Returns the version of the [`Viewport`] of the [`State`]. + /// + /// The version is incremented every time the [`Viewport`] changes. + /// + /// [`Viewport`]: ../struct.Viewport.html + /// [`State`]: struct.State.html pub fn viewport_version(&self) -> usize { self.viewport_version } + /// Returns the physical [`Size`] of the [`Viewport`] of the [`State`]. + /// + /// [`Size`]: ../struct.Size.html + /// [`Viewport`]: ../struct.Viewport.html + /// [`State`]: struct.State.html pub fn physical_size(&self) -> Size<u32> { self.viewport.physical_size() } + /// Returns the logical [`Size`] of the [`Viewport`] of the [`State`]. + /// + /// [`Size`]: ../struct.Size.html + /// [`Viewport`]: ../struct.Viewport.html + /// [`State`]: struct.State.html pub fn logical_size(&self) -> Size<f32> { self.viewport.logical_size() } + /// Returns the current scale factor of the [`Viewport`] of the [`State`]. + /// + /// [`Viewport`]: ../struct.Viewport.html + /// [`State`]: struct.State.html pub fn scale_factor(&self) -> f64 { self.viewport.scale_factor() } + /// Returns the current cursor position of the [`State`]. + /// + /// [`State`]: struct.State.html pub fn cursor_position(&self) -> Point { conversion::cursor_position( self.cursor_position, @@ -79,10 +117,17 @@ impl<A: Application> State<A> { ) } + /// Returns the current keyboard modifiers of the [`State`]. + /// + /// [`State`]: struct.State.html pub fn modifiers(&self) -> winit::event::ModifiersState { self.modifiers } + /// Processes the provided window event and updates the [`State`] + /// accordingly. + /// + /// [`State`]: struct.State.html pub fn update( &mut self, window: &Window, @@ -139,6 +184,15 @@ impl<A: Application> State<A> { } } + /// Synchronizes the [`State`] with its [`Application`] and its respective + /// window. + /// + /// Normally an [`Application`] should be synchronized with its [`State`] + /// and window after calling [`Application::update`]. + /// + /// [`State`]: struct.State.html + /// [`Application`]: ../trait.Application.html + /// [`Application::update`]: ../trait.Application.html#tymethod.update pub fn synchronize(&mut self, application: &A, window: &Window) { // Update window title let new_title = application.title(); |