Make clippy happy
This commit is contained in:
parent
1cd96d0d61
commit
6fbba6f4ee
@ -1,4 +1,5 @@
|
|||||||
/// The hasher used to compare layouts.
|
/// The hasher used to compare layouts.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Hasher(twox_hash::XxHash64);
|
pub struct Hasher(twox_hash::XxHash64);
|
||||||
|
|
||||||
impl Default for Hasher {
|
impl Default for Hasher {
|
||||||
|
|||||||
@ -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)]
|
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum KeyCode {
|
pub enum KeyCode {
|
||||||
/// The '1' key over the letters.
|
/// The '1' key over the letters.
|
||||||
Key1,
|
Key1,
|
||||||
@ -50,7 +55,7 @@ pub enum KeyCode {
|
|||||||
Y,
|
Y,
|
||||||
Z,
|
Z,
|
||||||
|
|
||||||
/// The Escape key, next to F1.
|
/// The Escape key, next to F1
|
||||||
Escape,
|
Escape,
|
||||||
|
|
||||||
F1,
|
F1,
|
||||||
@ -78,14 +83,14 @@ pub enum KeyCode {
|
|||||||
F23,
|
F23,
|
||||||
F24,
|
F24,
|
||||||
|
|
||||||
/// Print Screen/SysRq.
|
/// Print Screen/SysRq
|
||||||
Snapshot,
|
Snapshot,
|
||||||
/// Scroll Lock.
|
/// Scroll Lock
|
||||||
Scroll,
|
Scroll,
|
||||||
/// Pause/Break key, next to Scroll lock.
|
/// Pause/Break key, next to Scroll lock
|
||||||
Pause,
|
Pause,
|
||||||
|
|
||||||
/// `Insert`, next to Backspace.
|
/// `Insert`, next to Backspace
|
||||||
Insert,
|
Insert,
|
||||||
Home,
|
Home,
|
||||||
Delete,
|
Delete,
|
||||||
@ -98,15 +103,11 @@ pub enum KeyCode {
|
|||||||
Right,
|
Right,
|
||||||
Down,
|
Down,
|
||||||
|
|
||||||
/// The Backspace key, right over Enter.
|
Backspace,
|
||||||
// TODO: rename
|
Enter,
|
||||||
Back,
|
|
||||||
/// The Enter key.
|
|
||||||
Return,
|
|
||||||
/// The space bar.
|
|
||||||
Space,
|
Space,
|
||||||
|
|
||||||
/// The "Compose" key on Linux.
|
/// The "Compose" key on Linux
|
||||||
Compose,
|
Compose,
|
||||||
|
|
||||||
Caret,
|
Caret,
|
||||||
|
|||||||
@ -191,8 +191,8 @@
|
|||||||
//! [documentation]: https://docs.rs/iced
|
//! [documentation]: https://docs.rs/iced
|
||||||
//! [examples]: https://github.com/hecrj/iced/tree/master/examples
|
//! [examples]: https://github.com/hecrj/iced/tree/master/examples
|
||||||
//! [`UserInterface`]: struct.UserInterface.html
|
//! [`UserInterface`]: struct.UserInterface.html
|
||||||
//#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
//#![deny(missing_debug_implementations)]
|
#![deny(missing_debug_implementations)]
|
||||||
#![deny(unused_results)]
|
#![deny(unused_results)]
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![deny(rust_2018_idioms)]
|
#![deny(rust_2018_idioms)]
|
||||||
|
|||||||
@ -3,7 +3,10 @@ use crate::Vector;
|
|||||||
/// A 2D point.
|
/// A 2D point.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
|
/// The X coordinate.
|
||||||
pub x: f32,
|
pub x: f32,
|
||||||
|
|
||||||
|
/// The Y coordinate.
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use stretch::result;
|
|||||||
/// charge of using this type in your system in any way you want.
|
/// charge of using this type in your system in any way you want.
|
||||||
///
|
///
|
||||||
/// [`Layout`]: struct.Layout.html
|
/// [`Layout`]: struct.Layout.html
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct UserInterface<'a, Message, Renderer> {
|
pub struct UserInterface<'a, Message, Renderer> {
|
||||||
hash: u64,
|
hash: u64,
|
||||||
root: Element<'a, Message, Renderer>,
|
root: Element<'a, Message, Renderer>,
|
||||||
@ -173,11 +174,8 @@ impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> {
|
|||||||
let mut messages = Vec::new();
|
let mut messages = Vec::new();
|
||||||
|
|
||||||
for event in events {
|
for event in events {
|
||||||
match event {
|
if let Event::Mouse(mouse::Event::CursorMoved { x, y }) = event {
|
||||||
Event::Mouse(mouse::Event::CursorMoved { x, y }) => {
|
self.cursor_position = Point::new(x, y);
|
||||||
self.cursor_position = Point::new(x, y);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.root.widget.on_event(
|
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 {
|
pub fn draw(&self, renderer: &mut Renderer) -> MouseCursor {
|
||||||
let cursor = self.root.widget.draw(
|
self.root.widget.draw(
|
||||||
renderer,
|
renderer,
|
||||||
Layout::new(&self.layout),
|
Layout::new(&self.layout),
|
||||||
self.cursor_position,
|
self.cursor_position,
|
||||||
);
|
)
|
||||||
|
|
||||||
cursor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the [`Cache`] of the [`UserInterface`], consuming it in the
|
/// Extract the [`Cache`] of the [`UserInterface`], consuming it in the
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use crate::{
|
|||||||
/// A [`Column`] will try to fill the horizontal space of its container.
|
/// A [`Column`] will try to fill the horizontal space of its container.
|
||||||
///
|
///
|
||||||
/// [`Column`]: struct.Column.html
|
/// [`Column`]: struct.Column.html
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Column<'a, Message, Renderer> {
|
pub struct Column<'a, Message, Renderer> {
|
||||||
style: Style,
|
style: Style,
|
||||||
spacing: u16,
|
spacing: u16,
|
||||||
@ -144,7 +145,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
|
|||||||
|
|
||||||
let mut style = node.0.style();
|
let mut style = node.0.style();
|
||||||
style.margin.bottom =
|
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.0.set_style(style);
|
||||||
node
|
node
|
||||||
|
|||||||
@ -10,6 +10,7 @@ use crate::{
|
|||||||
/// A [`Row`] will try to fill the horizontal space of its container.
|
/// A [`Row`] will try to fill the horizontal space of its container.
|
||||||
///
|
///
|
||||||
/// [`Row`]: struct.Row.html
|
/// [`Row`]: struct.Row.html
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Row<'a, Message, Renderer> {
|
pub struct Row<'a, Message, Renderer> {
|
||||||
style: Style,
|
style: Style,
|
||||||
spacing: u16,
|
spacing: u16,
|
||||||
@ -141,7 +142,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
|
|||||||
|
|
||||||
let mut style = node.0.style();
|
let mut style = node.0.style();
|
||||||
style.margin.end =
|
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.0.set_style(style);
|
||||||
node
|
node
|
||||||
|
|||||||
@ -112,7 +112,7 @@ where
|
|||||||
Renderer: self::Renderer<Color>,
|
Renderer: self::Renderer<Color>,
|
||||||
{
|
{
|
||||||
fn node(&self, renderer: &Renderer) -> Node {
|
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(
|
fn draw(
|
||||||
@ -124,7 +124,7 @@ where
|
|||||||
renderer.draw(
|
renderer.draw(
|
||||||
layout.bounds(),
|
layout.bounds(),
|
||||||
&self.content,
|
&self.content,
|
||||||
self.size as f32,
|
f32::from(self.size),
|
||||||
self.color,
|
self.color,
|
||||||
self.horizontal_alignment,
|
self.horizontal_alignment,
|
||||||
self.vertical_alignment,
|
self.vertical_alignment,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user