1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! `no_std` on-screen keyboard and text field widgets for `embedded-graphics`,
//! driven by navigation buttons and/or a touch screen.
//!
//! - [`Keyboard`]: QWERTY by default, or any [`Layout`]. Every letter key has the
//! same size; the bottom action row spans the full width.
//! - [`TextField`]: single-line input with an optional title and a configurable
//! [`FrameStyle`].
//!
//! Keys are styled by a [`KeyboardTheme`]: one [`KeyStyle`] (frame and font)
//! per state. Text goes through the [`FontStyle`] trait, implemented for `MonoTextStyle`
//! and, with the `glyphix` feature, for `GlyphixStyle`.
//!
//! # Example
//!
//! ```
//! use embedded_graphics::{
//! mono_font::{ascii::FONT_10X20, MonoTextStyle},
//! pixelcolor::Rgb565,
//! prelude::*,
//! primitives::Rectangle,
//! };
//! use embedded_graphics_keyboard::{
//! FrameStyle, KeyEvent, KeyStyle, Keyboard, KeyboardConfig, KeyboardTheme, NavButton,
//! TextField, TextFieldStyle,
//! };
//!
//! fn run<D: DrawTarget<Color = Rgb565>>(display: &mut D) -> Result<(), D::Error> {
//! let white_text = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
//! let black_text = MonoTextStyle::new(&FONT_10X20, Rgb565::BLACK);
//!
//! // One style per key state, the others derived from the idle one.
//! let idle = KeyStyle::new(white_text)
//! .with_fill(Rgb565::CSS_DARK_SLATE_GRAY)
//! .with_border(Rgb565::CSS_GRAY, 1)
//! .with_corner_radius(8);
//! let theme = KeyboardTheme {
//! idle,
//! selected: idle.with_fill(Rgb565::CSS_DODGER_BLUE).with_font(black_text),
//! pressed: idle.with_fill(Rgb565::WHITE).with_font(black_text),
//! };
//!
//! let area = Rectangle::new(Point::new(4, 76), Size::new(472, 240));
//! let mut keyboard = Keyboard::new(KeyboardConfig::new(area, theme))
//! .expect("every label fits inside its key");
//!
//! // Text field with a title, aligned on the keys.
//! let field_style = TextFieldStyle::new(white_text, white_text).with_frame(
//! FrameStyle::new()
//! .with_fill(Rgb565::BLACK)
//! .with_border(Rgb565::YELLOW, 2)
//! .with_corner_radius(8),
//! );
//! let keys = keyboard.keys_bounds();
//! let field_bounds = Rectangle::new(
//! Point::new(keys.top_left.x, 4),
//! Size::new(keys.size.width, field_style.height(true)),
//! );
//!
//! let mut text = String::new();
//! // In your event loop: feed button presses or touches...
//! if let Some(event) = keyboard.handle_button(NavButton::Validate) {
//! match event {
//! KeyEvent::Char(c) => text.push(c),
//! KeyEvent::Backspace => drop(text.pop()),
//! KeyEvent::Enter => { /* submit */ }
//! KeyEvent::Back => { /* cancel */ }
//! }
//! }
//! keyboard.release();
//!
//! // ...then draw.
//! TextField::new(field_bounds, &text, &field_style)
//! .with_title("Wi-Fi password")
//! .draw(display)?;
//! // Only the keys that changed since the last call are sent to the display.
//! keyboard.redraw(display, Rgb565::BLACK)
//! }
//! # fn main() {
//! # let mut display = embedded_graphics_simulator::SimulatorDisplay::<Rgb565>::new(Size::new(480, 320));
//! # run(&mut display).unwrap();
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;