1 use starry_server::core::{SCREEN_HEIGHT, SCREEN_WIDTH}; 2 use starry_toolkit::{ 3 base::{panel::Panel, rect::Rect}, 4 traits::{place::Place, text::Text}, 5 widgets::{image::Image, label::Label}, 6 }; 7 8 const IMAGE_PATH: &[u8] = include_bytes!("./asset/desktop_bg.png"); 9 10 fn main() { 11 let panel = Panel::new( 12 Rect::new(0, 0, SCREEN_WIDTH as u32, SCREEN_HEIGHT as u32), 13 "Title", 14 ); 15 16 // Label 17 let label = Label::new(); 18 label.position(100, 100); 19 label.text("hello world"); 20 label.text_offset(50, 50); 21 panel.add_child(&label); 22 23 // Image 24 let image = Image::from_path(IMAGE_PATH).unwrap(); 25 image.position(0, SCREEN_HEIGHT as i32 / 2); 26 image.size(SCREEN_WIDTH as u32, SCREEN_HEIGHT as u32 / 2); 27 panel.add_child(&image); 28 29 panel.draw(); 30 31 // 便于观察结果 32 loop {} 33 } 34