2021-01-04 20:45:23 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
2021-01-16 20:02:08 +00:00
|
|
|
/*
|
|
|
|
|
Primitives needed:
|
|
|
|
|
|
|
|
|
|
- clipping rectangles (for drawing)
|
|
|
|
|
- rounded rectangles
|
|
|
|
|
- inverse text
|
|
|
|
|
- icons/sprites
|
|
|
|
|
- width of a text string with a given font (to compute alignments)
|
|
|
|
|
- untrusted backgrounds
|
|
|
|
|
- bitmaps
|
|
|
|
|
|
|
|
|
|
*/
|
2020-12-02 17:48:10 +00:00
|
|
|
|
2021-01-19 09:10:31 +00:00
|
|
|
//////////////// primitives
|
|
|
|
|
pub mod points;
|
|
|
|
|
pub use points::Point;
|
|
|
|
|
pub mod styles;
|
|
|
|
|
pub use styles::*;
|
|
|
|
|
pub mod shapes;
|
|
|
|
|
pub use shapes::*;
|
|
|
|
|
pub mod text;
|
|
|
|
|
pub use text::*;
|
2020-12-02 17:48:10 +00:00
|
|
|
|
2021-01-19 09:10:31 +00:00
|
|
|
use hash32::{Hash, Hasher};
|
2020-12-02 17:48:10 +00:00
|
|
|
|
2021-04-02 16:53:30 +00:00
|
|
|
//////////////// IPC APIs
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
2021-01-19 09:10:31 +00:00
|
|
|
pub struct Gid {
|
|
|
|
|
/// a 128-bit random identifier for graphical objects
|
|
|
|
|
gid: [u32; 4],
|
2020-08-29 17:17:56 +00:00
|
|
|
}
|
2021-01-19 09:10:31 +00:00
|
|
|
impl Gid {
|
|
|
|
|
pub fn new(id: [u32; 4]) -> Self { Gid{gid: id} }
|
|
|
|
|
pub fn gid(&self) -> [u32; 4] { self.gid }
|
2020-12-02 17:48:10 +00:00
|
|
|
}
|
2021-01-19 09:10:31 +00:00
|
|
|
impl hash32::Hash for Gid {
|
|
|
|
|
fn hash<H>(&self, state: &mut H)
|
|
|
|
|
where
|
|
|
|
|
H: Hasher,
|
|
|
|
|
{
|
|
|
|
|
Hash::hash(&self.gid[..], state);
|
2020-12-02 17:48:10 +00:00
|
|
|
}
|
2020-11-22 16:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-02 16:53:30 +00:00
|
|
|
pub const SERVER_NAME_GFX: &str = "_Graphics_";
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
2021-04-02 16:57:30 +00:00
|
|
|
pub(crate) enum Opcode {
|
2020-08-29 17:17:56 +00:00
|
|
|
/// Flush the buffer to the screen
|
|
|
|
|
Flush,
|
|
|
|
|
|
2020-12-02 17:48:10 +00:00
|
|
|
/// Clear the buffer to "light" colored pixels
|
|
|
|
|
Clear,
|
2020-08-29 17:17:56 +00:00
|
|
|
|
|
|
|
|
/// Draw a line at the specified area
|
2021-04-02 16:53:30 +00:00
|
|
|
Line, //(Line),
|
2020-08-29 17:17:56 +00:00
|
|
|
|
|
|
|
|
/// Draw a rectangle or square at the specified coordinates
|
2021-04-02 16:53:30 +00:00
|
|
|
Rectangle, //(Rectangle),
|
2020-08-29 17:17:56 +00:00
|
|
|
|
2021-02-28 20:01:33 +00:00
|
|
|
/// Draw a rounded rectangle
|
2021-04-02 16:53:30 +00:00
|
|
|
RoundedRectangle, //(RoundedRectangle),
|
2021-02-28 20:01:33 +00:00
|
|
|
|
2020-08-29 17:17:56 +00:00
|
|
|
/// Draw a circle with a specified radius
|
2021-04-02 16:53:30 +00:00
|
|
|
Circle, //(Circle),
|
2021-01-18 16:05:33 +00:00
|
|
|
|
2020-11-23 06:55:56 +00:00
|
|
|
/// Retrieve the X and Y dimensions of the screen
|
|
|
|
|
ScreenSize,
|
2020-11-23 07:42:58 +00:00
|
|
|
|
2021-01-17 20:12:40 +00:00
|
|
|
/// gets info about the current glyph to assist with layout
|
2021-04-02 16:53:30 +00:00
|
|
|
QueryGlyphProps, //(GlyphStyle),
|
2021-01-18 20:54:54 +00:00
|
|
|
|
2021-03-05 17:10:18 +00:00
|
|
|
/// draws a textview
|
2021-04-02 16:53:30 +00:00
|
|
|
DrawTextView, //(TextView),
|
2021-03-05 17:10:18 +00:00
|
|
|
|
|
|
|
|
/// draws an object that requires clipping
|
2021-04-02 16:53:30 +00:00
|
|
|
DrawClipObject, //(ClipObject),
|
2021-03-10 17:45:54 +00:00
|
|
|
|
|
|
|
|
/// draws the sleep screen; assumes requests are vetted by GAM/xous-names
|
|
|
|
|
DrawSleepScreen
|
2020-08-29 17:17:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-03-05 17:10:18 +00:00
|
|
|
pub enum ClipObjectType {
|
|
|
|
|
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-03-05 17:10:18 +00:00
|
|
|
pub struct ClipObject {
|
|
|
|
|
pub clip: Rectangle,
|
|
|
|
|
pub obj: ClipObjectType,
|
|
|
|
|
}
|