parent
3c49ef2f62
commit
4d60c10330
@ -1,3 +1,4 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
|
#[cfg(feature = "ui")]
|
||||||
pub mod display;
|
pub mod display;
|
||||||
pub mod random;
|
pub mod random;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
mod base;
|
mod base;
|
||||||
pub mod model_t1;
|
pub mod empty;
|
||||||
pub mod model_tt;
|
pub mod label;
|
||||||
|
pub mod text;
|
||||||
|
|
||||||
pub use base::{Child, Component, Event, EventCtx, Never, TimerToken};
|
pub use base::{Child, Component, Event, EventCtx, Never, TimerToken};
|
||||||
|
pub use empty::Empty;
|
||||||
|
pub use label::{Label, LabelStyle};
|
||||||
|
pub use text::{LineBreaking, PageBreaking, Text, TextLayout};
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
pub mod constants;
|
||||||
|
pub mod theme;
|
||||||
|
|
||||||
|
@ -1,2 +1 @@
|
|||||||
mod example;
|
pub mod obj;
|
||||||
mod obj;
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
pub const WIDTH: i32 = 128;
|
||||||
|
pub const HEIGHT: i32 = 64;
|
||||||
|
pub const TEXT_HEIGHT: i32 = 8;
|
||||||
|
pub const LINE_HEIGHT: i32 = 9;
|
@ -0,0 +1,29 @@
|
|||||||
|
use crate::error;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
pub enum T1Button {
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
pub enum ButtonEvent {
|
||||||
|
ButtonPressed(T1Button),
|
||||||
|
ButtonReleased(T1Button),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ButtonEvent {
|
||||||
|
pub fn new(event: u32, button: u32, _unused: u32) -> Result<Self, error::Error> {
|
||||||
|
let button = match button {
|
||||||
|
0 => T1Button::Left,
|
||||||
|
1 => T1Button::Right,
|
||||||
|
_ => return Err(error::Error::OutOfRange),
|
||||||
|
};
|
||||||
|
let result = match event {
|
||||||
|
1 => Self::ButtonPressed(button),
|
||||||
|
2 => Self::ButtonReleased(button),
|
||||||
|
_ => return Err(error::Error::OutOfRange),
|
||||||
|
};
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
pub mod constant;
|
||||||
|
pub mod event;
|
||||||
|
pub mod theme;
|
@ -0,0 +1,61 @@
|
|||||||
|
use crate::ui::display::{Color, Font};
|
||||||
|
|
||||||
|
use super::component::{ButtonStyle, ButtonStyleSheet};
|
||||||
|
|
||||||
|
// Font constants.
|
||||||
|
pub const FONT_NORMAL: Font = Font::new(-1);
|
||||||
|
pub const FONT_BOLD: Font = Font::new(-2);
|
||||||
|
pub const FONT_MONO: Font = Font::new(-3);
|
||||||
|
|
||||||
|
// Color palette.
|
||||||
|
pub const WHITE: Color = Color::rgb(255, 255, 255);
|
||||||
|
pub const BLACK: Color = Color::rgb(0, 0, 0);
|
||||||
|
pub const GREY_LIGHT: Color = WHITE; // Word/page break characters.
|
||||||
|
pub const FG: Color = WHITE; // Default foreground (text & icon) color.
|
||||||
|
pub const BG: Color = BLACK; // Default background color.
|
||||||
|
|
||||||
|
pub fn button_default() -> ButtonStyleSheet {
|
||||||
|
ButtonStyleSheet {
|
||||||
|
normal: &ButtonStyle {
|
||||||
|
font: FONT_BOLD,
|
||||||
|
text_color: BG,
|
||||||
|
background_color: FG,
|
||||||
|
border_horiz: true,
|
||||||
|
},
|
||||||
|
active: &ButtonStyle {
|
||||||
|
font: FONT_BOLD,
|
||||||
|
text_color: FG,
|
||||||
|
background_color: BG,
|
||||||
|
border_horiz: true,
|
||||||
|
},
|
||||||
|
disabled: &ButtonStyle {
|
||||||
|
font: FONT_BOLD,
|
||||||
|
text_color: FG,
|
||||||
|
background_color: BG,
|
||||||
|
border_horiz: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn button_cancel() -> ButtonStyleSheet {
|
||||||
|
ButtonStyleSheet {
|
||||||
|
normal: &ButtonStyle {
|
||||||
|
font: FONT_BOLD,
|
||||||
|
text_color: FG,
|
||||||
|
background_color: BG,
|
||||||
|
border_horiz: false,
|
||||||
|
},
|
||||||
|
active: &ButtonStyle {
|
||||||
|
font: FONT_BOLD,
|
||||||
|
text_color: BG,
|
||||||
|
background_color: FG,
|
||||||
|
border_horiz: false,
|
||||||
|
},
|
||||||
|
disabled: &ButtonStyle {
|
||||||
|
font: FONT_BOLD,
|
||||||
|
text_color: BG,
|
||||||
|
background_color: FG,
|
||||||
|
border_horiz: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,13 @@
|
|||||||
mod button;
|
mod button;
|
||||||
mod dialog;
|
mod dialog;
|
||||||
mod empty;
|
|
||||||
mod label;
|
|
||||||
mod page;
|
mod page;
|
||||||
mod passphrase;
|
mod passphrase;
|
||||||
mod pin;
|
mod pin;
|
||||||
mod swipe;
|
mod swipe;
|
||||||
pub mod text;
|
|
||||||
pub mod theme;
|
|
||||||
|
|
||||||
pub use button::{Button, ButtonContent, ButtonMsg, ButtonStyle, ButtonStyleSheet};
|
pub use button::{Button, ButtonContent, ButtonMsg, ButtonStyle, ButtonStyleSheet};
|
||||||
pub use dialog::{Dialog, DialogMsg};
|
pub use dialog::{Dialog, DialogMsg};
|
||||||
pub use empty::Empty;
|
|
||||||
pub use label::{Label, LabelStyle};
|
|
||||||
pub use swipe::{Swipe, SwipeDirection};
|
pub use swipe::{Swipe, SwipeDirection};
|
||||||
pub use text::{LineBreaking, PageBreaking, Text, TextLayout};
|
|
||||||
|
use super::event;
|
||||||
|
use super::theme;
|
@ -0,0 +1,4 @@
|
|||||||
|
pub const WIDTH: i32 = 240;
|
||||||
|
pub const HEIGHT: i32 = 240;
|
||||||
|
pub const TEXT_HEIGHT: i32 = 16;
|
||||||
|
pub const LINE_HEIGHT: i32 = 26;
|
@ -0,0 +1,24 @@
|
|||||||
|
use core::convert::TryInto;
|
||||||
|
|
||||||
|
use crate::{error, ui::geometry::Point};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
pub enum TouchEvent {
|
||||||
|
TouchStart(Point),
|
||||||
|
TouchMove(Point),
|
||||||
|
TouchEnd(Point),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TouchEvent {
|
||||||
|
pub fn new(event: u32, x: u32, y: u32) -> Result<Self, error::Error> {
|
||||||
|
let point = Point::new(x.try_into()?, y.try_into()?);
|
||||||
|
let result = match event {
|
||||||
|
1 => Self::TouchStart(point),
|
||||||
|
2 => Self::TouchMove(point),
|
||||||
|
4 => Self::TouchEnd(point),
|
||||||
|
_ => return Err(error::Error::OutOfRange),
|
||||||
|
};
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
pub mod component;
|
||||||
|
pub mod constant;
|
||||||
|
pub mod event;
|
||||||
|
pub mod layout;
|
||||||
|
pub mod theme;
|
@ -1,8 +1,10 @@
|
|||||||
use crate::ui::{
|
use crate::ui::{
|
||||||
component::model_tt::{ButtonStyle, ButtonStyleSheet, LabelStyle},
|
component::{label::LabelStyle, text::DefaultTextTheme},
|
||||||
display::{Color, Font},
|
display::{Color, Font},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::component::{ButtonStyle, ButtonStyleSheet};
|
||||||
|
|
||||||
// Font constants.
|
// Font constants.
|
||||||
pub const FONT_NORMAL: Font = Font::new(-1);
|
pub const FONT_NORMAL: Font = Font::new(-1);
|
||||||
pub const FONT_BOLD: Font = Font::new(-2);
|
pub const FONT_BOLD: Font = Font::new(-2);
|
Loading…
Reference in new issue