mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
bring chat lib up to date with new ux-api layer
This commit is contained in:
parent
e27f468acd
commit
0770d5437f
4 changed files with 21 additions and 19 deletions
|
|
@ -16,7 +16,8 @@ log-server = { package = "xous-api-log", version = "0.1.63" }
|
||||||
ticktimer-server = { package = "xous-api-ticktimer", version = "0.9.63" }
|
ticktimer-server = { package = "xous-api-ticktimer", version = "0.9.63" }
|
||||||
xous-names = { package = "xous-api-names", version = "0.9.65" }
|
xous-names = { package = "xous-api-names", version = "0.9.65" }
|
||||||
gam = { path = "../../services/gam" }
|
gam = { path = "../../services/gam" }
|
||||||
graphics-server = { path = "../../services/graphics-server" }
|
ux-api = { path = "../../libs/ux-api" }
|
||||||
|
blitstr2 = { path = "../blitstr2" }
|
||||||
trng = { path = "../../services/trng" }
|
trng = { path = "../../services/trng" }
|
||||||
locales = { path = "../../locales" }
|
locales = { path = "../../locales" }
|
||||||
ime-plugin-api = { path = "../../services/ime-plugin-api" }
|
ime-plugin-api = { path = "../../services/ime-plugin-api" }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use enumset::EnumSet;
|
use enumset::EnumSet;
|
||||||
use graphics_server::Rectangle;
|
|
||||||
use rkyv::{Archive, Deserialize, Serialize};
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
use ux_api::minigfx::*;
|
||||||
|
|
||||||
use super::attach::Attach;
|
use super::attach::Attach;
|
||||||
use crate::PostFlag;
|
use crate::PostFlag;
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ use std::thread;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
pub use api::*;
|
pub use api::*;
|
||||||
|
use blitstr2::GlyphStyle;
|
||||||
use gam::MenuItem;
|
use gam::MenuItem;
|
||||||
use graphics_server::api::GlyphStyle;
|
|
||||||
use graphics_server::{Point, Rectangle, TextBounds, TextView};
|
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
pub use ui::BUSY_ANIMATION_RATE_MS;
|
pub use ui::BUSY_ANIMATION_RATE_MS;
|
||||||
use ui::VisualProperties;
|
use ui::VisualProperties;
|
||||||
|
use ux_api::minigfx::*;
|
||||||
use xous::{CID, Error, SID, msg_scalar_unpack};
|
use xous::{CID, Error, SID, msg_scalar_unpack};
|
||||||
use xous_ipc::Buffer;
|
use xous_ipc::Buffer;
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ pub(crate) fn default_textview(
|
||||||
bubble_tv.border_width = 1;
|
bubble_tv.border_width = 1;
|
||||||
}
|
}
|
||||||
bubble_tv.clip_rect =
|
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.draw_border = true;
|
||||||
bubble_tv.clear_area = true;
|
bubble_tv.clear_area = true;
|
||||||
bubble_tv.rounded_border = Some(vp.bubble_radius);
|
bubble_tv.rounded_border = Some(vp.bubble_radius);
|
||||||
|
|
@ -63,7 +63,7 @@ fn bubble(
|
||||||
post: &crate::dialogue::post::Post,
|
post: &crate::dialogue::post::Post,
|
||||||
dialogue: &crate::dialogue::Dialogue,
|
dialogue: &crate::dialogue::Dialogue,
|
||||||
hilite: bool,
|
hilite: bool,
|
||||||
anchor_y: i16,
|
anchor_y: isize,
|
||||||
) -> TextView {
|
) -> TextView {
|
||||||
// create a textview with all of our default properties
|
// create a textview with all of our default properties
|
||||||
let mut bubble_tv = default_textview(post, hilite, vp);
|
let mut bubble_tv = default_textview(post, hilite, vp);
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,14 @@ use std::cmp::min;
|
||||||
use std::fmt::Write as TextWrite;
|
use std::fmt::Write as TextWrite;
|
||||||
use std::io::{Error, ErrorKind, Read, Write};
|
use std::io::{Error, ErrorKind, Read, Write};
|
||||||
|
|
||||||
|
use blitstr2::GlyphStyle;
|
||||||
use dialogue::{Dialogue, post::Post};
|
use dialogue::{Dialogue, post::Post};
|
||||||
use gam::{MenuMatic, UxRegistration, menu_matic};
|
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 locales::t;
|
||||||
use modals::Modals;
|
use modals::Modals;
|
||||||
use ticktimer_server::Ticktimer;
|
use ticktimer_server::Ticktimer;
|
||||||
|
use ux_api::minigfx::*;
|
||||||
|
use ux_api::service::api::*;
|
||||||
use xous::{CID, MessageEnvelope};
|
use xous::{CID, MessageEnvelope};
|
||||||
use xous_names::XousNames;
|
use xous_names::XousNames;
|
||||||
|
|
||||||
|
|
@ -29,7 +30,7 @@ pub struct VisualProperties {
|
||||||
pub margin: Point, // margin to edge of canvas
|
pub margin: Point, // margin to edge of canvas
|
||||||
pub bubble_margin: Point, // margin of text in bubbles
|
pub bubble_margin: Point, // margin of text in bubbles
|
||||||
pub bubble_radius: u16,
|
pub bubble_radius: u16,
|
||||||
pub bubble_space: i16, // spacing between text bubbles
|
pub bubble_space: isize, // spacing between text bubbles
|
||||||
}
|
}
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) struct Ui {
|
pub(crate) struct Ui {
|
||||||
|
|
@ -145,7 +146,7 @@ impl Ui {
|
||||||
let bubble_properties = VisualProperties {
|
let bubble_properties = VisualProperties {
|
||||||
canvas,
|
canvas,
|
||||||
total_screensize: screensize,
|
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,
|
status_height,
|
||||||
bubble_width: ((screensize.x / 5) * 4) as u16, // 80% width for the text bubbles
|
bubble_width: ((screensize.x / 5) * 4) as u16, // 80% width for the text bubbles
|
||||||
margin: Point::new(4, 4),
|
margin: Point::new(4, 4),
|
||||||
|
|
@ -482,7 +483,7 @@ impl Ui {
|
||||||
.draw_rectangle(
|
.draw_rectangle(
|
||||||
self.vp.canvas,
|
self.vp.canvas,
|
||||||
Rectangle::new_with_style(
|
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,
|
self.vp.total_screensize,
|
||||||
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
|
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.
|
// 4. draw the text bubbles, in the order computed in step 2.
|
||||||
let mut y = if self.layout_topdown {
|
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 {
|
} 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!(
|
log::debug!(
|
||||||
"Laying out with selected {:?} in range {:?}; topdown: {:?}",
|
"Laying out with selected {:?} in range {:?}; topdown: {:?}",
|
||||||
|
|
@ -745,13 +746,13 @@ impl Ui {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if self.layout_topdown {
|
if self.layout_topdown {
|
||||||
y += actual_r.height() as i16;
|
y += actual_r.height() as isize;
|
||||||
} else {
|
} else {
|
||||||
y -= actual_r.height() as i16;
|
y -= actual_r.height() as isize;
|
||||||
}
|
}
|
||||||
// sanity check the computations
|
// sanity check the computations
|
||||||
if y > self.vp.layout_screensize.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 i16
|
|| y < self.vp.status_height as isize
|
||||||
{
|
{
|
||||||
log::error!(
|
log::error!(
|
||||||
"Computed range of elements sent to layout overflows at index {}",
|
"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...
|
// 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");
|
self.gam.post_textview(&mut self.status_tv).expect("couldn't render status bar");
|
||||||
let status_border = Line::new(
|
let status_border = Line::new(
|
||||||
Point::new(0, 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 i16),
|
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");
|
self.gam.draw_line(self.vp.canvas, status_border).expect("couldn't draw status lower border");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue