Skip to content

Commit 7d7274b

Browse files
wash2mmstick
authored andcommitted
fix(header-bar): allocate space that accounts for window controls
1 parent 12317d8 commit 7d7274b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/widget/header_bar.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
307307
let center = std::mem::take(&mut self.center);
308308
let mut end = std::mem::take(&mut self.end);
309309

310+
let window_control_cnt = self.on_close.is_some() as usize
311+
+ self.on_maximize.is_some() as usize
312+
+ self.on_minimize.is_some() as usize;
310313
// Also packs the window controls at the very end.
311314
end.push(self.window_controls());
312315

@@ -327,8 +330,9 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
327330
}
328331
}
329332
};
330-
let portion = ((start.len().max(end.len()) as f32 / center.len().max(1) as f32).round()
331-
as u16)
333+
let portion = ((start.len().max(end.len() + window_control_cnt) as f32
334+
/ center.len().max(1) as f32)
335+
.round() as u16)
332336
.max(1);
333337
// Creates the headerbar widget.
334338
let mut widget = widget::row::with_capacity(3)

0 commit comments

Comments
 (0)