Skip to content

Commit 251e781

Browse files
committed
feat: Made space for buttons on address bar
1 parent 32bdcaa commit 251e781

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

harbor/engine/res/pages/tab.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>New Tab</title>
77
<style>
8-
body {
8+
html, body {
99
background-color: #11111b;
10+
color: #a6adc8;
1011
}
1112

1213
h1 {
1314
color: #cdd6f4;
1415
}
1516

16-
p {
17-
color: #a6adc8;
17+
a {
18+
color: #89b4fa;
1819
}
1920

20-
h1, p { margin-left: 2rem; }
21+
h1, h2, p, ul { margin-left: 2rem; }
2122
</style>
2223
</head>
2324
<body>
2425
<h1>Welcome to your new tab!</h1>
2526
<p>This is a custom new tab page.</p>
27+
<h2>Awesome Flavortown projects</h2>
28+
<ul>
29+
<li><a href="https://flavortown.hackclub.com/projects/13380">Override.exe</a> - by @rupnil.codes</li>
30+
<li><a href="https://flavortown.hackclub.com/projects/12732">Shish's Personal Website</a> - by @Shish</li>
31+
</ul>
2632
</body>
2733
</html>

harbor/engine/src/globals.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ pub const TABS_BAR_OFFSET: fn(f64, f64) -> (f64, f64) =
2525
pub const ADDRESS_BAR_OFFSET: fn(f64, f64) -> (f64, f64) =
2626
|_window_width, window_height| (0.0, (window_height * 0.05).min(50.0));
2727

28+
pub const ADDRESS_BAR_ADDRESS_OFFSET: fn(f64, f64) -> (f64, f64) =
29+
|window_width, _window_height| (window_width * 0.1, 0.0);
30+
2831
pub const TOOLBAR_OFFSET: fn(f64, f64) -> (f64, f64) = |window_width, window_height| {
2932
let tabs_bar_offset = TABS_BAR_OFFSET(window_width, window_height);
3033
let address_bar_offset = ADDRESS_BAR_OFFSET(window_width, window_height);

harbor/engine/src/render/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::css::r#box::Box as CssBox;
1616
use crate::css::colors::UsedColor;
1717
use crate::css::layout::Layout;
1818
use crate::globals::{
19-
ADDRESS_BAR_OFFSET, INITIAL_WINDOW_HEIGHT, INITIAL_WINDOW_WIDTH, MINIMUM_WINDOW_HEIGHT,
20-
MINIMUM_WINDOW_WIDTH, TAB_WIDTH, TABS_BAR_OFFSET, TOOLBAR_OFFSET,
19+
ADDRESS_BAR_ADDRESS_OFFSET, ADDRESS_BAR_OFFSET, INITIAL_WINDOW_HEIGHT, INITIAL_WINDOW_WIDTH,
20+
MINIMUM_WINDOW_HEIGHT, MINIMUM_WINDOW_WIDTH, TAB_WIDTH, TABS_BAR_OFFSET, TOOLBAR_OFFSET,
2121
};
2222
use crate::html5::dom::Document;
2323
use crate::html5::elements::anchor::AnchorElement;
@@ -230,6 +230,11 @@ impl ApplicationHandler<AppEvent> for App {
230230
let address_bar_offset =
231231
ADDRESS_BAR_OFFSET(state.config.width as f64, state.config.height as f64);
232232

233+
let address_bar_address_offset = ADDRESS_BAR_ADDRESS_OFFSET(
234+
state.config.width as f64,
235+
state.config.height as f64,
236+
);
237+
233238
let toolbar_offset =
234239
TOOLBAR_OFFSET(state.config.width as f64, state.config.height as f64);
235240

@@ -251,8 +256,11 @@ impl ApplicationHandler<AppEvent> for App {
251256
}
252257
}
253258
} else if state.cursor_position.1 < tabs_bar_offset.1 + address_bar_offset.1 {
254-
if elem_state == ElementState::Pressed {
255-
state.address_bar_active = true;
259+
if state.cursor_position.0 > address_bar_address_offset.0 {
260+
if elem_state == ElementState::Pressed {
261+
state.address_bar_active = true;
262+
}
263+
} else {
256264
}
257265
} else {
258266
if let Some(root) = layout.root_box.as_ref() {

harbor/engine/src/render/state.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::{
1111
properties::FontStyle,
1212
},
1313
globals::{
14-
ADDRESS_BAR_OFFSET, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FONT_STYLE_ITALIC,
15-
DEFAULT_FONT_WEIGHT, TAB_WIDTH, TABS_BAR_OFFSET, TOOLBAR_OFFSET,
14+
ADDRESS_BAR_ADDRESS_OFFSET, ADDRESS_BAR_OFFSET, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE,
15+
DEFAULT_FONT_STYLE_ITALIC, DEFAULT_FONT_WEIGHT, TAB_WIDTH, TABS_BAR_OFFSET, TOOLBAR_OFFSET,
1616
},
1717
html5::dom::{Document, Element, NodeKind},
1818
render::{
@@ -289,6 +289,8 @@ impl WindowState {
289289
let tabs_bar_offset = TABS_BAR_OFFSET(self.config.width as f64, self.config.height as f64);
290290
let address_bar_offset =
291291
ADDRESS_BAR_OFFSET(self.config.width as f64, self.config.height as f64);
292+
let address_bar_address_offset =
293+
ADDRESS_BAR_ADDRESS_OFFSET(self.config.width as f64, self.config.height as f64);
292294

293295
let color = if self.address_bar_active {
294296
ACTIVE_ADDRESS_BAR_COLOR
@@ -316,7 +318,7 @@ impl WindowState {
316318
render_pass.draw(0..verts.len() as u32, 0..1);
317319

318320
let adj_position = (
319-
address_bar_offset.0 + 10.0,
321+
address_bar_offset.0 + address_bar_address_offset.0,
320322
tabs_bar_offset.1 + address_bar_offset.1 / 4.0,
321323
);
322324

0 commit comments

Comments
 (0)