mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
format apps/hello
This commit is contained in:
parent
b479d56c10
commit
7e794b3c52
1 changed files with 10 additions and 20 deletions
|
|
@ -2,10 +2,11 @@
|
||||||
#![cfg_attr(target_os = "none", no_main)]
|
#![cfg_attr(target_os = "none", no_main)]
|
||||||
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
use graphics_server::api::GlyphStyle;
|
use graphics_server::api::GlyphStyle;
|
||||||
use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView};
|
use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView};
|
||||||
use num_traits::*;
|
|
||||||
use locales::t;
|
use locales::t;
|
||||||
|
use num_traits::*;
|
||||||
#[cfg(feature = "tts")]
|
#[cfg(feature = "tts")]
|
||||||
use tts_frontend::*;
|
use tts_frontend::*;
|
||||||
|
|
||||||
|
|
@ -51,12 +52,8 @@ impl Hello {
|
||||||
.expect("Could not register GAM UX")
|
.expect("Could not register GAM UX")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let content = gam
|
let content = gam.request_content_canvas(gam_token).expect("Could not get content canvas");
|
||||||
.request_content_canvas(gam_token)
|
let screensize = gam.get_canvas_bounds(content).expect("Could not get canvas dimensions");
|
||||||
.expect("Could not get content canvas");
|
|
||||||
let screensize = gam
|
|
||||||
.get_canvas_bounds(content)
|
|
||||||
.expect("Could not get canvas dimensions");
|
|
||||||
Self {
|
Self {
|
||||||
gam,
|
gam,
|
||||||
_gam_token: gam_token,
|
_gam_token: gam_token,
|
||||||
|
|
@ -75,11 +72,7 @@ impl Hello {
|
||||||
Rectangle::new_with_style(
|
Rectangle::new_with_style(
|
||||||
Point::new(0, 0),
|
Point::new(0, 0),
|
||||||
self.screensize,
|
self.screensize,
|
||||||
DrawStyle {
|
DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 },
|
||||||
fill_color: Some(PixelColor::Light),
|
|
||||||
stroke_color: None,
|
|
||||||
stroke_width: 0,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("can't clear content area");
|
.expect("can't clear content area");
|
||||||
|
|
@ -105,13 +98,12 @@ impl Hello {
|
||||||
text_view.clear_area = true;
|
text_view.clear_area = true;
|
||||||
text_view.rounded_border = Some(3);
|
text_view.rounded_border = Some(3);
|
||||||
text_view.style = GlyphStyle::Regular;
|
text_view.style = GlyphStyle::Regular;
|
||||||
write!(text_view.text, "{}", t!("helloworld.hello", locales::LANG)).expect("Could not write to text view");
|
write!(text_view.text, "{}", t!("helloworld.hello", locales::LANG))
|
||||||
#[cfg(feature="tts")]
|
.expect("Could not write to text view");
|
||||||
|
#[cfg(feature = "tts")]
|
||||||
self.tts.tts_simple(t!("helloworld.hello", locales::LANG)).unwrap();
|
self.tts.tts_simple(t!("helloworld.hello", locales::LANG)).unwrap();
|
||||||
|
|
||||||
self.gam
|
self.gam.post_textview(&mut text_view).expect("Could not render text view");
|
||||||
.post_textview(&mut text_view)
|
|
||||||
.expect("Could not render text view");
|
|
||||||
self.gam.redraw().expect("Could not redraw screen");
|
self.gam.redraw().expect("Could not redraw screen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -124,9 +116,7 @@ fn main() -> ! {
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
|
||||||
// Register the server with xous
|
// Register the server with xous
|
||||||
let sid = xns
|
let sid = xns.register_name(SERVER_NAME_HELLO, None).expect("can't register server");
|
||||||
.register_name(SERVER_NAME_HELLO, None)
|
|
||||||
.expect("can't register server");
|
|
||||||
|
|
||||||
let mut hello = Hello::new(&xns, sid);
|
let mut hello = Hello::new(&xns, sid);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue