mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
clean up ux-api to be no-std clean
ux-api can't do rkyv derives and rely on std items in a no-std environment. This is necessary because some of the base layer APIs (frame buffers, points, etc.) are relied upon in a no-std loader environment to render diagnostics to the screen. Thus ux-api needs to have a baseline of primitives available without a std flag.
This commit is contained in:
parent
1dcf7b191b
commit
2235f7a3f1
11 changed files with 56 additions and 29 deletions
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
xous = "0.9.64"
|
||||
xous-ipc = "0.10.4"
|
||||
xous-ipc = { version = "0.10.4", optional = true }
|
||||
log = "0.4.14"
|
||||
num-derive = { version = "0.4.2", default-features = false }
|
||||
num-traits = { version = "0.2.14", default-features = false }
|
||||
|
|
@ -18,13 +18,15 @@ enum_dispatch = "0.3.7"
|
|||
blitstr2 = { path = "../blitstr2", optional = true }
|
||||
|
||||
# used in notifications
|
||||
locales = { path = "../../locales" }
|
||||
qrcode = { version = "0.12", default-features = false }
|
||||
locales = { path = "../../locales", optional = true }
|
||||
qrcode = { version = "0.12", default-features = false, optional = true }
|
||||
|
||||
# used in bip39 dialogue
|
||||
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
|
||||
sha2 = { version = "0.10.8" }
|
||||
digest = "0.9.0"
|
||||
hex = { version = "0.4.3", default-features = false, features = [
|
||||
"alloc",
|
||||
], optional = true }
|
||||
sha2 = { version = "0.10.8", optional = true }
|
||||
digest = { version = "0.9.0", optional = true }
|
||||
|
||||
[features]
|
||||
# various feature gates - recommended to be selective about these because
|
||||
|
|
@ -50,7 +52,9 @@ default-widgets = [
|
|||
|
||||
# board definition is used to define things like the size of the screen.
|
||||
board-baosec = ["blitstr2/board-baosec"]
|
||||
loader-baosec = []
|
||||
board-baosor = []
|
||||
loader-baosor = []
|
||||
hosted-baosec = ["blitstr2/hosted-baosec"]
|
||||
|
||||
# Used by font codegen routine
|
||||
|
|
@ -58,6 +62,7 @@ hosted = ["blitstr2/hosted"]
|
|||
renode = ["blitstr2/renode"]
|
||||
cramium-soc = []
|
||||
precursor = ["blitstr2/precursor"]
|
||||
derive-rkyv = ["rkyv"]
|
||||
|
||||
std = ["rkyv"]
|
||||
std = ["derive-rkyv", "locales", "qrcode", "xous-ipc", "hex", "sha2", "digest"]
|
||||
default = ["std", "default-widgets"]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod minigfx;
|
||||
pub mod widgets;
|
||||
mod wordwrap;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod cursor;
|
||||
mod fontmap;
|
||||
pub mod minigfx;
|
||||
pub mod platform;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod widgets;
|
||||
#[cfg(feature = "std")]
|
||||
mod wordwrap;
|
||||
#[cfg(feature = "std")]
|
||||
pub const SYSTEM_STYLE: blitstr2::GlyphStyle = blitstr2::GlyphStyle::Tall;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::minigfx::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Circle {
|
||||
pub center: Point,
|
||||
pub radius: isize,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ use crate::minigfx::Point;
|
|||
/// Cursor specifies a drawing position along a line of text. Lines of text can
|
||||
/// be different heights. Line_height is for keeping track of the tallest
|
||||
/// character that has been drawn so far on the current line.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct Cursor {
|
||||
pub pt: Point,
|
||||
pub line_height: usize,
|
||||
|
|
|
|||
|
|
@ -8,12 +8,19 @@ pub mod style;
|
|||
pub use style::*;
|
||||
pub mod circle;
|
||||
pub use circle::*;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod textview;
|
||||
#[cfg(feature = "std")]
|
||||
pub use textview::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub mod cursor;
|
||||
#[cfg(feature = "std")]
|
||||
pub use cursor::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub(crate) mod op;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use blitstr2::GlyphSprite;
|
||||
|
||||
/// Abstract trait for a FrameBuffer. Slower than native manipulation
|
||||
|
|
@ -35,6 +42,7 @@ pub trait FrameBuffer {
|
|||
/// defined by its `bb` record. The intention is that this abstract representation can be passed directly to
|
||||
/// a rasterizer for rendering.
|
||||
#[derive(Debug)]
|
||||
#[cfg(feature = "std")]
|
||||
pub(crate) struct TypesetWord {
|
||||
/// glyph data to directly render the word
|
||||
pub gs: Vec<GlyphSprite>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::ops::{Add, AddAssign, Div, DivAssign, Index, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct Point {
|
||||
pub x: isize,
|
||||
pub y: isize,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ use core::cmp::{max, min};
|
|||
|
||||
use crate::minigfx::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Rectangle {
|
||||
pub tl: Point,
|
||||
pub br: Point,
|
||||
|
|
@ -193,7 +194,8 @@ impl Rectangle {
|
|||
}
|
||||
|
||||
//////////////////////// Rounded Rectangle
|
||||
#[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct RoundedRectangle {
|
||||
pub border: Rectangle, // drawstyle is inherited from the Rectangle
|
||||
pub radius: isize,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use crate::minigfx::Point;
|
||||
|
||||
/// Type wrapper for native colors
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub struct ColorNative(pub usize);
|
||||
impl From<usize> for ColorNative {
|
||||
fn from(value: usize) -> Self { Self { 0: value } }
|
||||
|
|
@ -11,7 +12,8 @@ impl Into<usize> for ColorNative {
|
|||
}
|
||||
|
||||
/// Style properties for an object
|
||||
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct DrawStyle {
|
||||
/// Fill colour of the object
|
||||
pub fill_color: Option<ColorNative>,
|
||||
|
|
@ -40,7 +42,8 @@ impl Default for DrawStyle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum PixelColor {
|
||||
Dark,
|
||||
Light,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use core::ops::Add;
|
||||
|
||||
use String;
|
||||
use blitstr2::GlyphStyle;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// coordinates are local to the canvas, not absolute to the screen
|
||||
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum TextBounds {
|
||||
// fixed width and height in a rectangle
|
||||
BoundingBox(Rectangle),
|
||||
|
|
@ -46,7 +46,8 @@ impl TextBounds {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, PartialEq)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
// operations that may be requested of a TextView when sent to GAM
|
||||
pub enum TextOp {
|
||||
Nop,
|
||||
|
|
@ -76,7 +77,8 @@ impl From<usize> for TextOp {
|
|||
pub const TEXTVIEW_LEN: usize = 3072;
|
||||
pub const TEXTVIEW_DEFAULT_STYLE: GlyphStyle = GlyphStyle::Regular;
|
||||
|
||||
#[derive(Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||
#[derive(Clone)]
|
||||
pub struct TextView {
|
||||
// this is the operation as specified for the GAM. Note this is different from the "op" when sent to
|
||||
// graphics-server only the GAM should be sending TextViews to the graphics-server, and a different
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#[cfg(any(feature = "board-baosec", feature = "hosted-baosec"))]
|
||||
#[cfg(any(feature = "board-baosec", feature = "hosted-baosec", feature = "loader-baosec"))]
|
||||
mod baosec;
|
||||
#[cfg(any(feature = "board-baosec", feature = "hosted-baosec"))]
|
||||
#[cfg(any(feature = "board-baosec", feature = "hosted-baosec", feature = "loader-baosec"))]
|
||||
pub use baosec::*;
|
||||
|
||||
#[cfg(feature = "board-baosor")]
|
||||
#[cfg(any(feature = "board-baosor", feature = "loader-baosor"))]
|
||||
mod baosor;
|
||||
#[cfg(feature = "board-baosor")]
|
||||
#[cfg(any(feature = "board-baosor", feature = "loader-baosor"))]
|
||||
pub use baosor::*;
|
||||
|
|
|
|||
|
|
@ -227,7 +227,9 @@ fn layout(modal: &mut Modal, top_text: Option<&str>, bot_text: Option<&str>, sty
|
|||
|
||||
// compute height of action item
|
||||
log::trace!("step 1 total_height: {}", total_height);
|
||||
total_height += modal.action.height(modal.line_height, modal.margin, &modal);
|
||||
total_height +=
|
||||
modal.action.height(modal.line_height.try_into().unwrap(), modal.margin.try_into().unwrap(), &modal)
|
||||
as isize;
|
||||
total_height += modal.margin;
|
||||
|
||||
// compute height of bot_text, if any
|
||||
|
|
|
|||
Loading…
Reference in a new issue