mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 20:29:04 +03:00
every composite will automatically be scrollable if needed. simplify API.
This commit is contained in:
parent
ffb8270b10
commit
5af9c7e17b
@ -769,27 +769,6 @@ impl CompositeBuilder {
|
||||
clip_rect: None,
|
||||
};
|
||||
c.recompute_layout(ctx);
|
||||
c.contents_dims = ScreenDims::new(c.top_level.rect.width(), c.top_level.rect.height());
|
||||
c.container_dims = c.contents_dims.clone();
|
||||
ctx.fake_mouseover(|ctx| assert!(c.event(ctx).is_none()));
|
||||
c
|
||||
}
|
||||
pub fn build_scrollable(self, ctx: &mut EventCtx) -> Composite {
|
||||
let mut c = Composite {
|
||||
top_level: self.top_level,
|
||||
layout: self.layout,
|
||||
sliders: self.sliders,
|
||||
menus: self.menus,
|
||||
fillers: self.fillers,
|
||||
|
||||
scrollable_x: false,
|
||||
scrollable_y: false,
|
||||
contents_dims: ScreenDims::new(0.0, 0.0),
|
||||
container_dims: ScreenDims::new(0.0, 0.0),
|
||||
clip_rect: None,
|
||||
};
|
||||
// If the panel fits without a scrollbar, don't add one.
|
||||
c.recompute_layout(ctx);
|
||||
|
||||
c.contents_dims = ScreenDims::new(c.top_level.rect.width(), c.top_level.rect.height());
|
||||
c.container_dims = ScreenDims::new(
|
||||
@ -809,6 +788,7 @@ impl CompositeBuilder {
|
||||
},
|
||||
);
|
||||
|
||||
// If the panel fits without a scrollbar, don't add one.
|
||||
let top_left = ctx
|
||||
.canvas
|
||||
.align_window(c.container_dims, c.layout.horiz, c.layout.vert);
|
||||
@ -836,7 +816,6 @@ impl CompositeBuilder {
|
||||
.abs(top_left.x + c.container_dims.width, top_left.y),
|
||||
]);
|
||||
}
|
||||
|
||||
if c.scrollable_x || c.scrollable_y {
|
||||
c.recompute_layout(ctx);
|
||||
c.clip_rect = Some(ScreenRectangle::top_left(top_left, c.container_dims));
|
||||
|
@ -295,7 +295,7 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
|
||||
self.ctx,
|
||||
),
|
||||
)
|
||||
.build_scrollable(self.ctx),
|
||||
.build(self.ctx),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ impl InfoPanel {
|
||||
VerticalAlignment::Percent(0.2),
|
||||
)
|
||||
.size_percent(30, 60)
|
||||
.build_scrollable(ctx),
|
||||
.build(ctx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ fn make_diagram(
|
||||
|
||||
ezgui::Composite::new(ManagedWidget::col(col).bg(Color::hex("#545454")))
|
||||
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
|
||||
.build_scrollable(ctx)
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
fn change_traffic_signal(signal: ControlTrafficSignal, ui: &mut UI, ctx: &mut EventCtx) {
|
||||
|
@ -321,5 +321,5 @@ fn make_diagram(i: IntersectionID, selected: usize, ui: &UI, ctx: &mut EventCtx)
|
||||
|
||||
Composite::new(ManagedWidget::col(col).bg(Color::hex("#545454")))
|
||||
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
|
||||
.build_scrollable(ctx)
|
||||
.build(ctx)
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ pub fn make(ctx: &mut EventCtx, ui: &UI, tab: Tab) -> Box<dyn State> {
|
||||
content,
|
||||
]))
|
||||
.fullscreen()
|
||||
.build_scrollable(ctx),
|
||||
.build(ctx),
|
||||
)
|
||||
.cb("BACK", Box::new(|_, _| Some(Transition::Pop)));
|
||||
for (t, label) in tab_data {
|
||||
|
Loading…
Reference in New Issue
Block a user