Skip to content

Commit

Permalink
Fix window bound calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
vE5li committed Mar 5, 2024
1 parent ca66635 commit 48e8154
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/interface/layout/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ pub struct PlacementResolver {
impl PlacementResolver {
pub fn new(
font_loader: Rc<RefCell<FontLoader>>,
mut available_space: ScreenSize,
screen_size: ScreenSize,
mut window_size: ScreenSize,
size_bound: &SizeBound,
border: ScreenSize,
gaps: ScreenSize,
scaling: f32,
) -> Self {
available_space.width -= border.width * scaling * 2.0;
available_space.height -= border.height * scaling * 2.0;
window_size -= border * scaling * 2.0;

let parent_limits = ParentLimits::from_bound(size_bound, available_space, scaling);
// NOTE: I'm not enirely sure why we need to subtract one border here, but if we
// don't the `super` bound is too big.
let parent_limits = ParentLimits::from_bound(size_bound, screen_size - border * scaling, scaling);
let base_position = ScreenPosition::from_size(border * scaling);
let horizontal_accumulator = 0.0;
let vertical_offset = 0.0;
let total_height = 0.0;

let height = (!size_bound.height.is_flexible()).then_some(available_space.height);
let available_space = PartialScreenSize::new(available_space.width, height);
let height = (!size_bound.height.is_flexible()).then_some(window_size.height);
let available_space = PartialScreenSize::new(window_size.width, height);

Self {
font_loader,
Expand Down
7 changes: 3 additions & 4 deletions src/interface/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ impl Window {
) -> (Option<&str>, ScreenPosition, ScreenSize) {
let mut placement_resolver = PlacementResolver::new(
font_loader.clone(),
ScreenSize {
height: available_space.height,
width: self.size.width,
},
available_space,
self.size,
&self.size_bound,
theme.window.border_size.get(),
theme.window.gaps.get(),
Expand Down Expand Up @@ -111,6 +109,7 @@ impl Window {

let mut placement_resolver = PlacementResolver::new(
font_loader,
available_space,
// TODO: 250 is an arbitrary limitation. This should be replaced with a value based
// on some reasoning.
ScreenSize {
Expand Down

0 comments on commit 48e8154

Please sign in to comment.