From bb9ccc4f62ceea08dc1ef0c6c4d3d219897e44a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 30 Apr 2020 05:04:45 +0200 Subject: [PATCH] Remove inconsistent `input` module in `iced_native` --- native/src/event.rs | 5 +---- native/src/input.rs | 3 --- native/src/{input => }/keyboard.rs | 0 native/src/lib.rs | 3 ++- native/src/{input => }/mouse.rs | 0 native/src/{input => }/mouse/click.rs | 0 native/src/user_interface.rs | 4 +--- native/src/widget/button.rs | 4 ++-- native/src/widget/checkbox.rs | 2 +- native/src/widget/pane_grid.rs | 5 ++--- native/src/widget/pane_grid/state.rs | 2 +- native/src/widget/radio.rs | 2 +- native/src/widget/scrollable.rs | 4 ++-- native/src/widget/slider.rs | 4 ++-- native/src/widget/text_input.rs | 12 +++++------- src/keyboard.rs | 6 +----- src/mouse.rs | 3 +-- web/src/lib.rs | 4 ++-- wgpu/src/widget/canvas/event.rs | 2 +- winit/src/conversion.rs | 7 ++----- 20 files changed, 27 insertions(+), 45 deletions(-) delete mode 100644 native/src/input.rs rename native/src/{input => }/keyboard.rs (100%) rename native/src/{input => }/mouse.rs (100%) rename native/src/{input => }/mouse/click.rs (100%) diff --git a/native/src/event.rs b/native/src/event.rs index b2550ead..606a71d6 100644 --- a/native/src/event.rs +++ b/native/src/event.rs @@ -1,7 +1,4 @@ -use crate::{ - input::{keyboard, mouse}, - window, -}; +use crate::{keyboard, mouse, window}; /// A user interface event. /// diff --git a/native/src/input.rs b/native/src/input.rs deleted file mode 100644 index ad8ed252..00000000 --- a/native/src/input.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Map your system events into input events that the runtime can understand. -pub mod keyboard; -pub mod mouse; diff --git a/native/src/input/keyboard.rs b/native/src/keyboard.rs similarity index 100% rename from native/src/input/keyboard.rs rename to native/src/keyboard.rs diff --git a/native/src/lib.rs b/native/src/lib.rs index a3b581b3..88bf4423 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -39,8 +39,9 @@ #![deny(unused_results)] #![forbid(unsafe_code)] #![forbid(rust_2018_idioms)] -pub mod input; +pub mod keyboard; pub mod layout; +pub mod mouse; pub mod renderer; pub mod subscription; pub mod widget; diff --git a/native/src/input/mouse.rs b/native/src/mouse.rs similarity index 100% rename from native/src/input/mouse.rs rename to native/src/mouse.rs diff --git a/native/src/input/mouse/click.rs b/native/src/mouse/click.rs similarity index 100% rename from native/src/input/mouse/click.rs rename to native/src/mouse/click.rs diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index 5d9221e9..48cd6111 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -1,6 +1,4 @@ -use crate::{ - input::mouse, layout, Clipboard, Element, Event, Layout, Point, Size, -}; +use crate::{layout, mouse, Clipboard, Element, Event, Layout, Point, Size}; use std::hash::Hasher; diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index 5d414023..c932da2b 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -5,8 +5,8 @@ //! [`Button`]: struct.Button.html //! [`State`]: struct.State.html use crate::{ - input::mouse, layout, Clipboard, Element, Event, Hasher, Layout, Length, - Point, Rectangle, Widget, + layout, mouse, Clipboard, Element, Event, Hasher, Layout, Length, Point, + Rectangle, Widget, }; use std::hash::Hash; diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index c49ac707..5fb13290 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -2,7 +2,7 @@ use std::hash::Hash; use crate::{ - input::mouse, layout, row, text, Align, Clipboard, Element, Event, Hasher, + layout, mouse, row, text, Align, Clipboard, Element, Event, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index fe2bbe07..c398a30b 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -22,9 +22,8 @@ pub use split::Split; pub use state::{Focus, State}; use crate::{ - input::{keyboard, mouse}, - layout, Clipboard, Element, Event, Hasher, Layout, Length, Point, Size, - Widget, + keyboard, layout, mouse, Clipboard, Element, Event, Hasher, Layout, Length, + Point, Size, Widget, }; /// A collection of panes distributed using either vertical or horizontal splits diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs index 0a8b8419..ed2813b8 100644 --- a/native/src/widget/pane_grid/state.rs +++ b/native/src/widget/pane_grid/state.rs @@ -1,5 +1,5 @@ use crate::{ - input::keyboard, + keyboard, pane_grid::{node::Node, Axis, Direction, Pane, Split}, Hasher, Point, Rectangle, Size, }; diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index deea7034..ab5bcf32 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -1,6 +1,6 @@ //! Create choices using radio buttons. use crate::{ - input::mouse, layout, row, text, Align, Clipboard, Element, Event, Hasher, + layout, mouse, row, text, Align, Clipboard, Element, Event, Hasher, HorizontalAlignment, Layout, Length, Point, Rectangle, Row, Text, VerticalAlignment, Widget, }; diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index da11c50c..3c8e5e5b 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -1,7 +1,7 @@ //! Navigate an endless amount of content with a scrollbar. use crate::{ - column, input::mouse, layout, Align, Clipboard, Column, Element, Event, - Hasher, Layout, Length, Point, Rectangle, Size, Widget, + column, layout, mouse, Align, Clipboard, Column, Element, Event, Hasher, + Layout, Length, Point, Rectangle, Size, Widget, }; use std::{f32, hash::Hash, u32}; diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index a00d7c8d..8cdfc3de 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -5,8 +5,8 @@ //! [`Slider`]: struct.Slider.html //! [`State`]: struct.State.html use crate::{ - input::mouse, layout, Clipboard, Element, Event, Hasher, Layout, Length, - Point, Rectangle, Size, Widget, + layout, mouse, Clipboard, Element, Event, Hasher, Layout, Length, Point, + Rectangle, Size, Widget, }; use std::{hash::Hash, ops::RangeInclusive}; diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index b11269db..1cdbe007 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -15,12 +15,10 @@ pub use value::Value; use editor::Editor; use crate::{ - input::{ - keyboard, - mouse::{self, click}, - }, - layout, Clipboard, Element, Event, Font, Hasher, Layout, Length, Point, - Rectangle, Size, Widget, + keyboard, layout, + mouse::{self, click}, + Clipboard, Element, Event, Font, Hasher, Layout, Length, Point, Rectangle, + Size, Widget, }; use std::u32; @@ -739,7 +737,7 @@ fn find_cursor_position( } mod platform { - use crate::input::keyboard; + use crate::keyboard; pub fn is_jump_modifier_pressed( modifiers: keyboard::ModifiersState, diff --git a/src/keyboard.rs b/src/keyboard.rs index 181dd974..0b3e894d 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -1,6 +1,2 @@ //! Listen and react to keyboard events. -#[cfg(not(target_arch = "wasm32"))] -pub use iced_winit::input::keyboard::{KeyCode, ModifiersState}; - -#[cfg(target_arch = "wasm32")] -pub use iced_web::keyboard::{KeyCode, ModifiersState}; +pub use crate::runtime::keyboard::{Event, KeyCode, ModifiersState}; diff --git a/src/mouse.rs b/src/mouse.rs index 8be36d37..c511399b 100644 --- a/src/mouse.rs +++ b/src/mouse.rs @@ -1,3 +1,2 @@ //! Listen and react to mouse events. -#[cfg(not(target_arch = "wasm32"))] -pub use iced_winit::input::mouse::{Button, Event, ScrollDelta}; +pub use crate::runtime::mouse::{Button, Event, ScrollDelta}; diff --git a/web/src/lib.rs b/web/src/lib.rs index c525021f..3fe98dfb 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -74,8 +74,8 @@ pub use dodrio; pub use element::Element; pub use hasher::Hasher; pub use iced_core::{ - keyboard, Align, Background, Color, Font, HorizontalAlignment, Length, - MouseCursor, Point, Rectangle, Size, Vector, VerticalAlignment, + keyboard, mouse, Align, Background, Color, Font, HorizontalAlignment, + Length, MouseCursor, Point, Rectangle, Size, Vector, VerticalAlignment, }; pub use iced_futures::{executor, futures, Command}; pub use subscription::Subscription; diff --git a/wgpu/src/widget/canvas/event.rs b/wgpu/src/widget/canvas/event.rs index 7a8b0829..4e7c1869 100644 --- a/wgpu/src/widget/canvas/event.rs +++ b/wgpu/src/widget/canvas/event.rs @@ -1,4 +1,4 @@ -use iced_native::input::mouse; +use iced_native::mouse; #[derive(Debug, Clone, Copy, PartialEq)] pub enum Event { diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 8b98e254..93827e37 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -3,11 +3,8 @@ //! [`winit`]: https://github.com/rust-windowing/winit //! [`iced_native`]: https://github.com/hecrj/iced/tree/master/native use crate::{ - input::{ - keyboard::{self, KeyCode, ModifiersState}, - mouse, - }, - window, Event, Mode, MouseCursor, + keyboard::{self, KeyCode, ModifiersState}, + mouse, window, Event, Mode, MouseCursor, }; /// Converts a winit window event into an iced event.