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