Skip to content

Commit

Permalink
fix(window): round corners based on header
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x authored and jackpot51 committed Nov 6, 2024
1 parent cb51f2d commit 20d5290
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,7 +2666,8 @@ impl Application for App {
})
.on_middle_click(move || Message::MiddleClick(pane, Some(entity_middle_click)))
.opacity(self.config.opacity_ratio())
.padding(space_xxs);
.padding(space_xxs)
.show_headerbar(self.config.show_headerbar);

if self.config.focus_follow_mouse {
terminal_box = terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
Expand Down
13 changes: 12 additions & 1 deletion src/terminal_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct TerminalBox<'a, Message> {
id: Option<Id>,
border: Border,
padding: Padding,
show_headerbar: bool,
click_timing: Duration,
context_menu: Option<Point>,
on_context_menu: Option<Box<dyn Fn(Option<Point>) -> Message + 'a>>,
Expand All @@ -70,6 +71,7 @@ where
id: None,
border: Border::default(),
padding: Padding::new(0.0),
show_headerbar: true,
click_timing: Duration::from_millis(500),
context_menu: None,
on_context_menu: None,
Expand All @@ -96,6 +98,11 @@ where
self
}

pub fn show_headerbar(mut self, show_headerbar: bool) -> Self {
self.show_headerbar = show_headerbar;
self
}

pub fn click_timing(mut self, click_timing: Duration) -> Self {
self.click_timing = click_timing;
self
Expand Down Expand Up @@ -281,7 +288,11 @@ where
Quad {
bounds: layout.bounds(),
border: Border {
radius: [0.0, 0.0, radius_s, radius_s].into(),
radius: if self.show_headerbar {
[0.0, 0.0, radius_s, radius_s].into()
} else {
[radius_s, radius_s, radius_s, radius_s].into()
},
width: self.border.width,
color: self.border.color,
},
Expand Down

0 comments on commit 20d5290

Please sign in to comment.