Move common keyboard types to iced_core

Also expose them in `iced` through `iced_native` and `iced_web`.
This commit is contained in:
Héctor Ramón Jiménez 2020-03-17 07:28:28 +01:00
parent 1cd1582506
commit 05beb87852
10 changed files with 20 additions and 10 deletions

6
core/src/keyboard.rs Normal file
View File

@ -0,0 +1,6 @@
//! Reuse basic keyboard types.
mod key_code;
mod modifiers_state;
pub use key_code::KeyCode;
pub use modifiers_state::ModifiersState;

View File

@ -14,6 +14,7 @@
#![deny(unused_results)]
#![forbid(unsafe_code)]
#![forbid(rust_2018_idioms)]
pub mod keyboard;
mod align;
mod background;

View File

@ -7,4 +7,3 @@ publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }

View File

@ -1,8 +1,8 @@
use iced::{
button, pane_grid, scrollable, Align, Button, Column, Container, Element,
HorizontalAlignment, Length, PaneGrid, Sandbox, Scrollable, Settings, Text,
button, keyboard, pane_grid, scrollable, Align, Button, Column, Container,
Element, HorizontalAlignment, Length, PaneGrid, Sandbox, Scrollable,
Settings, Text,
};
use iced_native::input::keyboard;
pub fn main() {
Example::run(Settings::default())

View File

@ -1,8 +1,5 @@
//! Build keyboard events.
mod event;
mod key_code;
mod modifiers_state;
pub use event::Event;
pub use key_code::KeyCode;
pub use modifiers_state::ModifiersState;
pub use iced_core::keyboard::{KeyCode, ModifiersState};

6
src/keyboard.rs Normal file
View File

@ -0,0 +1,6 @@
//! 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};

View File

@ -183,6 +183,7 @@ mod element;
mod sandbox;
pub mod executor;
pub mod keyboard;
pub mod settings;
pub mod widget;
pub mod window;

View File

@ -73,8 +73,8 @@ pub use dodrio;
pub use element::Element;
pub use hasher::Hasher;
pub use iced_core::{
Align, Background, Color, Font, HorizontalAlignment, Length, Point, Size,
Vector, VerticalAlignment,
keyboard, Align, Background, Color, Font, HorizontalAlignment, Length,
Point, Size, Vector, VerticalAlignment,
};
pub use iced_futures::{executor, futures, Command};
pub use subscription::Subscription;