xref: /StarryEngine/starry_toolkit/src/main.rs (revision 49182ea7bc0263215864dd04cd265e345a4af8f5)
1 use starry_server::core::{SCREEN_HEIGHT, SCREEN_WIDTH};
2 use starry_toolkit::{
3     base::{panel::Panel, rect::Rect},
4     layout::grid::Grid,
5     traits::{text::Text, transform::Transform},
6     widgets::label::Label,
7 };
8 
9 fn main() {
10     let panel = Panel::new(
11         Rect::new(0, 0, SCREEN_WIDTH as u32, SCREEN_HEIGHT as u32),
12         "Title",
13     );
14 
15     let label1 = Label::new();
16     label1.text("hello world");
17 
18     let label2 = Label::new();
19     label2.text("hello world");
20 
21     let label3 = Label::new();
22     label3.text("hello world");
23 
24     let grid = Grid::new();
25     grid.set_space(10, 10);
26     grid.resize(500, 500);
27     grid.set_max_columns(2);
28     grid.add(&label1);
29     grid.add(&label2);
30     grid.add(&label3);
31 
32     panel.add_child(&grid);
33 
34     // // Image
35     // let image = Image::from_path(IMAGE_PATH).unwrap();
36     // image.reposition(0, SCREEN_HEIGHT as i32 / 2);
37     // image.resize(SCREEN_WIDTH as u32, SCREEN_HEIGHT as u32 / 2);
38     // panel.add_child(&image);
39 
40     panel.draw();
41 
42     // 便于观察结果
43     loop {}
44 }
45