mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
vault: use platform-neutral ux-api instead of graphics-server
This commit is contained in:
parent
09bf7f00e4
commit
81a9355ef8
4 changed files with 20 additions and 19 deletions
|
|
@ -16,7 +16,6 @@ rkyv = { version = "0.8.8", default-features = false, features = [
|
||||||
log-server = { package = "xous-api-log", version = "0.1.63" }
|
log-server = { package = "xous-api-log", version = "0.1.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" }
|
|
||||||
locales = { path = "../../locales" }
|
locales = { path = "../../locales" }
|
||||||
tts-frontend = { path = "../../services/tts" }
|
tts-frontend = { path = "../../services/tts" }
|
||||||
usb-device-xous = { path = "../../services/usb-device-xous" }
|
usb-device-xous = { path = "../../services/usb-device-xous" }
|
||||||
|
|
@ -34,6 +33,7 @@ subtle = { version = "2.5.0", features = ["core_hint_black_box"] }
|
||||||
rand_core = "0.6.3"
|
rand_core = "0.6.3"
|
||||||
ticktimer-server = { package = "xous-api-ticktimer", version = "0.9.63" }
|
ticktimer-server = { package = "xous-api-ticktimer", version = "0.9.63" }
|
||||||
userprefs = { path = "../../libs/userprefs" }
|
userprefs = { path = "../../libs/userprefs" }
|
||||||
|
ux-api = { path = "../../libs/ux-api", default-features = false }
|
||||||
|
|
||||||
# opensk
|
# opensk
|
||||||
ctap-crypto = { path = "libraries/crypto" }
|
ctap-crypto = { path = "libraries/crypto" }
|
||||||
|
|
@ -69,9 +69,9 @@ random-pick = { version = "1.2.15", optional = true }
|
||||||
enum-iterator = "0.6.0"
|
enum-iterator = "0.6.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
precursor = []
|
precursor = ["ux-api/precursor"]
|
||||||
hosted = []
|
hosted = ["ux-api/hosted"]
|
||||||
renode = []
|
renode = ["ux-api/renode"]
|
||||||
tts = []
|
tts = []
|
||||||
with_ctap1 = ["ctap-crypto/with_ctap1"]
|
with_ctap1 = ["ctap-crypto/with_ctap1"]
|
||||||
vendor_hid = []
|
vendor_hid = []
|
||||||
|
|
|
||||||
|
|
@ -478,7 +478,7 @@ impl ItemLists {
|
||||||
self.li_mut(list_type).remove(key)
|
self.li_mut(list_type).remove(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_items_per_screen(&mut self, ips: i16) {
|
pub fn set_items_per_screen(&mut self, ips: isize) {
|
||||||
self.fido.set_items_per_screen(ips as usize);
|
self.fido.set_items_per_screen(ips as usize);
|
||||||
self.totp.set_items_per_screen(ips as usize);
|
self.totp.set_items_per_screen(ips as usize);
|
||||||
self.pw.set_items_per_screen(ips as usize);
|
self.pw.set_items_per_screen(ips as usize);
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ use std::time::SystemTime;
|
||||||
|
|
||||||
use chrono::{TimeZone, Utc};
|
use chrono::{TimeZone, Utc};
|
||||||
use gam::{GlyphStyle, UxRegistration};
|
use gam::{GlyphStyle, UxRegistration};
|
||||||
use graphics_server::{DrawStyle, PixelColor, Point, Rectangle, TextView};
|
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use sntpc::{Error, NtpContext, NtpTimestampGenerator, NtpUdpSocket, Result};
|
use sntpc::{Error, NtpContext, NtpTimestampGenerator, NtpUdpSocket, Result};
|
||||||
|
use ux_api::minigfx::*;
|
||||||
use xous::{Message, send_message};
|
use xous::{Message, send_message};
|
||||||
|
|
||||||
use crate::VaultOp;
|
use crate::VaultOp;
|
||||||
|
|
@ -98,7 +98,7 @@ pub(crate) fn prereqs(sid: xous::SID, time_conn: xous::CID) -> ([u32; 4], bool)
|
||||||
|
|
||||||
let mut title_text = TextView::new(
|
let mut title_text = TextView::new(
|
||||||
content,
|
content,
|
||||||
graphics_server::TextBounds::CenteredBot(Rectangle::new(
|
TextBounds::CenteredBot(Rectangle::new(
|
||||||
Point::new(0, 0),
|
Point::new(0, 0),
|
||||||
Point::new(screensize.x, 150),
|
Point::new(screensize.x, 150),
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,12 @@ use std::sync::atomic::Ordering as AtomicOrdering;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use gam::{GlyphStyle, MenuItem, MenuMatic, MenuPayload};
|
use gam::{GlyphStyle, MenuItem, MenuMatic, MenuPayload};
|
||||||
use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextView};
|
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use pddb::Pddb;
|
use pddb::Pddb;
|
||||||
use usb_device_xous::UsbDeviceType;
|
use usb_device_xous::UsbDeviceType;
|
||||||
|
use ux_api::minigfx::*;
|
||||||
|
use ux_api::service::api::*;
|
||||||
use vault::{VaultOp, utc_now};
|
use vault::{VaultOp, utc_now};
|
||||||
|
|
||||||
use crate::actions::ActionOp;
|
use crate::actions::ActionOp;
|
||||||
|
|
@ -53,8 +54,8 @@ pub struct VaultUx {
|
||||||
|
|
||||||
/// current font style
|
/// current font style
|
||||||
style: GlyphStyle,
|
style: GlyphStyle,
|
||||||
item_height: i16,
|
item_height: isize,
|
||||||
items_per_screen: i16,
|
items_per_screen: isize,
|
||||||
|
|
||||||
/// menu manager
|
/// menu manager
|
||||||
menu_mgr: MenuMatic,
|
menu_mgr: MenuMatic,
|
||||||
|
|
@ -97,7 +98,7 @@ fn style_to_name(style: &GlyphStyle) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const TITLE_HEIGHT: i16 = 26;
|
const TITLE_HEIGHT: isize = 26;
|
||||||
const VAULT_CONFIG_DICT: &'static str = "vault.config";
|
const VAULT_CONFIG_DICT: &'static str = "vault.config";
|
||||||
const VAULT_CONFIG_KEY_FONT: &'static str = "fontstyle";
|
const VAULT_CONFIG_KEY_FONT: &'static str = "fontstyle";
|
||||||
|
|
||||||
|
|
@ -123,7 +124,7 @@ impl VaultUx {
|
||||||
let style = GlyphStyle::Regular;
|
let style = GlyphStyle::Regular;
|
||||||
let available_height = screensize.y - TITLE_HEIGHT;
|
let available_height = screensize.y - TITLE_HEIGHT;
|
||||||
let glyph_height = gam.glyph_height_hint(style).unwrap();
|
let glyph_height = gam.glyph_height_hint(style).unwrap();
|
||||||
let item_height = (glyph_height * 2) as i16 + margin.y * 2 + 2; // +2 because of the border width
|
let item_height = (glyph_height * 2) as isize + margin.y * 2 + 2; // +2 because of the border width
|
||||||
let items_per_screen = available_height / item_height;
|
let items_per_screen = available_height / item_height;
|
||||||
item_lists.lock().unwrap().set_items_per_screen(items_per_screen);
|
item_lists.lock().unwrap().set_items_per_screen(items_per_screen);
|
||||||
|
|
||||||
|
|
@ -259,7 +260,7 @@ impl VaultUx {
|
||||||
}
|
}
|
||||||
let available_height = self.screensize.y - TITLE_HEIGHT;
|
let available_height = self.screensize.y - TITLE_HEIGHT;
|
||||||
let glyph_height = self.gam.glyph_height_hint(self.style).unwrap();
|
let glyph_height = self.gam.glyph_height_hint(self.style).unwrap();
|
||||||
self.item_height = (glyph_height * 2) as i16 + self.margin.y * 2 + 2; // +2 because of the border width
|
self.item_height = (glyph_height * 2) as isize + self.margin.y * 2 + 2; // +2 because of the border width
|
||||||
self.items_per_screen = available_height / self.item_height;
|
self.items_per_screen = available_height / self.item_height;
|
||||||
self.item_lists.lock().unwrap().set_items_per_screen(self.items_per_screen);
|
self.item_lists.lock().unwrap().set_items_per_screen(self.items_per_screen);
|
||||||
}
|
}
|
||||||
|
|
@ -445,7 +446,7 @@ impl VaultUx {
|
||||||
if self.title_dirty || self.action_active.load(AtomicOrdering::SeqCst) {
|
if self.title_dirty || self.action_active.load(AtomicOrdering::SeqCst) {
|
||||||
let mut title_text = TextView::new(
|
let mut title_text = TextView::new(
|
||||||
self.content,
|
self.content,
|
||||||
graphics_server::TextBounds::CenteredTop(Rectangle::new(
|
TextBounds::CenteredTop(Rectangle::new(
|
||||||
Point::new(self.margin.x, 0),
|
Point::new(self.margin.x, 0),
|
||||||
Point::new(self.screensize.x - self.margin.x, TITLE_HEIGHT),
|
Point::new(self.screensize.x - self.margin.x, TITLE_HEIGHT),
|
||||||
)),
|
)),
|
||||||
|
|
@ -460,8 +461,8 @@ impl VaultUx {
|
||||||
};
|
};
|
||||||
self.gam.post_textview(&mut title_text).expect("couldn't post title");
|
self.gam.post_textview(&mut title_text).expect("couldn't post title");
|
||||||
if mode_at_entry == VaultMode::Totp {
|
if mode_at_entry == VaultMode::Totp {
|
||||||
const BAR_HEIGHT: i16 = 5;
|
const BAR_HEIGHT: isize = 5;
|
||||||
const BAR_GAP: i16 = -10;
|
const BAR_GAP: isize = -10;
|
||||||
// draw the duration bar
|
// draw the duration bar
|
||||||
let delta = (self.current_time - (self.last_epoch * 30)) as i32;
|
let delta = (self.current_time - (self.last_epoch * 30)) as i32;
|
||||||
let width = (self.screensize.x - (self.margin.x * 2)) as i32;
|
let width = (self.screensize.x - (self.margin.x * 2)) as i32;
|
||||||
|
|
@ -472,7 +473,7 @@ impl VaultUx {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
tl: Point::new(self.margin.x, TITLE_HEIGHT - (BAR_HEIGHT + BAR_GAP)),
|
tl: Point::new(self.margin.x, TITLE_HEIGHT - (BAR_HEIGHT + BAR_GAP)),
|
||||||
br: Point::new(
|
br: Point::new(
|
||||||
self.screensize.x - self.margin.x - delta_width as i16,
|
self.screensize.x - self.margin.x - delta_width as isize,
|
||||||
TITLE_HEIGHT - BAR_GAP,
|
TITLE_HEIGHT - BAR_GAP,
|
||||||
),
|
),
|
||||||
style: DrawStyle {
|
style: DrawStyle {
|
||||||
|
|
@ -498,7 +499,7 @@ impl VaultUx {
|
||||||
if self.item_lists.lock().unwrap().filter_len(mode_at_entry) == 0 {
|
if self.item_lists.lock().unwrap().filter_len(mode_at_entry) == 0 {
|
||||||
let mut box_text = TextView::new(
|
let mut box_text = TextView::new(
|
||||||
self.content,
|
self.content,
|
||||||
graphics_server::TextBounds::CenteredBot(Rectangle::new(
|
TextBounds::CenteredBot(Rectangle::new(
|
||||||
Point::new(0, insert_at),
|
Point::new(0, insert_at),
|
||||||
Point::new(self.screensize.x, insert_at + self.item_height),
|
Point::new(self.screensize.x, insert_at + self.item_height),
|
||||||
)),
|
)),
|
||||||
|
|
@ -525,7 +526,7 @@ impl VaultUx {
|
||||||
log::debug!("drawing {}", item.name());
|
log::debug!("drawing {}", item.name());
|
||||||
let mut box_text = TextView::new(
|
let mut box_text = TextView::new(
|
||||||
self.content,
|
self.content,
|
||||||
graphics_server::TextBounds::BoundingBox(Rectangle::new(
|
TextBounds::BoundingBox(Rectangle::new(
|
||||||
Point::new(0, insert_at),
|
Point::new(0, insert_at),
|
||||||
Point::new(self.screensize.x, insert_at + self.item_height),
|
Point::new(self.screensize.x, insert_at + self.item_height),
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue