mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
rename toggle/checkbox
This commit is contained in:
parent
23b19fa7ce
commit
d774aeae44
@ -5,8 +5,8 @@ use geom::Percent;
|
|||||||
use map_gui::tools::PopupMsg;
|
use map_gui::tools::PopupMsg;
|
||||||
use map_model::{AmenityType, BuildingID};
|
use map_model::{AmenityType, BuildingID};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel,
|
Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel,
|
||||||
SimpleState, State, StyledButtons, TextExt, Transition, VerticalAlignment, Widget,
|
SimpleState, State, StyledButtons, TextExt, Toggle, Transition, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::isochrone::Options;
|
use crate::isochrone::Options;
|
||||||
@ -30,7 +30,7 @@ impl FindHome {
|
|||||||
Widget::custom_row(
|
Widget::custom_row(
|
||||||
AmenityType::all()
|
AmenityType::all()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|at| Checkbox::switch(ctx, &at.to_string(), None, false))
|
.map(|at| Toggle::switch(ctx, &at.to_string(), None, false))
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
.flex_wrap(ctx, Percent::int(50)),
|
.flex_wrap(ctx, Percent::int(50)),
|
||||||
|
@ -12,9 +12,9 @@ use map_model::connectivity::WalkingOptions;
|
|||||||
use map_model::{AmenityType, Building, BuildingID, LaneType};
|
use map_model::{AmenityType, Building, BuildingID, LaneType};
|
||||||
use widgetry::table::{Col, Filter, Table};
|
use widgetry::table::{Col, Filter, Table};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Cached, Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx,
|
lctrl, Cached, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||||
HorizontalAlignment, Key, Line, Outcome, Panel, RewriteColor, State, StyledButtons, Text,
|
Line, Outcome, Panel, RewriteColor, State, StyledButtons, Text, Toggle, Transition,
|
||||||
Transition, VerticalAlignment, Widget,
|
VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::find_home::FindHome;
|
use crate::find_home::FindHome;
|
||||||
@ -201,7 +201,7 @@ impl State<App> for Viewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn options_to_controls(ctx: &mut EventCtx, opts: &Options) -> Widget {
|
fn options_to_controls(ctx: &mut EventCtx, opts: &Options) -> Widget {
|
||||||
let mut rows = vec![Checkbox::toggle(
|
let mut rows = vec![Toggle::choice(
|
||||||
ctx,
|
ctx,
|
||||||
"walking / biking",
|
"walking / biking",
|
||||||
"walking",
|
"walking",
|
||||||
@ -214,7 +214,7 @@ fn options_to_controls(ctx: &mut EventCtx, opts: &Options) -> Widget {
|
|||||||
)];
|
)];
|
||||||
match opts {
|
match opts {
|
||||||
Options::Walking(ref opts) => {
|
Options::Walking(ref opts) => {
|
||||||
rows.push(Checkbox::switch(
|
rows.push(Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"Allow walking on the shoulder of the road without a sidewalk",
|
"Allow walking on the shoulder of the road without a sidewalk",
|
||||||
None,
|
None,
|
||||||
|
@ -7,9 +7,8 @@ use map_gui::ID;
|
|||||||
use map_model::{IntersectionID, Map, RoadID};
|
use map_model::{IntersectionID, Map, RoadID};
|
||||||
use sim::{AgentType, TripMode, TripPhaseType};
|
use sim::{AgentType, TripMode, TripPhaseType};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Checkbox, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel,
|
lctrl, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel, ScreenDims,
|
||||||
ScreenDims, ScreenPt, ScreenRectangle, StyledButtons, Text, TextSpan, VerticalAlignment,
|
ScreenPt, ScreenRectangle, StyledButtons, Text, TextSpan, Toggle, VerticalAlignment, Widget,
|
||||||
Widget,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use self::minimap::MinimapController;
|
pub use self::minimap::MinimapController;
|
||||||
@ -397,7 +396,7 @@ pub fn checkbox_per_mode(
|
|||||||
let mut filters = Vec::new();
|
let mut filters = Vec::new();
|
||||||
for m in TripMode::all() {
|
for m in TripMode::all() {
|
||||||
filters.push(
|
filters.push(
|
||||||
Checkbox::colored(
|
Toggle::colored_checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
m.ongoing_verb(),
|
m.ongoing_verb(),
|
||||||
color_for_mode(app, m),
|
color_for_mode(app, m),
|
||||||
|
@ -14,8 +14,8 @@ use map_model::{
|
|||||||
};
|
};
|
||||||
use sim::{Sim, TripEndpoint};
|
use sim::{Sim, TripEndpoint};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Cached, Checkbox, Choice, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx,
|
lctrl, Cached, Choice, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx,
|
||||||
HorizontalAlignment, Key, Line, Outcome, Panel, ScreenDims, State, StyledButtons, Text,
|
HorizontalAlignment, Key, Line, Outcome, Panel, ScreenDims, State, StyledButtons, Text, Toggle,
|
||||||
UpdateType, VerticalAlignment, Widget,
|
UpdateType, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,12 +55,12 @@ impl DebugMode {
|
|||||||
ctx.style().btn_close_widget(ctx),
|
ctx.style().btn_close_widget(ctx),
|
||||||
]),
|
]),
|
||||||
Text::new().draw(ctx).named("current info"),
|
Text::new().draw(ctx).named("current info"),
|
||||||
Checkbox::switch(ctx, "show buildings", Key::Num1, true),
|
Toggle::switch(ctx, "show buildings", Key::Num1, true),
|
||||||
Checkbox::switch(ctx, "show intersections", Key::Num2, true),
|
Toggle::switch(ctx, "show intersections", Key::Num2, true),
|
||||||
Checkbox::switch(ctx, "show lanes", Key::Num3, true),
|
Toggle::switch(ctx, "show lanes", Key::Num3, true),
|
||||||
Checkbox::switch(ctx, "show areas", Key::Num4, true),
|
Toggle::switch(ctx, "show areas", Key::Num4, true),
|
||||||
Checkbox::switch(ctx, "show labels", Key::Num5, false),
|
Toggle::switch(ctx, "show labels", Key::Num5, false),
|
||||||
Checkbox::switch(ctx, "show route for all agents", lctrl(Key::R), false),
|
Toggle::switch(ctx, "show route for all agents", lctrl(Key::R), false),
|
||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_outline_text("unhide everything")
|
.btn_outline_text("unhide everything")
|
||||||
|
@ -4,8 +4,8 @@ use geom::{Circle, Distance, Duration, FindClosest, Polygon, Time};
|
|||||||
use map_gui::tools::ColorNetwork;
|
use map_gui::tools::ColorNetwork;
|
||||||
use map_gui::ID;
|
use map_gui::ID;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line,
|
Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome,
|
||||||
Outcome, Panel, Slider, State, StyledButtons, Text, TextExt, VerticalAlignment, Widget,
|
Panel, Slider, State, StyledButtons, Text, TextExt, Toggle, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, Transition};
|
use crate::app::{App, Transition};
|
||||||
@ -88,7 +88,7 @@ impl Filters {
|
|||||||
|
|
||||||
fn to_controls(ctx: &mut EventCtx) -> Widget {
|
fn to_controls(ctx: &mut EventCtx) -> Widget {
|
||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
Checkbox::toggle(
|
Toggle::choice(
|
||||||
ctx,
|
ctx,
|
||||||
"individual / aggregated",
|
"individual / aggregated",
|
||||||
"individual",
|
"individual",
|
||||||
|
@ -4,8 +4,8 @@ use map_gui::ID;
|
|||||||
use map_model::{AmenityType, BuildingID};
|
use map_model::{AmenityType, BuildingID};
|
||||||
use sim::{Scenario, TripEndpoint};
|
use sim::{Scenario, TripEndpoint};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome,
|
Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome, Panel, State,
|
||||||
Panel, State, StyledButtons, Text, VerticalAlignment, Widget,
|
StyledButtons, Text, Toggle, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, Transition};
|
use crate::app::{App, Transition};
|
||||||
@ -97,7 +97,7 @@ impl PopularDestinations {
|
|||||||
Line("Most popular destinations").small_heading().draw(ctx),
|
Line("Most popular destinations").small_heading().draw(ctx),
|
||||||
ctx.style().btn_close_widget(ctx),
|
ctx.style().btn_close_widget(ctx),
|
||||||
]),
|
]),
|
||||||
Checkbox::switch(ctx, "Show heatmap", None, opts.is_some()),
|
Toggle::switch(ctx, "Show heatmap", None, opts.is_some()),
|
||||||
controls,
|
controls,
|
||||||
breakdown.draw(ctx),
|
breakdown.draw(ctx),
|
||||||
]))
|
]))
|
||||||
|
@ -4,8 +4,8 @@ use map_model::{
|
|||||||
ControlStopSign, ControlTrafficSignal, EditCmd, EditIntersection, IntersectionID, StageType,
|
ControlStopSign, ControlTrafficSignal, EditCmd, EditIntersection, IntersectionID, StageType,
|
||||||
};
|
};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Choice, DrawBaselayer, EventCtx, Key, Line, Panel, SimpleState, Spinner, State,
|
Choice, DrawBaselayer, EventCtx, Key, Line, Panel, SimpleState, Spinner, State, StyledButtons,
|
||||||
StyledButtons, TextExt, Widget,
|
TextExt, Toggle, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, Transition};
|
use crate::app::{App, Transition};
|
||||||
@ -47,7 +47,7 @@ impl ChangeDuration {
|
|||||||
]),
|
]),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
"Type:".draw_text(ctx),
|
"Type:".draw_text(ctx),
|
||||||
Checkbox::toggle(
|
Toggle::choice(
|
||||||
ctx,
|
ctx,
|
||||||
"stage type",
|
"stage type",
|
||||||
"fixed",
|
"fixed",
|
||||||
|
@ -7,8 +7,8 @@ use map_gui::render::traffic_signal::draw_signal_stage;
|
|||||||
use map_model::{IntersectionID, IntersectionType, StageType};
|
use map_model::{IntersectionID, IntersectionType, StageType};
|
||||||
use sim::AgentType;
|
use sim::AgentType;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, DrawWithTooltips, EventCtx, FanChart, GeomBatch, Line, PlotOptions,
|
Color, DrawWithTooltips, EventCtx, FanChart, GeomBatch, Line, PlotOptions, ScatterPlot, Series,
|
||||||
ScatterPlot, Series, StyledButtons, Text, Widget,
|
StyledButtons, Text, Toggle, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
@ -117,7 +117,7 @@ pub fn delay(
|
|||||||
|
|
||||||
assert!(i.is_traffic_signal());
|
assert!(i.is_traffic_signal());
|
||||||
rows.push(opts.to_controls(ctx, app));
|
rows.push(opts.to_controls(ctx, app));
|
||||||
rows.push(Checkbox::toggle(
|
rows.push(Toggle::choice(
|
||||||
ctx,
|
ctx,
|
||||||
"fan chart / scatter plot",
|
"fan chart / scatter plot",
|
||||||
"fan chart",
|
"fan chart",
|
||||||
|
@ -11,9 +11,9 @@ use sim::{
|
|||||||
VehicleType,
|
VehicleType,
|
||||||
};
|
};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, ControlState, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
Color, ControlState, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||||
Line, LinePlot, Outcome, Panel, PlotOptions, Series, StyledButtons, TextExt, VerticalAlignment,
|
LinePlot, Outcome, Panel, PlotOptions, Series, StyledButtons, TextExt, Toggle,
|
||||||
Widget,
|
VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, Transition};
|
use crate::app::{App, Transition};
|
||||||
@ -765,7 +765,7 @@ impl DataOptions {
|
|||||||
return Widget::nothing();
|
return Widget::nothing();
|
||||||
}
|
}
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::custom_checkbox(
|
Toggle::custom_checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Show before changes",
|
"Show before changes",
|
||||||
vec![
|
vec![
|
||||||
@ -776,7 +776,7 @@ impl DataOptions {
|
|||||||
self.show_before,
|
self.show_before,
|
||||||
),
|
),
|
||||||
if self.show_before {
|
if self.show_before {
|
||||||
Checkbox::switch(ctx, "Show full day", None, self.show_end_of_day)
|
Toggle::switch(ctx, "Show full day", None, self.show_end_of_day)
|
||||||
} else {
|
} else {
|
||||||
Widget::nothing()
|
Widget::nothing()
|
||||||
},
|
},
|
||||||
|
@ -5,8 +5,8 @@ use geom::{Circle, Distance, Pt2D, Time};
|
|||||||
use map_gui::tools::{make_heatmap, HeatmapOptions};
|
use map_gui::tools::{make_heatmap, HeatmapOptions};
|
||||||
use sim::PersonState;
|
use sim::PersonState;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line,
|
Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome,
|
||||||
Outcome, Panel, Text, TextExt, VerticalAlignment, Widget,
|
Panel, Text, TextExt, Toggle, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
@ -223,7 +223,7 @@ fn make_controls(ctx: &mut EventCtx, app: &App, opts: &Options, legend: Option<W
|
|||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
|
|
||||||
col.push(Checkbox::switch(
|
col.push(Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"Show heatmap",
|
"Show heatmap",
|
||||||
None,
|
None,
|
||||||
|
@ -9,8 +9,8 @@ use map_model::{
|
|||||||
};
|
};
|
||||||
use sim::{ParkingSpot, Scenario, VehicleType};
|
use sim::{ParkingSpot, Scenario, VehicleType};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome, Panel,
|
Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome, Panel, Text, Toggle,
|
||||||
Text, VerticalAlignment, Widget,
|
VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
@ -228,16 +228,16 @@ impl Occupancy {
|
|||||||
])
|
])
|
||||||
.draw(ctx),
|
.draw(ctx),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::switch(ctx, "On-street spots", None, onstreet),
|
Toggle::switch(ctx, "On-street spots", None, onstreet),
|
||||||
Checkbox::switch(ctx, "Parking lots", None, lots),
|
Toggle::switch(ctx, "Parking lots", None, lots),
|
||||||
])
|
])
|
||||||
.evenly_spaced(),
|
.evenly_spaced(),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::switch(ctx, "Public garages", None, garages),
|
Toggle::switch(ctx, "Public garages", None, garages),
|
||||||
Checkbox::switch(ctx, "Private buildings", None, private_bldgs),
|
Toggle::switch(ctx, "Private buildings", None, private_bldgs),
|
||||||
])
|
])
|
||||||
.evenly_spaced(),
|
.evenly_spaced(),
|
||||||
Checkbox::colored(
|
Toggle::colored_checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Cars looking for parking",
|
"Cars looking for parking",
|
||||||
app.cs.parking_trip,
|
app.cs.parking_trip,
|
||||||
|
@ -5,8 +5,8 @@ use geom::{Circle, Distance, Pt2D, Time};
|
|||||||
use map_gui::tools::{make_heatmap, HeatmapOptions};
|
use map_gui::tools::{make_heatmap, HeatmapOptions};
|
||||||
use sim::PersonState;
|
use sim::PersonState;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome,
|
Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome, Panel,
|
||||||
Panel, VerticalAlignment, Widget,
|
Toggle, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
@ -172,7 +172,7 @@ fn make_controls(ctx: &mut EventCtx, app: &App, opts: &Options, legend: Option<W
|
|||||||
.centered(),
|
.centered(),
|
||||||
];
|
];
|
||||||
|
|
||||||
col.push(Checkbox::switch(
|
col.push(Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"Show heatmap",
|
"Show heatmap",
|
||||||
None,
|
None,
|
||||||
|
@ -10,8 +10,8 @@ use map_gui::ID;
|
|||||||
use map_model::{IntersectionID, Map, Traversable};
|
use map_model::{IntersectionID, Map, Traversable};
|
||||||
use sim::{AgentType, VehicleType};
|
use sim::{AgentType, VehicleType};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome,
|
Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Outcome, Panel, Text,
|
||||||
Panel, Text, TextExt, VerticalAlignment, Widget,
|
TextExt, Toggle, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
@ -223,7 +223,7 @@ impl Throughput {
|
|||||||
.wrap_to_pct(ctx, 15)
|
.wrap_to_pct(ctx, 15)
|
||||||
.draw(ctx),
|
.draw(ctx),
|
||||||
if app.has_prebaked().is_some() {
|
if app.has_prebaked().is_some() {
|
||||||
Checkbox::switch(ctx, "Compare before proposal", None, false)
|
Toggle::switch(ctx, "Compare before proposal", None, false)
|
||||||
} else {
|
} else {
|
||||||
Widget::nothing()
|
Widget::nothing()
|
||||||
},
|
},
|
||||||
@ -231,7 +231,7 @@ impl Throughput {
|
|||||||
AgentType::all()
|
AgentType::all()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|agent_type| {
|
.map(|agent_type| {
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
agent_type.noun(),
|
agent_type.noun(),
|
||||||
None,
|
None,
|
||||||
@ -367,7 +367,7 @@ impl CompareThroughput {
|
|||||||
|
|
||||||
let panel = Panel::new(Widget::col(vec![
|
let panel = Panel::new(Widget::col(vec![
|
||||||
header(ctx, "Relative Throughput"),
|
header(ctx, "Relative Throughput"),
|
||||||
Checkbox::switch(ctx, "Compare before proposal", None, true),
|
Toggle::switch(ctx, "Compare before proposal", None, true),
|
||||||
scale.make_legend(ctx, vec!["less traffic", "same", "more"]),
|
scale.make_legend(ctx, vec!["less traffic", "same", "more"]),
|
||||||
]))
|
]))
|
||||||
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
|
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use map_gui::tools::ColorDiscrete;
|
use map_gui::tools::ColorDiscrete;
|
||||||
use map_model::{PathConstraints, PathStep};
|
use map_model::{PathConstraints, PathStep};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Outcome, Panel, VerticalAlignment,
|
Drawable, EventCtx, GfxCtx, HorizontalAlignment, Outcome, Panel, Toggle, VerticalAlignment,
|
||||||
Widget,
|
Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,9 +116,9 @@ impl TransitNetwork {
|
|||||||
|
|
||||||
let panel = Panel::new(Widget::col(vec![
|
let panel = Panel::new(Widget::col(vec![
|
||||||
header(ctx, "Transit network"),
|
header(ctx, "Transit network"),
|
||||||
Checkbox::switch(ctx, "show all routes", None, show_all_routes),
|
Toggle::switch(ctx, "show all routes", None, show_all_routes),
|
||||||
Checkbox::switch(ctx, "show buses", None, show_buses),
|
Toggle::switch(ctx, "show buses", None, show_buses),
|
||||||
Checkbox::switch(ctx, "show trains", None, show_trains),
|
Toggle::switch(ctx, "show trains", None, show_trains),
|
||||||
legend,
|
legend,
|
||||||
]))
|
]))
|
||||||
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
|
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
|
||||||
|
@ -8,9 +8,8 @@ use map_gui::tools::ColorLegend;
|
|||||||
use map_model::{osm, BuildingID, BuildingType, IntersectionID, LaneID, Map, RoadID, TurnType};
|
use map_model::{osm, BuildingID, BuildingType, IntersectionID, LaneID, Map, RoadID, TurnType};
|
||||||
use sim::{TripEndpoint, TripInfo, TripMode};
|
use sim::{TripEndpoint, TripInfo, TripMode};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
|
||||||
Outcome, Panel, RewriteColor, Slider, State, StyledButtons, Text, TextExt, VerticalAlignment,
|
RewriteColor, Slider, State, StyledButtons, Text, TextExt, Toggle, VerticalAlignment, Widget,
|
||||||
Widget,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, Transition};
|
use crate::app::{App, Transition};
|
||||||
@ -685,8 +684,8 @@ fn make_panel(ctx: &mut EventCtx, app: &App) -> Panel {
|
|||||||
Line("Commute map by block").small_heading().draw(ctx),
|
Line("Commute map by block").small_heading().draw(ctx),
|
||||||
ctx.style().btn_close_widget(ctx),
|
ctx.style().btn_close_widget(ctx),
|
||||||
]),
|
]),
|
||||||
Checkbox::toggle(ctx, "from / to this block", "from", "to", Key::Space, true),
|
Toggle::choice(ctx, "from / to this block", "from", "to", Key::Space, true),
|
||||||
Checkbox::switch(ctx, "include borders", None, true),
|
Toggle::switch(ctx, "include borders", None, true),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
"Departing from:".draw_text(ctx).margin_right(20),
|
"Departing from:".draw_text(ctx).margin_right(20),
|
||||||
Slider::area(ctx, 0.15 * ctx.canvas.window_width, 0.0).named("depart from"),
|
Slider::area(ctx, 0.15 * ctx.canvas.window_width, 0.0).named("depart from"),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use geom::Duration;
|
use geom::Duration;
|
||||||
use sim::{TripEndpoint, TripID, TripPhaseType};
|
use sim::{TripEndpoint, TripID, TripPhaseType};
|
||||||
use widgetry::table::{Col, Filter, Table};
|
use widgetry::table::{Col, Filter, Table};
|
||||||
use widgetry::{Checkbox, EventCtx, Filler, Line, Panel, State, Text, Widget};
|
use widgetry::{EventCtx, Filler, Line, Panel, State, Text, Toggle, Widget};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::sandbox::dashboards::generic_trip_table::GenericTripTable;
|
use crate::sandbox::dashboards::generic_trip_table::GenericTripTable;
|
||||||
@ -100,8 +100,8 @@ fn make_table(app: &App) -> Table<App, Entry, Filters> {
|
|||||||
},
|
},
|
||||||
to_controls: Box::new(move |ctx, _, state| {
|
to_controls: Box::new(move |ctx, _, state| {
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::switch(ctx, "starting off-map", None, state.starts_off_map),
|
Toggle::switch(ctx, "starting off-map", None, state.starts_off_map),
|
||||||
Checkbox::switch(ctx, "ending off-map", None, state.ends_off_map),
|
Toggle::switch(ctx, "ending off-map", None, state.ends_off_map),
|
||||||
])
|
])
|
||||||
}),
|
}),
|
||||||
from_controls: Box::new(|panel| Filters {
|
from_controls: Box::new(|panel| Filters {
|
||||||
|
@ -9,8 +9,8 @@ use geom::{Distance, Duration, Polygon, Pt2D};
|
|||||||
use map_gui::tools::PopupMsg;
|
use map_gui::tools::PopupMsg;
|
||||||
use sim::TripMode;
|
use sim::TripMode;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Choice, Color, CompareTimes, DrawBaselayer, DrawWithTooltips, EventCtx, GeomBatch,
|
Choice, Color, CompareTimes, DrawBaselayer, DrawWithTooltips, EventCtx, GeomBatch, GfxCtx,
|
||||||
GfxCtx, Line, Outcome, Panel, State, StyledButtons, Text, TextExt, Widget,
|
Line, Outcome, Panel, State, StyledButtons, Text, TextExt, Toggle, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, Transition};
|
use crate::app::{App, Transition};
|
||||||
@ -25,7 +25,7 @@ impl TripSummaries {
|
|||||||
pub fn new(ctx: &mut EventCtx, app: &App, filter: Filter) -> Box<dyn State<App>> {
|
pub fn new(ctx: &mut EventCtx, app: &App, filter: Filter) -> Box<dyn State<App>> {
|
||||||
let mut filters = vec!["Filters".draw_text(ctx)];
|
let mut filters = vec!["Filters".draw_text(ctx)];
|
||||||
for mode in TripMode::all() {
|
for mode in TripMode::all() {
|
||||||
filters.push(Checkbox::colored(
|
filters.push(Toggle::colored_checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
mode.ongoing_verb(),
|
mode.ongoing_verb(),
|
||||||
color_for_mode(app, mode),
|
color_for_mode(app, mode),
|
||||||
|
@ -5,7 +5,7 @@ use geom::{Duration, Time};
|
|||||||
use sim::{TripEndpoint, TripID, TripMode};
|
use sim::{TripEndpoint, TripID, TripMode};
|
||||||
use widgetry::table::{Col, Filter, Table};
|
use widgetry::table::{Col, Filter, Table};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, ControlState, EventCtx, Filler, Line, Panel, State, StyledButtons, Text, Widget,
|
ControlState, EventCtx, Filler, Line, Panel, State, StyledButtons, Text, Toggle, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
@ -190,10 +190,10 @@ fn make_table_finished_trips(app: &App) -> Table<App, FinishedTrip, Filters> {
|
|||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
checkbox_per_mode(ctx, app, &state.modes),
|
checkbox_per_mode(ctx, app, &state.modes),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::switch(ctx, "starting off-map", None, state.off_map_starts),
|
Toggle::switch(ctx, "starting off-map", None, state.off_map_starts),
|
||||||
Checkbox::switch(ctx, "ending off-map", None, state.off_map_ends),
|
Toggle::switch(ctx, "ending off-map", None, state.off_map_ends),
|
||||||
if app.primary.has_modified_trips {
|
if app.primary.has_modified_trips {
|
||||||
Checkbox::switch(
|
Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"trips unmodified by experiment",
|
"trips unmodified by experiment",
|
||||||
None,
|
None,
|
||||||
@ -203,7 +203,7 @@ fn make_table_finished_trips(app: &App) -> Table<App, FinishedTrip, Filters> {
|
|||||||
Widget::nothing()
|
Widget::nothing()
|
||||||
},
|
},
|
||||||
if app.primary.has_modified_trips {
|
if app.primary.has_modified_trips {
|
||||||
Checkbox::switch(
|
Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"trips modified by experiment",
|
"trips modified by experiment",
|
||||||
None,
|
None,
|
||||||
@ -213,7 +213,7 @@ fn make_table_finished_trips(app: &App) -> Table<App, FinishedTrip, Filters> {
|
|||||||
Widget::nothing()
|
Widget::nothing()
|
||||||
},
|
},
|
||||||
if any_congestion_caps {
|
if any_congestion_caps {
|
||||||
Checkbox::switch(
|
Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"trips not affected by congestion caps",
|
"trips not affected by congestion caps",
|
||||||
None,
|
None,
|
||||||
@ -223,7 +223,7 @@ fn make_table_finished_trips(app: &App) -> Table<App, FinishedTrip, Filters> {
|
|||||||
Widget::nothing()
|
Widget::nothing()
|
||||||
},
|
},
|
||||||
if any_congestion_caps {
|
if any_congestion_caps {
|
||||||
Checkbox::switch(
|
Toggle::switch(
|
||||||
ctx,
|
ctx,
|
||||||
"trips affected by congestion caps",
|
"trips affected by congestion caps",
|
||||||
None,
|
None,
|
||||||
@ -407,8 +407,8 @@ fn make_table_cancelled_trips(app: &App) -> Table<App, CancelledTrip, Filters> {
|
|||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
checkbox_per_mode(ctx, app, &state.modes),
|
checkbox_per_mode(ctx, app, &state.modes),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::switch(ctx, "starting off-map", None, state.off_map_starts),
|
Toggle::switch(ctx, "starting off-map", None, state.off_map_starts),
|
||||||
Checkbox::switch(ctx, "ending off-map", None, state.off_map_ends),
|
Toggle::switch(ctx, "ending off-map", None, state.off_map_ends),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
}),
|
}),
|
||||||
|
@ -6,8 +6,8 @@ use map_gui::render::DrawOptions;
|
|||||||
use map_gui::tools::{grey_out_map, PopupMsg};
|
use map_gui::tools::{grey_out_map, PopupMsg};
|
||||||
use map_gui::ID;
|
use map_gui::ID;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel,
|
Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, Slider,
|
||||||
Slider, State, StyledButtons, Text, UpdateType, Widget,
|
State, StyledButtons, Text, Toggle, UpdateType, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, FindDelayedIntersections, ShowEverything, Transition};
|
use crate::app::{App, FindDelayedIntersections, ShowEverything, Transition};
|
||||||
@ -69,7 +69,7 @@ impl JumpToTime {
|
|||||||
target.to_percent(end_of_day).min(1.0),
|
target.to_percent(end_of_day).min(1.0),
|
||||||
)
|
)
|
||||||
.named("time slider"),
|
.named("time slider"),
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"skip drawing (for faster simulations)",
|
"skip drawing (for faster simulations)",
|
||||||
None,
|
None,
|
||||||
@ -194,7 +194,7 @@ impl JumpToDelay {
|
|||||||
),
|
),
|
||||||
Line("minute delay").small_heading().draw(ctx),
|
Line("minute delay").small_heading().draw(ctx),
|
||||||
]),
|
]),
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"skip drawing (for faster simulations)",
|
"skip drawing (for faster simulations)",
|
||||||
None,
|
None,
|
||||||
|
@ -6,8 +6,8 @@ use map_gui::tools::PopupMsg;
|
|||||||
use map_gui::ID;
|
use map_gui::ID;
|
||||||
use map_model::{IntersectionCluster, IntersectionID, Map, PathConstraints, RoadID};
|
use map_model::{IntersectionCluster, IntersectionID, Map, PathConstraints, RoadID};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment,
|
Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||||
Key, Line, Panel, SimpleState, State, StyledButtons, Text, TextExt, VerticalAlignment, Widget,
|
Panel, SimpleState, State, StyledButtons, Text, TextExt, Toggle, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::{App, ShowEverything, Transition};
|
use crate::app::{App, ShowEverything, Transition};
|
||||||
@ -201,7 +201,7 @@ impl UberTurnViewer {
|
|||||||
]),
|
]),
|
||||||
format!("driving_cost for a Car: {}", sum_cost).draw_text(ctx),
|
format!("driving_cost for a Car: {}", sum_cost).draw_text(ctx),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::toggle(
|
Toggle::choice(
|
||||||
ctx,
|
ctx,
|
||||||
"legal / illegal movements",
|
"legal / illegal movements",
|
||||||
"legal",
|
"legal",
|
||||||
|
@ -13,8 +13,8 @@ use map_gui::tools::CameraState;
|
|||||||
use map_model::osm;
|
use map_model::osm;
|
||||||
use map_model::raw::OriginalRoad;
|
use map_model::raw::OriginalRoad;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Canvas, Checkbox, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
|
Canvas, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
|
||||||
SharedAppState, State, StyledButtons, Text, Transition, VerticalAlignment, Widget,
|
SharedAppState, State, StyledButtons, Text, Toggle, Transition, VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod edit;
|
mod edit;
|
||||||
@ -109,7 +109,7 @@ impl MainState {
|
|||||||
]),
|
]),
|
||||||
Text::new().draw(ctx).named("instructions"),
|
Text::new().draw(ctx).named("instructions"),
|
||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
Checkbox::switch(ctx, "intersection geometry", Key::G, false),
|
Toggle::switch(ctx, "intersection geometry", Key::G, false),
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_outline_text("adjust boundary")
|
.btn_outline_text("adjust boundary")
|
||||||
.build_def(ctx),
|
.build_def(ctx),
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use abstutil::CmdArgs;
|
use abstutil::CmdArgs;
|
||||||
use geom::{Duration, UnitFmt};
|
use geom::{Duration, UnitFmt};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, Choice, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, Spinner, State,
|
Choice, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, Spinner, State, StyledButtons,
|
||||||
StyledButtons, TextExt, Widget,
|
TextExt, Toggle, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::colors::ColorSchemeChoice;
|
use crate::colors::ColorSchemeChoice;
|
||||||
@ -133,26 +133,26 @@ impl OptionsPanel {
|
|||||||
]),
|
]),
|
||||||
"Camera controls".draw_text(ctx),
|
"Camera controls".draw_text(ctx),
|
||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Invert direction of vertical scrolling",
|
"Invert direction of vertical scrolling",
|
||||||
None,
|
None,
|
||||||
ctx.canvas.invert_scroll,
|
ctx.canvas.invert_scroll,
|
||||||
),
|
),
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Pan map when cursor is at edge of screen",
|
"Pan map when cursor is at edge of screen",
|
||||||
None,
|
None,
|
||||||
ctx.canvas.edge_auto_panning,
|
ctx.canvas.edge_auto_panning,
|
||||||
)
|
)
|
||||||
.named("autopan"),
|
.named("autopan"),
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Use touchpad to pan and hold Control to zoom",
|
"Use touchpad to pan and hold Control to zoom",
|
||||||
None,
|
None,
|
||||||
ctx.canvas.touchpad_to_move,
|
ctx.canvas.touchpad_to_move,
|
||||||
),
|
),
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Use arrow keys to pan and Q/W to zoom",
|
"Use arrow keys to pan and Q/W to zoom",
|
||||||
None,
|
None,
|
||||||
@ -236,7 +236,7 @@ impl OptionsPanel {
|
|||||||
choices
|
choices
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
Checkbox::toggle(
|
Toggle::choice(
|
||||||
ctx,
|
ctx,
|
||||||
"metric / imperial units",
|
"metric / imperial units",
|
||||||
"metric",
|
"metric",
|
||||||
@ -249,8 +249,8 @@ impl OptionsPanel {
|
|||||||
.padding(8),
|
.padding(8),
|
||||||
"Debug".draw_text(ctx),
|
"Debug".draw_text(ctx),
|
||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
Checkbox::checkbox(ctx, "Enable developer mode", None, app.opts().dev),
|
Toggle::checkbox(ctx, "Enable developer mode", None, app.opts().dev),
|
||||||
Checkbox::checkbox(
|
Toggle::checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
"Draw all agents to debug geometry (Slow!)",
|
"Draw all agents to debug geometry (Slow!)",
|
||||||
None,
|
None,
|
||||||
|
@ -6,7 +6,7 @@ use aabb_quadtree::QuadTree;
|
|||||||
use geom::{Circle, Pt2D, Time};
|
use geom::{Circle, Pt2D, Time};
|
||||||
use map_model::{Map, Traversable};
|
use map_model::{Map, Traversable};
|
||||||
use sim::{AgentID, Sim, UnzoomedAgent, VehicleType};
|
use sim::{AgentID, Sim, UnzoomedAgent, VehicleType};
|
||||||
use widgetry::{Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, Panel, Prerender, Widget};
|
use widgetry::{Color, Drawable, EventCtx, GeomBatch, GfxCtx, Panel, Prerender, Toggle, Widget};
|
||||||
|
|
||||||
use crate::colors::ColorScheme;
|
use crate::colors::ColorScheme;
|
||||||
use crate::render::{
|
use crate::render::{
|
||||||
@ -209,19 +209,20 @@ impl UnzoomedAgents {
|
|||||||
|
|
||||||
pub fn make_horiz_viz_panel(&self, ctx: &mut EventCtx) -> Widget {
|
pub fn make_horiz_viz_panel(&self, ctx: &mut EventCtx) -> Widget {
|
||||||
Widget::custom_row(vec![
|
Widget::custom_row(vec![
|
||||||
Checkbox::colored(ctx, "Car", self.car_color, self.cars).margin_right(24),
|
Toggle::colored_checkbox(ctx, "Car", self.car_color, self.cars).margin_right(24),
|
||||||
Checkbox::colored(ctx, "Bike", self.bike_color, self.bikes).margin_right(24),
|
Toggle::colored_checkbox(ctx, "Bike", self.bike_color, self.bikes).margin_right(24),
|
||||||
Checkbox::colored(ctx, "Bus", self.bus_color, self.buses_and_trains).margin_right(24),
|
Toggle::colored_checkbox(ctx, "Bus", self.bus_color, self.buses_and_trains)
|
||||||
Checkbox::colored(ctx, "Walk", self.ped_color, self.peds).margin_right(8),
|
.margin_right(24),
|
||||||
|
Toggle::colored_checkbox(ctx, "Walk", self.ped_color, self.peds).margin_right(8),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_vert_viz_panel(&self, ctx: &mut EventCtx) -> Widget {
|
pub fn make_vert_viz_panel(&self, ctx: &mut EventCtx) -> Widget {
|
||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
Checkbox::colored(ctx, "Car", self.car_color, self.cars),
|
Toggle::colored_checkbox(ctx, "Car", self.car_color, self.cars),
|
||||||
Checkbox::colored(ctx, "Bike", self.bike_color, self.bikes),
|
Toggle::colored_checkbox(ctx, "Bike", self.bike_color, self.bikes),
|
||||||
Checkbox::colored(ctx, "Bus", self.bus_color, self.buses_and_trains),
|
Toggle::colored_checkbox(ctx, "Bus", self.bus_color, self.buses_and_trains),
|
||||||
Checkbox::colored(ctx, "Walk", self.ped_color, self.peds),
|
Toggle::colored_checkbox(ctx, "Walk", self.ped_color, self.peds),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use geom::{Bounds, Histogram, Polygon, Pt2D, Statistic};
|
use geom::{Bounds, Histogram, Polygon, Pt2D, Statistic};
|
||||||
use widgetry::{Checkbox, Choice, Color, EventCtx, GeomBatch, Panel, Spinner, TextExt, Widget};
|
use widgetry::{Choice, Color, EventCtx, GeomBatch, Panel, Spinner, TextExt, Toggle, Widget};
|
||||||
|
|
||||||
use crate::tools::{ColorLegend, ColorScale};
|
use crate::tools::{ColorLegend, ColorScale};
|
||||||
|
|
||||||
@ -53,8 +53,8 @@ impl HeatmapOptions {
|
|||||||
.named("radius")
|
.named("radius")
|
||||||
.align_right(),
|
.align_right(),
|
||||||
]),
|
]),
|
||||||
Checkbox::switch(ctx, "smoothing", None, self.smoothing),
|
Toggle::switch(ctx, "smoothing", None, self.smoothing),
|
||||||
Checkbox::switch(ctx, "contours", None, self.contours),
|
Toggle::switch(ctx, "contours", None, self.contours),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
"Color scheme".draw_text(ctx).centered_vert(),
|
"Color scheme".draw_text(ctx).centered_vert(),
|
||||||
Widget::dropdown(
|
Widget::dropdown(
|
||||||
|
@ -6,7 +6,7 @@ use anyhow::Result;
|
|||||||
use abstio::{DataPacks, Manifest};
|
use abstio::{DataPacks, Manifest};
|
||||||
use abstutil::Timer;
|
use abstutil::Timer;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, EventCtx, GfxCtx, Line, Outcome, Panel, State, StyledButtons, TextExt, Transition,
|
EventCtx, GfxCtx, Line, Outcome, Panel, State, StyledButtons, TextExt, Toggle, Transition,
|
||||||
Widget,
|
Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ impl<A: AppLike + 'static> Picker<A> {
|
|||||||
];
|
];
|
||||||
for (city, bytes) in size_per_city(&manifest) {
|
for (city, bytes) in size_per_city(&manifest) {
|
||||||
col.push(Widget::row(vec![
|
col.push(Widget::row(vec![
|
||||||
Checkbox::checkbox(ctx, &city, None, data_packs.runtime.contains(&city)),
|
Toggle::checkbox(ctx, &city, None, data_packs.runtime.contains(&city)),
|
||||||
prettyprint_bytes(bytes).draw_text(ctx).centered_vert(),
|
prettyprint_bytes(bytes).draw_text(ctx).centered_vert(),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ use map_gui::tools::{
|
|||||||
use map_gui::{SimpleApp, ID};
|
use map_gui::{SimpleApp, ID};
|
||||||
use map_model::osm;
|
use map_model::osm;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Checkbox, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx,
|
lctrl, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||||
HorizontalAlignment, Key, Line, Outcome, Panel, State, StyledButtons, Text, TextExt,
|
Line, Outcome, Panel, State, StyledButtons, Text, TextExt, Toggle, Transition,
|
||||||
Transition, VerticalAlignment, Widget,
|
VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
type App = SimpleApp<()>;
|
type App = SimpleApp<()>;
|
||||||
@ -444,7 +444,7 @@ impl BusinessSearch {
|
|||||||
format!("{} businesses total", prettyprint_usize(self.counts.sum())).draw_text(ctx),
|
format!("{} businesses total", prettyprint_usize(self.counts.sum())).draw_text(ctx),
|
||||||
);
|
);
|
||||||
for (amenity, cnt) in self.counts.borrow() {
|
for (amenity, cnt) in self.counts.borrow() {
|
||||||
col.push(Checkbox::custom_checkbox(
|
col.push(Toggle::custom_checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
amenity,
|
amenity,
|
||||||
vec![Line(format!("{}: {}", amenity, prettyprint_usize(*cnt)))],
|
vec![Line(format!("{}: {}", amenity, prettyprint_usize(*cnt)))],
|
||||||
|
@ -9,8 +9,8 @@ use map_gui::{SimpleApp, ID};
|
|||||||
use map_model::{osm, RoadID};
|
use map_model::{osm, RoadID};
|
||||||
use osm::WayID;
|
use osm::WayID;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment,
|
lctrl, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
|
||||||
Key, Line, Menu, Outcome, Panel, State, StyledButtons, Text, TextExt, Transition,
|
Menu, Outcome, Panel, State, StyledButtons, Text, TextExt, Toggle, Transition,
|
||||||
VerticalAlignment, Widget,
|
VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ impl ParkingMapper {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
Checkbox::checkbox(ctx, "max 3 days parking (default in Seattle)", None, false),
|
Toggle::checkbox(ctx, "max 3 days parking (default in Seattle)", None, false),
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_outline_text("Generate OsmChange file")
|
.btn_outline_text("Generate OsmChange file")
|
||||||
.build_def(ctx),
|
.build_def(ctx),
|
||||||
|
@ -4,8 +4,7 @@ use anyhow::Result;
|
|||||||
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink};
|
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink};
|
||||||
|
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
Checkbox, EventCtx, GfxCtx, HorizontalAlignment, Outcome, Panel, StyledButtons,
|
EventCtx, GfxCtx, HorizontalAlignment, Outcome, Panel, StyledButtons, Toggle, VerticalAlignment,
|
||||||
VerticalAlignment,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO Speed up when we're almost out of time, slow down when we're low on energy
|
// TODO Speed up when we're almost out of time, slow down when we're low on energy
|
||||||
@ -108,7 +107,7 @@ impl Inner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let panel = Panel::new(
|
let panel = Panel::new(
|
||||||
Checkbox::new(
|
Toggle::new(
|
||||||
play_music,
|
play_music,
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_solid_icon("system/assets/tools/volume_off.svg")
|
.btn_solid_icon("system/assets/tools/volume_off.svg")
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//!
|
//!
|
||||||
//! * [`Autocomplete`] - select predefined value by combining text entry with menus
|
//! * [`Autocomplete`] - select predefined value by combining text entry with menus
|
||||||
//! * [`Button`] - clickable buttons with keybindings and tooltips
|
//! * [`Button`] - clickable buttons with keybindings and tooltips
|
||||||
//! * [`Checkbox`] - toggle between two buttons
|
//! * [`Toggle`] - checkboxes, switches, and other toggles
|
||||||
//! * [`CompareTimes`] - a scatter plot specialized for comparing times
|
//! * [`CompareTimes`] - a scatter plot specialized for comparing times
|
||||||
//! * [`DrawWithTooltips`] - draw static geometry, with mouse tooltips in certain regions
|
//! * [`DrawWithTooltips`] - draw static geometry, with mouse tooltips in certain regions
|
||||||
//! * [`Dropdown`] - a button that expands into a menu
|
//! * [`Dropdown`] - a button that expands into a menu
|
||||||
@ -48,7 +48,6 @@ pub use crate::tools::Cached;
|
|||||||
pub use crate::widgets::autocomplete::Autocomplete;
|
pub use crate::widgets::autocomplete::Autocomplete;
|
||||||
pub(crate) use crate::widgets::button::Button;
|
pub(crate) use crate::widgets::button::Button;
|
||||||
pub use crate::widgets::button::{ButtonBuilder, MultiButton};
|
pub use crate::widgets::button::{ButtonBuilder, MultiButton};
|
||||||
pub use crate::widgets::checkbox::Checkbox;
|
|
||||||
pub use crate::widgets::compare_times::CompareTimes;
|
pub use crate::widgets::compare_times::CompareTimes;
|
||||||
pub(crate) use crate::widgets::dropdown::Dropdown;
|
pub(crate) use crate::widgets::dropdown::Dropdown;
|
||||||
pub use crate::widgets::fan_chart::FanChart;
|
pub use crate::widgets::fan_chart::FanChart;
|
||||||
@ -63,6 +62,7 @@ pub use crate::widgets::slider::Slider;
|
|||||||
pub use crate::widgets::spinner::Spinner;
|
pub use crate::widgets::spinner::Spinner;
|
||||||
pub use crate::widgets::table;
|
pub use crate::widgets::table;
|
||||||
pub(crate) use crate::widgets::text_box::TextBox;
|
pub(crate) use crate::widgets::text_box::TextBox;
|
||||||
|
pub use crate::widgets::toggle::Toggle;
|
||||||
pub use crate::widgets::{
|
pub use crate::widgets::{
|
||||||
CornerRounding, EdgeInsets, Outcome, Panel, Widget, WidgetImpl, WidgetOutput,
|
CornerRounding, EdgeInsets, Outcome, Panel, Widget, WidgetImpl, WidgetOutput,
|
||||||
};
|
};
|
||||||
|
@ -7,8 +7,8 @@ use geom::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, JustDraw, Line, ScreenDims, ScreenPt,
|
Color, Drawable, EventCtx, GeomBatch, GfxCtx, JustDraw, Line, ScreenDims, ScreenPt,
|
||||||
ScreenRectangle, Text, TextExt, Widget, WidgetImpl, WidgetOutput,
|
ScreenRectangle, Text, TextExt, Toggle, Widget, WidgetImpl, WidgetOutput,
|
||||||
};
|
};
|
||||||
|
|
||||||
// The X is always time
|
// The X is always time
|
||||||
@ -332,7 +332,7 @@ pub fn make_legend<T: Yvalue<T>>(
|
|||||||
}
|
}
|
||||||
seen.insert(s.label.clone());
|
seen.insert(s.label.clone());
|
||||||
if opts.filterable {
|
if opts.filterable {
|
||||||
row.push(Checkbox::colored(
|
row.push(Toggle::colored_checkbox(
|
||||||
ctx,
|
ctx,
|
||||||
&s.label,
|
&s.label,
|
||||||
s.color,
|
s.color,
|
||||||
|
@ -12,14 +12,13 @@ use geom::{CornerRadii, Distance, Percent, Polygon};
|
|||||||
use crate::widgets::containers::{Container, Nothing};
|
use crate::widgets::containers::{Container, Nothing};
|
||||||
pub use crate::widgets::panel::Panel;
|
pub use crate::widgets::panel::Panel;
|
||||||
use crate::{
|
use crate::{
|
||||||
Button, Checkbox, Choice, Color, DeferDraw, DrawWithTooltips, Drawable, Dropdown, EventCtx,
|
Button, Choice, Color, DeferDraw, DrawWithTooltips, Drawable, Dropdown, EventCtx, GeomBatch,
|
||||||
GeomBatch, GfxCtx, JustDraw, Menu, RewriteColor, ScreenDims, ScreenPt, ScreenRectangle, Text,
|
GfxCtx, JustDraw, Menu, RewriteColor, ScreenDims, ScreenPt, ScreenRectangle, Text, TextBox,
|
||||||
TextBox,
|
Toggle,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod autocomplete;
|
pub mod autocomplete;
|
||||||
pub mod button;
|
pub mod button;
|
||||||
pub mod checkbox;
|
|
||||||
pub mod compare_times;
|
pub mod compare_times;
|
||||||
pub mod containers;
|
pub mod containers;
|
||||||
pub mod dropdown;
|
pub mod dropdown;
|
||||||
@ -35,6 +34,7 @@ pub mod slider;
|
|||||||
pub mod spinner;
|
pub mod spinner;
|
||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod text_box;
|
pub mod text_box;
|
||||||
|
pub mod toggle;
|
||||||
|
|
||||||
/// Create a new widget by implementing this trait. You can instantiate your widget by calling
|
/// Create a new widget by implementing this trait. You can instantiate your widget by calling
|
||||||
/// `Widget::new(Box::new(instance of your new widget))`, which gives you the usual style options.
|
/// `Widget::new(Box::new(instance of your new widget))`, which gives you the usual style options.
|
||||||
@ -660,7 +660,7 @@ impl Widget {
|
|||||||
if btn.hovering {
|
if btn.hovering {
|
||||||
return Some(&btn.action);
|
return Some(&btn.action);
|
||||||
}
|
}
|
||||||
} else if let Some(checkbox) = self.widget.downcast_ref::<Checkbox>() {
|
} else if let Some(checkbox) = self.widget.downcast_ref::<Toggle>() {
|
||||||
if checkbox.btn.hovering {
|
if checkbox.btn.hovering {
|
||||||
return Some(&checkbox.btn.action);
|
return Some(&checkbox.btn.action);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ use geom::{Percent, Polygon};
|
|||||||
use crate::widgets::slider;
|
use crate::widgets::slider;
|
||||||
use crate::widgets::Container;
|
use crate::widgets::Container;
|
||||||
use crate::{
|
use crate::{
|
||||||
Autocomplete, Button, Checkbox, Color, Dropdown, EventCtx, GfxCtx, HorizontalAlignment, Menu,
|
Autocomplete, Button, Color, Dropdown, EventCtx, GfxCtx, HorizontalAlignment, Menu, Outcome,
|
||||||
Outcome, PersistentSplit, ScreenDims, ScreenPt, ScreenRectangle, Slider, Spinner, TextBox,
|
PersistentSplit, ScreenDims, ScreenPt, ScreenRectangle, Slider, Spinner, TextBox, Toggle,
|
||||||
VerticalAlignment, Widget, WidgetImpl, WidgetOutput,
|
VerticalAlignment, Widget, WidgetImpl, WidgetOutput,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -360,11 +360,11 @@ impl Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_checked(&self, name: &str) -> bool {
|
pub fn is_checked(&self, name: &str) -> bool {
|
||||||
self.find::<Checkbox>(name).enabled
|
self.find::<Toggle>(name).enabled
|
||||||
}
|
}
|
||||||
pub fn maybe_is_checked(&self, name: &str) -> Option<bool> {
|
pub fn maybe_is_checked(&self, name: &str) -> Option<bool> {
|
||||||
if self.has_widget(name) {
|
if self.has_widget(name) {
|
||||||
Some(self.find::<Checkbox>(name).enabled)
|
Some(self.find::<Toggle>(name).enabled)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,22 @@ use crate::{
|
|||||||
WidgetOutput,
|
WidgetOutput,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Checkbox {
|
pub struct Toggle {
|
||||||
pub(crate) enabled: bool,
|
pub(crate) enabled: bool,
|
||||||
pub(crate) btn: Button,
|
pub(crate) btn: Button,
|
||||||
other_btn: Button,
|
other_btn: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Checkbox {
|
impl Toggle {
|
||||||
pub fn new(enabled: bool, false_btn: Button, true_btn: Button) -> Widget {
|
pub fn new(enabled: bool, false_btn: Button, true_btn: Button) -> Widget {
|
||||||
if enabled {
|
if enabled {
|
||||||
Widget::new(Box::new(Checkbox {
|
Widget::new(Box::new(Toggle {
|
||||||
enabled,
|
enabled,
|
||||||
btn: true_btn,
|
btn: true_btn,
|
||||||
other_btn: false_btn,
|
other_btn: false_btn,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
Widget::new(Box::new(Checkbox {
|
Widget::new(Box::new(Toggle {
|
||||||
enabled,
|
enabled,
|
||||||
btn: false_btn,
|
btn: false_btn,
|
||||||
other_btn: true_btn,
|
other_btn: true_btn,
|
||||||
@ -50,7 +50,7 @@ impl Checkbox {
|
|||||||
.image_bytes(include_labeled_bytes!("../../icons/toggle_on.svg"))
|
.image_bytes(include_labeled_bytes!("../../icons/toggle_on.svg"))
|
||||||
.build(ctx, label);
|
.build(ctx, label);
|
||||||
|
|
||||||
Checkbox::new(enabled, off_button, on_button).named(label)
|
Toggle::new(enabled, off_button, on_button).named(label)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn checkbox<MK: Into<Option<MultiKey>>>(
|
pub fn checkbox<MK: Into<Option<MultiKey>>>(
|
||||||
@ -84,7 +84,7 @@ impl Checkbox {
|
|||||||
.clone()
|
.clone()
|
||||||
.image_bytes(include_labeled_bytes!("../../icons/checkbox_checked.svg"));
|
.image_bytes(include_labeled_bytes!("../../icons/checkbox_checked.svg"));
|
||||||
|
|
||||||
Checkbox::new(
|
Toggle::new(
|
||||||
enabled,
|
enabled,
|
||||||
false_btn.build(ctx, label),
|
false_btn.build(ctx, label),
|
||||||
true_btn.build(ctx, label),
|
true_btn.build(ctx, label),
|
||||||
@ -124,7 +124,7 @@ impl Checkbox {
|
|||||||
.clone()
|
.clone()
|
||||||
.image_bytes(include_labeled_bytes!("../../icons/checkbox_checked.svg"));
|
.image_bytes(include_labeled_bytes!("../../icons/checkbox_checked.svg"));
|
||||||
|
|
||||||
Checkbox::new(
|
Toggle::new(
|
||||||
enabled,
|
enabled,
|
||||||
false_btn.build(ctx, action),
|
false_btn.build(ctx, action),
|
||||||
true_btn.build(ctx, action),
|
true_btn.build(ctx, action),
|
||||||
@ -132,7 +132,7 @@ impl Checkbox {
|
|||||||
.named(action)
|
.named(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn colored(ctx: &EventCtx, label: &str, color: Color, enabled: bool) -> Widget {
|
pub fn colored_checkbox(ctx: &EventCtx, label: &str, color: Color, enabled: bool) -> Widget {
|
||||||
let buttons = ctx.style().btn_plain().label_text(label).padding(4.0);
|
let buttons = ctx.style().btn_plain().label_text(label).padding(4.0);
|
||||||
|
|
||||||
let false_btn = buttons
|
let false_btn = buttons
|
||||||
@ -154,7 +154,7 @@ impl Checkbox {
|
|||||||
ControlState::Default,
|
ControlState::Default,
|
||||||
);
|
);
|
||||||
|
|
||||||
Checkbox::new(
|
Toggle::new(
|
||||||
enabled,
|
enabled,
|
||||||
false_btn.build(ctx, label),
|
false_btn.build(ctx, label),
|
||||||
true_btn.build(ctx, label),
|
true_btn.build(ctx, label),
|
||||||
@ -163,7 +163,7 @@ impl Checkbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO These should actually be radio buttons
|
// TODO These should actually be radio buttons
|
||||||
pub fn toggle<MK: Into<Option<MultiKey>>>(
|
pub fn choice<MK: Into<Option<MultiKey>>>(
|
||||||
ctx: &EventCtx,
|
ctx: &EventCtx,
|
||||||
label: &str,
|
label: &str,
|
||||||
left_label: &str,
|
left_label: &str,
|
||||||
@ -203,7 +203,7 @@ impl Checkbox {
|
|||||||
let right_text_button = left_text_button.clone().label_text(right_label);
|
let right_text_button = left_text_button.clone().label_text(right_label);
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
left_text_button.build_def(ctx).centered_vert(),
|
left_text_button.build_def(ctx).centered_vert(),
|
||||||
Checkbox::new(
|
Toggle::new(
|
||||||
enabled,
|
enabled,
|
||||||
toggle_right_button.build(ctx, right_label),
|
toggle_right_button.build(ctx, right_label),
|
||||||
toggle_left_button.build(ctx, left_label),
|
toggle_left_button.build(ctx, left_label),
|
||||||
@ -215,7 +215,7 @@ impl Checkbox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WidgetImpl for Checkbox {
|
impl WidgetImpl for Toggle {
|
||||||
fn get_dims(&self) -> ScreenDims {
|
fn get_dims(&self) -> ScreenDims {
|
||||||
self.btn.get_dims()
|
self.btn.get_dims()
|
||||||
}
|
}
|
@ -5,10 +5,10 @@ use rand_xorshift::XorShiftRng;
|
|||||||
|
|
||||||
use geom::{Angle, Duration, Percent, Polygon, Pt2D, Time};
|
use geom::{Angle, Duration, Percent, Polygon, Pt2D, Time};
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
lctrl, Checkbox, Choice, Color, Drawable, EventCtx, Fill, GeomBatch, GfxCtx,
|
lctrl, Choice, Color, Drawable, EventCtx, Fill, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||||
HorizontalAlignment, Key, Line, LinePlot, Outcome, Panel, PersistentSplit, PlotOptions, Series,
|
Line, LinePlot, Outcome, Panel, PersistentSplit, PlotOptions, Series, SharedAppState, State,
|
||||||
SharedAppState, State, StyledButtons, Text, TextExt, Texture, Transition, UpdateType,
|
StyledButtons, Text, TextExt, Texture, Toggle, Transition, UpdateType, VerticalAlignment,
|
||||||
VerticalAlignment, Widget,
|
Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
@ -342,15 +342,15 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
|
|||||||
.btn_outline_text("New faces")
|
.btn_outline_text("New faces")
|
||||||
.hotkey(Key::F)
|
.hotkey(Key::F)
|
||||||
.build_widget(ctx, "generate new faces"),
|
.build_widget(ctx, "generate new faces"),
|
||||||
Checkbox::switch(ctx, "Draw scrollable canvas", None, true),
|
Toggle::switch(ctx, "Draw scrollable canvas", None, true),
|
||||||
Checkbox::switch(ctx, "Show timeseries", lctrl(Key::T), false),
|
Toggle::switch(ctx, "Show timeseries", lctrl(Key::T), false),
|
||||||
]),
|
]),
|
||||||
"Stopwatch: ..."
|
"Stopwatch: ..."
|
||||||
.draw_text(ctx)
|
.draw_text(ctx)
|
||||||
.named("stopwatch")
|
.named("stopwatch")
|
||||||
.margin_above(30),
|
.margin_above(30),
|
||||||
Widget::row(vec![
|
Widget::row(vec![
|
||||||
Checkbox::new(
|
Toggle::new(
|
||||||
false,
|
false,
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_solid_text("Pause")
|
.btn_solid_text("Pause")
|
||||||
@ -471,7 +471,7 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
|
|||||||
),
|
),
|
||||||
Widget::col(
|
Widget::col(
|
||||||
(0..row_height)
|
(0..row_height)
|
||||||
.map(|_| widgetry::Checkbox::checkbox(ctx, "checkbox", None, true))
|
.map(|_| widgetry::Toggle::checkbox(ctx, "checkbox", None, true))
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user