1
1
use alloc:: string:: String ;
2
2
use liumlib:: gui:: * ;
3
- use liumlib:: * ;
4
3
5
4
#[ derive( Debug , Clone ) ]
6
5
pub struct ApplicationWindow {
@@ -13,8 +12,8 @@ pub struct ApplicationWindow {
13
12
impl ApplicationWindow {
14
13
pub fn new ( w : u64 , h : u64 , title : String ) -> Self {
15
14
let window_buffer = match create_window ( w as usize , h as usize ) {
16
- Err ( _) => panic ! ( "Failed to create window" ) ,
17
15
Ok ( w) => w,
16
+ Err ( e) => panic ! ( "Failed to create an application window: {:?}" , e) ,
18
17
} ;
19
18
20
19
Self {
@@ -28,15 +27,66 @@ impl ApplicationWindow {
28
27
pub fn initialize ( & mut self ) {
29
28
match draw_rect (
30
29
& self . buffer ,
31
- 0xffffff ,
30
+ 0xffffff , // color (red, green, blue)
32
31
0 ,
33
32
0 ,
34
33
self . width as i64 ,
35
34
self . height as i64 ,
36
35
) {
37
36
Ok ( ( ) ) => { }
38
- Err ( e) => println ! ( "{ }" , e) ,
37
+ Err ( e) => panic ! ( "Failed to draw a background window: {:? }" , e) ,
39
38
} ;
39
+
40
+ // address bar
41
+ match draw_rect (
42
+ & self . buffer ,
43
+ 0x2222ff , // color (red, green, blue)
44
+ 1 , // px
45
+ 1 , // py
46
+ self . width as i64 - 2 , // w
47
+ 20 , // h
48
+ ) {
49
+ Ok ( ( ) ) => { }
50
+ Err ( e) => panic ! ( "Failed to draw a bar: {:?}" , e) ,
51
+ } ;
52
+
53
+ // close button
54
+ match draw_rect (
55
+ & self . buffer ,
56
+ 0xff3333 , // color (red, green, blue)
57
+ self . width as i64 - 20 , // px
58
+ 3 , // py
59
+ 16 , // w
60
+ 16 , // h
61
+ ) {
62
+ Ok ( ( ) ) => { }
63
+ Err ( e) => panic ! ( "Failed to draw a close button: {:?}" , e) ,
64
+ } ;
65
+
66
+ match draw_line (
67
+ & self . buffer ,
68
+ 0xffffff , // color
69
+ self . width as i64 - 20 , // x0
70
+ 3 , // y0
71
+ self . width as i64 - 5 , // x1
72
+ 18 , // y1
73
+ ) {
74
+ Ok ( ( ) ) => { }
75
+ Err ( e) => panic ! ( "Failed to draw a line: {:?}" , e) ,
76
+ } ;
77
+
78
+ match draw_line (
79
+ & self . buffer ,
80
+ 0xffffff , // color
81
+ self . width as i64 - 5 , // x0
82
+ 3 , // y0
83
+ self . width as i64 - 20 , // x1
84
+ 18 , // y1
85
+ ) {
86
+ Ok ( ( ) ) => { }
87
+ Err ( e) => panic ! ( "Failed to draw a line: {:?}" , e) ,
88
+ } ;
89
+
40
90
self . buffer . flush ( ) ;
41
91
}
42
92
}
0 commit comments