diff --git a/libs/chat/Cargo.toml b/libs/chat/Cargo.toml index b635a0883..4fefac1ab 100644 --- a/libs/chat/Cargo.toml +++ b/libs/chat/Cargo.toml @@ -16,7 +16,8 @@ log-server = { package = "xous-api-log", version = "0.1.63" } ticktimer-server = { package = "xous-api-ticktimer", version = "0.9.63" } xous-names = { package = "xous-api-names", version = "0.9.65" } gam = { path = "../../services/gam" } -graphics-server = { path = "../../services/graphics-server" } +ux-api = { path = "../../libs/ux-api" } +blitstr2 = { path = "../blitstr2" } trng = { path = "../../services/trng" } locales = { path = "../../locales" } ime-plugin-api = { path = "../../services/ime-plugin-api" } diff --git a/libs/chat/src/dialogue/post.rs b/libs/chat/src/dialogue/post.rs index dd8f48f88..ef3524db8 100644 --- a/libs/chat/src/dialogue/post.rs +++ b/libs/chat/src/dialogue/post.rs @@ -1,6 +1,6 @@ use enumset::EnumSet; -use graphics_server::Rectangle; use rkyv::{Archive, Deserialize, Serialize}; +use ux_api::minigfx::*; use super::attach::Attach; use crate::PostFlag; diff --git a/libs/chat/src/lib.rs b/libs/chat/src/lib.rs index 735595330..e03f12447 100644 --- a/libs/chat/src/lib.rs +++ b/libs/chat/src/lib.rs @@ -9,12 +9,12 @@ use std::thread; use std::time::{SystemTime, UNIX_EPOCH}; pub use api::*; +use blitstr2::GlyphStyle; use gam::MenuItem; -use graphics_server::api::GlyphStyle; -use graphics_server::{Point, Rectangle, TextBounds, TextView}; use num_traits::FromPrimitive; pub use ui::BUSY_ANIMATION_RATE_MS; use ui::VisualProperties; +use ux_api::minigfx::*; use xous::{CID, Error, SID, msg_scalar_unpack}; use xous_ipc::Buffer; @@ -35,7 +35,7 @@ pub(crate) fn default_textview( bubble_tv.border_width = 1; } bubble_tv.clip_rect = - Some(Rectangle::new(Point::new(0, vp.status_height as i16 + vp.margin.y), vp.layout_screensize)); + Some(Rectangle::new(Point::new(0, vp.status_height as isize + vp.margin.y), vp.layout_screensize)); bubble_tv.draw_border = true; bubble_tv.clear_area = true; bubble_tv.rounded_border = Some(vp.bubble_radius); @@ -63,7 +63,7 @@ fn bubble( post: &crate::dialogue::post::Post, dialogue: &crate::dialogue::Dialogue, hilite: bool, - anchor_y: i16, + anchor_y: isize, ) -> TextView { // create a textview with all of our default properties let mut bubble_tv = default_textview(post, hilite, vp); diff --git a/libs/chat/src/ui.rs b/libs/chat/src/ui.rs index 09f20b3a6..4c1fffc1f 100644 --- a/libs/chat/src/ui.rs +++ b/libs/chat/src/ui.rs @@ -2,13 +2,14 @@ use std::cmp::min; use std::fmt::Write as TextWrite; use std::io::{Error, ErrorKind, Read, Write}; +use blitstr2::GlyphStyle; use dialogue::{Dialogue, post::Post}; use gam::{MenuMatic, UxRegistration, menu_matic}; -use graphics_server::api::GlyphStyle; -use graphics_server::{DrawStyle, Gid, Line, PixelColor, Point, Rectangle, TextBounds, TextView}; use locales::t; use modals::Modals; use ticktimer_server::Ticktimer; +use ux_api::minigfx::*; +use ux_api::service::api::*; use xous::{CID, MessageEnvelope}; use xous_names::XousNames; @@ -29,7 +30,7 @@ pub struct VisualProperties { pub margin: Point, // margin to edge of canvas pub bubble_margin: Point, // margin of text in bubbles pub bubble_radius: u16, - pub bubble_space: i16, // spacing between text bubbles + pub bubble_space: isize, // spacing between text bubbles } #[allow(dead_code)] pub(crate) struct Ui { @@ -145,7 +146,7 @@ impl Ui { let bubble_properties = VisualProperties { canvas, total_screensize: screensize, - layout_screensize: Point::new(screensize.x, screensize.y - status_height as i16), + layout_screensize: Point::new(screensize.x, screensize.y - status_height as isize), status_height, bubble_width: ((screensize.x / 5) * 4) as u16, // 80% width for the text bubbles margin: Point::new(4, 4), @@ -482,7 +483,7 @@ impl Ui { .draw_rectangle( self.vp.canvas, Rectangle::new_with_style( - Point::new(0, self.vp.status_height as i16), + Point::new(0, self.vp.status_height as isize), self.vp.total_screensize, DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 }, ), @@ -705,9 +706,9 @@ impl Ui { // 4. draw the text bubbles, in the order computed in step 2. let mut y = if self.layout_topdown { - self.vp.status_height as i16 + self.vp.bubble_margin.y + self.vp.status_height as isize + self.vp.bubble_margin.y } else { - self.vp.status_height as i16 + self.vp.layout_screensize.y - self.vp.bubble_margin.y + self.vp.status_height as isize + self.vp.layout_screensize.y - self.vp.bubble_margin.y }; log::debug!( "Laying out with selected {:?} in range {:?}; topdown: {:?}", @@ -745,13 +746,13 @@ impl Ui { ); } if self.layout_topdown { - y += actual_r.height() as i16; + y += actual_r.height() as isize; } else { - y -= actual_r.height() as i16; + y -= actual_r.height() as isize; } // sanity check the computations - if y > self.vp.layout_screensize.y + self.vp.status_height as i16 - || y < self.vp.status_height as i16 + if y > self.vp.layout_screensize.y + self.vp.status_height as isize + || y < self.vp.status_height as isize { log::error!( "Computed range of elements sent to layout overflows at index {}", @@ -779,8 +780,8 @@ impl Ui { // 5. draw status bar on top of any post that happens to flow over the top... self.gam.post_textview(&mut self.status_tv).expect("couldn't render status bar"); let status_border = Line::new( - Point::new(0, self.vp.status_height as i16), - Point::new(self.vp.total_screensize.x, self.vp.status_height as i16), + Point::new(0, self.vp.status_height as isize), + Point::new(self.vp.total_screensize.x, self.vp.status_height as isize), ); self.gam.draw_line(self.vp.canvas, status_border).expect("couldn't draw status lower border");