Skip to content

Commit d6fb05c

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/main'
2 parents 0995c00 + 515fd53 commit d6fb05c

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

app/browser-rs/src/gui.rs

+54-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use alloc::string::String;
22
use liumlib::gui::*;
3-
use liumlib::*;
43

54
#[derive(Debug, Clone)]
65
pub struct ApplicationWindow {
@@ -13,8 +12,8 @@ pub struct ApplicationWindow {
1312
impl ApplicationWindow {
1413
pub fn new(w: u64, h: u64, title: String) -> Self {
1514
let window_buffer = match create_window(w as usize, h as usize) {
16-
Err(_) => panic!("Failed to create window"),
1715
Ok(w) => w,
16+
Err(e) => panic!("Failed to create an application window: {:?}", e),
1817
};
1918

2019
Self {
@@ -28,15 +27,66 @@ impl ApplicationWindow {
2827
pub fn initialize(&mut self) {
2928
match draw_rect(
3029
&self.buffer,
31-
0xffffff,
30+
0xffffff, // color (red, green, blue)
3231
0,
3332
0,
3433
self.width as i64,
3534
self.height as i64,
3635
) {
3736
Ok(()) => {}
38-
Err(e) => println!("{}", e),
37+
Err(e) => panic!("Failed to draw a background window: {:?}", e),
3938
};
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+
4090
self.buffer.flush();
4191
}
4292
}

app/browser-rs/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod url;
1010
extern crate alloc;
1111

1212
use alloc::string::ToString;
13-
use liumlib::gui::*;
1413
use liumlib::*;
1514

1615
use crate::gui::ApplicationWindow;
@@ -46,7 +45,8 @@ fn main() {
4645

4746
let parsed_url = ParsedUrl::new(url.to_string());
4847

49-
let _app = ApplicationWindow::new(512, 256, "my browser".to_string()).initialize();
48+
let mut app = ApplicationWindow::new(512, 256, "my browser".to_string());
49+
app.initialize();
5050

5151
let response = udp_response(&parsed_url);
5252

0 commit comments

Comments
 (0)