mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
more GAM API coming together
This commit is contained in:
parent
5701bf4968
commit
01abbd4f47
7 changed files with 211 additions and 53 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -259,6 +259,8 @@ dependencies = [
|
||||||
"blitstr",
|
"blitstr",
|
||||||
"com",
|
"com",
|
||||||
"graphics-server",
|
"graphics-server",
|
||||||
|
"hash32",
|
||||||
|
"hash32-derive",
|
||||||
"heapless",
|
"heapless",
|
||||||
"keyboard",
|
"keyboard",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ keyboard = { path = "../keyboard" }
|
||||||
trng = { path = "../trng" }
|
trng = { path = "../trng" }
|
||||||
heapless = "0.5"
|
heapless = "0.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
hash32 = "0.1.0"
|
||||||
|
hash32-derive = "0.1.0"
|
||||||
|
|
||||||
com = { path = "../com"}
|
com = { path = "../com"}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,23 @@
|
||||||
use xous::{Message, ScalarMessage};
|
use xous::{Message, ScalarMessage};
|
||||||
use graphics_server::{Point, Rectangle};
|
use graphics_server::{Point, Rectangle};
|
||||||
use blitstr::{GlyphStyle, Cursor};
|
use blitstr::{GlyphStyle, Cursor};
|
||||||
|
use hash32::{Hash, Hasher};
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Gid {
|
||||||
|
gid: [u32; 4],
|
||||||
|
}
|
||||||
|
impl Gid {
|
||||||
|
pub fn new(id: [u32; 4]) -> Self { Gid{gid: id} }
|
||||||
|
}
|
||||||
|
impl hash32::Hash for Gid {
|
||||||
|
fn hash<H>(&self, state: &mut H)
|
||||||
|
where
|
||||||
|
H: Hasher,
|
||||||
|
{
|
||||||
|
Hash::hash(&self.gid[..], state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum TextAlignment {
|
pub enum TextAlignment {
|
||||||
|
|
@ -21,8 +38,36 @@ pub enum TextBounds {
|
||||||
GrowableFromBl(Point, u16),
|
GrowableFromBl(Point, u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
// operations that may be requested of a TextView when sent to GAM
|
||||||
|
pub enum TextOp {
|
||||||
|
Nop,
|
||||||
|
Render,
|
||||||
|
ComputeBounds,
|
||||||
|
}
|
||||||
|
impl Into<usize> for TextOp {
|
||||||
|
fn into(self) -> usize {
|
||||||
|
match self {
|
||||||
|
TextOp::Nop => 0,
|
||||||
|
TextOp::Render => 1,
|
||||||
|
TextOp::ComputeBounds => 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<usize> for TextOp {
|
||||||
|
fn from(code: usize) -> Self {
|
||||||
|
match code {
|
||||||
|
1 => TextOp::Render,
|
||||||
|
2 => TextOp::ComputeBounds,
|
||||||
|
_ => TextOp::Nop,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct TextView<'a> {
|
pub struct TextView<'a> {
|
||||||
|
operation: TextOp,
|
||||||
|
|
||||||
untrusted: bool, // render content with random stipples to indicate the strings within are untrusted
|
untrusted: bool, // render content with random stipples to indicate the strings within are untrusted
|
||||||
token: Option<[u32; 4]>, // optional 128-bit token which is presented to prove a field's trustability
|
token: Option<[u32; 4]>, // optional 128-bit token which is presented to prove a field's trustability
|
||||||
invert: bool, // only trusted, token-validated TextViews will have the invert bit respected
|
invert: bool, // only trusted, token-validated TextViews will have the invert bit respected
|
||||||
|
|
@ -31,8 +76,8 @@ pub struct TextView<'a> {
|
||||||
draw_order: usize,
|
draw_order: usize,
|
||||||
|
|
||||||
// offsets for text drawing -- exactly one of the following options should be specified
|
// offsets for text drawing -- exactly one of the following options should be specified
|
||||||
bounds: TextBounds,
|
bounds_hint: TextBounds,
|
||||||
computed_bounds: Option<Rectangle>, // is Some(Rectangle) if bounds have been computed and text has not been modified
|
bounds_computed: Option<Rectangle>, // is Some(Rectangle) if bounds have been computed and text has not been modified
|
||||||
|
|
||||||
style: GlyphStyle,
|
style: GlyphStyle,
|
||||||
text: xous::String<'a>,
|
text: xous::String<'a>,
|
||||||
|
|
@ -47,7 +92,32 @@ pub struct TextView<'a> {
|
||||||
// this field specifies the beginning and end of a "selected" region of text
|
// this field specifies the beginning and end of a "selected" region of text
|
||||||
selected: Option<[usize; 2]>,
|
selected: Option<[usize; 2]>,
|
||||||
|
|
||||||
canvas: [u32; 4], // GID of the canvas to draw on
|
canvas: Gid, // GID of the canvas to draw on
|
||||||
|
}
|
||||||
|
impl<'a> TextView<'a> {
|
||||||
|
pub fn new(maxlen: usize, draw_order: usize, bounds_hint: TextBounds, canvas: Gid) -> Self {
|
||||||
|
TextView {
|
||||||
|
operation: TextOp::Nop,
|
||||||
|
untrusted: true,
|
||||||
|
token: None,
|
||||||
|
invert: false,
|
||||||
|
draw_order,
|
||||||
|
bounds_hint,
|
||||||
|
bounds_computed: None,
|
||||||
|
style: GlyphStyle::Regular,
|
||||||
|
text: xous::String::new(maxlen),
|
||||||
|
alignment: TextAlignment::Left,
|
||||||
|
draw_border: true,
|
||||||
|
border_width: 1,
|
||||||
|
rounded_border: false,
|
||||||
|
x_margin: 4,
|
||||||
|
y_margin: 4,
|
||||||
|
selected: None,
|
||||||
|
canvas,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn set_op(&mut self, op: TextOp) { self.operation = op; }
|
||||||
|
pub fn get_op(&self) -> TextOp { self.operation }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> core::fmt::Debug for TextView<'a> {
|
impl<'a> core::fmt::Debug for TextView<'a> {
|
||||||
|
|
@ -61,16 +131,16 @@ impl<'a> core::fmt::Debug for TextView<'a> {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Opcode<'a> {
|
pub enum Opcode<'a> {
|
||||||
// clears a canvas with a given GID
|
// clears a canvas with a given GID
|
||||||
ClearCanvas([u32; 4]),
|
ClearCanvas(Gid),
|
||||||
|
|
||||||
// renders a TextView
|
// renders a TextView
|
||||||
RenderTextView(TextView<'a>),
|
RenderTextView(TextView<'a>),
|
||||||
|
|
||||||
// returns a GID to the "content" Canvas; requires an authentication token
|
// returns a GID to the "content" Canvas; requires an authentication token
|
||||||
RequestContentCanvas([u32; 4]),
|
RequestContentCanvas(Gid),
|
||||||
|
|
||||||
// hides a canvas with a given GID
|
// hides a canvas with a given GID
|
||||||
HideCanvas([u32; 4]),
|
HideCanvas(Gid),
|
||||||
|
|
||||||
// requests the GID to the "input" Canvas; call only works once (for the IME server), then maps out
|
// requests the GID to the "input" Canvas; call only works once (for the IME server), then maps out
|
||||||
RequestInputCanvas(),
|
RequestInputCanvas(),
|
||||||
|
|
@ -84,7 +154,7 @@ impl<'a> core::convert::TryFrom<&'a Message> for Opcode<'a> {
|
||||||
fn try_from(message: &'a Message) -> Result<Self, Self::Error> {
|
fn try_from(message: &'a Message) -> Result<Self, Self::Error> {
|
||||||
match message {
|
match message {
|
||||||
Message::Scalar(m) => match m.id {
|
Message::Scalar(m) => match m.id {
|
||||||
0 => Ok(Opcode::ClearCanvas([m.arg1 as _, m.arg2 as _, m.arg3 as _, m.arg4 as _])),
|
0 => Ok(Opcode::ClearCanvas(Gid::new([m.arg1 as _, m.arg2 as _, m.arg3 as _, m.arg4 as _]))),
|
||||||
_ => Err("GAM api: unknown Scalar ID"),
|
_ => Err("GAM api: unknown Scalar ID"),
|
||||||
},
|
},
|
||||||
_ => Err("GAM api: unhandled message type"),
|
_ => Err("GAM api: unhandled message type"),
|
||||||
|
|
@ -96,7 +166,7 @@ impl<'a> Into<Message> for Opcode<'a> {
|
||||||
fn into(self) -> Message {
|
fn into(self) -> Message {
|
||||||
match self {
|
match self {
|
||||||
Opcode::ClearCanvas(gid) => Message::Scalar(ScalarMessage {
|
Opcode::ClearCanvas(gid) => Message::Scalar(ScalarMessage {
|
||||||
id: 0, arg1: gid[0] as _, arg2: gid[1] as _, arg3: gid[2] as _, arg4: gid[3] as _
|
id: 0, arg1: gid.gid[0] as _, arg2: gid.gid[1] as _, arg3: gid.gid[2] as _, arg4: gid.gid[3] as _
|
||||||
}),
|
}),
|
||||||
_ => panic!("GAM api: Opcode type not handled by Into(), maybe you meant to use a helper method?"),
|
_ => panic!("GAM api: Opcode type not handled by Into(), maybe you meant to use a helper method?"),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ use heapless::Vec;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
use graphics_server::{Rectangle, Point};
|
use graphics_server::{Rectangle, Point};
|
||||||
|
|
||||||
|
use crate::api::*;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum CanvasState {
|
pub enum CanvasState {
|
||||||
// the initial state of every Canvas. Not drawable.
|
// the initial state of every Canvas. Not drawable.
|
||||||
|
|
@ -33,14 +35,14 @@ pub struct Canvas {
|
||||||
state: CanvasState,
|
state: CanvasState,
|
||||||
|
|
||||||
// unique, random identifier for the Canvas
|
// unique, random identifier for the Canvas
|
||||||
gid: [u32; 4],
|
gid: Gid,
|
||||||
|
|
||||||
// enables scroll/pan of objects within a region
|
// enables scroll/pan of objects within a region
|
||||||
pan_offset: Point,
|
pan_offset: Point,
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need the "screen" parameter so we can turn off drawing to canvases that are off-screen
|
// we need the "screen" parameter so we can turn off drawing to canvases that are off-screen
|
||||||
pub fn recompute_canvases(mut canvases: BinaryHeap<Canvas, U32, Max>, screen: Rectangle) -> (BinaryHeap<Canvas, U32, Max>, FnvIndexMap<[u32; 4], Canvas, U32>) {
|
pub fn recompute_canvases(mut canvases: BinaryHeap<Canvas, U32, Max>, screen: Rectangle) -> (BinaryHeap<Canvas, U32, Max>, FnvIndexMap<Gid, Canvas, U32>) {
|
||||||
let mut higher_clipregions: BinaryHeap<Canvas, U32, Max> = BinaryHeap::new();
|
let mut higher_clipregions: BinaryHeap<Canvas, U32, Max> = BinaryHeap::new();
|
||||||
|
|
||||||
let mut trust_level: u8 = 255;
|
let mut trust_level: u8 = 255;
|
||||||
|
|
@ -73,7 +75,7 @@ pub fn recompute_canvases(mut canvases: BinaryHeap<Canvas, U32, Max>, screen: Re
|
||||||
higher_clipregions.push(canvas).unwrap();
|
higher_clipregions.push(canvas).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut map: FnvIndexMap<[u32; 4], Canvas, U32> = FnvIndexMap::new();
|
let mut map: FnvIndexMap<Gid, Canvas, U32> = FnvIndexMap::new();
|
||||||
for &c in higher_clipregions.iter() {
|
for &c in higher_clipregions.iter() {
|
||||||
map.insert(c.gid(), c).unwrap();
|
map.insert(c.gid(), c).unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -95,16 +97,16 @@ impl Canvas {
|
||||||
|
|
||||||
Ok(if pan_offset.is_some() {
|
Ok(if pan_offset.is_some() {
|
||||||
Canvas {
|
Canvas {
|
||||||
clip_rect, trust_level, state: CanvasState::Created, gid, pan_offset: pan_offset.unwrap()
|
clip_rect, trust_level, state: CanvasState::Created, gid: Gid::new(gid), pan_offset: pan_offset.unwrap()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Canvas {
|
Canvas {
|
||||||
clip_rect, trust_level, state: CanvasState::Created, gid, pan_offset: Point::new(0, 0)
|
clip_rect, trust_level, state: CanvasState::Created, gid: Gid::new(gid), pan_offset: Point::new(0, 0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn clip_rect(&self) -> Rectangle { self.clip_rect }
|
pub fn clip_rect(&self) -> Rectangle { self.clip_rect }
|
||||||
pub fn gid(&self) -> [u32; 4] { self.gid }
|
pub fn gid(&self) -> Gid { self.gid }
|
||||||
pub fn trust_level(&self) -> u8 { self.trust_level }
|
pub fn trust_level(&self) -> u8 { self.trust_level }
|
||||||
pub fn state(&self) -> CanvasState { self.state }
|
pub fn state(&self) -> CanvasState { self.state }
|
||||||
pub fn set_state(&mut self, state: CanvasState) { self.state = state; }
|
pub fn set_state(&mut self, state: CanvasState) { self.state = state; }
|
||||||
|
|
|
||||||
16
services/gam/src/lib.rs
Normal file
16
services/gam/src/lib.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
|
||||||
|
pub mod api;
|
||||||
|
use api::*;
|
||||||
|
|
||||||
|
use xous::ipc::*;
|
||||||
|
use core::fmt::Write;
|
||||||
|
|
||||||
|
pub fn draw_textview(gam_cid: xous::CID, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||||
|
let mut sendable_tv = Sendable::new(tv).expect("can't create sendable textview");
|
||||||
|
sendable_tv.set_op(TextOp::Render);
|
||||||
|
sendable_tv.lend_mut(gam_cid, sendable_tv.get_op().into()).expect("draw_textview operation failure");
|
||||||
|
|
||||||
|
sendable_tv.set_op(TextOp::Nop);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -22,6 +22,92 @@ use heapless::binary_heap::{BinaryHeap, Max};
|
||||||
use heapless::FnvIndexMap;
|
use heapless::FnvIndexMap;
|
||||||
use heapless::consts::*;
|
use heapless::consts::*;
|
||||||
|
|
||||||
|
// GIDs of canvases that are used the "Chat" layout.
|
||||||
|
struct ChatLayout {
|
||||||
|
// a set of GIDs to track the elements of the chat layout
|
||||||
|
pub status: Gid,
|
||||||
|
pub content: Gid,
|
||||||
|
pub predictive: Gid,
|
||||||
|
pub input: Gid,
|
||||||
|
}
|
||||||
|
|
||||||
|
// remember GIDs of the canvases for modal pop-up boxes
|
||||||
|
struct ModalCanvases {
|
||||||
|
pub password: Gid,
|
||||||
|
pub menu: Gid,
|
||||||
|
pub alert: Gid,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_modal_layout(trng_conn: xous::CID, canvases: &mut BinaryHeap<Canvas, U32, Max>) -> Result<ModalCanvases, xous::Error> {
|
||||||
|
let password_canvas = Canvas::new(
|
||||||
|
Rectangle::new_coords(-1, -1, -1, -1),
|
||||||
|
0, trng_conn, None
|
||||||
|
).expect("GAM: couldn't create password canvas");
|
||||||
|
canvases.push(password_canvas).expect("GAM: can't store password canvas");
|
||||||
|
|
||||||
|
let menu_canvas = Canvas::new(
|
||||||
|
Rectangle::new_coords(-1, -1, -1, -1),
|
||||||
|
0, trng_conn, None
|
||||||
|
).expect("GAM: couldn't create menu canvas");
|
||||||
|
canvases.push(menu_canvas).expect("GAM: can't store menu canvas");
|
||||||
|
|
||||||
|
let alert_canvas = Canvas::new(
|
||||||
|
Rectangle::new_coords(-1, -1, -1, -1),
|
||||||
|
0, trng_conn, None
|
||||||
|
).expect("GAM: couldn't create alert canvas");
|
||||||
|
canvases.push(alert_canvas).expect("GAM: can't store alert canvas");
|
||||||
|
|
||||||
|
Ok(ModalCanvases {
|
||||||
|
password: password_canvas.gid(),
|
||||||
|
menu: menu_canvas.gid(),
|
||||||
|
alert: alert_canvas.gid(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_chat_layout(gfx_conn: xous::CID, trng_conn: xous::CID, canvases: &mut BinaryHeap<Canvas, U32, Max>) -> Result<ChatLayout, xous::Error> {
|
||||||
|
let screensize = graphics_server::screen_size(gfx_conn).expect("GAM: Couldn't get screen size");
|
||||||
|
// get the height of various text regions to compute the layout
|
||||||
|
graphics_server::set_glyph_style(gfx_conn, GlyphStyle::Small).expect("GAM: couldn't set glyph style");
|
||||||
|
let (_, small_height_tuple) = graphics_server::query_glyph(gfx_conn).expect("GAM: couldn't get glyph height");
|
||||||
|
let small_height: i16 = small_height_tuple as i16;
|
||||||
|
graphics_server::set_glyph_style(gfx_conn, GlyphStyle::Regular).expect("GAM: couldn't set glyph style");
|
||||||
|
let (_, regular_height_tuple) = graphics_server::query_glyph(gfx_conn).expect("GAM: couldn't get glyph height");
|
||||||
|
let regular_height: i16 = regular_height_tuple as i16;
|
||||||
|
|
||||||
|
// allocate canvases in structures, and record their GID for future reference
|
||||||
|
let status_canvas = Canvas::new(
|
||||||
|
Rectangle::new_coords(0, 0, screensize.x, small_height),
|
||||||
|
0, trng_conn, None
|
||||||
|
).expect("GAM: couldn't create status canvas");
|
||||||
|
canvases.push(status_canvas).expect("GAM: can't store status canvus");
|
||||||
|
|
||||||
|
let predictive_canvas = Canvas::new(
|
||||||
|
Rectangle::new_coords(0, screensize.y - regular_height, screensize.x, screensize.y),
|
||||||
|
1,
|
||||||
|
trng_conn, None
|
||||||
|
).expect("GAM: couldn't create predictive text canvas");
|
||||||
|
canvases.push(predictive_canvas).expect("GAM: couldn't store predictive canvas");
|
||||||
|
|
||||||
|
let input_canvas = Canvas::new(
|
||||||
|
Rectangle::new_v_stack(predictive_canvas.clip_rect(), -regular_height),
|
||||||
|
1, trng_conn, None
|
||||||
|
).expect("GAM: couldn't create input text canvas");
|
||||||
|
canvases.push(input_canvas).expect("GAM: couldn't store input canvas");
|
||||||
|
|
||||||
|
let content_canvas = Canvas::new(
|
||||||
|
Rectangle::new_v_span(status_canvas.clip_rect(), input_canvas.clip_rect()),
|
||||||
|
2, trng_conn, None
|
||||||
|
).expect("GAM: couldn't create content canvas");
|
||||||
|
canvases.push(content_canvas).expect("GAM: can't store content canvas");
|
||||||
|
|
||||||
|
Ok(ChatLayout {
|
||||||
|
status: status_canvas.gid(),
|
||||||
|
content: content_canvas.gid(),
|
||||||
|
predictive: predictive_canvas.gid(),
|
||||||
|
input: input_canvas.gid(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
|
|
@ -35,52 +121,21 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
let screensize = graphics_server::screen_size(gfx_conn).expect("GAM: Couldn't get screen size");
|
let screensize = graphics_server::screen_size(gfx_conn).expect("GAM: Couldn't get screen size");
|
||||||
|
|
||||||
graphics_server::set_glyph_style(gfx_conn, GlyphStyle::Small).expect("GAM: couldn't set glyph style");
|
|
||||||
let (_, small_height_tuple) = graphics_server::query_glyph(gfx_conn).expect("GAM: couldn't get glyph height");
|
|
||||||
let small_height: i16 = small_height_tuple as i16;
|
|
||||||
graphics_server::set_glyph_style(gfx_conn, GlyphStyle::Regular).expect("GAM: couldn't set glyph style");
|
|
||||||
let (_, regular_height_tuple) = graphics_server::query_glyph(gfx_conn).expect("GAM: couldn't get glyph height");
|
|
||||||
let regular_height: i16 = regular_height_tuple as i16;
|
|
||||||
|
|
||||||
let mut canvases: BinaryHeap<Canvas, U32, Max> = BinaryHeap::new();
|
let mut canvases: BinaryHeap<Canvas, U32, Max> = BinaryHeap::new();
|
||||||
let mut status_canvas = Canvas::new(
|
let modallayout = add_modal_layout(trng_conn, &mut canvases).expect("GAM: can't add modal layouts");
|
||||||
Rectangle::new_coords(0, 0, screensize.x, small_height),
|
let chatlayout = add_chat_layout(gfx_conn, trng_conn, &mut canvases).expect("GAM: couldn't create chat layout");
|
||||||
0, trng_conn, None
|
|
||||||
).expect("GAM: couldn't create status canvas");
|
|
||||||
canvases.push(status_canvas).expect("GAM: can't store status canvus");
|
|
||||||
|
|
||||||
let mut password_canvas = Canvas::new(
|
// canvas_map is a copy of the canvases, but searchable by GID
|
||||||
Rectangle::new_coords(-1, -1, -1, -1),
|
let canvas_map: FnvIndexMap<Gid, Canvas, U32>;
|
||||||
0, trng_conn, None
|
|
||||||
).expect("GAM: couldn't create password canvas");
|
|
||||||
canvases.push(password_canvas).expect("GAM: can't store password canvas");
|
|
||||||
|
|
||||||
let mut predictive_canvas = Canvas::new(
|
// now that all the initial canvases have been allocated, compute what canvases are drawable
|
||||||
Rectangle::new_coords(0, screensize.y - regular_height, screensize.x, screensize.y),
|
// this _replaces_ the original canvas structure, to avoid complications of tracking mutable references through compound data structures
|
||||||
1,
|
|
||||||
trng_conn, None
|
|
||||||
).expect("GAM: couldn't create predictive text canvas");
|
|
||||||
canvases.push(predictive_canvas).expect("GAM: couldn't store predictive canvas");
|
|
||||||
|
|
||||||
let mut input_canvas = Canvas::new(
|
|
||||||
Rectangle::new_v_stack(predictive_canvas.clip_rect(), -regular_height),
|
|
||||||
1, trng_conn, None
|
|
||||||
).expect("GAM: couldn't create input text canvas");
|
|
||||||
canvases.push(input_canvas).expect("GAM: couldn't store input canvas");
|
|
||||||
|
|
||||||
let mut content_canvas = Canvas::new(
|
|
||||||
Rectangle::new_v_span(status_canvas.clip_rect(), input_canvas.clip_rect()),
|
|
||||||
2, trng_conn, None
|
|
||||||
).expect("GAM: couldn't create content canvas");
|
|
||||||
canvases.push(content_canvas).expect("GAM: can't store content canvas");
|
|
||||||
|
|
||||||
let mut canvas_map: FnvIndexMap<[u32;4], Canvas, U32>;
|
|
||||||
// this is broken into two steps because of https://github.com/rust-lang/rust/issues/71126
|
// this is broken into two steps because of https://github.com/rust-lang/rust/issues/71126
|
||||||
let (c_tuple, m_tuple) = recompute_canvases(canvases, Rectangle::new(Point::new(0, 0), screensize));
|
let (c_tuple, m_tuple) = recompute_canvases(canvases, Rectangle::new(Point::new(0, 0), screensize));
|
||||||
canvases = c_tuple; canvas_map = m_tuple;
|
canvases = c_tuple; canvas_map = m_tuple;
|
||||||
|
|
||||||
// make a thread to manage the status bar
|
// make a thread to manage the status bar
|
||||||
xous::create_thread_simple(status_thread, status_canvas.gid()).expect("GAM: couldn't create status thread");
|
xous::create_thread_simple(status_thread, chatlayout.status).expect("GAM: couldn't create status thread");
|
||||||
|
|
||||||
let gam_sid = xous_names::register_name(xous::names::SERVER_NAME_GAM).expect("GAM: can't register server");
|
let gam_sid = xous_names::register_name(xous::names::SERVER_NAME_GAM).expect("GAM: can't register server");
|
||||||
|
|
||||||
|
|
@ -108,6 +163,16 @@ fn xmain() -> ! {
|
||||||
},
|
},
|
||||||
_ => todo!("GAM: opcode not yet implemented"),
|
_ => todo!("GAM: opcode not yet implemented"),
|
||||||
}
|
}
|
||||||
|
} else if let xous::Message::MutableBorrow(m) = &envelope.body {
|
||||||
|
match TextOp::from(m.id) {
|
||||||
|
TextOp::Nop => (),
|
||||||
|
TextOp::Render => {
|
||||||
|
|
||||||
|
},
|
||||||
|
TextOp::ComputeBounds => {
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => xous::yield_slice(),
|
_ => xous::yield_slice(),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
|
use crate::api::*;
|
||||||
|
|
||||||
pub fn status_thread(status_gid: [u32; 4]) {
|
pub fn status_thread(status_gid: Gid) {
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue