2021-03-07 10:58:48 +00:00
|
|
|
use graphics_server::api::{Rectangle, TextView, Gid, Line, RoundedRectangle, Circle, Point};
|
2021-03-26 12:22:33 +00:00
|
|
|
use xous_ipc::String;
|
2021-01-17 09:02:40 +00:00
|
|
|
|
2021-04-04 21:47:17 +00:00
|
|
|
pub(crate) const SERVER_NAME_GAM: &str = "_Graphical Abstraction Manager_";
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-02-28 20:01:33 +00:00
|
|
|
pub enum GamObjectType {
|
|
|
|
|
Line(Line),
|
|
|
|
|
Circ(Circle),
|
|
|
|
|
Rect(Rectangle),
|
|
|
|
|
RoundRect(RoundedRectangle),
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-02-28 20:01:33 +00:00
|
|
|
pub struct GamObject {
|
|
|
|
|
pub canvas: Gid,
|
|
|
|
|
pub obj: GamObjectType,
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-03-07 10:58:48 +00:00
|
|
|
pub struct SetCanvasBoundsRequest {
|
|
|
|
|
pub canvas: Gid,
|
|
|
|
|
pub requested: Point,
|
|
|
|
|
pub granted: Option<Point>,
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-03-09 16:25:14 +00:00
|
|
|
pub struct ContentCanvasRequest {
|
|
|
|
|
// return value of the canvas Gid
|
|
|
|
|
pub canvas: Gid,
|
|
|
|
|
// name of the server requesting the content canvas
|
2021-03-26 12:22:33 +00:00
|
|
|
pub servername: String<256>,
|
2021-04-05 15:50:00 +00:00
|
|
|
// redraw message scalar ID - to be sent back to the requestor in case a redraw is required
|
|
|
|
|
pub redraw_scalar_id: usize,
|
2021-03-09 16:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-04 21:47:17 +00:00
|
|
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
2021-03-13 10:05:33 +00:00
|
|
|
pub(crate) enum Opcode {
|
2021-01-16 20:02:08 +00:00
|
|
|
// clears a canvas with a given GID
|
2021-04-04 21:47:17 +00:00
|
|
|
ClearCanvas, //(Gid),
|
2021-01-16 20:02:08 +00:00
|
|
|
|
2021-03-07 10:58:48 +00:00
|
|
|
// return the dimensions of a canvas as a Point (the top left is always (0,0))
|
2021-04-04 21:47:17 +00:00
|
|
|
GetCanvasBounds, //(Gid),
|
2021-03-07 10:58:48 +00:00
|
|
|
|
|
|
|
|
// request a new size for my canvas.
|
|
|
|
|
// This normally will be denied, unless the requested Gid corresponds to a special canvas that allows resizing.
|
2021-04-04 21:47:17 +00:00
|
|
|
SetCanvasBounds, //(SetCanvasBoundsRequest),
|
2021-03-07 10:58:48 +00:00
|
|
|
|
|
|
|
|
// draws an object
|
2021-04-04 21:47:17 +00:00
|
|
|
RenderObject, //(GamObject),
|
2021-03-07 10:58:48 +00:00
|
|
|
|
2021-01-16 20:02:08 +00:00
|
|
|
// renders a TextView
|
2021-04-04 21:47:17 +00:00
|
|
|
RenderTextView, //(TextView),
|
2021-01-16 20:02:08 +00:00
|
|
|
|
2021-03-08 18:32:36 +00:00
|
|
|
// forces a redraw (which also does defacement, etc.)
|
|
|
|
|
Redraw,
|
|
|
|
|
|
2021-03-09 16:25:14 +00:00
|
|
|
// returns a GID to the "content" Canvas; currently, anyone can request it and draw to it, but maybe that policy should be stricter.
|
|
|
|
|
// the Gid argument is the rkyv return value.
|
2021-04-04 21:47:17 +00:00
|
|
|
RequestContentCanvas, //(ContentCanvasRequest),
|
2021-03-07 10:58:48 +00:00
|
|
|
|
2021-03-10 17:45:54 +00:00
|
|
|
// Requests setting the UI to the power down screen
|
|
|
|
|
PowerDownRequest,
|
|
|
|
|
|
2021-03-09 16:25:14 +00:00
|
|
|
/////// planned
|
2021-01-16 20:02:08 +00:00
|
|
|
|
|
|
|
|
// hides a canvas with a given GID
|
2021-04-04 21:47:17 +00:00
|
|
|
//HideCanvas(Gid),
|
2021-01-16 20:02:08 +00:00
|
|
|
|
|
|
|
|
// indicates if the current UI layout requires an input field
|
2021-04-04 21:47:17 +00:00
|
|
|
//HasInput(bool),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
|
|
|
|
pub(crate) enum Return {
|
|
|
|
|
RenderReturn(TextView),
|
|
|
|
|
SetCanvasBoundsReturn(SetCanvasBoundsRequest),
|
|
|
|
|
ContentCanvasReturn(ContentCanvasRequest),
|
|
|
|
|
Failure,
|
2021-01-16 20:02:08 +00:00
|
|
|
}
|