Rename {Text,TextSpan}::draw to into_widget, for consistency. #253

This commit is contained in:
Dustin Carlino 2021-03-09 09:59:30 -08:00
parent a4a20ce1e5
commit 65d7bc5c8e
84 changed files with 350 additions and 287 deletions

View File

@ -22,7 +22,9 @@ impl FindHome {
pub fn new(ctx: &mut EventCtx, options: Options) -> Box<dyn State<App>> {
let panel = Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Find your walkable home").small_heading().draw(ctx),
Line("Find your walkable home")
.small_heading()
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
// TODO Adjust text to say bikeshed, or otherwise reflect the options chosen
@ -141,7 +143,7 @@ impl Results {
let panel = Panel::new(Widget::col(vec![
Line("Results for your walkable home")
.small_heading()
.draw(ctx),
.into_widget(ctx),
// TODO Adjust text to say bikeshed, or otherwise reflect the options chosen
"Here are all of the matching houses.".text_widget(ctx),
format!(

View File

@ -280,7 +280,7 @@ fn build_panel(ctx: &mut EventCtx, app: &App, start: &Building, isochrone: &Isoc
rows.push(
Line("15-minute neighborhood explorer")
.small_heading()
.draw(ctx),
.into_widget(ctx),
);
rows.push(
@ -298,7 +298,7 @@ fn build_panel(ctx: &mut EventCtx, app: &App, start: &Building, isochrone: &Isoc
Line("Starting from: ").secondary(),
Line(&start.address),
])
.draw(ctx),
.into_widget(ctx),
);
rows.push(
@ -306,7 +306,7 @@ fn build_panel(ctx: &mut EventCtx, app: &App, start: &Building, isochrone: &Isoc
Line("Estimated population: ").secondary(),
Line(prettyprint_usize(isochrone.population)),
])
.draw(ctx),
.into_widget(ctx),
);
rows.push(
@ -314,7 +314,7 @@ fn build_panel(ctx: &mut EventCtx, app: &App, start: &Building, isochrone: &Isoc
Line("Estimated street parking spots: ").secondary(),
Line(prettyprint_usize(isochrone.onstreet_parking_spots)),
])
.draw(ctx),
.into_widget(ctx),
);
rows.push(ColorLegend::categories(
@ -488,7 +488,7 @@ impl ExploreAmenities {
Widget::row(vec![
Line(format!("{} within 15 minutes", category))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
table.render(ctx, app),
@ -509,7 +509,7 @@ impl ExploreAmenities {
Widget::row(vec![
Line(format!("{} within 15 minutes", self.category))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
self.table.render(ctx, app),

View File

@ -179,7 +179,11 @@ fn make_panel(
.autocrop()
.into_widget(ctx),
Widget::custom_row(vec![
scenes[idx].msg.clone().wrap_to_pct(ctx, 30).draw(ctx),
scenes[idx]
.msg
.clone()
.wrap_to_pct(ctx, 30)
.into_widget(ctx),
Image::untinted("system/assets/characters/player.svg").into_widget(ctx),
])
.align_right(),
@ -189,7 +193,11 @@ fn make_panel(
.scale(0.75)
.autocrop()
.into_widget(ctx),
scenes[idx].msg.clone().wrap_to_pct(ctx, 30).draw(ctx),
scenes[idx]
.msg
.clone()
.wrap_to_pct(ctx, 30)
.into_widget(ctx),
Image::untinted("system/assets/characters/player.svg")
.into_widget(ctx)
.align_right(),
@ -207,7 +215,11 @@ fn make_panel(
.scale(scale)
.autocrop()
.into_widget(ctx),
scenes[idx].msg.clone().wrap_to_pct(ctx, 30).draw(ctx),
scenes[idx]
.msg
.clone()
.wrap_to_pct(ctx, 30)
.into_widget(ctx),
]),
Image::untinted("system/assets/characters/player.svg").into_widget(ctx),
])
@ -232,7 +244,7 @@ fn make_panel(
.btn_back("Home")
.build_widget(ctx, "quit")
.margin_right(100),
Line(name).big_heading_styled().draw(ctx),
Line(name).big_heading_styled().into_widget(ctx),
])
.margin_below(40),
inner

View File

@ -140,7 +140,7 @@ impl ChallengesPicker {
Line("A/B STREET").display_title(),
Line("CHALLENGES").big_heading_styled(),
])
.draw(ctx)
.into_widget(ctx)
.centered_horiz(),
ctx.style()
.btn_outline
@ -215,7 +215,7 @@ impl ChallengesPicker {
}
let mut inner_col = vec![
txt.draw(ctx),
txt.into_widget(ctx),
ctx.style()
.btn_outline
.text("Start!")
@ -234,7 +234,7 @@ impl ChallengesPicker {
)));
idx += 1;
}
inner_col.push(txt.draw(ctx));
inner_col.push(txt.into_widget(ctx));
} else {
inner_col.push("No attempts yet".text_widget(ctx));
}

View File

@ -74,7 +74,9 @@ impl DebugWarp {
Box::new(DebugWarp {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Warp to an object by ID").small_heading().draw(ctx),
Line("Warp to an object by ID")
.small_heading()
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Example: r42 is Road #42".text_widget(ctx),
@ -108,13 +110,13 @@ impl DebugWarp {
Line("L").fg(c),
Line("ot"),
])
.draw(ctx),
.into_widget(ctx),
Text::from_all(vec![
Line("Or "),
Line("j").fg(c),
Line("ump to the previous position"),
])
.draw(ctx),
.into_widget(ctx),
Widget::text_entry(ctx, String::new(), true).named("input"),
ctx.style()
.btn_outline

View File

@ -39,11 +39,11 @@ impl Viewer {
Widget::row(vec![
Line("What agents are blocked by others?")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Text::from(Line("Root causes"))
.draw(ctx)
.into_widget(ctx)
.named("root causes"),
]))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)

View File

@ -51,7 +51,7 @@ impl Floodfiller {
Box::new(Floodfiller {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line(title).small_heading().draw(ctx),
Line(title).small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
format!("{} unreachable lanes", num_unreachable).text_widget(ctx),

View File

@ -52,10 +52,10 @@ impl DebugMode {
Box::new(DebugMode {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Debug Mode").small_heading().draw(ctx),
Line("Debug Mode").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Text::new().draw(ctx).named("current info"),
Text::new().into_widget(ctx).named("current info"),
Toggle::switch(ctx, "show buildings", Key::Num1, true),
Toggle::switch(ctx, "show intersections", Key::Num2, true),
Toggle::switch(ctx, "show lanes", Key::Num3, true),
@ -139,7 +139,7 @@ impl DebugMode {
Key::LeftControl.txt(ctx),
Line(" to show position"),
])
.draw(ctx),
.into_widget(ctx),
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top)
.build(ctx),
@ -171,7 +171,8 @@ impl DebugMode {
abstutil::prettyprint_usize(n)
)));
}
self.panel.replace(ctx, "current info", txt.draw(ctx));
self.panel
.replace(ctx, "current info", txt.into_widget(ctx));
}
}

View File

@ -67,7 +67,7 @@ impl PathCounter {
Widget::row(vec![
Line(format!("Paths across {}", i))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ColorLegend::gradient(

View File

@ -35,7 +35,7 @@ impl PolygonDebugger {
Box::new(PolygonDebugger {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Geometry debugger").small_heading().draw(ctx),
Line("Geometry debugger").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::row(vec![

View File

@ -27,7 +27,7 @@ impl RouteExplorer {
goal: None,
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Route explorer").small_heading().draw(ctx),
Line("Route explorer").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ctx.style()
@ -288,7 +288,7 @@ impl AllRoutesExplorer {
Box::new(AllRoutesExplorer {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("All routes explorer").small_heading().draw(ctx),
Line("All routes explorer").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
format!("{} total requests", prettyprint_usize(requests.len())).text_widget(ctx),

View File

@ -31,7 +31,7 @@ impl UberTurnPicker {
Widget::row(vec![
Line("Select multiple intersections")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ctx.style()
@ -174,7 +174,7 @@ impl UberTurnViewer {
let panel = Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Uber-turn viewer").small_heading().draw(ctx),
Line("Uber-turn viewer").small_heading().into_widget(ctx),
Widget::vert_separator(ctx, 50.0),
ctx.style()
.btn_prev()
@ -182,7 +182,7 @@ impl UberTurnViewer {
.hotkey(Key::LeftArrow)
.build_widget(ctx, "previous uber-turn"),
Text::from(Line(format!("{}/{}", idx + 1, ic.uber_turns.len())).secondary())
.draw(ctx)
.into_widget(ctx)
.centered_vert(),
ctx.style()
.btn_next()

View File

@ -38,7 +38,7 @@ impl CollisionsViewer {
Box::new(CollisionsViewer {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Collisions viewer").small_heading().draw(ctx),
Line("Collisions viewer").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
format!("{} collisions", prettyprint_usize(count))

View File

@ -94,12 +94,14 @@ impl PopularDestinations {
draw: ctx.upload(batch),
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Most popular destinations").small_heading().draw(ctx),
Line("Most popular destinations")
.small_heading()
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Toggle::switch(ctx, "Show heatmap", None, opts.is_some()),
controls,
breakdown.draw(ctx),
breakdown.into_widget(ctx),
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top)
.build(ctx),

View File

@ -69,7 +69,7 @@ impl ViewKML {
draw: ctx.upload(batch),
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("KML viewer").small_heading().draw(ctx),
Line("KML viewer").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
format!(

View File

@ -31,7 +31,7 @@ impl DevToolsMode {
Box::new(DevToolsMode {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Internal dev tools").small_heading().draw(ctx),
Line("Internal dev tools").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::row(vec![

View File

@ -29,7 +29,7 @@ impl PolygonEditor {
Box::new(PolygonEditor {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Polygon editor").small_heading().draw(ctx),
Line("Polygon editor").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ctx.style()

View File

@ -51,7 +51,7 @@ impl ScenarioManager {
Widget::row(vec![
Line(format!("Scenario {}", scenario.scenario_name))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ctx.style()
@ -75,7 +75,7 @@ impl ScenarioManager {
Line(""),
Line("Parked cars per building"),
])
.draw(ctx),
.into_widget(ctx),
legend,
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top)

View File

@ -310,7 +310,7 @@ impl State<App> for StoryMapEditor {
fn make_panel(ctx: &mut EventCtx, story: &StoryMap, mode: &Mode, dirty: bool) -> Panel {
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Story map editor").small_heading().draw(ctx),
Line("Story map editor").small_heading().into_widget(ctx),
Widget::vert_separator(ctx, 30.0),
ctx.style()
.btn_outline
@ -489,7 +489,7 @@ impl Marker {
fn make_editor(&self, ctx: &mut EventCtx) -> Panel {
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Editing marker").small_heading().draw(ctx),
Line("Editing marker").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ctx.style().btn_outline.text("delete").build_def(ctx),

View File

@ -29,7 +29,7 @@ impl BulkSelect {
fn make_select_panel(ctx: &mut EventCtx, selector: &RoadSelector) -> Panel {
Panel::new(Widget::col(vec![
Line("Edit many roads").small_heading().draw(ctx),
Line("Edit many roads").small_heading().into_widget(ctx),
selector.make_controls(ctx),
Widget::row(vec![
ctx.style()
@ -158,7 +158,7 @@ impl BulkEdit {
panel: Panel::new(Widget::col(vec![
Line(format!("Editing {} roads", roads.len()))
.small_heading()
.draw(ctx),
.into_widget(ctx),
"Lane types".text_widget(ctx),
make_lt_switcher(ctx, vec![(None, None)]).named("lt transformations"),
{

View File

@ -69,7 +69,9 @@ impl LaneEditor {
let parent = app.primary.map.get_parent(l);
let col = vec![
Widget::row(vec![
Line(format!("Editing {}", l)).small_heading().draw(ctx),
Line(format!("Editing {}", l))
.small_heading()
.into_widget(ctx),
ctx.style()
.btn_plain
.text("+ Edit multiple")

View File

@ -394,14 +394,14 @@ impl SaveEdits {
let mut save = SaveEdits {
current_name: initial_name.clone(),
panel: Panel::new(Widget::col(vec![
Line(title).small_heading().draw(ctx),
Line(title).small_heading().into_widget(ctx),
Widget::row(vec![
"Name:".text_widget(ctx).centered_vert(),
Widget::text_entry(ctx, initial_name, true).named("filename"),
]),
// TODO Want this to always consistently be one line high, but it isn't for a blank
// line
Text::new().draw(ctx).named("warning"),
Text::new().into_widget(ctx).named("warning"),
Widget::row(vec![
if discard {
ctx.style()
@ -448,7 +448,8 @@ impl SaveEdits {
.disabled(true)
.build_def(ctx),
);
self.panel.replace(ctx, "warning", Text::new().draw(ctx));
self.panel
.replace(ctx, "warning", Text::new().into_widget(ctx));
} else if abstio::file_exists(abstio::path_edits(
app.primary.map.get_name(),
&self.current_name,
@ -467,7 +468,7 @@ impl SaveEdits {
"warning",
Line("A proposal with this name already exists")
.fg(Color::hex("#FF5E5E"))
.draw(ctx),
.into_widget(ctx),
);
} else {
self.panel.replace(
@ -479,7 +480,8 @@ impl SaveEdits {
.hotkey(Key::Enter)
.build_def(ctx),
);
self.panel.replace(ctx, "warning", Text::new().draw(ctx));
self.panel
.replace(ctx, "warning", Text::new().into_widget(ctx));
}
}
}
@ -534,7 +536,7 @@ impl LoadEdits {
fn new(ctx: &mut EventCtx, app: &App, mode: GameplayMode) -> Box<dyn State<App>> {
let current_edits_name = &app.primary.map.get_edits().edits_name;
let your_edits = vec![
Line("Your proposals").small_heading().draw(ctx),
Line("Your proposals").small_heading().into_widget(ctx),
Menu::widget(
ctx,
abstio::list_all_objects(abstio::path_all_edits(app.primary.map.get_name()))
@ -545,7 +547,7 @@ impl LoadEdits {
];
// widgetry can't toggle keyboard focus between two menus, so just use buttons for the less
// common use case.
let mut proposals = vec![Line("Community proposals").small_heading().draw(ctx)];
let mut proposals = vec![Line("Community proposals").small_heading().into_widget(ctx)];
// Up-front filter out proposals that definitely don't fit the current map
for name in abstio::list_all_objects(abstio::path("system/proposals")) {
let path = abstio::path(format!("system/proposals/{}.json", name));
@ -558,7 +560,7 @@ impl LoadEdits {
mode,
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Load proposal").small_heading().draw(ctx),
Line("Load proposal").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
ctx.style()
@ -652,7 +654,7 @@ fn make_topcenter(ctx: &mut EventCtx, app: &App) -> Panel {
Panel::new(Widget::col(vec![
Line("Editing map")
.small_heading()
.draw(ctx)
.into_widget(ctx)
.centered_horiz(),
ctx.style()
.btn_solid_primary
@ -868,7 +870,7 @@ impl ConfirmDiscard {
.into_widget(ctx)
.container()
.padding_top(6),
Line("Alert").small_heading().draw(ctx),
Line("Alert").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Are you sure you want to discard changes you made?".text_widget(ctx),

View File

@ -22,10 +22,10 @@ impl RouteEditor {
Box::new(RouteEditor {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Route editor").small_heading().draw(ctx),
Line("Route editor").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Line(&route.full_name).draw(ctx),
Line(&route.full_name).into_widget(ctx),
// TODO This UI needs design, just something to start plumbing the edits
Widget::row(vec![
"Frequency in minutes".text_widget(ctx),

View File

@ -50,7 +50,7 @@ impl StopSignEditor {
.collect();
let panel = Panel::new(Widget::col(vec![
Line("Stop sign editor").small_heading().draw(ctx),
Line("Stop sign editor").small_heading().into_widget(ctx),
ctx.style()
.btn_outline
.text("reset to default")

View File

@ -27,7 +27,7 @@ impl ChangeDuration {
Widget::row(vec![
Line("How long should this stage last?")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::row(vec![
@ -61,7 +61,7 @@ impl ChangeDuration {
]),
Widget::row(vec![Line("Additional time this stage can last?")
.small_heading()
.draw(ctx)]),
.into_widget(ctx)]),
Widget::row(vec![
"Seconds:".text_widget(ctx).centered_vert(),
Spinner::widget(
@ -78,7 +78,7 @@ impl ChangeDuration {
]),
Widget::row(vec![Line("How long with no demand to end stage?")
.small_heading()
.draw(ctx)]),
.into_widget(ctx)]),
Widget::row(vec![
"Seconds:".text_widget(ctx).centered_vert(),
Spinner::widget(
@ -93,7 +93,7 @@ impl ChangeDuration {
]),
Line("Minimum time is set by the time required for crosswalk")
.secondary()
.draw(ctx),
.into_widget(ctx),
ctx.style()
.btn_solid_primary
.text("Apply")

View File

@ -525,7 +525,9 @@ fn make_top_panel(ctx: &mut EventCtx, app: &App, can_undo: bool, can_redo: bool)
];
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Traffic signal editor").small_heading().draw(ctx),
Line("Traffic signal editor")
.small_heading()
.into_widget(ctx),
ctx.style()
.btn_plain
.text("+ Edit multiple")
@ -595,7 +597,7 @@ fn make_side_panel(
.secondary(),
);
}
let mut col = vec![txt.draw(ctx)];
let mut col = vec![txt.into_widget(ctx)];
col.push(Widget::horiz_separator(ctx, 0.2));
// TODO Say "normally" to account for variable stages?

View File

@ -47,7 +47,7 @@ impl ShowAbsolute {
Widget::row(vec![
Line(format!("Tuning offset for {} signals", members.len()))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Select an intersection as the base".text_widget(ctx),
@ -136,7 +136,7 @@ impl ShowRelative {
Widget::row(vec![
Line(format!("Tuning offset for {} signals", members.len()))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Select a second intersection to tune offset between the two".text_widget(ctx),
@ -228,7 +228,7 @@ impl TuneRelative {
Widget::row(vec![
Line(format!("Tuning offset between {} and {}", i1, i2))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Text::from_multiline(vec![
@ -246,7 +246,7 @@ impl TuneRelative {
dist_btwn / Scenario::max_ped_speed()
)),
])
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
"Offset (seconds):".text_widget(ctx),
Spinner::widget(ctx, (0, 90), (offset2 - offset1).inner_seconds() as isize)

View File

@ -30,7 +30,7 @@ impl SignalPicker {
Widget::row(vec![
Line("Select multiple traffic signals")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
make_btn(ctx, members.len()),

View File

@ -51,7 +51,7 @@ impl ZoneEditor {
panel: Panel::new(Widget::col(vec![
Line("Editing restricted access zone")
.small_heading()
.draw(ctx),
.into_widget(ctx),
selector.make_controls(ctx).named("selector"),
legend,
make_instructions(ctx, &allow_through_traffic).named("instructions"),
@ -224,9 +224,9 @@ fn make_instructions(ctx: &mut EventCtx, allow_through_traffic: &BTreeSet<TripMo
Would you like to restrict it?",
))
.wrap_to_pct(ctx, 30)
.draw(ctx)
.into_widget(ctx)
} else {
Line("Trips may start or end in this zone, but through-traffic is only allowed for:")
.draw(ctx)
.into_widget(ctx)
}
}

View File

@ -102,7 +102,7 @@ pub fn info(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BuildingID
}
if !txt.is_empty() {
rows.push(txt.draw(ctx))
rows.push(txt.into_widget(ctx))
}
if app.opts.dev {
@ -233,7 +233,7 @@ fn header(
let mut rows = vec![];
rows.push(Widget::row(vec![
Line(id.to_string()).small_heading().draw(ctx),
Line(id.to_string()).small_heading().into_widget(ctx),
header_btns(ctx),
]));

View File

@ -16,10 +16,10 @@ pub fn stop(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusStopID)
let sim = &app.primary.sim;
rows.push(Widget::row(vec![
Line("Bus stop").small_heading().draw(ctx),
Line("Bus stop").small_heading().into_widget(ctx),
header_btns(ctx),
]));
rows.push(Line(&bs.name).draw(ctx));
rows.push(Line(&bs.name).into_widget(ctx));
let all_arrivals = &sim.get_analytics().bus_arrivals;
for r in app.primary.map.get_routes_serving_stop(id) {
@ -45,7 +45,7 @@ pub fn stop(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusStopID)
} else {
txt.add(Line(" No arrivals yet").secondary());
}
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
}
let mut boardings: Counter<BusRouteID> = Counter::new();
@ -87,7 +87,7 @@ pub fn stop(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusStopID)
.secondary(),
);
}
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
// Draw where the bus/train stops
details.zoomed.push(
@ -122,7 +122,7 @@ pub fn bus_status(ctx: &mut EventCtx, app: &App, details: &mut Details, id: CarI
"Currently has {} passengers",
app.primary.sim.num_transit_passengers(id),
))
.draw(ctx),
.into_widget(ctx),
);
rows
@ -153,7 +153,7 @@ fn bus_header(
app.primary.map.get_br(route).short_name
))
.small_heading()
.draw(ctx),
.into_widget(ctx),
header_btns(ctx),
]));
rows.push(make_tabs(
@ -174,13 +174,13 @@ pub fn route(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusRouteI
rows.push(Widget::row(vec![
Line(format!("Route {}", route.short_name))
.small_heading()
.draw(ctx),
.into_widget(ctx),
header_btns(ctx),
]));
rows.push(
Text::from(Line(&route.full_name))
.wrap_to_pct(ctx, 20)
.draw(ctx),
.into_widget(ctx),
);
if app.opts.dev {
@ -248,7 +248,7 @@ pub fn route(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusRouteI
))
.secondary(),
])
.draw(ctx),
.into_widget(ctx),
);
rows.push(format!("{} stops", route.stops.len()).text_widget(ctx));
@ -282,7 +282,7 @@ pub fn route(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusRouteI
))
.secondary(),
])
.draw(ctx),
.into_widget(ctx),
]));
details.warpers.insert(name, ID::BusStop(bs.id));
}
@ -308,7 +308,7 @@ pub fn route(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusRouteI
.hotkey(Key::E)
.build_widget(ctx, &format!("edit {}", route.id)),
);
rows.push(describe_schedule(route).draw(ctx));
rows.push(describe_schedule(route).into_widget(ctx));
}
// Draw the route, label stops, and show location of buses

View File

@ -8,7 +8,7 @@ pub fn area(ctx: &EventCtx, app: &App, _: &mut Details, id: AreaID) -> Vec<Widge
let mut rows = vec![];
rows.push(Widget::row(vec![
Line(id.to_string()).small_heading().draw(ctx),
Line(id.to_string()).small_heading().into_widget(ctx),
header_btns(ctx),
]));

View File

@ -32,7 +32,7 @@ pub fn info(ctx: &EventCtx, app: &App, details: &mut Details, id: IntersectionID
for r in road_names {
txt.add(Line(format!(" {}", r)));
}
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
if app.opts.dev {
rows.push(
@ -73,7 +73,7 @@ pub fn traffic(
.total_for(id)
)
)));
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
rows.push(opts.to_controls(ctx, app));
@ -197,7 +197,7 @@ pub fn current_demand(
rows.push(
Widget::col(vec![
txt.draw(ctx),
txt.into_widget(ctx),
DrawWithTooltips::new(
ctx,
batch,
@ -287,7 +287,7 @@ pub fn traffic_signal(
// TODO Say "normally" or something?
txt.add(Line(format!("One cycle lasts {}", total)));
}
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
}
for (idx, stage) in signal.stages.iter().enumerate() {
@ -302,7 +302,7 @@ pub fn traffic_signal(
additional
)),
}
.draw(ctx),
.into_widget(ctx),
);
{
@ -377,7 +377,9 @@ fn delay_plot(
disabled: opts.disabled_series(),
};
Widget::col(vec![
Line("Delay through intersection").small_heading().draw(ctx),
Line("Delay through intersection")
.small_heading()
.into_widget(ctx),
if fan_chart {
FanChart::new(ctx, series, plot_opts)
} else {
@ -407,7 +409,7 @@ fn header(
IntersectionType::Construction => format!("{} (under construction)", id),
};
rows.push(Widget::row(vec![
Line(label).small_heading().draw(ctx),
Line(label).small_heading().into_widget(ctx),
header_btns(ctx),
]));

View File

@ -80,7 +80,9 @@ pub fn info(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID) -> Vec
});
}
let section = Widget::col(vec![
Line("Parking spots available").small_heading().draw(ctx),
Line("Parking spots available")
.small_heading()
.into_widget(ctx),
LinePlot::new(
ctx,
series,
@ -178,7 +180,7 @@ pub fn debug(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID) -> Ve
let mut txt = Text::from(Line(""));
txt.add(Line("Raw OpenStreetMap data"));
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
rows.extend(make_table(
ctx,
@ -210,7 +212,7 @@ pub fn traffic(
"Since midnight: {} commuters and vehicles crossed",
prettyprint_usize(app.primary.sim.get_analytics().road_thruput.total_for(r.id))
)));
rows.push(txt.draw(ctx));
rows.push(txt.into_widget(ctx));
rows.push(opts.to_controls(ctx, app));
@ -255,7 +257,7 @@ fn header(ctx: &EventCtx, app: &App, details: &mut Details, id: LaneID, tab: Tab
rows.push(Widget::row(vec![
Line(format!("{} #{}", label, id.0))
.small_heading()
.draw(ctx),
.into_widget(ctx),
header_btns(ctx),
]));
rows.push(format!("@ {}", r.get_name(app.opts.language.as_ref())).text_widget(ctx));

View File

@ -641,7 +641,7 @@ fn make_table<I: Into<String>>(ctx: &EventCtx, rows: Vec<(I, String)>) -> Vec<Wi
rows.into_iter()
.map(|(k, v)| {
Widget::row(vec![
Line(k).secondary().draw(ctx),
Line(k).secondary().into_widget(ctx),
// TODO not quite...
v.text_widget(ctx).centered_vert().align_right(),
])
@ -678,7 +678,7 @@ fn throughput<F: Fn(&Analytics) -> Vec<(AgentType, Vec<(Time, usize)>)>>(
let mut plot_opts = PlotOptions::filterable();
plot_opts.disabled = opts.disabled_series();
Widget::col(vec![
Line(title).small_heading().draw(ctx),
Line(title).small_heading().into_widget(ctx),
LinePlot::new(ctx, series, plot_opts),
])
.padding(10)

View File

@ -43,7 +43,9 @@ pub fn info(ctx: &mut EventCtx, app: &App, details: &mut Details, id: ParkingLot
}
let section = Widget::col(vec![
Line("Parking spots available").small_heading().draw(ctx),
Line("Parking spots available")
.small_heading()
.into_widget(ctx),
LinePlot::new(
ctx,
series,
@ -75,7 +77,7 @@ pub fn info(ctx: &mut EventCtx, app: &App, details: &mut Details, id: ParkingLot
fn header(ctx: &EventCtx, details: &mut Details, id: ParkingLotID, tab: Tab) -> Vec<Widget> {
vec![
Widget::row(vec![
Line(id.to_string()).small_heading().draw(ctx),
Line(id.to_string()).small_heading().into_widget(ctx),
header_btns(ctx),
]),
make_tabs(

View File

@ -320,7 +320,7 @@ pub fn bio(
Line("Pandemic model state: ").secondary(),
Line(status),
])
.draw(ctx),
.into_widget(ctx),
);
}
@ -368,7 +368,7 @@ pub fn bio(
app.primary.sim.debug_car_ui(car)
)))
.wrap_to_pct(ctx, 20)
.draw(ctx),
.into_widget(ctx),
);
}
}
@ -414,7 +414,7 @@ pub fn schedule(
trip.departure - last_t,
at
)))
.draw(ctx),
.into_widget(ctx),
);
// TODO Ideally end time if we know
last_t = trip.departure;
@ -444,7 +444,7 @@ pub fn schedule(
app.primary.sim.get_end_of_day() - last_trip.departure,
at
)))
.draw(ctx),
.into_widget(ctx),
);
rows
@ -459,7 +459,7 @@ pub fn crowd(
let mut rows = vec![];
rows.push(Widget::row(vec![
Line("Pedestrian crowd").small_heading().draw(ctx),
Line("Pedestrian crowd").small_heading().into_widget(ctx),
header_btns(ctx),
]));
@ -506,7 +506,7 @@ pub fn parked_car(
rows.push(Widget::row(vec![
Line(format!("Parked car #{}", id.0))
.small_heading()
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
// Little indirect, but the handler of this action is actually the ContextualActions
// for SandboxMode.
@ -622,7 +622,7 @@ fn header(
};
rows.push(Widget::custom_row(vec![
Line(format!("{}", id)).small_heading().draw(ctx),
Line(format!("{}", id)).small_heading().into_widget(ctx),
if let Some(icon) = maybe_icon {
let batch = GeomBatch::load_svg(ctx, icon)
.color(RewriteColor::ChangeAll(Color::hex("#A3A3A3")))
@ -636,7 +636,7 @@ fn header(
Line(format!("{}", descr))
.small_heading()
.fg(Color::hex("#A3A3A3"))
.draw(ctx)
.into_widget(ctx)
.margin_horiz(10),
Widget::row(vec![
// Little indirect, but the handler of this action is actually the ContextualActions

View File

@ -66,7 +66,7 @@ pub fn ongoing(
{
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Trip time").secondary().draw(ctx)])
Widget::custom_row(vec![Line("Trip time").secondary().into_widget(ctx)])
.force_width_pct(ctx, col_width),
Text::from_all(vec![
Line(props.total_time.to_string(&app.opts.units)),
@ -77,25 +77,25 @@ pub fn ongoing(
))
.secondary(),
])
.draw(ctx),
.into_widget(ctx),
]));
}
{
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Distance").secondary().draw(ctx)])
Widget::custom_row(vec![Line("Distance").secondary().into_widget(ctx)])
.force_width_pct(ctx, col_width),
Text::from_all(vec![
Line(props.dist_crossed.to_string(&app.opts.units)),
Line(format!("/{}", props.total_dist.to_string(&app.opts.units))).secondary(),
])
.draw(ctx),
.into_widget(ctx),
]));
}
{
col.push(Widget::custom_row(vec![
Line("Waiting")
.secondary()
.draw(ctx)
.into_widget(ctx)
.container()
.force_width_pct(ctx, col_width),
Widget::col(vec![
@ -111,15 +111,15 @@ pub fn ongoing(
},
Line(format!(" total of {} time spent waiting", activity)).secondary(),
])
.draw(ctx),
.into_widget(ctx),
]),
]));
}
{
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Purpose").secondary().draw(ctx)])
Widget::custom_row(vec![Line("Purpose").secondary().into_widget(ctx)])
.force_width_pct(ctx, col_width),
Line(trip.purpose.to_string()).secondary().draw(ctx),
Line(trip.purpose.to_string()).secondary().into_widget(ctx),
]));
}
@ -295,7 +295,7 @@ pub fn finished(
if let Some(end_time) = phases.last().as_ref().and_then(|p| p.end_time) {
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Trip time").secondary().draw(ctx)])
Widget::custom_row(vec![Line("Trip time").secondary().into_widget(ctx)])
.force_width_pct(ctx, col_width),
(end_time - trip.departure)
.to_string(&app.opts.units)
@ -303,7 +303,7 @@ pub fn finished(
]));
} else {
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Trip time").secondary().draw(ctx)])
Widget::custom_row(vec![Line("Trip time").secondary().into_widget(ctx)])
.force_width_pct(ctx, col_width),
"Trip didn't complete before map changes".text_widget(ctx),
]));
@ -313,15 +313,17 @@ pub fn finished(
// look at the prebaked results! Misleading -- change the text.
let (_, waiting, _) = app.primary.sim.finished_trip_details(id).unwrap();
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Total waiting time").secondary().draw(ctx)])
.force_width_pct(ctx, col_width),
Widget::custom_row(vec![Line("Total waiting time")
.secondary()
.into_widget(ctx)])
.force_width_pct(ctx, col_width),
waiting.to_string(&app.opts.units).text_widget(ctx),
]));
col.push(Widget::custom_row(vec![
Widget::custom_row(vec![Line("Purpose").secondary().draw(ctx)])
Widget::custom_row(vec![Line("Purpose").secondary().into_widget(ctx)])
.force_width_pct(ctx, col_width),
Line(trip.purpose.to_string()).secondary().draw(ctx),
Line(trip.purpose.to_string()).secondary().into_widget(ctx),
]));
}
@ -352,7 +354,7 @@ pub fn cancelled(
trip.cancellation_reason.as_ref().unwrap()
)))
.wrap_to_pct(ctx, 20)
.draw(ctx)];
.into_widget(ctx)];
col.extend(make_table(ctx, vec![("Purpose", trip.purpose.to_string())]));

View File

@ -93,7 +93,7 @@ impl Elevation {
Line(format!("Steepest road: {:.0}% grade", max * 100.0)),
Line("Note: elevation data is currently wrong!").secondary(),
])
.draw(ctx),
.into_widget(ctx),
ColorLegend::gradient(ctx, &app.cs.good_to_bad_red, vec!["flat", "steep"]),
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)

View File

@ -142,14 +142,14 @@ impl BikeActivity {
total_dist.to_string(&app.opts.units)
)),
])
.draw(ctx),
Line("Throughput on bike lanes").draw(ctx),
.into_widget(ctx),
Line("Throughput on bike lanes").into_widget(ctx),
ColorLegend::gradient(
ctx,
&app.cs.good_to_bad_green,
vec!["lowest count", "highest"],
),
Line("Throughput on unprotected roads").draw(ctx),
Line("Throughput on unprotected roads").into_widget(ctx),
ColorLegend::gradient(
ctx,
&app.cs.good_to_bad_red,
@ -254,7 +254,7 @@ impl Static {
edits.original_intersections.len()
)),
])
.draw(ctx),
.into_widget(ctx),
)
}

View File

@ -83,7 +83,7 @@ impl PickLayer {
pub fn pick(ctx: &mut EventCtx, app: &App) -> Box<dyn State<App>> {
let mut col = vec![Widget::custom_row(vec![
Line("Layers").small_heading().draw(ctx),
Line("Layers").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
])];

View File

@ -205,7 +205,7 @@ fn make_controls(ctx: &mut EventCtx, app: &App, opts: &Options, legend: Option<W
(model.count_dead() as f64) * pct
)),
])
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
"Filter:".text_widget(ctx),
Widget::dropdown(

View File

@ -125,7 +125,7 @@ impl Occupancy {
Line("Parking simulation disabled."),
Line("Every building has unlimited capacity.").secondary(),
])
.draw(ctx),
.into_widget(ctx),
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
.build(ctx);
@ -226,7 +226,7 @@ impl Occupancy {
prettyprint_usize(private_filled + private_avail)
)),
])
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
Toggle::switch(ctx, "On-street spots", None, onstreet),
Toggle::switch(ctx, "Parking lots", None, lots),
@ -363,7 +363,7 @@ impl Efficiency {
header(ctx, "Parking efficiency"),
Text::from(Line("How far away are people parked? (minutes)").secondary())
.wrap_to_pct(ctx, 15)
.draw(ctx),
.into_widget(ctx),
ColorLegend::gradient(
ctx,
&app.cs.good_to_bad_red,

View File

@ -163,11 +163,13 @@ fn make_controls(ctx: &mut EventCtx, app: &App, opts: &Options, legend: Option<W
Widget::row(vec![
Widget::row(vec![
Image::icon("system/assets/tools/home.svg").into_widget(ctx),
Line(prettyprint_usize(ppl_in_bldg)).small().draw(ctx),
Line(prettyprint_usize(ppl_in_bldg))
.small()
.into_widget(ctx),
]),
Line(format!("Off-map: {}", prettyprint_usize(ppl_off_map)))
.small()
.draw(ctx),
.into_widget(ctx),
])
.centered(),
];

View File

@ -77,7 +77,7 @@ impl Backpressure {
.secondary(),
)
.wrap_to_pct(ctx, 15)
.draw(ctx),
.into_widget(ctx),
ColorLegend::gradient(
ctx,
&app.cs.good_to_bad_red,
@ -221,7 +221,7 @@ impl Throughput {
header(ctx, "Throughput"),
Text::from(Line("This counts all people crossing since midnight").secondary())
.wrap_to_pct(ctx, 15)
.draw(ctx),
.into_widget(ctx),
if app.has_prebaked().is_some() {
Toggle::switch(ctx, "Compare before proposal", None, false)
} else {
@ -455,7 +455,7 @@ impl TrafficJams {
Line("A jam starts when delay exceeds 5 mins, then spreads out").secondary(),
)
.wrap_to_pct(ctx, 15)
.draw(ctx),
.into_widget(ctx),
format!("{} jams detected", cnt).text_widget(ctx),
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)

View File

@ -96,7 +96,7 @@ impl MainMenu {
{
let mut txt = Text::from(Line("A/B STREET").display_title());
txt.add(Line("Created by Dustin Carlino, Yuwen Li, & Michael Kirk"));
txt.draw(ctx).centered_horiz()
txt.into_widget(ctx).centered_horiz()
},
Widget::row({
let btn_builder = ctx
@ -177,7 +177,7 @@ impl MainMenu {
ctx.style().btn_outline.text("About").build_def(ctx),
ctx.style().btn_outline.text("Feedback").build_def(ctx),
]),
built_info::time().draw(ctx),
built_info::time().into_widget(ctx),
])
.centered(),
];
@ -283,7 +283,7 @@ impl About {
),
])
.wrap_to_pct(ctx, 50)
.draw(ctx)
.into_widget(ctx)
.centered_horiz()
.align_vert_center()
.bg(app.cs.panel_bg)
@ -357,7 +357,7 @@ impl Proposals {
}
current_tab.push(
txt.wrap_to_pct(ctx, 70)
.draw(ctx)
.into_widget(ctx)
.margin_below(15)
.margin_above(15),
);
@ -410,7 +410,7 @@ impl Proposals {
"These are proposed changes to Seattle made by community members.",
));
txt.add(Line("Contact dabreegster@gmail.com to add your idea here!"));
txt.draw(ctx).centered_horiz().margin_below(20)
txt.into_widget(ctx).centered_horiz().margin_below(20)
},
Widget::custom_row(buttons).flex_wrap(ctx, Percent::int(80)),
];

View File

@ -318,7 +318,7 @@ impl CommuterPatterns {
}
}
self.panel.replace(ctx, "current", txt.draw(ctx));
self.panel.replace(ctx, "current", txt.into_widget(ctx));
let new_scale = ColorLegend::gradient(
ctx,
@ -681,7 +681,9 @@ fn partition_sidewalk_loops(app: &App) -> Vec<Loop> {
fn make_panel(ctx: &mut EventCtx, app: &App) -> Panel {
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Commute map by block").small_heading().draw(ctx),
Line("Commute map by block")
.small_heading()
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Toggle::choice(ctx, "from / to this block", "from", "to", Key::Space, true),

View File

@ -153,7 +153,7 @@ impl TransitRoutes {
DashTab::TransitRoutes.picker(ctx, app),
Line(format!("{} Transit routes", routes.len()))
.small_heading()
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
Image::icon("system/assets/tools/search.svg").into_widget(ctx),
Autocomplete::new(

View File

@ -45,7 +45,7 @@ impl DashTab {
}
Widget::row(vec![
Image::icon("system/assets/meters/trip_histogram.svg").into_widget(ctx),
Line("Data").big_heading_plain().draw(ctx),
Line("Data").big_heading_plain().into_widget(ctx),
Widget::dropdown(ctx, "tab", self, choices),
format!("By {}", app.primary.sim.time().ampm_tostring())
.text_widget(ctx)

View File

@ -186,7 +186,7 @@ fn make_panel(ctx: &mut EventCtx, app: &App, table: &Table<App, Entry, Filters>)
),
Line("since the time spent driving off-map isn't shown here."),
])
.draw(ctx),
.into_widget(ctx),
Filler::square_width(ctx, 0.15).named("preview"),
])
.evenly_spaced(),

View File

@ -179,7 +179,7 @@ fn summary_boxes(ctx: &mut EventCtx, app: &App, filter: &Filter) -> Widget {
.small(),
Line(format!("Saved {} in total", sum_faster)).small(),
])
.draw(ctx)
.into_widget(ctx)
.container()
.padding(20)
.bg(Color::hex("#72CE36").alpha(0.5))
@ -202,7 +202,7 @@ fn summary_boxes(ctx: &mut EventCtx, app: &App, filter: &Filter) -> Widget {
.small(),
Line(format!("Lost {} in total", sum_slower)).small(),
])
.draw(ctx)
.into_widget(ctx)
.container()
.padding(20)
.bg(Color::hex("#EB3223").alpha(0.5))
@ -215,7 +215,7 @@ fn summary_boxes(ctx: &mut EventCtx, app: &App, filter: &Filter) -> Widget {
))
.small(),
])
.draw(ctx)
.into_widget(ctx)
.container()
.padding(20)
.bg(Color::hex("#F4DA22").alpha(0.5))
@ -235,7 +235,9 @@ fn scatter_plot(ctx: &mut EventCtx, app: &App, filter: &Filter) -> Widget {
}
Widget::col(vec![
Line("Trip time before and after").small_heading().draw(ctx),
Line("Trip time before and after")
.small_heading()
.into_widget(ctx),
CompareTimes::new(
ctx,
format!(
@ -393,10 +395,14 @@ fn contingency_table(ctx: &mut EventCtx, app: &App, filter: &Filter) -> Widget {
Line("Number of slower/faster trips").small_heading(),
Line("by ranges of trip time (after)").small_heading(),
])
.draw(ctx),
Line("number of trips (faster)").secondary().draw(ctx),
.into_widget(ctx),
Line("number of trips (faster)")
.secondary()
.into_widget(ctx),
DrawWithTooltips::new(ctx, batch, tooltips, Box::new(|_| GeomBatch::new())),
Line("number of trips (slower)").secondary().draw(ctx),
Line("number of trips (slower)")
.secondary()
.into_widget(ctx),
])
.padding(16)
.outline(ctx.style().section_outline)

View File

@ -43,7 +43,7 @@ impl TrafficSignalDemand {
Widget::row(vec![
Line("Traffic signal demand over time")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Text::from_all(vec![
@ -53,7 +53,7 @@ impl TrafficSignalDemand {
Key::RightArrow.txt(ctx),
Line(" to adjust the hour"),
])
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
"Hour:".text_widget(ctx),
Spinner::widget(ctx, (0, 24), 7).named("hour"),

View File

@ -113,19 +113,19 @@ impl GameplayState for Actdev {
"about A/B Street" => {
let panel = Panel::new(Widget::col(vec![
Widget::row(vec![
Line("About A/B Street").small_heading().draw(ctx),
Line("About A/B Street").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Line("Created by Dustin Carlino, Yuwen Li, & Michael Kirk")
.small()
.draw(ctx),
.into_widget(ctx),
Text::from(Line(
"A/B Street is a traffic simulation game based on OpenStreetMap. You \
can modify roads and intersections, measure the effects on different \
groups, and advocate for your proposal.",
))
.wrap_to_pct(ctx, 50)
.draw(ctx),
.into_widget(ctx),
"This is a simplified version. Check out the full version below."
.text_widget(ctx),
ctx.style().btn_outline.text("abstreet.org").build_def(ctx),
@ -200,7 +200,7 @@ impl GameplayState for Actdev {
.centered_vert(),
Line(nice_map_name(app.primary.map.get_name()))
.small_heading()
.draw(ctx),
.into_widget(ctx),
Widget::vert_separator(ctx, 50.0),
ctx.style()
.btn_popup_icon_text("system/assets/tools/calendar.svg", "scenario")

View File

@ -167,7 +167,7 @@ impl GameplayState for OptimizeCommute {
txt.add(Line("Use the locator at the top right to find the VIP."));
txt.add(Line("You can wait for one of their trips to begin or end."));
txt.add(Line("Focus on trips spent mostly waiting"));
let contents = txt.draw(ctx);
let contents = txt.into_widget(ctx);
return Some(Transition::Push(FYI::new(ctx, contents, app.cs.panel_bg)));
}
_ => unreachable!(),
@ -254,7 +254,7 @@ fn make_meter(
.icon("system/assets/tools/location.svg")
.build_widget(ctx, "locate VIP"),
format!("{}/{} trips done", done, trips).text_widget(ctx),
txt.draw(ctx),
txt.into_widget(ctx),
]),
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top)
@ -326,11 +326,11 @@ fn cutscene_task(mode: &GameplayMode) -> Box<dyn Fn(&mut EventCtx) -> Widget> {
Line(format!("Speed up the VIP's trips by a total of {}", goal)).fg(Color::BLACK),
Line("Ignore the damage done to everyone else.").fg(Color::BLACK),
])
.draw(ctx)
.into_widget(ctx)
.margin_below(30),
Widget::row(vec![
Widget::col(vec![
Line("Time").fg(Color::BLACK).draw(ctx),
Line("Time").fg(Color::BLACK).into_widget(ctx),
Image::icon("system/assets/tools/time.svg")
.color(Color::BLACK)
.into_widget(ctx),
@ -338,10 +338,10 @@ fn cutscene_task(mode: &GameplayMode) -> Box<dyn Fn(&mut EventCtx) -> Widget> {
Line("Until the VIP's").fg(Color::BLACK),
Line("last trip is done").fg(Color::BLACK),
])
.draw(ctx),
.into_widget(ctx),
]),
Widget::col(vec![
Line("Goal").fg(Color::BLACK).draw(ctx),
Line("Goal").fg(Color::BLACK).into_widget(ctx),
Image::icon("system/assets/tools/location.svg")
.color(Color::BLACK)
.into_widget(ctx),
@ -349,10 +349,10 @@ fn cutscene_task(mode: &GameplayMode) -> Box<dyn Fn(&mut EventCtx) -> Widget> {
Line("Speed up the VIP's trips").fg(Color::BLACK),
Line(format!("by at least {}", goal)).fg(Color::BLACK),
])
.draw(ctx),
.into_widget(ctx),
]),
Widget::col(vec![
Line("Score").fg(Color::BLACK).draw(ctx),
Line("Score").fg(Color::BLACK).into_widget(ctx),
Image::icon("system/assets/tools/star.svg")
.color(Color::BLACK)
.into_widget(ctx),
@ -360,7 +360,7 @@ fn cutscene_task(mode: &GameplayMode) -> Box<dyn Fn(&mut EventCtx) -> Widget> {
Line("How much time").fg(Color::BLACK),
Line("the VIP saves").fg(Color::BLACK),
])
.draw(ctx),
.into_widget(ctx),
]),
])
.evenly_spaced(),

View File

@ -182,7 +182,7 @@ impl GameplayState for FixTrafficSignals {
Key::J.txt(ctx),
Line("ams"),
]);
let contents = txt.draw(ctx);
let contents = txt.into_widget(ctx);
return Some(Transition::Push(FYI::new(ctx, contents, app.cs.panel_bg)));
}
"try again" => {
@ -227,7 +227,7 @@ impl GameplayState for FixTrafficSignals {
),
Line("Then you should check if your changes work from midnight."),
])
.draw(ctx),
.into_widget(ctx),
app.cs.panel_bg,
)));
}
@ -251,7 +251,7 @@ impl GameplayState for FixTrafficSignals {
Widget::row(vec![
Line(format!("Delay exceeded {} at {}", THRESHOLD, time))
.fg(Color::RED)
.draw(ctx)
.into_widget(ctx)
.centered_vert(),
ctx.style().btn_outline.text("try again").build_def(ctx),
]),
@ -266,7 +266,7 @@ impl GameplayState for FixTrafficSignals {
"Keep delay at all intersections under {}",
THRESHOLD
))
.draw(ctx),
.into_widget(ctx),
ctx.style()
.btn_plain
.icon_text("system/assets/tools/lightbulb.svg", "Hint")
@ -303,7 +303,7 @@ fn make_meter(ctx: &mut EventCtx, app: &App, worst: Option<(IntersectionID, Dura
Color::hex("#EB3223")
}),
])
.draw(ctx),
.into_widget(ctx),
ctx.style()
.btn_plain
.icon("system/assets/tools/location.svg")
@ -320,7 +320,8 @@ fn make_meter(ctx: &mut EventCtx, app: &App, worst: Option<(IntersectionID, Dura
} else {
Widget::nothing()
},
Text::from_all(vec![Line("Worst delay: "), Line("none!").secondary()]).draw(ctx),
Text::from_all(vec![Line("Worst delay: "), Line("none!").secondary()])
.into_widget(ctx),
Image::icon("system/assets/tools/location.svg")
.color(RewriteColor::ChangeAlpha(0.5))
.into_widget(ctx)
@ -373,18 +374,18 @@ fn cutscene_pt1_task(ctx: &mut EventCtx) -> Widget {
Line("Survive as long as possible through 24 hours of a busy weekday.")
.fg(Color::BLACK),
])
.draw(ctx)
.into_widget(ctx)
.margin_below(30),
Widget::custom_row(vec![
Widget::col(vec![
Line("Time").fg(Color::BLACK).draw(ctx),
Line("Time").fg(Color::BLACK).into_widget(ctx),
Image::icon("system/assets/tools/time.svg")
.color(Color::BLACK)
.into_widget(ctx),
Line("24 hours").fg(Color::BLACK).draw(ctx),
Line("24 hours").fg(Color::BLACK).into_widget(ctx),
]),
Widget::col(vec![
Line("Goal").fg(Color::BLACK).draw(ctx),
Line("Goal").fg(Color::BLACK).into_widget(ctx),
Image::icon("system/assets/tools/location.svg")
.color(Color::BLACK)
.into_widget(ctx),
@ -392,14 +393,16 @@ fn cutscene_pt1_task(ctx: &mut EventCtx) -> Widget {
Line("Keep delay at all intersections").fg(Color::BLACK),
Line(format!("under {}", THRESHOLD)).fg(Color::BLACK),
])
.draw(ctx),
.into_widget(ctx),
]),
Widget::col(vec![
Line("Score").fg(Color::BLACK).draw(ctx),
Line("Score").fg(Color::BLACK).into_widget(ctx),
Image::icon("system/assets/tools/star.svg")
.color(Color::BLACK)
.into_widget(ctx),
Line("How long you survive").fg(Color::BLACK).draw(ctx),
Line("How long you survive")
.fg(Color::BLACK)
.into_widget(ctx),
]),
])
.evenly_spaced(),

View File

@ -120,7 +120,10 @@ impl GameplayState for Freeform {
fn recreate_panels(&mut self, ctx: &mut EventCtx, app: &App) {
let rows = vec![
Widget::custom_row(vec![
Line("Sandbox").small_heading().draw(ctx).margin_right(18),
Line("Sandbox")
.small_heading()
.into_widget(ctx)
.margin_right(18),
ctx.style()
.btn_popup_icon_text(
"system/assets/tools/map.svg",
@ -158,7 +161,7 @@ impl GameplayState for Freeform {
Key::Z.txt(ctx),
Line(" to start traffic nearby"),
])
.draw(ctx),
.into_widget(ctx),
];
self.top_center = Panel::new(Widget::col(rows))
@ -221,10 +224,11 @@ impl ChangeScenario {
let mut col = vec![
Widget::row(vec![
Line("Pick your scenario").small_heading().draw(ctx),
Line("Pick your scenario").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Line("Each scenario determines what people live and travel around this map").draw(ctx),
Line("Each scenario determines what people live and travel around this map")
.into_widget(ctx),
];
for (name, label, description) in choices {
let btn = ctx
@ -237,7 +241,7 @@ impl ChangeScenario {
btn.build_widget(ctx, &name),
Text::from(Line(description).secondary())
.wrap_to_pct(ctx, 40)
.draw(ctx)
.into_widget(ctx)
.align_right(),
])
.margin_above(30),
@ -305,7 +309,7 @@ impl AgentSpawner {
confirmed: false,
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("New trip").small_heading().draw(ctx),
Line("New trip").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Click a building or border to specify start"

View File

@ -235,7 +235,7 @@ impl GameplayMode {
fn challenge_header(ctx: &mut EventCtx, title: &str) -> Widget {
Widget::row(vec![
Line(title).small_heading().draw(ctx).centered_vert(),
Line(title).small_heading().into_widget(ctx).centered_vert(),
ctx.style()
.btn_plain
.icon("system/assets/tools/info.svg")

View File

@ -127,7 +127,10 @@ impl GameplayState for PlayScenario {
fn recreate_panels(&mut self, ctx: &mut EventCtx, app: &App) {
let rows = vec![
Widget::custom_row(vec![
Line("Sandbox").small_heading().draw(ctx).margin_right(18),
Line("Sandbox")
.small_heading()
.into_widget(ctx)
.margin_right(18),
ctx.style()
.btn_popup_icon_text(
"system/assets/tools/map.svg",
@ -185,7 +188,9 @@ impl EditScenarioModifiers {
modifiers: Vec<ScenarioModifier>,
) -> Box<dyn State<App>> {
let mut rows = vec![
Line("Modify traffic patterns").small_heading().draw(ctx),
Line("Modify traffic patterns")
.small_heading()
.into_widget(ctx),
Text::from_multiline(vec![
Line(
"Data for all of the people in this simulation comes from PSRC's 2014 \
@ -196,7 +201,7 @@ impl EditScenarioModifiers {
Line("You can modify those patterns here. The modifications apply in order."),
])
.wrap_to_pct(ctx, 50)
.draw(ctx),
.into_widget(ctx),
];
for (idx, m) in modifiers.iter().enumerate() {
rows.push(
@ -369,7 +374,7 @@ impl ChangeMode {
scenario_name,
modifiers,
panel: Panel::new(Widget::col(vec![
Line("Change trip mode").small_heading().draw(ctx),
Line("Change trip mode").small_heading().into_widget(ctx),
Widget::row(vec![
"Percent of people to modify:"
.text_widget(ctx)

View File

@ -735,7 +735,7 @@ impl TutorialState {
fn make_top_center(&self, ctx: &mut EventCtx, edit_map: bool) -> Panel {
let mut col = vec![Widget::row(vec![
Line("Tutorial").small_heading().draw(ctx),
Line("Tutorial").small_heading().into_widget(ctx),
Widget::vert_separator(ctx, 50.0),
ctx.style()
.btn_prev()
@ -745,7 +745,7 @@ impl TutorialState {
let mut txt = Text::from(Line(format!("Task {}", self.current.stage + 1)));
// TODO Smaller font and use alpha for the "/9" part
txt.append(Line(format!("/{}", self.stages.len())).fg(Color::grey(0.7)));
txt.draw(ctx)
txt.into_widget(ctx)
},
ctx.style()
.btn_next()
@ -766,7 +766,7 @@ impl TutorialState {
))
.small_heading(),
)
.draw(ctx),
.into_widget(ctx),
// TODO also text saying "instructions"... can we layout two things easily to
// make a button?
ctx.style()
@ -776,7 +776,7 @@ impl TutorialState {
.centered_vert()
.align_right(),
]));
col.push(task.top_txt(self).draw(ctx));
col.push(task.top_txt(self).into_widget(ctx));
}
}
if edit_map {
@ -826,7 +826,7 @@ impl TutorialState {
for l in lines {
txt.add(Line(l));
}
txt.wrap_to_pct(ctx, 30).draw(ctx)
txt.wrap_to_pct(ctx, 30).into_widget(ctx)
}];
let mut controls = vec![Widget::row(vec![
ctx.style()
@ -1415,7 +1415,7 @@ fn intro_story(ctx: &mut EventCtx) -> Box<dyn State<App>> {
ctx,
Box::new(|ctx| {
Text::from(Line("Use the tutorial to learn the basic controls.").fg(Color::BLACK))
.draw(ctx)
.into_widget(ctx)
}),
)
}

View File

@ -84,7 +84,7 @@ impl TrafficRecorder {
Widget::row(vec![
Line("Select the bounding intersections for recording traffic")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
make_btn(ctx, members.len()),

View File

@ -414,7 +414,7 @@ impl AgentMeter {
prettyprint_usize(finished),
pct as usize
)));
txt.draw(ctx).centered_vert()
txt.into_widget(ctx).centered_vert()
},
if app.primary.dirty_from_edits {
ctx.style()

View File

@ -368,7 +368,7 @@ impl TimePanel {
time: app.primary.sim.time(),
panel: Panel::new(Widget::col(vec![
Text::from(Line(app.primary.sim.time().ampm_tostring()).big_monospaced())
.draw(ctx)
.into_widget(ctx)
.centered_horiz(),
{
let mut batch = GeomBatch::new();
@ -404,11 +404,11 @@ impl TimePanel {
batch.into_widget(ctx)
},
Widget::custom_row(vec![
Line("00:00").small_monospaced().draw(ctx),
Line("00:00").small_monospaced().into_widget(ctx),
Image::icon("system/assets/speed/sunrise.svg").into_widget(ctx),
Line("12:00").small_monospaced().draw(ctx),
Line("12:00").small_monospaced().into_widget(ctx),
Image::icon("system/assets/speed/sunset.svg").into_widget(ctx),
Line("24:00").small_monospaced().draw(ctx),
Line("24:00").small_monospaced().into_widget(ctx),
])
.evenly_spaced(),
]))

View File

@ -47,7 +47,7 @@ impl JumpToTime {
.build_def(ctx),
])
.bg(Color::WHITE),
Line("Jump to what time?").small_heading().draw(ctx),
Line("Jump to what time?").small_heading().into_widget(ctx),
if app.has_prebaked().is_some() {
GeomBatch::from(vec![(
Color::WHITE.alpha(0.7),
@ -182,7 +182,7 @@ impl JumpToDelay {
])
.bg(Color::WHITE),
Widget::row(vec![
Line("Jump to next").small_heading().draw(ctx),
Line("Jump to next").small_heading().into_widget(ctx),
Widget::dropdown(
ctx,
"delay",
@ -194,7 +194,7 @@ impl JumpToDelay {
Choice::new("10", Duration::minutes(10)),
],
),
Line("minute delay").small_heading().draw(ctx),
Line("minute delay").small_heading().into_widget(ctx),
]),
Toggle::checkbox(
ctx,
@ -295,7 +295,7 @@ impl TimeWarpScreen {
halt_upon_delay,
panel: Panel::new(
Widget::col(vec![
Text::new().draw(ctx).named("text"),
Text::new().into_widget(ctx).named("text"),
ctx.style()
.btn_outline
.text("stop now")
@ -392,7 +392,7 @@ impl State<App> for TimeWarpScreen {
},
]);
self.panel.replace(ctx, "text", txt.draw(ctx));
self.panel.replace(ctx, "text", txt.into_widget(ctx));
}
// >= because of the case of resetting to midnight. GameplayMode::initialize takes a tiny
// step past midnight after spawning things, so that agents initially appear on the map.

View File

@ -28,7 +28,7 @@ impl EditRoad {
for (k, v) in road.osm_tags.inner() {
txt.add(Line(format!("{} = {}", k, v)).secondary());
}
let info = txt.draw(ctx);
let info = txt.into_widget(ctx);
let controls = Widget::col(vec![
Widget::row(vec![
@ -103,7 +103,7 @@ impl EditRoad {
let col = vec![
Widget::row(vec![
Line("Editing road").small_heading().draw(ctx),
Line("Editing road").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::row(vec![info, controls]),

View File

@ -104,10 +104,10 @@ impl MainState {
mode: Mode::Viewing,
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Map Editor").small_heading().draw(ctx),
Line("Map Editor").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Text::new().draw(ctx).named("instructions"),
Text::new().into_widget(ctx).named("instructions"),
Widget::col(vec![
Toggle::switch(ctx, "intersection geometry", Key::G, false),
ctx.style()
@ -206,7 +206,7 @@ impl State<App> for MainState {
Key::T.txt(ctx),
Line(" to toggle stop sign / traffic signal"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
}
Some(ID::Building(b)) => {
@ -228,7 +228,7 @@ impl State<App> for MainState {
Key::LeftControl.txt(ctx),
Line(" to move"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
}
Some(ID::Road(r)) => {
@ -273,7 +273,7 @@ impl State<App> for MainState {
Key::M.txt(ctx),
Line(" to merge"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
}
Some(ID::RoadPoint(r, idx)) => {
@ -295,7 +295,7 @@ impl State<App> for MainState {
Key::LeftControl.txt(ctx),
Line(" to move"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
}
None => {
@ -348,7 +348,7 @@ impl State<App> for MainState {
Key::B.txt(ctx),
Line(" to create a building"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
}
}
@ -397,7 +397,7 @@ impl State<App> for MainState {
Line("Click").fg(ctx.style().text_hotkey_color),
Line(" the top-left corner of this map"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
if let Some(pt) = cursor {
@ -412,7 +412,7 @@ impl State<App> for MainState {
Line("Click").fg(ctx.style().text_hotkey_color),
Line(" the bottom-right corner of this map"),
]);
let instructions = txt.draw(ctx);
let instructions = txt.into_widget(ctx);
self.panel.replace(ctx, "instructions", instructions);
if let Some(pt2) = cursor {

View File

@ -128,7 +128,7 @@ impl OptionsPanel {
Box::new(OptionsPanel {
panel: Panel::new(Widget::col(vec![
Widget::custom_row(vec![
Line("Settings").small_heading().draw(ctx),
Line("Settings").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Camera controls".text_widget(ctx),

View File

@ -104,7 +104,7 @@ impl<A: AppLike + 'static> CityPicker<A> {
}
}
let mut other_places = vec![Line("Other places").draw(ctx)];
let mut other_places = vec![Line("Other places").into_widget(ctx)];
for (country, cities) in cities_per_country() {
// If there's only one city and we're already there, skip it.
if cities.len() == 1 && cities[0] == city_name {
@ -150,7 +150,7 @@ impl<A: AppLike + 'static> CityPicker<A> {
on_load: Some(on_load),
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Select a district").small_heading().draw(ctx),
Line("Select a district").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::row(vec![
@ -357,7 +357,7 @@ impl<A: AppLike + 'static> AllCityPicker<A> {
on_load: Some(on_load),
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Select a district").small_heading().draw(ctx),
Line("Select a district").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::row(vec![
@ -459,7 +459,7 @@ impl<A: AppLike + 'static> CitiesInCountryPicker<A> {
draw_flag,
Line(format!("Select a city in {}", nice_country_name(country)))
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::custom_row(buttons).flex_wrap(ctx, Percent::int(70)),

View File

@ -109,7 +109,9 @@ impl ColorLegend {
)])
.into_widget(ctx)
.centered_vert(),
Text::from(Line(label)).wrap_to_pct(ctx, 35).draw(ctx),
Text::from(Line(label))
.wrap_to_pct(ctx, 35)
.into_widget(ctx),
])
}
@ -148,7 +150,7 @@ impl ColorLegend {
Widget::custom_row(
labels
.into_iter()
.map(|lbl| Line(lbl).small().draw(ctx))
.map(|lbl| Line(lbl).small().into_widget(ctx))
.collect(),
)
.evenly_spaced(),
@ -175,7 +177,7 @@ impl ColorLegend {
Widget::custom_row(
pairs
.into_iter()
.map(|(_, lbl)| Line(lbl).small().draw(ctx))
.map(|(_, lbl)| Line(lbl).small().into_widget(ctx))
.collect(),
)
.evenly_spaced(),

View File

@ -146,7 +146,7 @@ impl<A: AppLike + 'static, T: MinimapControls<A>> Minimap<A, T> {
.bg(app.cs().inner_panel_bg),
if self.controls.has_zorder(app) {
Widget::col(vec![
Line("Z-order:").small().draw(ctx),
Line("Z-order:").small().into_widget(ctx),
Spinner::widget(
ctx,
app.draw_map().zorder_range,

View File

@ -19,7 +19,7 @@ impl Navigator {
Box::new(Navigator {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Enter a street name").small_heading().draw(ctx),
Line("Enter a street name").small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Autocomplete::new(
@ -115,7 +115,7 @@ impl CrossStreet {
"(Or just quit to go to {})",
map.get_r(first[0]).get_name(app.opts().language.as_ref()),
)));
txt.draw(ctx)
txt.into_widget(ctx)
},
ctx.style().btn_close_widget(ctx),
]),
@ -205,7 +205,7 @@ impl SearchBuildings {
Widget::row(vec![
Line("Enter a business name or address")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Autocomplete::new(

View File

@ -117,7 +117,7 @@ impl TurnExplorer {
))
.small_heading(),
)
.draw(ctx),
.into_widget(ctx),
Widget::vert_separator(ctx, 50.0),
ctx.style()
.btn_prev()
@ -125,7 +125,7 @@ impl TurnExplorer {
.hotkey(Key::LeftArrow)
.build_widget(ctx, "previous turn"),
Text::from(Line(format!("{}/{}", idx, turns.len())).secondary())
.draw(ctx)
.into_widget(ctx)
.centered_vert(),
ctx.style()
.btn_next()

View File

@ -24,7 +24,7 @@ impl<A: AppLike + 'static, T: 'static> ChooseSomething<A, T> {
Box::new(ChooseSomething {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line(query).small_heading().draw(ctx),
Line(query).small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Menu::widget(ctx, choices).named("menu"),
@ -79,7 +79,7 @@ impl<A: AppLike + 'static> PromptInput<A> {
Box::new(PromptInput {
panel: Panel::new(Widget::col(vec![
Widget::row(vec![
Line(query).small_heading().draw(ctx),
Line(query).small_heading().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Widget::text_entry(ctx, String::new(), true).named("input"),
@ -161,7 +161,7 @@ impl PopupMsg {
}
Box::new(PopupMsg {
panel: Panel::new(Widget::col(vec![
txt.draw(ctx),
txt.into_widget(ctx),
ctx.style()
.btn_solid_primary
.text("OK")

View File

@ -30,7 +30,9 @@ impl<A: AppLike + 'static> Picker<A> {
let mut col = vec![
Widget::row(vec![
Line("Download more cities").small_heading().draw(ctx),
Line("Download more cities")
.small_heading()
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
"Select the cities you want to include".text_widget(ctx),
@ -39,7 +41,7 @@ impl<A: AppLike + 'static> Picker<A> {
will be larger",
)
.secondary()
.draw(ctx),
.into_widget(ctx),
];
for (city, bytes) in size_per_city(&manifest) {
col.push(Widget::row(vec![

View File

@ -56,7 +56,9 @@ impl Viewer {
biz_search_panel: Option<Widget>,
) {
let top_panel = Panel::new(Widget::col(vec![
Line("OpenStreetMap viewer").small_heading().draw(ctx),
Line("OpenStreetMap viewer")
.small_heading()
.into_widget(ctx),
ctx.style()
.btn_popup_icon_text(
"system/assets/tools/map.svg",
@ -142,7 +144,7 @@ impl Viewer {
ctx,
&format!("open https://wiki.openstreetmap.org/wiki/Key:{}", k),
),
Line(v).draw(ctx).align_right(),
Line(v).into_widget(ctx).align_right(),
]));
}
}
@ -187,7 +189,7 @@ impl Viewer {
)));
}
}
col.push(txt.draw(ctx));
col.push(txt.into_widget(ctx));
if !b.osm_tags.is_empty() {
for (k, v) in b.osm_tags.inner() {
@ -199,7 +201,7 @@ impl Viewer {
ctx,
&format!("open https://wiki.openstreetmap.org/wiki/Key:{}", k),
),
Line(v).draw(ctx).align_right(),
Line(v).into_widget(ctx).align_right(),
]));
}
}

View File

@ -127,7 +127,7 @@ impl ParkingMapper {
draw_layer: ctx.upload(batch),
show,
panel: Panel::new(Widget::col(vec![
Line("Parking mapper").small_heading().draw(ctx),
Line("Parking mapper").small_heading().into_widget(ctx),
ctx.style()
.btn_popup_icon_text(
"system/assets/tools/map.svg",
@ -260,7 +260,7 @@ impl State<App> for ParkingMapper {
txt.add(Line(format!("{} = {}", k, v)).secondary());
}
}
self.panel.replace(ctx, "info", txt.draw(ctx));
self.panel.replace(ctx, "info", txt.into_widget(ctx));
}
} else if self.selected.is_some() {
self.selected = None;
@ -423,7 +423,7 @@ impl ChangeWay {
Widget::row(vec![
Line("What kind of parking does this road have?")
.small_heading()
.draw(ctx),
.into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
Menu::widget(

View File

@ -94,7 +94,7 @@ impl Strategize {
batch.push(Color::CYAN, path.render(Distance::meters(2.0)));
let panel = Panel::new(Widget::col(vec![
txt.draw(ctx),
txt.into_widget(ctx),
ctx.style()
.btn_outline
.text("Back to title screen")
@ -196,7 +196,7 @@ impl Results {
SimpleState::new(
Panel::new(Widget::col(vec![
txt.draw(ctx),
txt.into_widget(ctx),
ctx.style()
.btn_solid_primary
.text("OK")

View File

@ -73,7 +73,7 @@ impl Picker {
]);
let instructions_panel = Panel::new(Widget::col(vec![
txt.draw(ctx),
txt.into_widget(ctx),
Widget::row(vec![
GeomBatch::load_svg_bytes(
&ctx.prerender,
@ -86,7 +86,7 @@ impl Picker {
Line("WASD").fg(ctx.style().text_hotkey_color),
Line(")"),
])
.draw(ctx),
.into_widget(ctx),
]),
Widget::row(vec![
Image::icon("system/assets/tools/mouse.svg").into_widget(ctx),
@ -95,13 +95,13 @@ impl Picker {
.fg(ctx.style().text_hotkey_color),
Line(" to zoom in or out"),
])
.draw(ctx),
.into_widget(ctx),
]),
Text::from_all(vec![
Line("Escape key").fg(ctx.style().text_hotkey_color),
Line(" to pause"),
])
.draw(ctx),
.into_widget(ctx),
]))
.aligned(HorizontalAlignment::LeftInset, VerticalAlignment::TopInset)
.build(ctx);
@ -273,9 +273,11 @@ fn make_vehicle_panel(ctx: &mut EventCtx, app: &App) -> Panel {
let (max_speed, max_energy) = Vehicle::max_stats();
Panel::new(Widget::col(vec![
Line("Pick Santa's vehicle").small_heading().draw(ctx),
Line("Pick Santa's vehicle")
.small_heading()
.into_widget(ctx),
Widget::row(buttons),
Line(&vehicle.name).small_heading().draw(ctx),
Line(&vehicle.name).small_heading().into_widget(ctx),
Widget::row(vec![
"Speed:".text_widget(ctx),
custom_bar(
@ -321,7 +323,7 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("Upzoning").small_heading().draw(ctx),
Line("Upzoning").small_heading().into_widget(ctx),
ctx.style()
.btn_plain
.icon("system/assets/tools/info.svg")
@ -332,7 +334,7 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel
Image::icon("system/assets/tools/mouse.svg").into_widget(ctx),
Line("Select the houses you want to turn into stores")
.fg(ctx.style().text_hotkey_color)
.draw(ctx),
.into_widget(ctx),
]),
Widget::row(vec![
"Upzones chosen:".text_widget(ctx),

View File

@ -55,7 +55,7 @@ impl Game {
Image::icon("system/assets/tools/map.svg")
.into_widget(ctx)
.centered_vert(),
Line(&level.title).draw(ctx),
Line(&level.title).into_widget(ctx),
])
.padding(10)
.bg(Color::hex("#003046")),
@ -128,7 +128,7 @@ impl Game {
))
.small_heading()
.fg(text_color)
.draw(ctx)
.into_widget(ctx)
.centered_vert();
self.time_panel.replace(ctx, "time label", label);
@ -301,7 +301,7 @@ impl Game {
let label = Text::from(
Line("SANTA'S HANGRY - grab some cookies from a store!").fg(Color::RED),
)
.draw(ctx);
.into_widget(ctx);
self.status_panel.replace(ctx, "energy label", label);
}
self.state

View File

@ -25,7 +25,7 @@ impl TitleScreen {
Panel::new(Widget::col(vec![
Line("15-minute Santa")
.display_title()
.draw(ctx)
.into_widget(ctx)
.container()
.padding(16)
.bg(app.cs.fade_map_dark)
@ -41,7 +41,7 @@ impl TitleScreen {
.small_heading(),
)
.wrap_to_pct(ctx, 50)
.draw(ctx)
.into_widget(ctx)
.container()
.padding(16)
.bg(app.cs.fade_map_dark)
@ -147,7 +147,7 @@ impl Credits {
SimpleState::new(
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("15-minute Santa").big_heading_plain().draw(ctx),
Line("15-minute Santa").big_heading_plain().into_widget(ctx),
ctx.style().btn_close_widget(ctx),
]),
link(
@ -159,7 +159,7 @@ impl Credits {
Line("Lead: Dustin Carlino"),
Line("Programming & game design: Michael Kirk"),
Line("UI/UX: Yuwen Li"),
]).draw(ctx),
]).into_widget(ctx),
link(
ctx,
"Santa made by @parallaxcreativedesign",

View File

@ -167,7 +167,7 @@ impl<'a> EventCtx<'a> {
.clone()
.default_fg(Color::WHITE)
.wrap_to_pct(self, 25)
.draw(self)
.into_widget(self)
.container()
.bg(Color::BLACK)
.padding(15)

View File

@ -68,8 +68,8 @@ impl TextSpan {
self.fg_color.unwrap_or(style.text_fg_color)
}
pub fn draw(self, ctx: &EventCtx) -> Widget {
Text::from(self).draw(ctx)
pub fn into_widget(self, ctx: &EventCtx) -> Widget {
Text::from(self).into_widget(ctx)
}
pub fn batch(self, ctx: &EventCtx) -> Widget {
Text::from(self).batch(ctx)
@ -370,7 +370,7 @@ impl Text {
format!("{:x}", hasher.finish())
}
pub fn draw(self, ctx: &EventCtx) -> Widget {
pub fn into_widget(self, ctx: &EventCtx) -> Widget {
JustDraw::wrap(ctx, self.render(ctx))
}
pub fn batch(self, ctx: &EventCtx) -> Widget {
@ -494,7 +494,7 @@ pub trait TextExt {
impl TextExt for &str {
fn text_widget(self, ctx: &EventCtx) -> Widget {
Line(self).draw(ctx)
Line(self).into_widget(ctx)
}
fn batch_text(self, ctx: &EventCtx) -> Widget {
Line(self).batch(ctx)
@ -503,7 +503,7 @@ impl TextExt for &str {
impl TextExt for String {
fn text_widget(self, ctx: &EventCtx) -> Widget {
Line(self).draw(ctx)
Line(self).into_widget(ctx)
}
fn batch_text(self, ctx: &EventCtx) -> Widget {
Line(self).batch(ctx)

View File

@ -96,7 +96,7 @@ impl CompareTimes {
labels
.iter()
.rev()
.map(|x| Line(x.to_string()).small().draw(ctx))
.map(|x| Line(x.to_string()).small().into_widget(ctx))
.collect(),
)
.evenly_spaced();
@ -111,7 +111,7 @@ impl CompareTimes {
let x_axis = Widget::custom_row(
labels
.iter()
.map(|x| Line(x.to_string()).small().draw(ctx))
.map(|x| Line(x.to_string()).small().into_widget(ctx))
.collect(),
)
.evenly_spaced();

View File

@ -113,7 +113,7 @@ impl<A, T, F> Table<A, T, F> {
} else if let Col::Sortable(_) = col.col {
ctx.style().btn_outline.text(&col.name).build_def(ctx)
} else {
Line(&col.name).draw(ctx).centered_vert()
Line(&col.name).into_widget(ctx).centered_vert()
}
})
.collect();

View File

@ -50,17 +50,17 @@ impl Demo {
fn make_timeseries_panel(&self, ctx: &mut EventCtx) -> Panel {
// Make a table with 3 columns.
let mut col1 = vec![Line("Time").draw(ctx)];
let mut col = vec![Line("Linear").draw(ctx)];
let mut col3 = vec![Line("Quadratic").draw(ctx)];
let mut col1 = vec![Line("Time").into_widget(ctx)];
let mut col = vec![Line("Linear").into_widget(ctx)];
let mut col3 = vec![Line("Quadratic").into_widget(ctx)];
for s in 0..(self.elapsed.inner_seconds() as usize) {
col1.push(
Line(format!("{}", Duration::seconds(s as f64)))
.secondary()
.draw(ctx),
.into_widget(ctx),
);
col.push(Line(s.to_string()).secondary().draw(ctx));
col3.push(Line(s.pow(2).to_string()).secondary().draw(ctx));
col.push(Line(s.to_string()).secondary().into_widget(ctx));
col3.push(Line(s.pow(2).to_string()).secondary().into_widget(ctx));
}
let mut c = Panel::new(Widget::col(vec![
@ -72,7 +72,7 @@ impl Demo {
)
.fg(Color::RED),
])
.draw(ctx),
.into_widget(ctx),
Widget::row(vec![
// Examples of styling widgets
Widget::col(col1).outline((2.0, Color::BLACK)).padding(5),
@ -308,7 +308,7 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
Line("widgetry demo").big_heading_styled(),
Line("Click and drag the background to pan, use touchpad or scroll wheel to zoom"),
])
.draw(ctx),
.into_widget(ctx),
Text::from_all(vec![
Line("You can "),
Line("change fonts ").big_heading_plain(),
@ -316,10 +316,10 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
Line("line!").small_heading(),
])
.bg(Color::PURPLE)
.draw(ctx),
.into_widget(ctx),
// Button Style Gallery
// TODO might be nice to have this in separate tabs or something.
Text::from(Line("Buttons").big_heading_styled().size(18)).draw(ctx),
Text::from(Line("Buttons").big_heading_styled().size(18)).into_widget(ctx),
Widget::row(vec![Widget::col(vec![
style
.btn_solid_primary
@ -358,7 +358,7 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
.icon_text("system/assets/tools/home.svg", "Secondary")
.build_widget(ctx, "btn_outline.icon_text"),
])]),
Text::from(Line("Spinner").big_heading_styled().size(18)).draw(ctx),
Text::from(Line("Spinner").big_heading_styled().size(18)).into_widget(ctx),
widgetry::Spinner::widget(ctx, (0, 11), 1),
Widget::row(vec![
ctx.style()
@ -449,7 +449,7 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
.big_heading_styled()
.size(18),
)
.draw(ctx),
.into_widget(ctx),
{
let row_height = 10;
let mut id = 0;