mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
refactor separators
This commit is contained in:
parent
9af8aafb44
commit
ae18b09b3b
@ -345,6 +345,24 @@ impl Widget {
|
||||
batch.autocrop_dims = false;
|
||||
(batch, hitbox)
|
||||
}
|
||||
|
||||
pub fn horiz_separator(ctx: &mut EventCtx, pct_width: f64) -> Widget {
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(pct_width * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz()
|
||||
}
|
||||
|
||||
pub fn vert_separator(ctx: &mut EventCtx, height_px: f64) -> Widget {
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, height_px))]),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Internals
|
||||
|
@ -303,10 +303,7 @@ fn make_panel(ctx: &mut EventCtx, story: &StoryMap, mode: &Mode, dirty: bool) ->
|
||||
Composite::new(Widget::col(vec![
|
||||
Widget::row(vec![
|
||||
Line("Story map editor").small_heading().draw(ctx),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 30.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 30.0),
|
||||
Btn::text_fg(format!("{} ↓", story.name)).build(ctx, "load", lctrl(Key::L)),
|
||||
if dirty {
|
||||
Btn::svg_def("system/assets/tools/save.svg").build(ctx, "save", lctrl(Key::S))
|
||||
|
@ -22,7 +22,7 @@ pub struct NewTrafficSignalEditor {
|
||||
side_panel: Composite,
|
||||
top_panel: Composite,
|
||||
|
||||
gameplay: GameplayMode,
|
||||
_gameplay: GameplayMode,
|
||||
members: BTreeSet<IntersectionID>,
|
||||
current_phase: usize,
|
||||
|
||||
@ -80,7 +80,7 @@ impl NewTrafficSignalEditor {
|
||||
let mut editor = NewTrafficSignalEditor {
|
||||
side_panel: make_side_panel(ctx, app, &members, 0),
|
||||
top_panel: make_top_panel(ctx, app, false, false),
|
||||
gameplay,
|
||||
_gameplay: gameplay,
|
||||
members,
|
||||
current_phase: 0,
|
||||
groups,
|
||||
@ -434,17 +434,7 @@ fn make_side_panel(
|
||||
// Use any member for phase duration
|
||||
let canonical_signal = map.get_traffic_signal(*members.iter().next().unwrap());
|
||||
for (idx, canonical_phase) in canonical_signal.phases.iter().enumerate() {
|
||||
// Separator
|
||||
col.push(
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
);
|
||||
col.push(Widget::horiz_separator(ctx, 0.2));
|
||||
|
||||
let unselected_btn = draw_multiple_signals(ctx, app, members, idx);
|
||||
let mut selected_btn = unselected_btn.clone();
|
||||
@ -508,17 +498,7 @@ fn make_side_panel(
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Widget::separator(ctx, pct_width)
|
||||
col.push(
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
);
|
||||
col.push(Widget::horiz_separator(ctx, 0.2));
|
||||
col.push(Btn::text_fg("Add new phase").build_def(ctx, None));
|
||||
|
||||
Composite::new(Widget::col(col))
|
||||
|
@ -874,17 +874,7 @@ fn make_signal_diagram(
|
||||
];
|
||||
|
||||
for (idx, phase) in signal.phases.iter().enumerate() {
|
||||
// Separator
|
||||
col.push(
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
);
|
||||
col.push(Widget::horiz_separator(ctx, 0.2));
|
||||
|
||||
let phase_btn = {
|
||||
let mut orig_batch = GeomBatch::new();
|
||||
@ -969,17 +959,7 @@ fn make_signal_diagram(
|
||||
}
|
||||
}
|
||||
|
||||
// Separator
|
||||
col.push(
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
);
|
||||
col.push(Widget::horiz_separator(ctx, 0.2));
|
||||
|
||||
col.push(Btn::text_fg("Add new phase").build_def(ctx, None));
|
||||
col.push(Widget::row(vec![
|
||||
|
@ -9,10 +9,10 @@ use crate::helpers::ID;
|
||||
use crate::sandbox::gameplay::{challenge_header, FinalScore, GameplayMode, GameplayState};
|
||||
use crate::sandbox::SandboxControls;
|
||||
use ezgui::{
|
||||
Btn, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
|
||||
RewriteColor, Text, TextExt, VerticalAlignment, Widget,
|
||||
Btn, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, RewriteColor,
|
||||
Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{Duration, Polygon, Time};
|
||||
use geom::{Duration, Time};
|
||||
use sim::{OrigPersonID, PersonID, TripID};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@ -243,15 +243,7 @@ fn make_meter(
|
||||
txt.append(Line(")"));
|
||||
|
||||
Composite::new(Widget::col(vec![
|
||||
// Separator
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
Widget::horiz_separator(ctx, 0.2),
|
||||
Widget::row(vec![
|
||||
Btn::svg_def("system/assets/tools/location.svg").build(ctx, "locate VIP", None),
|
||||
format!("{}/{} trips done", done, trips).draw_text(ctx),
|
||||
|
@ -8,10 +8,10 @@ use crate::helpers::ID;
|
||||
use crate::sandbox::gameplay::{challenge_header, FinalScore, GameplayMode, GameplayState};
|
||||
use crate::sandbox::{SandboxControls, SandboxMode};
|
||||
use ezgui::{
|
||||
Btn, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
|
||||
RewriteColor, Text, VerticalAlignment, Widget,
|
||||
Btn, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, RewriteColor,
|
||||
Text, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{Duration, Polygon, Time};
|
||||
use geom::{Duration, Time};
|
||||
use map_model::IntersectionID;
|
||||
|
||||
const THRESHOLD: Duration = Duration::const_seconds(20.0 * 60.0);
|
||||
@ -288,15 +288,7 @@ fn make_meter(
|
||||
worst: Option<(IntersectionID, Duration)>,
|
||||
) -> Composite {
|
||||
Composite::new(Widget::col(vec![
|
||||
// Separator
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
Widget::horiz_separator(ctx, 0.2),
|
||||
if let Some((_, delay)) = worst {
|
||||
Widget::row(vec![
|
||||
Text::from_all(vec![
|
||||
|
@ -8,8 +8,8 @@ use crate::sandbox::SandboxControls;
|
||||
use crate::sandbox::SandboxMode;
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Btn, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment,
|
||||
Key, Line, Outcome, ScreenRectangle, Spinner, Text, TextExt, VerticalAlignment, Widget,
|
||||
hotkey, lctrl, Btn, Choice, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
Outcome, ScreenRectangle, Spinner, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{Distance, Polygon};
|
||||
use map_model::{BuildingID, IntersectionID, Position, NORMAL_LANE_THICKNESS};
|
||||
@ -84,10 +84,7 @@ fn make_top_center(ctx: &mut EventCtx, app: &App) -> Composite {
|
||||
let rows = vec![
|
||||
Widget::row(vec![
|
||||
Line("Sandbox").small_heading().draw(ctx),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
"Map:".draw_text(ctx),
|
||||
Btn::text_fg(format!("{} ↓", nice_map_name(app.primary.map.get_name()))).build(
|
||||
ctx,
|
||||
|
@ -19,7 +19,7 @@ use abstutil::Timer;
|
||||
use ezgui::{
|
||||
lctrl, Btn, Color, Composite, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, TextExt, Widget,
|
||||
};
|
||||
use geom::{Duration, Polygon};
|
||||
use geom::Duration;
|
||||
use map_model::{EditCmd, EditIntersection, Map, MapEdits};
|
||||
use rand_xorshift::XorShiftRng;
|
||||
use sim::{Analytics, OrigPersonID, Scenario, ScenarioGenerator, ScenarioModifier};
|
||||
@ -284,10 +284,7 @@ fn challenge_header(ctx: &mut EventCtx, title: &str) -> Widget {
|
||||
Btn::svg_def("system/assets/tools/info.svg")
|
||||
.build(ctx, "instructions", None)
|
||||
.centered_vert(),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
Btn::svg_def("system/assets/tools/edit_map.svg")
|
||||
.build(ctx, "edit map", lctrl(Key::E))
|
||||
.centered_vert(),
|
||||
|
@ -7,10 +7,9 @@ use crate::sandbox::gameplay::freeform::make_change_traffic;
|
||||
use crate::sandbox::gameplay::{GameplayMode, GameplayState};
|
||||
use crate::sandbox::{SandboxControls, SandboxMode};
|
||||
use ezgui::{
|
||||
hotkey, lctrl, AreaSlider, Btn, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx,
|
||||
hotkey, lctrl, AreaSlider, Btn, Choice, Color, Composite, EventCtx, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, Outcome, Spinner, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::Polygon;
|
||||
use maplit::btreeset;
|
||||
use sim::{ScenarioModifier, TripMode};
|
||||
use std::collections::BTreeSet;
|
||||
@ -114,10 +113,7 @@ fn make_top_center(
|
||||
let rows = vec![
|
||||
Widget::row(vec![
|
||||
Line("Sandbox").small_heading().draw(ctx),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
"Map:".draw_text(ctx),
|
||||
Btn::text_fg(format!("{} ↓", nice_map_name(app.primary.map.get_name()))).build(
|
||||
ctx,
|
||||
|
@ -11,11 +11,10 @@ use crate::sandbox::{
|
||||
};
|
||||
use abstutil::Timer;
|
||||
use ezgui::{
|
||||
hotkey, hotkeys, lctrl, Btn, Color, Composite, EventCtx, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, Outcome, RewriteColor, ScreenPt, Text, TextExt,
|
||||
VerticalAlignment, Widget,
|
||||
hotkey, hotkeys, lctrl, Btn, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key,
|
||||
Line, Outcome, RewriteColor, ScreenPt, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{ArrowCap, Distance, Duration, PolyLine, Polygon, Pt2D, Time};
|
||||
use geom::{ArrowCap, Distance, Duration, PolyLine, Pt2D, Time};
|
||||
use map_model::raw::{OriginalBuilding, OriginalIntersection, OriginalRoad};
|
||||
use map_model::{osm, BuildingID, Map, OriginalLane, Position};
|
||||
use sim::{
|
||||
@ -724,10 +723,7 @@ impl TutorialState {
|
||||
fn make_top_center(&self, ctx: &mut EventCtx, edit_map: bool) -> Composite {
|
||||
let mut col = vec![Widget::row(vec![
|
||||
Line("Tutorial").small_heading().draw(ctx),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
if self.current.stage == 0 {
|
||||
Btn::text_fg("<").inactive(ctx)
|
||||
} else {
|
||||
|
@ -6,7 +6,7 @@ use ezgui::{
|
||||
hotkey, Btn, Color, Composite, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||
Line, Outcome, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{ArrowCap, Distance, Polygon, Time};
|
||||
use geom::{ArrowCap, Distance, Time};
|
||||
use map_model::{LaneID, TurnType};
|
||||
use sim::{AgentID, DontDrawAgents};
|
||||
|
||||
@ -168,10 +168,7 @@ impl TurnExplorer {
|
||||
.small_heading(),
|
||||
)
|
||||
.draw(ctx),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
if idx == 0 {
|
||||
Btn::text_fg("<").inactive(ctx)
|
||||
} else {
|
||||
|
@ -19,11 +19,11 @@ use crate::options::OptionsPanel;
|
||||
use crate::pregame::MainMenu;
|
||||
use crate::render::UnzoomedAgents;
|
||||
use ezgui::{
|
||||
hotkey, lctrl, Btn, Choice, Color, Composite, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment,
|
||||
Key, Line, Outcome, Text, TextExt, UpdateType, VerticalAlignment, Widget,
|
||||
hotkey, lctrl, Btn, Choice, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line,
|
||||
Outcome, Text, TextExt, UpdateType, VerticalAlignment, Widget,
|
||||
};
|
||||
pub use gameplay::{spawn_agents_around, GameplayMode, TutorialPointer, TutorialState};
|
||||
use geom::{Polygon, Time};
|
||||
use geom::Time;
|
||||
use map_model::MapEdits;
|
||||
use sim::AgentType;
|
||||
pub use speed::TimeWarpScreen;
|
||||
@ -325,15 +325,7 @@ impl AgentMeter {
|
||||
]),
|
||||
])
|
||||
.centered(),
|
||||
// Separator
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.centered_horiz(),
|
||||
Widget::horiz_separator(ctx, 0.2),
|
||||
Widget::row(vec![
|
||||
{
|
||||
let mut txt = Text::new();
|
||||
|
@ -397,14 +397,7 @@ impl JumpToTime {
|
||||
.build(ctx, "jump to time", hotkey(Key::Enter))
|
||||
.centered_horiz()
|
||||
.named("jump to time"),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
Color::WHITE,
|
||||
Polygon::rectangle(0.25 * ctx.canvas.window_width, 2.0),
|
||||
)]),
|
||||
)
|
||||
.margin_above(10),
|
||||
Widget::horiz_separator(ctx, 0.25).margin_above(10),
|
||||
Btn::text_bg2("Jump to the next delay over 5 minutes")
|
||||
.build_def(ctx, None)
|
||||
.centered_horiz(),
|
||||
|
@ -9,7 +9,7 @@ use ezgui::{
|
||||
hotkey, Btn, Checkbox, Color, Composite, Drawable, EventCtx, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Key, Line, Outcome, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{ArrowCap, Polygon};
|
||||
use geom::ArrowCap;
|
||||
use map_model::{IntersectionCluster, IntersectionID};
|
||||
use sim::DontDrawAgents;
|
||||
use std::collections::BTreeSet;
|
||||
@ -199,10 +199,7 @@ impl UberTurnViewer {
|
||||
composite: Composite::new(Widget::col(vec![
|
||||
Widget::row(vec![
|
||||
Line("Uber-turn viewer").small_heading().draw(ctx),
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(2.0, 50.0))]),
|
||||
),
|
||||
Widget::vert_separator(ctx, 50.0),
|
||||
if idx == 0 {
|
||||
Btn::text_fg("<").inactive(ctx)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user