mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix font setting
This commit is contained in:
parent
304c865bb3
commit
57f9e1a5f9
2 changed files with 35 additions and 38 deletions
|
|
@ -215,6 +215,7 @@ fn main() -> ! {
|
||||||
Message::new_blocking_scalar(ActionOp::UpdateMode.to_usize().unwrap(), 0, 0, 0, 0)
|
Message::new_blocking_scalar(ActionOp::UpdateMode.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
).ok();
|
).ok();
|
||||||
vaultux.update_mode();
|
vaultux.update_mode();
|
||||||
|
vaultux.get_glyph_style();
|
||||||
|
|
||||||
let mut allow_redraw = false;
|
let mut allow_redraw = false;
|
||||||
let modals = modals::Modals::new(&xns).unwrap();
|
let modals = modals::Modals::new(&xns).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -154,37 +154,8 @@ impl VaultUx {
|
||||||
let pddb = pddb::Pddb::new();
|
let pddb = pddb::Pddb::new();
|
||||||
// TODO: put some informative message asking to mount the PDDB if it's not mounted, right now you just get a blank screen.
|
// TODO: put some informative message asking to mount the PDDB if it's not mounted, right now you just get a blank screen.
|
||||||
pddb.is_mounted_blocking();
|
pddb.is_mounted_blocking();
|
||||||
// extract the style name from the settings, or update them if never initialized
|
// temporary style setting, this will get over-ridden after init
|
||||||
let mut style_name_bytes = [0u8; 32];
|
let style = GlyphStyle::Regular;
|
||||||
let style_name = match pddb.get(
|
|
||||||
VAULT_CONFIG_DICT,
|
|
||||||
VAULT_CONFIG_KEY_FONT,
|
|
||||||
None, true, true,
|
|
||||||
Some(32), Some(crate::basis_change)
|
|
||||||
) {
|
|
||||||
Ok(mut style_key) => {
|
|
||||||
style_key.read(&mut style_name_bytes).ok();
|
|
||||||
String::from_utf8_lossy(&style_name_bytes)
|
|
||||||
}
|
|
||||||
_ => panic!("PDDB access erorr"),
|
|
||||||
};
|
|
||||||
let style = match name_to_style(style_name.as_ref()) {
|
|
||||||
Some(s) => s,
|
|
||||||
None => {
|
|
||||||
match pddb.get(
|
|
||||||
VAULT_CONFIG_DICT,
|
|
||||||
VAULT_CONFIG_KEY_FONT,
|
|
||||||
None, true, true,
|
|
||||||
Some(32), Some(crate::basis_change)
|
|
||||||
) {
|
|
||||||
Ok(mut style_key) => {
|
|
||||||
style_key.write(style_to_name(&DEFAULT_FONT).as_bytes()).ok();
|
|
||||||
}
|
|
||||||
_ => panic!("PDDB access erorr"),
|
|
||||||
};
|
|
||||||
GlyphStyle::Regular
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let available_height = screensize.y - TITLE_HEIGHT;
|
let available_height = screensize.y - TITLE_HEIGHT;
|
||||||
let glyph_height = gam.glyph_height_hint(style).unwrap();
|
let glyph_height = gam.glyph_height_hint(style).unwrap();
|
||||||
let item_height = (glyph_height * 2) as i16 + margin.y * 2 + 2; // +2 because of the border width
|
let item_height = (glyph_height * 2) as i16 + margin.y * 2 + 2; // +2 because of the border width
|
||||||
|
|
@ -273,13 +244,41 @@ impl VaultUx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_glyph_style(&mut self, style: GlyphStyle) {
|
pub(crate) fn get_glyph_style(&mut self) {
|
||||||
|
let style = match self.pddb.borrow().get(
|
||||||
|
VAULT_CONFIG_DICT,
|
||||||
|
VAULT_CONFIG_KEY_FONT,
|
||||||
|
None, true, false,
|
||||||
|
Some(32), Some(crate::basis_change)
|
||||||
|
) {
|
||||||
|
Ok(mut style_key) => {
|
||||||
|
let mut name_bytes = Vec::<u8>::new();
|
||||||
|
match style_key.read_to_end(&mut name_bytes) {
|
||||||
|
Ok(_len) => {
|
||||||
|
log::info!("name_bytes: {:?} {:?}", name_bytes, String::from_utf8(name_bytes.to_vec()));
|
||||||
|
name_to_style(&String::from_utf8(name_bytes).unwrap_or("regular".to_string()))
|
||||||
|
.unwrap_or(GlyphStyle::Regular)
|
||||||
|
},
|
||||||
|
Err(_) => GlyphStyle::Regular
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
log::warn!("PDDB access error reading default glyph size");
|
||||||
|
GlyphStyle::Regular
|
||||||
|
},
|
||||||
|
};
|
||||||
// force redraw of all the items
|
// force redraw of all the items
|
||||||
self.title_dirty = true;
|
self.title_dirty = true;
|
||||||
for item in self.filtered_list.iter_mut() {
|
for item in self.filtered_list.iter_mut() {
|
||||||
item.dirty = true;
|
item.dirty = true;
|
||||||
}
|
}
|
||||||
|
self.style = style;
|
||||||
|
let available_height = self.screensize.y - TITLE_HEIGHT;
|
||||||
|
let glyph_height = self.gam.glyph_height_hint(self.style).unwrap();
|
||||||
|
self.item_height = (glyph_height * 2) as i16 + self.margin.y * 2 + 2; // +2 because of the border width
|
||||||
|
self.items_per_screen = available_height / self.item_height;
|
||||||
|
}
|
||||||
|
pub(crate) fn set_glyph_style(&mut self, style: GlyphStyle) {
|
||||||
self.pddb.borrow().delete_key(VAULT_CONFIG_DICT, VAULT_CONFIG_KEY_FONT, None)
|
self.pddb.borrow().delete_key(VAULT_CONFIG_DICT, VAULT_CONFIG_KEY_FONT, None)
|
||||||
.expect("couldn't delete previous setting");
|
.expect("couldn't delete previous setting");
|
||||||
|
|
||||||
|
|
@ -294,11 +293,8 @@ impl VaultUx {
|
||||||
}
|
}
|
||||||
_ => panic!("PDDB access erorr"),
|
_ => panic!("PDDB access erorr"),
|
||||||
};
|
};
|
||||||
self.style = style;
|
self.pddb.borrow().sync().ok();
|
||||||
let available_height = self.screensize.y - TITLE_HEIGHT;
|
self.get_glyph_style();
|
||||||
let glyph_height = self.gam.glyph_height_hint(self.style).unwrap();
|
|
||||||
self.item_height = (glyph_height * 2) as i16 + self.margin.y * 2 + 2; // +2 because of the border width
|
|
||||||
self.items_per_screen = available_height / self.item_height;
|
|
||||||
}
|
}
|
||||||
fn mark_as_dirty(&mut self, index: usize) {
|
fn mark_as_dirty(&mut self, index: usize) {
|
||||||
let list_len = self.filtered_list.len();
|
let list_len = self.filtered_list.len();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue