create_desktop in kernel can run correctly
This commit is contained in:
parent
5b0c372507
commit
c348cbdbfa
5 changed files with 38 additions and 23 deletions
|
@ -1,7 +1,14 @@
|
|||
use alloc::{sync::Arc, vec::{Vec, }, string::ToString};
|
||||
use embedded_graphics::{prelude::{Point, Size}, primitives::arc};
|
||||
use alloc::{string::ToString, sync::Arc, vec::Vec};
|
||||
use embedded_graphics::{
|
||||
prelude::{Point, Size},
|
||||
primitives::arc,
|
||||
};
|
||||
|
||||
use crate::{gui::{Component, Panel, ImageComp, IconController, Terminal, Button}, fs::ROOT_INODE, sync::UPIntrFreeCell};
|
||||
use crate::{
|
||||
fs::ROOT_INODE,
|
||||
gui::{Button, Component, IconController, ImageComp, Panel, Terminal},
|
||||
sync::UPIntrFreeCell,
|
||||
};
|
||||
|
||||
static DT: &[u8] = include_bytes!("../assert/desktop.bmp");
|
||||
|
||||
|
@ -15,8 +22,9 @@ lazy_static::lazy_static!(
|
|||
);
|
||||
|
||||
pub fn create_desktop() -> isize {
|
||||
let mut p:Arc<dyn Component + 'static> = Arc::new(Panel::new(Size::new(1024, 768), Point::new(0, 0)));
|
||||
let image = ImageComp::new(Size::new(1024, 768),Point::new(0, 0),DT,Some(p.clone()));
|
||||
let mut p: Arc<dyn Component + 'static> =
|
||||
Arc::new(Panel::new(Size::new(1024, 768), Point::new(0, 0)));
|
||||
let image = ImageComp::new(Size::new(1024, 768), Point::new(0, 0), DT, Some(p.clone()));
|
||||
let icon = IconController::new(ROOT_INODE.ls(), Some(p.clone()));
|
||||
p.add(Arc::new(image));
|
||||
p.add(Arc::new(icon));
|
||||
|
@ -30,17 +38,20 @@ pub fn create_desktop() -> isize {
|
|||
|
||||
pub fn create_terminal() {
|
||||
let desktop = DESKTOP.exclusive_access();
|
||||
let arc_t = Arc::new(
|
||||
Terminal::new(
|
||||
Size::new(400, 400),
|
||||
Point::new(200, 100),
|
||||
Some(desktop.clone()),
|
||||
Some("demo.txt".to_string()),
|
||||
"".to_string()
|
||||
)
|
||||
);
|
||||
let arc_t = Arc::new(Terminal::new(
|
||||
Size::new(400, 400),
|
||||
Point::new(200, 100),
|
||||
Some(desktop.clone()),
|
||||
Some("demo.txt".to_string()),
|
||||
"".to_string(),
|
||||
));
|
||||
let text = Panel::new(Size::new(400, 400), Point::new(200, 100));
|
||||
let button = Button::new(Size::new(20, 20), Point::new(370, 10), Some(arc_t.clone()), "X".to_string());
|
||||
let button = Button::new(
|
||||
Size::new(20, 20),
|
||||
Point::new(370, 10),
|
||||
Some(arc_t.clone()),
|
||||
"X".to_string(),
|
||||
);
|
||||
arc_t.add(Arc::new(text));
|
||||
arc_t.add(Arc::new(button));
|
||||
arc_t.paint();
|
||||
|
@ -48,4 +59,3 @@ pub fn create_terminal() {
|
|||
let mut pad = PAD.exclusive_access();
|
||||
*pad = Some(arc_t);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue