diff options
Diffstat (limited to '')
| -rw-r--r-- | src/hasher.rs | 1 | ||||
| -rw-r--r-- | src/input/keyboard/key_code.rs | 27 | ||||
| -rw-r--r-- | src/lib.rs | 4 | ||||
| -rw-r--r-- | src/point.rs | 3 | ||||
| -rw-r--r-- | src/user_interface.rs | 14 | ||||
| -rw-r--r-- | src/widget/column.rs | 3 | ||||
| -rw-r--r-- | src/widget/row.rs | 3 | ||||
| -rw-r--r-- | src/widget/text.rs | 4 | 
8 files changed, 31 insertions, 28 deletions
| diff --git a/src/hasher.rs b/src/hasher.rs index 2aa10336..9f6aacce 100644 --- a/src/hasher.rs +++ b/src/hasher.rs @@ -1,4 +1,5 @@  /// The hasher used to compare layouts. +#[derive(Debug)]  pub struct Hasher(twox_hash::XxHash64);  impl Default for Hasher { diff --git a/src/input/keyboard/key_code.rs b/src/input/keyboard/key_code.rs index 5cf9301f..940df0db 100644 --- a/src/input/keyboard/key_code.rs +++ b/src/input/keyboard/key_code.rs @@ -1,6 +1,11 @@ -/// The symbolic name of a keyboard key +/// The symbolic name of a keyboard key. +/// +/// This is mostly the `KeyCode` type found in `winit`. If you are using +/// `winit`, consider enabling the `winit` feature to get conversion +/// implementations for free!  #[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]  #[repr(u32)] +#[allow(missing_docs)]  pub enum KeyCode {      /// The '1' key over the letters.      Key1, @@ -50,7 +55,7 @@ pub enum KeyCode {      Y,      Z, -    /// The Escape key, next to F1. +    /// The Escape key, next to F1      Escape,      F1, @@ -78,14 +83,14 @@ pub enum KeyCode {      F23,      F24, -    /// Print Screen/SysRq. +    /// Print Screen/SysRq      Snapshot, -    /// Scroll Lock. +    /// Scroll Lock      Scroll, -    /// Pause/Break key, next to Scroll lock. +    /// Pause/Break key, next to Scroll lock      Pause, -    /// `Insert`, next to Backspace. +    /// `Insert`, next to Backspace      Insert,      Home,      Delete, @@ -98,15 +103,11 @@ pub enum KeyCode {      Right,      Down, -    /// The Backspace key, right over Enter. -    // TODO: rename -    Back, -    /// The Enter key. -    Return, -    /// The space bar. +    Backspace, +    Enter,      Space, -    /// The "Compose" key on Linux. +    /// The "Compose" key on Linux      Compose,      Caret, @@ -191,8 +191,8 @@  //! [documentation]: https://docs.rs/iced  //! [examples]: https://github.com/hecrj/iced/tree/master/examples  //! [`UserInterface`]: struct.UserInterface.html -//#![deny(missing_docs)] -//#![deny(missing_debug_implementations)] +#![deny(missing_docs)] +#![deny(missing_debug_implementations)]  #![deny(unused_results)]  #![deny(unsafe_code)]  #![deny(rust_2018_idioms)] diff --git a/src/point.rs b/src/point.rs index 80afffb7..183998dd 100644 --- a/src/point.rs +++ b/src/point.rs @@ -3,7 +3,10 @@ use crate::Vector;  /// A 2D point.  #[derive(Debug, Clone, Copy, PartialEq)]  pub struct Point { +    /// The X coordinate.      pub x: f32, + +    /// The Y coordinate.      pub y: f32,  } diff --git a/src/user_interface.rs b/src/user_interface.rs index b269951d..2efd831d 100644 --- a/src/user_interface.rs +++ b/src/user_interface.rs @@ -11,6 +11,7 @@ use stretch::result;  /// charge of using this type in your system in any way you want.  ///  /// [`Layout`]: struct.Layout.html +#[derive(Debug)]  pub struct UserInterface<'a, Message, Renderer> {      hash: u64,      root: Element<'a, Message, Renderer>, @@ -173,11 +174,8 @@ impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> {          let mut messages = Vec::new();          for event in events { -            match event { -                Event::Mouse(mouse::Event::CursorMoved { x, y }) => { -                    self.cursor_position = Point::new(x, y); -                } -                _ => {} +            if let Event::Mouse(mouse::Event::CursorMoved { x, y }) = event { +                self.cursor_position = Point::new(x, y);              }              self.root.widget.on_event( @@ -257,13 +255,11 @@ impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> {      /// }      /// ```      pub fn draw(&self, renderer: &mut Renderer) -> MouseCursor { -        let cursor = self.root.widget.draw( +        self.root.widget.draw(              renderer,              Layout::new(&self.layout),              self.cursor_position, -        ); - -        cursor +        )      }      /// Extract the [`Cache`] of the [`UserInterface`], consuming it in the diff --git a/src/widget/column.rs b/src/widget/column.rs index 83dd2f98..903de897 100644 --- a/src/widget/column.rs +++ b/src/widget/column.rs @@ -10,6 +10,7 @@ use crate::{  /// A [`Column`] will try to fill the horizontal space of its container.  ///  /// [`Column`]: struct.Column.html +#[derive(Default)]  pub struct Column<'a, Message, Renderer> {      style: Style,      spacing: u16, @@ -144,7 +145,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>                  let mut style = node.0.style();                  style.margin.bottom = -                    stretch::style::Dimension::Points(self.spacing as f32); +                    stretch::style::Dimension::Points(f32::from(self.spacing));                  node.0.set_style(style);                  node diff --git a/src/widget/row.rs b/src/widget/row.rs index a4d1be2c..7b7033a1 100644 --- a/src/widget/row.rs +++ b/src/widget/row.rs @@ -10,6 +10,7 @@ use crate::{  /// A [`Row`] will try to fill the horizontal space of its container.  ///  /// [`Row`]: struct.Row.html +#[derive(Default)]  pub struct Row<'a, Message, Renderer> {      style: Style,      spacing: u16, @@ -141,7 +142,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>                  let mut style = node.0.style();                  style.margin.end = -                    stretch::style::Dimension::Points(self.spacing as f32); +                    stretch::style::Dimension::Points(f32::from(self.spacing));                  node.0.set_style(style);                  node diff --git a/src/widget/text.rs b/src/widget/text.rs index c4b7eabb..7b62e5cb 100644 --- a/src/widget/text.rs +++ b/src/widget/text.rs @@ -112,7 +112,7 @@ where      Renderer: self::Renderer<Color>,  {      fn node(&self, renderer: &Renderer) -> Node { -        renderer.node(self.style, &self.content, self.size as f32) +        renderer.node(self.style, &self.content, f32::from(self.size))      }      fn draw( @@ -124,7 +124,7 @@ where          renderer.draw(              layout.bounds(),              &self.content, -            self.size as f32, +            f32::from(self.size),              self.color,              self.horizontal_alignment,              self.vertical_alignment, | 
