Include the vertical scrollbar when calculating panel size for horizontal alignment. Fixes #484

This commit is contained in:
Dustin Carlino 2021-01-28 10:31:47 -08:00
parent ca07c522ea
commit 16124f3f3b
2 changed files with 9 additions and 2 deletions

View File

@ -7,6 +7,7 @@ use stretch::style::{Dimension, Style};
use geom::{Percent, Polygon};
use crate::widgets::slider;
use crate::widgets::Container;
use crate::{
Autocomplete, Checkbox, Color, Dropdown, EventCtx, GfxCtx, HorizontalAlignment, Menu, Outcome,
@ -88,9 +89,15 @@ impl Panel {
self.top_level = container.members.remove(0);
}
let mut container_dims = self.container_dims;
// TODO Handle making room for a horizontal scrollbar on the bottom. The equivalent change
// to container_dims.height doesn't work as expected.
if self.scrollable_y {
container_dims.width += slider::BG_CROSS_AXIS_LEN;
}
let top_left = ctx
.canvas
.align_window(self.container_dims, self.horiz, self.vert);
.align_window(container_dims, self.horiz, self.vert);
// Wrap the main widget in scrollable containers if necessary.
if self.scrollable_x {

View File

@ -24,7 +24,7 @@ enum Style {
Area { width: f64 },
}
const BG_CROSS_AXIS_LEN: f64 = 20.0;
pub const BG_CROSS_AXIS_LEN: f64 = 20.0;
impl Slider {
pub fn horizontal(