mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
reduce verbosity of constructing text widgets [rebuild]
This commit is contained in:
parent
8f285be4fe
commit
fedacfe202
@ -10,7 +10,7 @@
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Button, Color, Composite, Drawable, EventCtx, EventLoopMode, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, Plot, PlotOptions, Series, Text,
|
||||
VerticalAlignment, GUI,
|
||||
TextExt, VerticalAlignment, GUI,
|
||||
};
|
||||
use geom::{Angle, Duration, Polygon, Pt2D, Time};
|
||||
|
||||
@ -42,36 +42,18 @@ impl App {
|
||||
|
||||
fn make_timeseries_panel(&self, ctx: &mut EventCtx) -> Composite {
|
||||
// Make a table with 3 columns.
|
||||
let mut col1 = vec![ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Time").roboto_bold()),
|
||||
)];
|
||||
let mut col2 = vec![ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Linear").roboto_bold()),
|
||||
)];
|
||||
let mut col3 = vec![ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Quadratic").roboto_bold()),
|
||||
)];
|
||||
let mut col1 = vec![Line("Time").roboto_bold().draw(ctx)];
|
||||
let mut col2 = vec![Line("Linear").roboto_bold().draw(ctx)];
|
||||
let mut col3 = vec![Line("Quadratic").roboto_bold().draw(ctx)];
|
||||
for s in 0..(self.elapsed.inner_seconds() as usize) {
|
||||
col1.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(Duration::seconds(s as f64).to_string())),
|
||||
));
|
||||
col2.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(s.to_string())),
|
||||
));
|
||||
col3.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(s.pow(2).to_string())),
|
||||
));
|
||||
col1.push(Duration::seconds(s as f64).to_string().draw_text(ctx));
|
||||
col2.push(s.to_string().draw_text(ctx));
|
||||
col3.push(s.pow(2).to_string().draw_text(ctx));
|
||||
}
|
||||
|
||||
let mut c = Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![ManagedWidget::draw_text(ctx, {
|
||||
ManagedWidget::row(vec![{
|
||||
let mut txt = Text::from(
|
||||
Line("Here's a bunch of text to force some scrolling.").roboto_bold(),
|
||||
);
|
||||
@ -82,8 +64,8 @@ impl App {
|
||||
)
|
||||
.fg(Color::RED),
|
||||
);
|
||||
txt
|
||||
})]),
|
||||
txt.draw(ctx)
|
||||
}]),
|
||||
ManagedWidget::row(vec![
|
||||
// Examples of styling widgets
|
||||
ManagedWidget::col(col1)
|
||||
@ -159,11 +141,9 @@ impl GUI for App {
|
||||
self.controls.replace(
|
||||
ctx,
|
||||
"stopwatch",
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Stopwatch: {}", self.elapsed))),
|
||||
)
|
||||
.named("stopwatch"),
|
||||
format!("Stopwatch: {}", self.elapsed)
|
||||
.draw_text(ctx)
|
||||
.named("stopwatch"),
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
@ -181,11 +161,9 @@ impl GUI for App {
|
||||
self.controls.replace(
|
||||
ctx,
|
||||
"stopwatch",
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Stopwatch: {}", self.elapsed))),
|
||||
)
|
||||
.named("stopwatch"),
|
||||
format!("Stopwatch: {}", self.elapsed)
|
||||
.draw_text(ctx)
|
||||
.named("stopwatch"),
|
||||
);
|
||||
}
|
||||
|
||||
@ -273,13 +251,13 @@ fn setup_scrollable_canvas(ctx: &mut EventCtx) -> Drawable {
|
||||
fn make_controls(ctx: &mut EventCtx) -> Composite {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, {
|
||||
{
|
||||
let mut txt = Text::from(Line("ezgui demo").roboto_bold());
|
||||
txt.add(Line(
|
||||
"Click and drag to pan, use touchpad or scroll wheel to zoom",
|
||||
));
|
||||
txt
|
||||
}),
|
||||
txt.draw(ctx)
|
||||
},
|
||||
ManagedWidget::row(vec![
|
||||
// This just cycles between two arbitrary buttons
|
||||
ManagedWidget::custom_checkbox(
|
||||
@ -320,7 +298,7 @@ fn make_controls(ctx: &mut EventCtx) -> Composite {
|
||||
ManagedWidget::checkbox(ctx, "Show timeseries", lctrl(Key::T), false).margin(5),
|
||||
])
|
||||
.evenly_spaced(),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Stopwatch: ..."))).named("stopwatch"),
|
||||
"Stopwatch: ...".draw_text(ctx).named("stopwatch"),
|
||||
])
|
||||
.bg(Color::grey(0.4)),
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ pub use crate::input::UserInput;
|
||||
pub use crate::managed::{Composite, ManagedWidget, Outcome};
|
||||
pub use crate::runner::{run, EventLoopMode, Settings, GUI};
|
||||
pub use crate::screen_geom::{ScreenDims, ScreenPt, ScreenRectangle};
|
||||
pub use crate::text::{Line, Text, TextSpan, HOTKEY_COLOR};
|
||||
pub use crate::text::{Line, Text, TextExt, TextSpan, HOTKEY_COLOR};
|
||||
pub use crate::widgets::{
|
||||
Autocomplete, Button, Choice, Filler, Histogram, ItemSlider, JustDraw, ModalMenu, Plot,
|
||||
PlotOptions, Series, Slider, Warper, WarpingItemSlider, Wizard, WrappedWizard,
|
||||
|
@ -247,7 +247,7 @@ impl ManagedWidget {
|
||||
ManagedWidget::new(WidgetType::Draw(j))
|
||||
}
|
||||
|
||||
pub fn draw_text(ctx: &EventCtx, txt: Text) -> ManagedWidget {
|
||||
pub(crate) fn draw_text(ctx: &EventCtx, txt: Text) -> ManagedWidget {
|
||||
JustDraw::text(ctx, txt)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::assets::Assets;
|
||||
use crate::{svg, Color, EventCtx, GeomBatch, GfxCtx, Prerender, ScreenDims};
|
||||
use crate::{svg, Color, EventCtx, GeomBatch, GfxCtx, ManagedWidget, Prerender, ScreenDims};
|
||||
use geom::Polygon;
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::fmt::Write;
|
||||
@ -55,6 +55,10 @@ impl TextSpan {
|
||||
self.font = Font::RobotoBold;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn draw(self, ctx: &EventCtx) -> ManagedWidget {
|
||||
Text::from(self).draw(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO What's the better way of doing this? Also "Line" is a bit of a misnomer
|
||||
@ -259,6 +263,10 @@ impl Text {
|
||||
hasher.write(format!("{:?}", self).as_ref());
|
||||
format!("{:x}", hasher.finish())
|
||||
}
|
||||
|
||||
pub fn draw(self, ctx: &EventCtx) -> ManagedWidget {
|
||||
ManagedWidget::draw_text(ctx, self)
|
||||
}
|
||||
}
|
||||
|
||||
fn render_text(spans: Vec<TextSpan>, tolerance: f32, assets: &Assets) -> GeomBatch {
|
||||
@ -305,3 +313,19 @@ fn render_text(spans: Vec<TextSpan>, tolerance: f32, assets: &Assets) -> GeomBat
|
||||
Err(err) => panic!("render_text({}): {}", contents, err),
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TextExt {
|
||||
fn draw_text(self, ctx: &EventCtx) -> ManagedWidget;
|
||||
}
|
||||
|
||||
impl TextExt for &str {
|
||||
fn draw_text(self, ctx: &EventCtx) -> ManagedWidget {
|
||||
Line(self).draw(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
impl TextExt for String {
|
||||
fn draw_text(self, ctx: &EventCtx) -> ManagedWidget {
|
||||
Line(self).draw(ctx)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::layout::Widget;
|
||||
use crate::{
|
||||
Color, Drawable, EventCtx, GeomBatch, GfxCtx, Line, ManagedWidget, ScreenDims, ScreenPt, Text,
|
||||
TextExt,
|
||||
};
|
||||
use abstutil::prettyprint_usize;
|
||||
use geom::{Distance, Duration, Polygon, Pt2D};
|
||||
@ -80,10 +81,7 @@ impl Histogram {
|
||||
for i in 0..num_x_labels {
|
||||
let percent_x = (i as f64) / ((num_x_labels - 1) as f64);
|
||||
let dt = min_x + (max_x - min_x) * percent_x;
|
||||
row.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(dt.to_string())),
|
||||
));
|
||||
row.push(dt.to_string().draw_text(ctx));
|
||||
}
|
||||
let x_axis = ManagedWidget::row(row);
|
||||
|
||||
@ -91,12 +89,7 @@ impl Histogram {
|
||||
let mut col = Vec::new();
|
||||
for i in 0..num_y_labels {
|
||||
let percent_y = (i as f64) / ((num_y_labels - 1) as f64);
|
||||
col.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(prettyprint_usize(
|
||||
((max_y as f64) * percent_y) as usize,
|
||||
))),
|
||||
));
|
||||
col.push(prettyprint_usize(((max_y as f64) * percent_y) as usize).draw_text(ctx));
|
||||
}
|
||||
col.reverse();
|
||||
let y_axis = ManagedWidget::col(col);
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::layout::Widget;
|
||||
use crate::{
|
||||
Color, Drawable, EventCtx, GeomBatch, GfxCtx, Line, ManagedWidget, ScreenDims, ScreenPt,
|
||||
ScreenRectangle, Text,
|
||||
ScreenRectangle, Text, TextExt,
|
||||
};
|
||||
use abstutil::prettyprint_usize;
|
||||
use geom::{Angle, Bounds, Circle, Distance, Duration, FindClosest, PolyLine, Pt2D, Time};
|
||||
@ -59,7 +59,7 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
|
||||
.to_polygon(),
|
||||
)]),
|
||||
),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(&s.label))),
|
||||
s.label.clone().draw_text(ctx),
|
||||
])
|
||||
})
|
||||
.collect(),
|
||||
@ -192,10 +192,7 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
|
||||
let mut col = Vec::new();
|
||||
for i in 0..num_y_labels {
|
||||
let percent_y = (i as f64) / ((num_y_labels - 1) as f64);
|
||||
col.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(max_y.from_percent(percent_y).prettyprint())),
|
||||
));
|
||||
col.push(max_y.from_percent(percent_y).prettyprint().draw_text(ctx));
|
||||
}
|
||||
col.reverse();
|
||||
let y_axis = ManagedWidget::col(col).padding(10);
|
||||
|
@ -86,7 +86,7 @@ impl Wizard {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(query).roboto_bold())),
|
||||
Line(query).roboto_bold().draw(ctx),
|
||||
// TODO nice text button
|
||||
ManagedWidget::btn(Button::text_bg(
|
||||
Text::from(Line("X").fg(Color::BLACK)),
|
||||
@ -265,10 +265,7 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
|
||||
}
|
||||
let mut col = Vec::new();
|
||||
if let Some(l) = query {
|
||||
col.push(ManagedWidget::draw_text(
|
||||
self.ctx,
|
||||
Text::from(Line(l).roboto_bold()),
|
||||
));
|
||||
col.push(Line(l).roboto_bold().draw(self.ctx));
|
||||
}
|
||||
col.push(ManagedWidget::menu("menu"));
|
||||
self.wizard.menu_comp = Some(
|
||||
@ -410,7 +407,7 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
|
||||
self.wizard.ack = Some(
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(self.ctx, txt),
|
||||
txt.draw(self.ctx),
|
||||
ManagedWidget::btn(Button::text_bg(
|
||||
Text::from(Line("OK")),
|
||||
Color::grey(0.6),
|
||||
|
@ -150,7 +150,7 @@ impl Tab {
|
||||
master_col.push({
|
||||
let mut txt = Text::from(Line("A/B STREET").size(100));
|
||||
txt.add(Line("CHALLENGES").size(50));
|
||||
ManagedWidget::draw_text(ctx, txt).centered_horiz()
|
||||
txt.draw(ctx).centered_horiz()
|
||||
});
|
||||
|
||||
// First list challenges
|
||||
@ -233,7 +233,7 @@ impl Tab {
|
||||
}
|
||||
main_row.push(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, txt),
|
||||
txt.draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "Start!", hotkey(Key::Enter)).margin(10),
|
||||
])
|
||||
.bg(colors::PANEL_BG)
|
||||
|
@ -139,7 +139,7 @@ impl ColorerBuilder {
|
||||
|
||||
// Build the legend
|
||||
let mut col = vec![ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, self.header),
|
||||
self.header.draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", None).align_right(),
|
||||
])];
|
||||
for (label, color) in self.prioritized_colors {
|
||||
@ -182,7 +182,7 @@ impl ColorLegend {
|
||||
)
|
||||
.margin(5)
|
||||
.centered_vert(),
|
||||
ManagedWidget::draw_text(ctx, txt),
|
||||
txt.draw(ctx),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use crate::sandbox::{SandboxMode, SpeedControls};
|
||||
use abstutil::prettyprint_usize;
|
||||
use ezgui::{
|
||||
hotkey, Button, Color, Composite, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment,
|
||||
Key, Line, ManagedWidget, Outcome, Plot, PlotOptions, RewriteColor, Series, Text,
|
||||
Key, Line, ManagedWidget, Outcome, Plot, PlotOptions, RewriteColor, Series, Text, TextExt,
|
||||
VerticalAlignment,
|
||||
};
|
||||
use geom::{Angle, Circle, Distance, Duration, Polygon, Pt2D, Statistic, Time};
|
||||
@ -400,16 +400,10 @@ fn info_for(
|
||||
{
|
||||
let label = if l.is_sidewalk() { "Sidewalk" } else { "Lane" };
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("{} #{}", label, id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("{} #{}", label, id.0)).roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
rows.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("@ {}", r.get_name()))),
|
||||
));
|
||||
rows.push(format!("@ {}", r.get_name()).draw_text(ctx));
|
||||
}
|
||||
rows.extend(action_btns);
|
||||
|
||||
@ -477,7 +471,7 @@ fn info_for(
|
||||
prettyprint_usize(sim.get_analytics().thruput_stats.count_per_road.get(r.id))
|
||||
)));
|
||||
txt.add(Line(format!("In 20 minute buckets:")));
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt));
|
||||
rows.push(txt.draw(ctx));
|
||||
|
||||
let r = app.primary.map.get_l(id).parent;
|
||||
rows.push(
|
||||
@ -504,7 +498,7 @@ fn info_for(
|
||||
}
|
||||
};
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(label).roboto_bold())),
|
||||
Line(label).roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -540,7 +534,7 @@ fn info_for(
|
||||
)
|
||||
)));
|
||||
txt.add(Line(format!("In 20 minute buckets:")));
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt));
|
||||
rows.push(txt.draw(ctx));
|
||||
|
||||
rows.push(
|
||||
throughput(ctx, app, move |a, t| {
|
||||
@ -553,7 +547,7 @@ fn info_for(
|
||||
let mut txt = Text::from(Line(""));
|
||||
txt.add(Line("Delay").roboto_bold());
|
||||
txt.add(Line(format!("In 20 minute buckets:")));
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt));
|
||||
rows.push(txt.draw(ctx));
|
||||
|
||||
rows.push(intersection_delay(ctx, app, id, Duration::minutes(20)).margin(10));
|
||||
}
|
||||
@ -565,10 +559,7 @@ fn info_for(
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Building #{}", id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Building #{}", id.0)).roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -639,15 +630,12 @@ fn info_for(
|
||||
}
|
||||
|
||||
if !txt.is_empty() {
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt))
|
||||
rows.push(txt.draw(ctx))
|
||||
}
|
||||
|
||||
let people = sim.bldg_to_people(id);
|
||||
if !people.is_empty() {
|
||||
rows.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("{} people inside right now", people.len()))),
|
||||
));
|
||||
rows.push(format!("{} people inside right now", people.len()).draw_text(ctx));
|
||||
// TODO Show buttons to examine first 3, or a ...More button
|
||||
for p in people {
|
||||
rows.push(
|
||||
@ -673,10 +661,7 @@ fn info_for(
|
||||
VehicleType::Bus => "Bus",
|
||||
};
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("{} #{}", label, id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("{} #{}", label, id.0)).roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -689,17 +674,16 @@ fn info_for(
|
||||
for line in extra {
|
||||
txt.add(Line(line));
|
||||
}
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt));
|
||||
rows.push(txt.draw(ctx));
|
||||
}
|
||||
}
|
||||
ID::Pedestrian(id) => {
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Pedestrian #{}", id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Pedestrian #{}", id.0))
|
||||
.roboto_bold()
|
||||
.draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -712,17 +696,14 @@ fn info_for(
|
||||
for line in extra {
|
||||
txt.add(Line(line));
|
||||
}
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt));
|
||||
rows.push(txt.draw(ctx));
|
||||
}
|
||||
}
|
||||
ID::PedCrowd(members) => {
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Pedestrian crowd").roboto_bold()),
|
||||
),
|
||||
Line("Pedestrian crowd").roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -730,13 +711,13 @@ fn info_for(
|
||||
|
||||
let mut txt = Text::new();
|
||||
txt.add(Line(format!("Crowd of {}", members.len())));
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt))
|
||||
rows.push(txt.draw(ctx))
|
||||
}
|
||||
ID::BusStop(id) => {
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Bus stop").roboto_bold())),
|
||||
Line("Bus stop").roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -770,16 +751,13 @@ fn info_for(
|
||||
txt.add(Line(format!(" Waiting: {}", hgram.describe())));
|
||||
}
|
||||
}
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt))
|
||||
rows.push(txt.draw(ctx))
|
||||
}
|
||||
ID::Area(id) => {
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Area #{}", id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Area #{}", id.0)).roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -796,10 +774,9 @@ fn info_for(
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Extra GIS shape #{}", id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Extra GIS shape #{}", id.0))
|
||||
.roboto_bold()
|
||||
.draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -817,10 +794,7 @@ fn info_for(
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Trip #{}", id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Trip #{}", id.0)).roboto_bold().draw(ctx),
|
||||
// No jump-to-object button; this is probably a finished trip.
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]));
|
||||
@ -831,10 +805,7 @@ fn info_for(
|
||||
// Header
|
||||
{
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Person #{}", id.0)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Person #{}", id.0)).roboto_bold().draw(ctx),
|
||||
header_btns,
|
||||
]));
|
||||
}
|
||||
@ -856,46 +827,26 @@ fn info_for(
|
||||
&format!("examine Building #{}", b.0),
|
||||
ctx,
|
||||
)),
|
||||
PersonState::Trip(t) => ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Currently doing Trip #{}", t.0))),
|
||||
),
|
||||
PersonState::OffMap => ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Currently outside the map boundaries")),
|
||||
),
|
||||
PersonState::Limbo => ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(
|
||||
"Currently in limbo -- they broke out of the Matrix! Woops. (A bug \
|
||||
occurred)",
|
||||
)),
|
||||
),
|
||||
PersonState::Trip(t) => format!("Currently doing Trip #{}", t.0).draw_text(ctx),
|
||||
PersonState::OffMap => "Currently outside the map boundaries".draw_text(ctx),
|
||||
PersonState::Limbo => "Currently in limbo -- they broke out of the Matrix! Woops. \
|
||||
(A bug occurred)"
|
||||
.draw_text(ctx),
|
||||
});
|
||||
|
||||
rows.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Schedule").roboto_bold()),
|
||||
));
|
||||
rows.push(Line("Schedule").roboto_bold().draw(ctx));
|
||||
for t in &person.trips {
|
||||
// TODO Still maybe unsafe? Check if trip has actually started or not
|
||||
// TODO Say where the trip goes, no matter what?
|
||||
let start_time = app.primary.sim.trip_start_time(*t);
|
||||
if app.primary.sim.time() < start_time {
|
||||
rows.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!(
|
||||
"{}: Trip #{} will start",
|
||||
start_time.ampm_tostring(),
|
||||
t.0
|
||||
))),
|
||||
));
|
||||
rows.push(
|
||||
format!("{}: Trip #{} will start", start_time.ampm_tostring(), t.0)
|
||||
.draw_text(ctx),
|
||||
);
|
||||
} else {
|
||||
rows.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("{}: ", start_time.ampm_tostring(),))),
|
||||
),
|
||||
format!("{}: ", start_time.ampm_tostring()).draw_text(ctx),
|
||||
ManagedWidget::btn(Button::text_bg(
|
||||
Text::from(Line(format!("Trip #{}", t.0))),
|
||||
colors::SECTION_BG,
|
||||
@ -919,11 +870,9 @@ fn make_table(ctx: &EventCtx, rows: Vec<(String, String)>) -> Vec<ManagedWidget>
|
||||
rows.into_iter()
|
||||
.map(|(k, v)| {
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(k).roboto_bold())),
|
||||
Line(k).roboto_bold().draw(ctx),
|
||||
// TODO not quite...
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(v)))
|
||||
.centered_vert()
|
||||
.align_right(),
|
||||
v.draw_text(ctx).centered_vert().align_right(),
|
||||
])
|
||||
})
|
||||
.collect()
|
||||
@ -936,8 +885,8 @@ fn make_table(ctx: &EventCtx, rows: Vec<(String, String)>) -> Vec<ManagedWidget>
|
||||
values.add(Line(v));
|
||||
}
|
||||
vec![ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, keys),
|
||||
ManagedWidget::draw_text(ctx, values).centered_vert().bg(Color::GREEN),
|
||||
keys.draw(ctx),
|
||||
values.draw(ctx).centered_vert().bg(Color::GREEN),
|
||||
])]*/
|
||||
}
|
||||
|
||||
|
@ -454,14 +454,12 @@ fn make_viz_panel(ctx: &mut EventCtx, acs: &AgentColorScheme) -> ManagedWidget {
|
||||
)]),
|
||||
)
|
||||
.margin(3),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(if *enabled {
|
||||
Line(label)
|
||||
} else {
|
||||
Line(label).fg(Color::WHITE.alpha(0.5))
|
||||
}),
|
||||
)
|
||||
Text::from(if *enabled {
|
||||
Line(label)
|
||||
} else {
|
||||
Line(label).fg(Color::WHITE.alpha(0.5))
|
||||
})
|
||||
.draw(ctx)
|
||||
.margin(3),
|
||||
])
|
||||
.centered_cross(),
|
||||
|
@ -9,7 +9,7 @@ use abstutil::{prettyprint_usize, Counter};
|
||||
use ezgui::{
|
||||
hotkey, Button, Color, Composite, Drawable, EventCtx, GeomBatch, GfxCtx, Histogram,
|
||||
HorizontalAlignment, JustDraw, Key, Line, ManagedWidget, Outcome, Plot, PlotOptions,
|
||||
RewriteColor, Series, Text, VerticalAlignment,
|
||||
RewriteColor, Series, Text, TextExt, VerticalAlignment,
|
||||
};
|
||||
use geom::{Circle, Distance, Duration, PolyLine, Polygon, Pt2D, Statistic, Time};
|
||||
use map_model::{BusRouteID, IntersectionID};
|
||||
@ -308,7 +308,7 @@ impl Overlays {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Heat Map Layers"))),
|
||||
"Heat Map Layers".draw_text(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::row(choices).flex_wrap(ctx, 20),
|
||||
@ -613,7 +613,7 @@ impl Overlays {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, {
|
||||
{
|
||||
let mut txt = Text::from(Line("Are trips "));
|
||||
txt.append(Line("faster").fg(Color::GREEN));
|
||||
txt.append(Line(", "));
|
||||
@ -621,8 +621,8 @@ impl Overlays {
|
||||
txt.append(Line(", or "));
|
||||
txt.append(Line("the same").fg(Color::YELLOW));
|
||||
txt.append(Line("?"));
|
||||
txt
|
||||
})
|
||||
txt.draw(ctx)
|
||||
}
|
||||
.margin(10),
|
||||
WrappedComposite::text_button(ctx, "X", None).align_right(),
|
||||
]),
|
||||
@ -672,7 +672,7 @@ impl Overlays {
|
||||
|
||||
let col = vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("intersection demand"))),
|
||||
"intersection demand".draw_text(ctx),
|
||||
ManagedWidget::btn(Button::rectangle_svg(
|
||||
"../data/system/assets/tools/locate.svg",
|
||||
"intersection demand",
|
||||
@ -702,10 +702,9 @@ impl Overlays {
|
||||
pub fn bus_passengers(id: BusRouteID, ctx: &mut EventCtx, app: &App) -> Overlays {
|
||||
let route = app.primary.map.get_br(id);
|
||||
let mut master_col = vec![ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Passengers for {}", route.name)).roboto_bold()),
|
||||
),
|
||||
Line(format!("Passengers for {}", route.name))
|
||||
.roboto_bold()
|
||||
.draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", None).align_right(),
|
||||
])];
|
||||
let mut col = Vec::new();
|
||||
@ -717,7 +716,7 @@ impl Overlays {
|
||||
.bus_passenger_delays(app.primary.sim.time(), id);
|
||||
for idx in 0..route.stops.len() {
|
||||
col.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(format!("Stop {}", idx + 1)))),
|
||||
format!("Stop {}", idx + 1).draw_text(ctx),
|
||||
ManagedWidget::btn(Button::rectangle_svg(
|
||||
"../data/system/assets/tools/locate.svg",
|
||||
&format!("Stop {}", idx + 1),
|
||||
@ -726,16 +725,14 @@ impl Overlays {
|
||||
ctx,
|
||||
)),
|
||||
if let Some(hgram) = delay_per_stop.remove(&route.stops[idx]) {
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!(
|
||||
": {} (avg {})",
|
||||
hgram.count(),
|
||||
hgram.select(Statistic::Mean)
|
||||
))),
|
||||
format!(
|
||||
": {} (avg {})",
|
||||
hgram.count(),
|
||||
hgram.select(Statistic::Mean)
|
||||
)
|
||||
.draw_text(ctx)
|
||||
} else {
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(": nobody")))
|
||||
": nobody".draw_text(ctx)
|
||||
},
|
||||
]));
|
||||
}
|
||||
@ -822,10 +819,7 @@ impl Overlays {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("delays for {}", route.name))),
|
||||
),
|
||||
format!("delays for {}", route.name).draw_text(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", None).align_right(),
|
||||
]),
|
||||
Plot::new_duration(ctx, series, PlotOptions::new()).margin(10),
|
||||
|
@ -249,28 +249,24 @@ impl TurnExplorer {
|
||||
let num_turns = app.primary.map.get_turns_from_lane(l).len();
|
||||
|
||||
let mut col = vec![ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(
|
||||
Line(format!(
|
||||
"Turns from {}",
|
||||
app.primary.map.get_parent(l).get_name()
|
||||
))
|
||||
.size(26),
|
||||
),
|
||||
Text::from(
|
||||
Line(format!(
|
||||
"Turns from {}",
|
||||
app.primary.map.get_parent(l).get_name()
|
||||
))
|
||||
.size(26),
|
||||
)
|
||||
.draw(ctx)
|
||||
.margin(5),
|
||||
ManagedWidget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
)
|
||||
.margin(5),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("{}/{}", idx, num_turns)).size(20)),
|
||||
)
|
||||
.margin(5)
|
||||
.centered_vert(),
|
||||
Text::from(Line(format!("{}/{}", idx, num_turns)).size(20))
|
||||
.draw(ctx)
|
||||
.margin(5)
|
||||
.centered_vert(),
|
||||
if idx == 0 {
|
||||
Button::inactive_button(ctx, "<")
|
||||
} else {
|
||||
|
@ -38,10 +38,10 @@ impl DebugMode {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Debug Mode").roboto_bold())),
|
||||
Line("Debug Mode").roboto_bold().draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::draw_text(ctx, Text::new()).named("current info"),
|
||||
Text::new().draw(ctx).named("current info"),
|
||||
ManagedWidget::row(
|
||||
vec![
|
||||
(hotkey(Key::Num1), "toggle buildings"),
|
||||
@ -96,11 +96,8 @@ impl DebugMode {
|
||||
if let routes::AllRoutesViewer::Active(ref traces) = self.all_routes {
|
||||
txt.add(Line(format!("Showing {} routes", traces.len())));
|
||||
}
|
||||
self.composite.replace(
|
||||
ctx,
|
||||
"current info",
|
||||
ManagedWidget::draw_text(ctx, txt).named("current info"),
|
||||
);
|
||||
self.composite
|
||||
.replace(ctx, "current info", txt.draw(ctx).named("current info"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use crate::managed::WrappedComposite;
|
||||
use abstutil::prettyprint_usize;
|
||||
use ezgui::{
|
||||
hotkey, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, ManagedWidget,
|
||||
Outcome, Slider, Text, VerticalAlignment,
|
||||
Outcome, Slider, TextExt, VerticalAlignment,
|
||||
};
|
||||
use geom::{Circle, Distance, Duration, PolyLine, Time};
|
||||
use map_model::NORMAL_LANE_THICKNESS;
|
||||
@ -71,14 +71,10 @@ impl TripsVisualizer {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Trips Visualizer").roboto_bold()),
|
||||
),
|
||||
Line("Trips Visualizer").roboto_bold().draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Active trips")))
|
||||
.named("active trips"),
|
||||
"Active trips".draw_text(ctx).named("active trips"),
|
||||
ManagedWidget::row(vec![
|
||||
WrappedComposite::text_button(
|
||||
ctx,
|
||||
@ -160,13 +156,11 @@ impl State for TripsVisualizer {
|
||||
self.composite.replace(
|
||||
ctx,
|
||||
"active trips",
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!(
|
||||
"{} active trips",
|
||||
prettyprint_usize(self.active_trips.len()),
|
||||
))),
|
||||
format!(
|
||||
"{} active trips",
|
||||
prettyprint_usize(self.active_trips.len()),
|
||||
)
|
||||
.draw_text(ctx)
|
||||
.named("active trips"),
|
||||
);
|
||||
}
|
||||
|
@ -554,10 +554,7 @@ impl DotMap {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Dot map of all trips").roboto_bold()),
|
||||
),
|
||||
Line("Dot map of all trips").roboto_bold().draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::slider("time slider"),
|
||||
|
@ -7,8 +7,8 @@ use crate::helpers::ID;
|
||||
use crate::managed::WrappedComposite;
|
||||
use crate::render::Renderable;
|
||||
use ezgui::{
|
||||
hotkey, Button, Choice, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
ManagedWidget, Outcome, RewriteColor, Text, VerticalAlignment,
|
||||
hotkey, Button, Choice, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key,
|
||||
ManagedWidget, Outcome, RewriteColor, TextExt, VerticalAlignment,
|
||||
};
|
||||
use map_model::{EditCmd, LaneID, LaneType, Map, RoadID};
|
||||
use std::collections::BTreeSet;
|
||||
@ -76,13 +76,11 @@ impl LaneEditor {
|
||||
}
|
||||
|
||||
let col = vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!(
|
||||
"Convert this lane of {} to what type?",
|
||||
app.primary.map.get_parent(l).get_name()
|
||||
))),
|
||||
format!(
|
||||
"Convert this lane of {} to what type?",
|
||||
app.primary.map.get_parent(l).get_name()
|
||||
)
|
||||
.draw_text(ctx)
|
||||
.centered_horiz(),
|
||||
ManagedWidget::row(row).centered(),
|
||||
WrappedComposite::text_button(ctx, "Finish", hotkey(Key::Escape)),
|
||||
|
@ -333,7 +333,7 @@ fn make_topcenter(ctx: &mut EventCtx, app: &App) -> Composite {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Editing map").size(26))).margin(5),
|
||||
Line("Editing map").size(26).draw(ctx).margin(5),
|
||||
ManagedWidget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 30.0))]),
|
||||
|
@ -8,7 +8,7 @@ use crate::render::DrawIntersection;
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, Button, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
ManagedWidget, Outcome, Text, VerticalAlignment,
|
||||
ManagedWidget, Outcome, Text, TextExt, VerticalAlignment,
|
||||
};
|
||||
use geom::Polygon;
|
||||
use map_model::{
|
||||
@ -52,7 +52,7 @@ impl StopSignEditor {
|
||||
|
||||
let composite = Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Stop sign editor"))),
|
||||
"Stop sign editor".draw_text(ctx),
|
||||
if ControlStopSign::new(&app.primary.map, id)
|
||||
!= app.primary.map.get_stop_sign(id).clone()
|
||||
{
|
||||
|
@ -11,7 +11,8 @@ use crate::sandbox::{spawn_agents_around, SpeedControls, TimePanel};
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Choice, Color, Composite, EventCtx, EventLoopMode, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, RewriteColor, Text, VerticalAlignment,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, RewriteColor, Text, TextExt,
|
||||
VerticalAlignment,
|
||||
};
|
||||
use geom::Duration;
|
||||
use map_model::{
|
||||
@ -709,7 +710,7 @@ impl PreviewTrafficSignal {
|
||||
PreviewTrafficSignal {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Previewing traffic signal"))),
|
||||
"Previewing traffic signal".draw_text(ctx),
|
||||
WrappedComposite::text_button(ctx, "back to editing", hotkey(Key::Escape)),
|
||||
])
|
||||
.bg(colors::PANEL_BG)
|
||||
|
@ -115,16 +115,16 @@ impl WrappedComposite {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(title.into()).roboto_bold())),
|
||||
Line(title.into()).roboto_bold().draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::draw_text(ctx, {
|
||||
{
|
||||
let mut txt = Text::new();
|
||||
for l in info {
|
||||
txt.add(Line(l));
|
||||
}
|
||||
txt
|
||||
}),
|
||||
txt.draw(ctx)
|
||||
},
|
||||
ManagedWidget::row(
|
||||
actions
|
||||
.into_iter()
|
||||
|
@ -2,7 +2,9 @@ use crate::app::App;
|
||||
use crate::colors;
|
||||
use crate::game::{State, Transition, WizardState};
|
||||
use crate::managed::WrappedComposite;
|
||||
use ezgui::{hotkey, Choice, Composite, EventCtx, GfxCtx, Key, Line, ManagedWidget, Outcome, Text};
|
||||
use ezgui::{
|
||||
hotkey, Choice, Composite, EventCtx, GfxCtx, Key, Line, ManagedWidget, Outcome, Text, TextExt,
|
||||
};
|
||||
|
||||
// TODO SimOptions stuff too
|
||||
#[derive(Clone)]
|
||||
@ -71,7 +73,7 @@ impl OptionsPanel {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Settings").roboto_bold())),
|
||||
Line("Settings").roboto_bold().draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::checkbox(ctx, "Enable developer mode", None, app.opts.dev)
|
||||
@ -91,11 +93,7 @@ impl OptionsPanel {
|
||||
)
|
||||
.margin(5),
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Traffic signal rendering:")),
|
||||
)
|
||||
.margin(5),
|
||||
"Traffic signal rendering:".draw_text(ctx).margin(5),
|
||||
// TODO Refactor this pattern somehow, using drop-down menus or radio
|
||||
// buttons
|
||||
WrappedComposite::nice_text_button(
|
||||
@ -110,7 +108,7 @@ impl OptionsPanel {
|
||||
.margin(5),
|
||||
]),
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Color scheme:"))).margin(5),
|
||||
"Color scheme:".draw_text(ctx).margin(5),
|
||||
WrappedComposite::nice_text_button(
|
||||
ctx,
|
||||
Text::from(Line(format!("{} ▼", app.opts.cs_name()))),
|
||||
@ -120,11 +118,9 @@ impl OptionsPanel {
|
||||
.margin(5),
|
||||
]),
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Scale factor for text / UI elements:")),
|
||||
)
|
||||
.margin(5),
|
||||
"Scale factor for text / UI elements:"
|
||||
.draw_text(ctx)
|
||||
.margin(5),
|
||||
WrappedComposite::nice_text_button(
|
||||
ctx,
|
||||
Text::from(Line(format!("{} ▼", ctx.get_scale_factor()))),
|
||||
|
@ -86,7 +86,7 @@ pub fn main_menu(ctx: &mut EventCtx, app: &App) -> Box<dyn State> {
|
||||
{
|
||||
let mut txt = Text::from(Line("A/B STREET").size(100));
|
||||
txt.add(Line("Created by Dustin Carlino"));
|
||||
ManagedWidget::draw_text(ctx, txt).centered_horiz()
|
||||
txt.draw(ctx).centered_horiz()
|
||||
},
|
||||
ManagedWidget::row(vec![
|
||||
WrappedComposite::svg_button(
|
||||
@ -121,7 +121,7 @@ pub fn main_menu(ctx: &mut EventCtx, app: &App) -> Box<dyn State> {
|
||||
},
|
||||
ManagedWidget::col(vec![
|
||||
WrappedComposite::text_bg_button(ctx, "About A/B Street", None),
|
||||
ManagedWidget::draw_text(ctx, built_info::time()),
|
||||
built_info::time().draw(ctx),
|
||||
])
|
||||
.centered(),
|
||||
];
|
||||
@ -253,9 +253,7 @@ fn about(ctx: &mut EventCtx) -> Box<dyn State> {
|
||||
"people is probably coincidental, except for PedestrianID(42). ",
|
||||
));
|
||||
txt.add(Line("Have the appropriate amount of fun."));
|
||||
ManagedWidget::draw_text(ctx, txt)
|
||||
.centered_horiz()
|
||||
.align_vert_center()
|
||||
txt.draw(ctx).centered_horiz().align_vert_center()
|
||||
},
|
||||
];
|
||||
|
||||
@ -319,9 +317,7 @@ fn proposals_picker(ctx: &mut EventCtx) -> Box<dyn State> {
|
||||
"These are proposed changes to Seattle made by community members.",
|
||||
));
|
||||
txt.add(Line("Contact dabreegster@gmail.com to add your idea here!"));
|
||||
ManagedWidget::draw_text(ctx, txt)
|
||||
.centered_horiz()
|
||||
.bg(colors::PANEL_BG)
|
||||
txt.draw(ctx).centered_horiz().bg(colors::PANEL_BG)
|
||||
},
|
||||
ManagedWidget::row(buttons)
|
||||
.flex_wrap(ctx, 80)
|
||||
|
@ -6,7 +6,7 @@ use crate::render::intersection::make_crosswalk;
|
||||
use crate::render::{DrawTurnGroup, BIG_ARROW_THICKNESS};
|
||||
use ezgui::{
|
||||
hotkey, Button, Color, Composite, EventCtx, GeomBatch, HorizontalAlignment, Key, Line,
|
||||
ManagedWidget, Prerender, Text, VerticalAlignment,
|
||||
ManagedWidget, Prerender, Text, TextExt, VerticalAlignment,
|
||||
};
|
||||
use geom::{Angle, Circle, Distance, Duration, Line, PolyLine, Polygon, Pt2D};
|
||||
use map_model::{IntersectionID, Phase, TurnPriority};
|
||||
@ -221,7 +221,7 @@ pub fn make_signal_diagram(
|
||||
let bbox = Polygon::rectangle(zoom * bounds.width(), zoom * bounds.height());
|
||||
|
||||
let signal = app.primary.map.get_traffic_signal(i);
|
||||
let txt_widget = ManagedWidget::draw_text(ctx, {
|
||||
let txt_widget = {
|
||||
let mut txt = Text::from(Line(format!("Intersection #{}", i.0)).roboto_bold());
|
||||
|
||||
let mut road_names = BTreeSet::new();
|
||||
@ -237,8 +237,8 @@ pub fn make_signal_diagram(
|
||||
txt.add(Line(format!("{} phases", signal.phases.len())).roboto_bold());
|
||||
txt.add(Line(format!("Signal offset: {}", signal.offset)));
|
||||
txt.add(Line(format!("One cycle lasts {}", signal.cycle_length())));
|
||||
txt
|
||||
});
|
||||
txt.draw(ctx)
|
||||
};
|
||||
let mut col = if edit_mode {
|
||||
vec![
|
||||
txt_widget,
|
||||
@ -270,10 +270,7 @@ pub fn make_signal_diagram(
|
||||
if edit_mode {
|
||||
phase_rows.push(
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Phase {}: {}", idx + 1, phase.duration))),
|
||||
),
|
||||
format!("Phase {}: {}", idx + 1, phase.duration).draw_text(ctx),
|
||||
WrappedComposite::svg_button(
|
||||
ctx,
|
||||
"../data/system/assets/tools/edit.svg",
|
||||
@ -290,10 +287,7 @@ pub fn make_signal_diagram(
|
||||
.centered(),
|
||||
);
|
||||
} else {
|
||||
phase_rows.push(ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Phase {}: {}", idx + 1, phase.duration))),
|
||||
));
|
||||
phase_rows.push(format!("Phase {}: {}", idx + 1, phase.duration).draw_text(ctx));
|
||||
}
|
||||
|
||||
let mut orig_batch = GeomBatch::new();
|
||||
|
@ -10,7 +10,7 @@ use abstutil::prettyprint_usize;
|
||||
use abstutil::Counter;
|
||||
use ezgui::{
|
||||
hotkey, Button, Color, Composite, EventCtx, Histogram, Key, Line, ManagedWidget, Plot,
|
||||
PlotOptions, Series, Text,
|
||||
PlotOptions, Series, Text, TextExt,
|
||||
};
|
||||
use geom::{Duration, Statistic, Time};
|
||||
use map_model::BusRouteID;
|
||||
@ -159,12 +159,9 @@ fn trips_summary_prebaked(ctx: &EventCtx, app: &App) -> ManagedWidget {
|
||||
}
|
||||
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, txt),
|
||||
txt.draw(ctx),
|
||||
finished_trips_plot(ctx, app).bg(colors::SECTION_BG),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line("Are trips faster or slower than the baseline?")),
|
||||
),
|
||||
"Are trips faster or slower than the baseline?".draw_text(ctx),
|
||||
Histogram::new(
|
||||
app.primary
|
||||
.sim
|
||||
@ -173,7 +170,7 @@ fn trips_summary_prebaked(ctx: &EventCtx, app: &App) -> ManagedWidget {
|
||||
ctx,
|
||||
)
|
||||
.bg(colors::SECTION_BG),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Active agents").roboto_bold())),
|
||||
Line("Active agents").roboto_bold().draw(ctx),
|
||||
Plot::new_usize(
|
||||
ctx,
|
||||
vec![
|
||||
@ -241,9 +238,9 @@ fn trips_summary_not_prebaked(ctx: &EventCtx, app: &App) -> ManagedWidget {
|
||||
}
|
||||
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, txt),
|
||||
txt.draw(ctx),
|
||||
finished_trips_plot(ctx, app).bg(colors::SECTION_BG),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Active agents").roboto_bold())),
|
||||
Line("Active agents").roboto_bold().draw(ctx),
|
||||
Plot::new_usize(
|
||||
ctx,
|
||||
vec![Series {
|
||||
@ -312,10 +309,7 @@ fn finished_trips_plot(ctx: &EventCtx, app: &App) -> ManagedWidget {
|
||||
.collect(),
|
||||
PlotOptions::new(),
|
||||
);
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("finished trips"))),
|
||||
plot.margin(10),
|
||||
])
|
||||
ManagedWidget::col(vec!["finished trips".draw_text(ctx), plot.margin(10)])
|
||||
}
|
||||
|
||||
fn pick_finished_trips_mode(ctx: &EventCtx) -> (ManagedWidget, Vec<(String, Callback)>) {
|
||||
@ -396,7 +390,7 @@ fn parking_overhead(ctx: &EventCtx, app: &App) -> ManagedWidget {
|
||||
for line in app.primary.sim.get_analytics().analyze_parking_phases() {
|
||||
txt.add_wrapped(line, 0.9 * ctx.canvas.window_width);
|
||||
}
|
||||
ManagedWidget::draw_text(ctx, txt)
|
||||
txt.draw(ctx)
|
||||
}
|
||||
|
||||
fn pick_bus_route(ctx: &EventCtx, app: &App) -> (ManagedWidget, Vec<(String, Callback)>) {
|
||||
|
@ -84,13 +84,14 @@ pub fn freeform_controller(
|
||||
) -> WrappedComposite {
|
||||
let c = Composite::new(
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Sandbox").size(26))).margin(5),
|
||||
Line("Sandbox").size(26).draw(ctx).margin(5),
|
||||
ManagedWidget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
)
|
||||
.margin(5),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Map:").size(18).roboto_bold()))
|
||||
Text::from(Line("Map:").size(18).roboto_bold())
|
||||
.draw(ctx)
|
||||
.margin(5),
|
||||
WrappedComposite::nice_text_button(
|
||||
ctx,
|
||||
@ -103,7 +104,8 @@ pub fn freeform_controller(
|
||||
"change map",
|
||||
)
|
||||
.margin(5),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Traffic:").size(18).roboto_bold()))
|
||||
Text::from(Line("Traffic:").size(18).roboto_bold())
|
||||
.draw(ctx)
|
||||
.margin(5),
|
||||
WrappedComposite::nice_text_button(
|
||||
ctx,
|
||||
|
@ -268,7 +268,7 @@ fn challenge_controller(
|
||||
}
|
||||
|
||||
let mut rows = vec![ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(title).size(26))).margin(5),
|
||||
Line(title).size(26).draw(ctx).margin(5),
|
||||
WrappedComposite::svg_button(ctx, "../data/system/assets/tools/info.svg", "info", None)
|
||||
.margin(5),
|
||||
ManagedWidget::draw_batch(
|
||||
@ -337,13 +337,10 @@ impl FinalScore {
|
||||
|
||||
Box::new(FinalScore {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, txt),
|
||||
ManagedWidget::row(row).centered(),
|
||||
])
|
||||
.bg(colors::PANEL_BG)
|
||||
.outline(10.0, Color::WHITE)
|
||||
.padding(10),
|
||||
ManagedWidget::col(vec![txt.draw(ctx), ManagedWidget::row(row).centered()])
|
||||
.bg(colors::PANEL_BG)
|
||||
.outline(10.0, Color::WHITE)
|
||||
.padding(10),
|
||||
)
|
||||
.aligned(HorizontalAlignment::Center, VerticalAlignment::Center)
|
||||
.build(ctx),
|
||||
|
@ -9,7 +9,7 @@ use crate::sandbox::SandboxMode;
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, ManagedWidget, Outcome,
|
||||
Text, VerticalAlignment,
|
||||
Text, TextExt, VerticalAlignment,
|
||||
};
|
||||
use geom::{Distance, Duration, PolyLine};
|
||||
use map_model::{
|
||||
@ -707,10 +707,10 @@ fn make_top_bar(ctx: &mut EventCtx, title: &str, howto: &str) -> Composite {
|
||||
Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(title).roboto_bold())),
|
||||
Line(title).roboto_bold().draw(ctx),
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
]),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(howto))),
|
||||
howto.draw_text(ctx),
|
||||
])
|
||||
.padding(10)
|
||||
.bg(colors::PANEL_BG),
|
||||
|
@ -13,7 +13,7 @@ use crate::sandbox::{
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, hotkeys, lctrl, Button, Color, Composite, EventCtx, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, RewriteColor, ScreenPt, Text,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, RewriteColor, ScreenPt, Text, TextExt,
|
||||
VerticalAlignment,
|
||||
};
|
||||
use geom::{Distance, Duration, PolyLine, Polygon, Pt2D, Statistic, Time};
|
||||
@ -888,19 +888,15 @@ impl TutorialState {
|
||||
|
||||
fn make_top_center(&self, ctx: &mut EventCtx, edit_map: bool) -> Composite {
|
||||
let mut col = vec![ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Tutorial").size(26))).margin(5),
|
||||
Line("Tutorial").size(26).draw(ctx).margin(5),
|
||||
ManagedWidget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
)
|
||||
.margin(5),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(
|
||||
Line(format!("{}/{}", self.current.stage + 1, self.stages.len())).size(20),
|
||||
),
|
||||
)
|
||||
.margin(5),
|
||||
Text::from(Line(format!("{}/{}", self.current.stage + 1, self.stages.len())).size(20))
|
||||
.draw(ctx)
|
||||
.margin(5),
|
||||
if self.current.stage == 0 {
|
||||
Button::inactive_button(ctx, "<")
|
||||
} else {
|
||||
@ -930,17 +926,15 @@ impl TutorialState {
|
||||
let task = self.interaction();
|
||||
if task != Task::Nil {
|
||||
col.push(ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(
|
||||
Line(format!(
|
||||
"Task {}: {}",
|
||||
self.current.stage + 1,
|
||||
self.stage().task.label()
|
||||
))
|
||||
.roboto_bold(),
|
||||
),
|
||||
),
|
||||
Text::from(
|
||||
Line(format!(
|
||||
"Task {}: {}",
|
||||
self.current.stage + 1,
|
||||
self.stage().task.label()
|
||||
))
|
||||
.roboto_bold(),
|
||||
)
|
||||
.draw(ctx),
|
||||
WrappedComposite::svg_button(
|
||||
ctx,
|
||||
"../data/system/assets/tools/info.svg",
|
||||
@ -950,7 +944,7 @@ impl TutorialState {
|
||||
.centered_vert()
|
||||
.align_right(),
|
||||
]));
|
||||
col.push(ManagedWidget::draw_text(ctx, task.top_txt(ctx, self)).margin(5));
|
||||
col.push(task.top_txt(ctx, self).draw(ctx).margin(5));
|
||||
}
|
||||
}
|
||||
if edit_map {
|
||||
@ -999,7 +993,7 @@ impl TutorialState {
|
||||
|
||||
msg_panel: if let Some((ref lines, _)) = self.lines() {
|
||||
let mut col = vec![
|
||||
ManagedWidget::draw_text(ctx, {
|
||||
{
|
||||
let mut txt = Text::new();
|
||||
txt.add(Line(self.stage().task.label()).roboto_bold());
|
||||
txt.add(Line(""));
|
||||
@ -1007,8 +1001,8 @@ impl TutorialState {
|
||||
for l in lines {
|
||||
txt.add(Line(*l));
|
||||
}
|
||||
txt
|
||||
}),
|
||||
txt.draw(ctx)
|
||||
},
|
||||
ManagedWidget::row(vec![
|
||||
if self.current.part > 0 {
|
||||
WrappedComposite::svg_button(
|
||||
@ -1025,16 +1019,10 @@ impl TutorialState {
|
||||
RewriteColor::ChangeAll(Color::WHITE.alpha(0.5)),
|
||||
)
|
||||
},
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!(
|
||||
"{}/{}",
|
||||
self.current.part + 1,
|
||||
self.stage().messages.len()
|
||||
))),
|
||||
)
|
||||
.centered_vert()
|
||||
.margin(5),
|
||||
format!("{}/{}", self.current.part + 1, self.stage().messages.len())
|
||||
.draw_text(ctx)
|
||||
.centered_vert()
|
||||
.margin(5),
|
||||
if self.current.part == self.stage().messages.len() - 1 {
|
||||
ManagedWidget::draw_svg_transform(
|
||||
ctx,
|
||||
|
@ -18,7 +18,8 @@ use crate::render::AgentColorScheme;
|
||||
pub use crate::sandbox::gameplay::{TutorialPointer, TutorialState};
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Choice, Color, Composite, EventCtx, EventLoopMode, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, Text, VerticalAlignment, Wizard,
|
||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, Text, TextExt, VerticalAlignment,
|
||||
Wizard,
|
||||
};
|
||||
pub use gameplay::spawner::spawn_agents_around;
|
||||
pub use gameplay::GameplayMode;
|
||||
@ -360,39 +361,24 @@ impl AgentMeter {
|
||||
let (finished, unfinished, by_mode, ppl_in_bldg, ppl_off_map) = app.primary.sim.num_trips();
|
||||
|
||||
let mut rows = vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Active agents"))),
|
||||
"Active agents".draw_text(ctx),
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/meters/pedestrian.svg"),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(prettyprint_usize(by_mode[&TripMode::Walk]))),
|
||||
),
|
||||
prettyprint_usize(by_mode[&TripMode::Walk]).draw_text(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/meters/bike.svg"),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(prettyprint_usize(by_mode[&TripMode::Bike]))),
|
||||
),
|
||||
prettyprint_usize(by_mode[&TripMode::Bike]).draw_text(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/meters/car.svg"),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(prettyprint_usize(by_mode[&TripMode::Drive]))),
|
||||
),
|
||||
prettyprint_usize(by_mode[&TripMode::Drive]).draw_text(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/meters/bus.svg"),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(prettyprint_usize(by_mode[&TripMode::Transit]))),
|
||||
),
|
||||
prettyprint_usize(by_mode[&TripMode::Transit]).draw_text(ctx),
|
||||
])
|
||||
.centered(),
|
||||
// TODO Not sure about this one yet
|
||||
if app.opts.dev {
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/tools/home.svg"),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line(prettyprint_usize(ppl_in_bldg)))),
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(format!("Off-map: {}", prettyprint_usize(ppl_off_map)))),
|
||||
),
|
||||
prettyprint_usize(ppl_in_bldg).draw_text(ctx),
|
||||
format!("Off-map: {}", prettyprint_usize(ppl_off_map)).draw_text(ctx),
|
||||
])
|
||||
.centered()
|
||||
} else {
|
||||
@ -420,7 +406,7 @@ impl AgentMeter {
|
||||
prettyprint_usize(finished),
|
||||
pct as usize
|
||||
)));
|
||||
ManagedWidget::draw_text(ctx, txt)
|
||||
txt.draw(ctx)
|
||||
},
|
||||
{
|
||||
ManagedWidget::row(vec![
|
||||
@ -473,7 +459,7 @@ impl AgentMeter {
|
||||
txt.append(Line("same as baseline"));
|
||||
}
|
||||
txt.add(Line(format!("Goal: {} faster", goal)).size(20));
|
||||
rows.push(ManagedWidget::draw_text(ctx, txt));
|
||||
rows.push(txt.draw(ctx));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,19 +357,19 @@ impl JumpToTime {
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
||||
ManagedWidget::draw_text(ctx, {
|
||||
{
|
||||
let mut txt = Text::from(Line("Jump to what time?").roboto_bold());
|
||||
txt.add(Line(target.ampm_tostring()));
|
||||
txt
|
||||
})
|
||||
txt.draw(ctx)
|
||||
}
|
||||
.named("target time"),
|
||||
ManagedWidget::slider("time slider").margin(10),
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("00:00").size(12).roboto())),
|
||||
Line("00:00").size(12).roboto().draw(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/speed/sunrise.svg"),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("12:00").size(12).roboto())),
|
||||
Line("12:00").size(12).roboto().draw(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/speed/sunset.svg"),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("24:00").size(12).roboto())),
|
||||
Line("24:00").size(12).roboto().draw(ctx),
|
||||
])
|
||||
.padding(10)
|
||||
.evenly_spaced(),
|
||||
@ -378,7 +378,7 @@ impl JumpToTime {
|
||||
.margin(10),
|
||||
WrappedComposite::text_bg_button(ctx, "Go!", hotkey(Key::Enter))
|
||||
.centered_horiz(),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("Active agents").roboto_bold())),
|
||||
Line("Active agents").roboto_bold().draw(ctx),
|
||||
// TODO Sync the slider / plot.
|
||||
Plot::new_usize(
|
||||
ctx,
|
||||
@ -453,15 +453,15 @@ impl State for JumpToTime {
|
||||
self.composite.replace(
|
||||
ctx,
|
||||
"target time",
|
||||
ManagedWidget::draw_text(ctx, {
|
||||
{
|
||||
let mut txt = Text::from(Line("Jump to what time?").roboto_bold());
|
||||
txt.add(Line(target.ampm_tostring()));
|
||||
// TODO The panel jumps too much and the slider position changes place.
|
||||
/*if target < app.primary.sim.time() {
|
||||
txt.add(Line("(Going back in time will reset to midnight, then simulate forwards)"));
|
||||
}*/
|
||||
txt
|
||||
})
|
||||
txt.draw(ctx)
|
||||
}
|
||||
.named("target time"),
|
||||
);
|
||||
}
|
||||
@ -500,7 +500,7 @@ impl TimeWarpScreen {
|
||||
traffic_jams,
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::new()).named("text"),
|
||||
Text::new().draw(ctx).named("text"),
|
||||
WrappedComposite::text_bg_button(ctx, "stop now", hotkey(Key::Escape))
|
||||
.centered_horiz(),
|
||||
])
|
||||
@ -548,11 +548,8 @@ impl State for TimeWarpScreen {
|
||||
Duration::realtime_elapsed(self.started)
|
||||
)));
|
||||
|
||||
self.composite.replace(
|
||||
ctx,
|
||||
"text",
|
||||
ManagedWidget::draw_text(ctx, txt).named("text"),
|
||||
);
|
||||
self.composite
|
||||
.replace(ctx, "text", txt.draw(ctx).named("text"));
|
||||
}
|
||||
if app.primary.sim.time() == self.target {
|
||||
return Transition::Pop;
|
||||
@ -597,12 +594,10 @@ impl TimePanel {
|
||||
time: app.primary.sim.time(),
|
||||
composite: Composite::new(
|
||||
ManagedWidget::col(vec![
|
||||
ManagedWidget::draw_text(
|
||||
ctx,
|
||||
Text::from(Line(app.primary.sim.time().ampm_tostring()).size(30)),
|
||||
)
|
||||
.margin(10)
|
||||
.centered_horiz(),
|
||||
Text::from(Line(app.primary.sim.time().ampm_tostring()).size(30))
|
||||
.draw(ctx)
|
||||
.margin(10)
|
||||
.centered_horiz(),
|
||||
{
|
||||
let mut batch = GeomBatch::new();
|
||||
// This is manually tuned
|
||||
@ -622,11 +617,11 @@ impl TimePanel {
|
||||
ManagedWidget::draw_batch(ctx, batch)
|
||||
},
|
||||
ManagedWidget::row(vec![
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("00:00").size(12).roboto())),
|
||||
Line("00:00").size(12).roboto().draw(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/speed/sunrise.svg"),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("12:00").size(12).roboto())),
|
||||
Line("12:00").size(12).roboto().draw(ctx),
|
||||
ManagedWidget::draw_svg(ctx, "../data/system/assets/speed/sunset.svg"),
|
||||
ManagedWidget::draw_text(ctx, Text::from(Line("24:00").size(12).roboto())),
|
||||
Line("24:00").size(12).roboto().draw(ctx),
|
||||
])
|
||||
.padding(10)
|
||||
.evenly_spaced(),
|
||||
|
Loading…
Reference in New Issue
Block a user