mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
update ui to use builder pattern
This commit is contained in:
parent
fe68753779
commit
c168c7d720
5 changed files with 27 additions and 20 deletions
|
|
@ -69,22 +69,25 @@ pub struct Bip39Entry {
|
|||
|
||||
impl Default for Bip39Entry {
|
||||
fn default() -> Self {
|
||||
let mut items = ScrollableList::default().set_margin(Point::new(4, 0));
|
||||
let mut items = ScrollableList::default();
|
||||
items.set_margin(Point::new(4, 0));
|
||||
let br = items.pane().br();
|
||||
let row_height = items.row_height();
|
||||
items = items.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
items.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
|
||||
items.add_item(0, t!("bip39.pick_word", locales::LANG));
|
||||
items.add_item(0, t!("bip39.scan_qr_code", locales::LANG));
|
||||
items.add_item(0, t!("bip39.cancel", locales::LANG));
|
||||
let extra_items = items.col_length(0).unwrap_or(0);
|
||||
|
||||
let mut sl = ScrollableList::default().set_margin(Point::new(10, 0));
|
||||
let mut sl = ScrollableList::default();
|
||||
sl.set_margin(Point::new(10, 0));
|
||||
let br = sl.pane().br();
|
||||
let row_height = sl.row_height();
|
||||
sl = sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
|
||||
let mut osk = ScrollableList::default().set_alignment(TextAlignment::Center);
|
||||
let mut osk = ScrollableList::default();
|
||||
osk.set_alignment(TextAlignment::Center);
|
||||
match locales::LANG {
|
||||
"en" => {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ pub struct CheckBoxes {
|
|||
}
|
||||
impl CheckBoxes {
|
||||
pub fn new(action_conn: xous::CID, action_opcode: u32) -> Self {
|
||||
let mut sl = ScrollableList::default().set_margin(Point::new(2, 0));
|
||||
let mut sl = ScrollableList::default();
|
||||
sl.set_margin(Point::new(2, 0));
|
||||
let br = sl.pane().br();
|
||||
let row_height = sl.row_height();
|
||||
sl = sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
sl.add_item(0, t!("radio.select_and_close", locales::LANG));
|
||||
CheckBoxes { items: sl, action_conn, action_opcode, action_payload: CheckBoxPayload::new() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ pub struct RadioButtons {
|
|||
}
|
||||
impl RadioButtons {
|
||||
pub fn new(action_conn: xous::CID, action_opcode: u32) -> Self {
|
||||
let mut sl = ScrollableList::default().set_margin(Point::new(12, 0));
|
||||
let mut sl = ScrollableList::default();
|
||||
sl.set_margin(Point::new(12, 0));
|
||||
let br = sl.pane().br();
|
||||
let row_height = sl.row_height();
|
||||
sl = sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
RadioButtons { items: sl, action_conn, action_opcode, action_payload: RadioButtonPayload::new("") }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ pub struct ScrollableList {
|
|||
|
||||
impl Clone for ScrollableList {
|
||||
fn clone(&self) -> Self {
|
||||
let mut sl = ScrollableList::default()
|
||||
.pane_size(self.pane())
|
||||
let mut sl = ScrollableList::default();
|
||||
sl.pane_size(self.pane())
|
||||
.set_min_col_width(self.min_col_width)
|
||||
.style(self.style)
|
||||
.set_with_scrollbars(self.with_scrollbars)
|
||||
|
|
@ -108,19 +108,19 @@ impl ScrollableList {
|
|||
|
||||
pub fn get_alignment(&self) -> TextAlignment { self.text_alignment }
|
||||
|
||||
pub fn set_alignment(mut self, alignment: TextAlignment) -> Self {
|
||||
pub fn set_alignment<'a>(&'a mut self, alignment: TextAlignment) -> &'a mut Self {
|
||||
self.text_alignment = alignment;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pane_size(mut self, pane: Rectangle) -> Self {
|
||||
pub fn pane_size<'a>(&'a mut self, pane: Rectangle) -> &'a mut Self {
|
||||
self.pane = RefCell::new(pane);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pane(&self) -> Rectangle { self.pane.borrow().clone() }
|
||||
|
||||
pub fn style(mut self, style: GlyphStyle) -> Self {
|
||||
pub fn style<'a>(&'a mut self, style: GlyphStyle) -> &'a mut Self {
|
||||
self.style = style;
|
||||
self.height_hint = self.gfx.glyph_height_hint(style).unwrap();
|
||||
self
|
||||
|
|
@ -180,20 +180,20 @@ impl ScrollableList {
|
|||
pub fn row_height(&self) -> usize { self.height_hint }
|
||||
|
||||
/// Use this to add space around list items for aesthetic tuning.
|
||||
pub fn set_margin(mut self, margin: Point) -> Self {
|
||||
pub fn set_margin<'a>(&'a mut self, margin: Point) -> &'a mut Self {
|
||||
self.margin = margin;
|
||||
self
|
||||
}
|
||||
|
||||
/// Tunes the desired minimum width of a column.
|
||||
pub fn set_min_col_width(mut self, width: usize) -> Self {
|
||||
pub fn set_min_col_width<'a>(&'a mut self, width: usize) -> &'a mut Self {
|
||||
self.min_col_width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// When `with_bars` is `true`, scroll bars are rendered when only part
|
||||
/// of the list is visible on the screen.
|
||||
pub fn set_with_scrollbars(mut self, with_bars: bool) -> Self {
|
||||
pub fn set_with_scrollbars<'a>(&'a mut self, with_bars: bool) -> &'a mut Self {
|
||||
self.with_scrollbars = with_bars;
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,14 @@ pub struct TextEntry {
|
|||
|
||||
impl Default for TextEntry {
|
||||
fn default() -> Self {
|
||||
let mut sl = ScrollableList::default().set_margin(Point::new(4, 0));
|
||||
let mut sl = ScrollableList::default();
|
||||
sl.set_margin(Point::new(4, 0));
|
||||
let br = sl.pane().br();
|
||||
let row_height = sl.row_height();
|
||||
sl = sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
sl.pane_size(Rectangle::new(Point::new(0, row_height as isize + 2), br));
|
||||
|
||||
let mut osk = ScrollableList::default().set_alignment(TextAlignment::Center);
|
||||
let mut osk = ScrollableList::default();
|
||||
osk.set_alignment(TextAlignment::Center);
|
||||
match locales::LANG {
|
||||
"en" => {
|
||||
let osk_matrix = en::OSK_MATRIX;
|
||||
|
|
|
|||
Loading…
Reference in a new issue