From b2c64eb61a27b643fa5563b4b26bed3c8ce3ce17 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 5 Jul 2023 15:13:38 +0800 Subject: [PATCH] aesthetic cleanup; change default font for all modals I decided to go back on the idea of not changing the modals and now all modals use the new larger font as well. This creates issue #396, which I will deal with later once I have the time to do some more testing. I'm pretty sure some other dialog boxes are broken now too. --- services/gam/src/layouts/chat.rs | 2 +- services/gam/src/layouts/menu.rs | 4 ++-- services/gam/src/modal/textentry.rs | 17 ++++++++++++++--- services/graphics-server/src/wordwrap.rs | 2 +- services/modals/src/main.rs | 2 +- services/pddb/src/ux.rs | 2 +- services/root-keys/src/main.rs | 2 +- services/status/src/wifi.rs | 2 ++ 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/services/gam/src/layouts/chat.rs b/services/gam/src/layouts/chat.rs index b4a62a5d3..05954a13f 100644 --- a/services/gam/src/layouts/chat.rs +++ b/services/gam/src/layouts/chat.rs @@ -30,7 +30,7 @@ impl ChatLayout { let screensize = gfx.screen_size().expect("Couldn't get screen size"); // get the height of various text regions to compute the layout let small_height: i16 = gfx.glyph_height_hint(GlyphStyle::Small).expect("couldn't get glyph height") as i16; - let regular_height: i16 = gfx.glyph_height_hint(GlyphStyle::Regular).expect("couldn't get glyph height") as i16; + let regular_height: i16 = gfx.glyph_height_hint(gam::SYSTEM_STYLE).expect("couldn't get glyph height") as i16; let margin = 4; // allocate canvases in structures, and record their GID for future reference diff --git a/services/gam/src/layouts/menu.rs b/services/gam/src/layouts/menu.rs index 1b26d19f2..0d618f323 100644 --- a/services/gam/src/layouts/menu.rs +++ b/services/gam/src/layouts/menu.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use crate::{Canvas, GlyphStyle}; +use crate::Canvas; use graphics_server::*; @@ -22,7 +22,7 @@ impl MenuLayout { pub fn init(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut HashMap) -> Result { let screensize = gfx.screen_size().expect("Couldn't get screen size"); // get the height of various text regions to compute the layout - let height: i16 = gfx.glyph_height_hint(GlyphStyle::Regular).expect("couldn't get glyph height") as i16; + let height: i16 = gfx.glyph_height_hint(gam::SYSTEM_STYLE).expect("couldn't get glyph height") as i16; const MENU_Y_PAD: i16 = 100; const MENU_X_PAD: i16 = 35; diff --git a/services/gam/src/modal/textentry.rs b/services/gam/src/modal/textentry.rs index d514914cc..40567b981 100644 --- a/services/gam/src/modal/textentry.rs +++ b/services/gam/src/modal/textentry.rs @@ -416,6 +416,10 @@ impl ActionApi for TextEntry { } } if self.is_password { + let aesthetic_margin = match crate::SYSTEM_STYLE { + GlyphStyle::Tall => 4, + _ => 0, + }; let select_index = match self.visibility { TextEntryVisibility::Visible => 0, TextEntryVisibility::LastChars => 1, @@ -428,7 +432,9 @@ impl ActionApi for TextEntry { let mut tv = TextView::new( modal.canvas, TextBounds::GrowableFromTl( - Point::new(modal.margin, at_height + glyph_to_height_hint(GlyphStyle::Monospace) as i16 + modal.margin), + Point::new(modal.margin, at_height + glyph_to_height_hint(GlyphStyle::Monospace) as i16 + modal.margin + + aesthetic_margin + ), lr_margin as u16 )); tv.style = GlyphStyle::Large; @@ -443,7 +449,10 @@ impl ActionApi for TextEntry { let mut tv = TextView::new( modal.canvas, TextBounds::GrowableFromTl( - Point::new(left_edge + i * prompt_width, at_height + glyph_to_height_hint(GlyphStyle::Monospace) as i16 + modal.margin), + Point::new(left_edge + i * prompt_width, at_height + + glyph_to_height_hint(GlyphStyle::Monospace) as i16 + modal.margin + + aesthetic_margin + ), prompt_width as u16) ); tv.style = GlyphStyle::Monospace; @@ -469,7 +478,9 @@ impl ActionApi for TextEntry { let mut tv = TextView::new( modal.canvas, TextBounds::GrowableFromTr( - Point::new(modal.canvas_width - modal.margin, at_height + glyph_to_height_hint(GlyphStyle::Monospace) as i16 + modal.margin), + Point::new(modal.canvas_width - modal.margin, at_height + glyph_to_height_hint(GlyphStyle::Monospace) as i16 + modal.margin + + aesthetic_margin + ), lr_margin as u16 )); tv.style = GlyphStyle::Large; diff --git a/services/graphics-server/src/wordwrap.rs b/services/graphics-server/src/wordwrap.rs index 9bebcdf52..60783c98d 100644 --- a/services/graphics-server/src/wordwrap.rs +++ b/services/graphics-server/src/wordwrap.rs @@ -269,7 +269,7 @@ impl Typesetter { // going out of scope at the end of the call. let mut composition = Vec::::new(); - if self.bb.max.x - self.bb.min.y < glyph_to_height_hint(GlyphStyle::Regular) as i16 { + if self.bb.max.y - self.bb.min.y < glyph_to_height_hint(GlyphStyle::Regular) as i16 { // we flag this because the typesetter algorithm may never converge if it can't set any characters // because the region is just too narrow. log::error!("Words cannot be typset because the width of the typset region is too narrow."); diff --git a/services/modals/src/main.rs b/services/modals/src/main.rs index 018ed6abd..a734b18ab 100644 --- a/services/modals/src/main.rs +++ b/services/modals/src/main.rs @@ -61,7 +61,7 @@ enum RendererState { RunImage(ManagedImage), } -const DEFAULT_STYLE: GlyphStyle = GlyphStyle::Regular; +const DEFAULT_STYLE: GlyphStyle = gam::SYSTEM_STYLE; fn main () -> ! { #[cfg(not(feature="ditherpunk"))] diff --git a/services/pddb/src/ux.rs b/services/pddb/src/ux.rs index c19401e0e..5bf49954f 100644 --- a/services/pddb/src/ux.rs +++ b/services/pddb/src/ux.rs @@ -80,7 +80,7 @@ pub(crate) fn password_ux_manager( ActionType::TextEntry(password_action.clone()), Some(t!("pddb.password", locales::LANG)), None, - GlyphStyle::Regular, + gam::SYSTEM_STYLE, 8 ); pddb_modal.spawn_helper(ux_sid, pddb_modal.sid, diff --git a/services/root-keys/src/main.rs b/services/root-keys/src/main.rs index 21f23a119..cfb5df982 100644 --- a/services/root-keys/src/main.rs +++ b/services/root-keys/src/main.rs @@ -496,7 +496,7 @@ fn main() -> ! { ActionType::TextEntry(password_action.clone()), Some(t!("rootkeys.updatefirstpass", locales::LANG)), None, - GlyphStyle::Regular, + gam::SYSTEM_STYLE, 8 ); rootkeys_modal.spawn_helper(keys_sid, rootkeys_modal.sid, diff --git a/services/status/src/wifi.rs b/services/status/src/wifi.rs index 04a936843..523afe650 100644 --- a/services/status/src/wifi.rs +++ b/services/status/src/wifi.rs @@ -266,6 +266,8 @@ impl WLANMan { self.modals.dynamic_notification_close().ok(); } let mut networks: Vec<&str> = networks.iter().map(|s| s.as_str()).collect(); + // TODO: we may need to add code here to truncate the list if it is too long, with the larger + // font, the dialog box could run off the screen. if networks.is_empty() { self.modals