mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +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 {
|
impl Default for Bip39Entry {
|
||||||
fn default() -> Self {
|
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 br = items.pane().br();
|
||||||
let row_height = items.row_height();
|
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.pick_word", locales::LANG));
|
||||||
items.add_item(0, t!("bip39.scan_qr_code", locales::LANG));
|
items.add_item(0, t!("bip39.scan_qr_code", locales::LANG));
|
||||||
items.add_item(0, t!("bip39.cancel", locales::LANG));
|
items.add_item(0, t!("bip39.cancel", locales::LANG));
|
||||||
let extra_items = items.col_length(0).unwrap_or(0);
|
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 br = sl.pane().br();
|
||||||
let row_height = sl.row_height();
|
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 {
|
match locales::LANG {
|
||||||
"en" => {
|
"en" => {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,11 @@ pub struct CheckBoxes {
|
||||||
}
|
}
|
||||||
impl CheckBoxes {
|
impl CheckBoxes {
|
||||||
pub fn new(action_conn: xous::CID, action_opcode: u32) -> Self {
|
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 br = sl.pane().br();
|
||||||
let row_height = sl.row_height();
|
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));
|
sl.add_item(0, t!("radio.select_and_close", locales::LANG));
|
||||||
CheckBoxes { items: sl, action_conn, action_opcode, action_payload: CheckBoxPayload::new() }
|
CheckBoxes { items: sl, action_conn, action_opcode, action_payload: CheckBoxPayload::new() }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ pub struct RadioButtons {
|
||||||
}
|
}
|
||||||
impl RadioButtons {
|
impl RadioButtons {
|
||||||
pub fn new(action_conn: xous::CID, action_opcode: u32) -> Self {
|
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 br = sl.pane().br();
|
||||||
let row_height = sl.row_height();
|
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("") }
|
RadioButtons { items: sl, action_conn, action_opcode, action_payload: RadioButtonPayload::new("") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ pub struct ScrollableList {
|
||||||
|
|
||||||
impl Clone for ScrollableList {
|
impl Clone for ScrollableList {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
let mut sl = ScrollableList::default()
|
let mut sl = ScrollableList::default();
|
||||||
.pane_size(self.pane())
|
sl.pane_size(self.pane())
|
||||||
.set_min_col_width(self.min_col_width)
|
.set_min_col_width(self.min_col_width)
|
||||||
.style(self.style)
|
.style(self.style)
|
||||||
.set_with_scrollbars(self.with_scrollbars)
|
.set_with_scrollbars(self.with_scrollbars)
|
||||||
|
|
@ -108,19 +108,19 @@ impl ScrollableList {
|
||||||
|
|
||||||
pub fn get_alignment(&self) -> TextAlignment { self.text_alignment }
|
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.text_alignment = alignment;
|
||||||
self
|
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.pane = RefCell::new(pane);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pane(&self) -> Rectangle { self.pane.borrow().clone() }
|
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.style = style;
|
||||||
self.height_hint = self.gfx.glyph_height_hint(style).unwrap();
|
self.height_hint = self.gfx.glyph_height_hint(style).unwrap();
|
||||||
self
|
self
|
||||||
|
|
@ -180,20 +180,20 @@ impl ScrollableList {
|
||||||
pub fn row_height(&self) -> usize { self.height_hint }
|
pub fn row_height(&self) -> usize { self.height_hint }
|
||||||
|
|
||||||
/// Use this to add space around list items for aesthetic tuning.
|
/// 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.margin = margin;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tunes the desired minimum width of a column.
|
/// 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.min_col_width = width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// When `with_bars` is `true`, scroll bars are rendered when only part
|
/// When `with_bars` is `true`, scroll bars are rendered when only part
|
||||||
/// of the list is visible on the screen.
|
/// 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.with_scrollbars = with_bars;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,14 @@ pub struct TextEntry {
|
||||||
|
|
||||||
impl Default for TextEntry {
|
impl Default for TextEntry {
|
||||||
fn default() -> Self {
|
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 br = sl.pane().br();
|
||||||
let row_height = sl.row_height();
|
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 {
|
match locales::LANG {
|
||||||
"en" => {
|
"en" => {
|
||||||
let osk_matrix = en::OSK_MATRIX;
|
let osk_matrix = en::OSK_MATRIX;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue