From 87cc45752d235021da24a6ddd151b4a45f72b091 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Wed, 1 Apr 2020 17:18:29 -0700 Subject: [PATCH] better person headers --- ezgui/src/managed.rs | 8 ++++++++ game/src/info/person.rs | 35 +++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ezgui/src/managed.rs b/ezgui/src/managed.rs index a8f0a6ec35..d7af8c0ec2 100644 --- a/ezgui/src/managed.rs +++ b/ezgui/src/managed.rs @@ -114,6 +114,14 @@ impl Widget { self.layout.style.margin.bottom = Dimension::Points(pixels as f32); self } + pub fn margin_left(mut self, pixels: usize) -> Widget { + self.layout.style.margin.start = Dimension::Points(pixels as f32); + self + } + pub fn margin_right(mut self, pixels: usize) -> Widget { + self.layout.style.margin.end = Dimension::Points(pixels as f32); + self + } pub fn margin_horiz(mut self, pixels: usize) -> Widget { self.layout.style.margin.start = Dimension::Points(pixels as f32); self.layout.style.margin.end = Dimension::Points(pixels as f32); diff --git a/game/src/info/person.rs b/game/src/info/person.rs index 531efbb04f..b0285ebbaf 100644 --- a/game/src/info/person.rs +++ b/game/src/info/person.rs @@ -229,32 +229,47 @@ fn header( ) -> Vec { let mut rows = vec![]; - let (current_trip, descr) = match app.primary.sim.get_person(id).state { + let (current_trip, (descr, maybe_icon)) = match app.primary.sim.get_person(id).state { PersonState::Inside(b) => { building::draw_occupants(details, app, b, Some(id)); - (None, "inside") + ( + None, + ("inside", Some("../data/system/assets/tools/home.svg")), + ) } PersonState::Trip(t) => ( Some(t), match app.primary.sim.trip_to_agent(t).ok() { - Some(AgentID::Pedestrian(_)) => "on foot", + Some(AgentID::Pedestrian(_)) => ( + "walking", + Some("../data/system/assets/meters/pedestrian.svg"), + ), Some(AgentID::Car(c)) => match c.1 { - VehicleType::Car => "in a car", - VehicleType::Bike => "on a bike", + VehicleType::Car => ("driving", Some("../data/system/assets/meters/car.svg")), + VehicleType::Bike => ("biking", Some("../data/system/assets/meters/bike.svg")), VehicleType::Bus => unreachable!(), }, // TODO Really should clean up the TripModeChange issue - None => "...", + None => ("...", None), }, ), - PersonState::OffMap => (None, "off map"), - PersonState::Limbo => (None, "in limbo"), + PersonState::OffMap => (None, ("off map", None)), + PersonState::Limbo => (None, ("in limbo", None)), }; rows.push(Widget::row(vec![ - Line(format!("{} ({})", id, descr)) + Line(format!("{}", id)).small_heading().draw(ctx), + if let Some(icon) = maybe_icon { + Widget::draw_svg_transform(ctx, icon, RewriteColor::ChangeAll(Color::hex("#A3A3A3"))) + .margin_left(28) + } else { + Widget::nothing() + }, + Line(format!("{}", descr)) .small_heading() - .draw(ctx), + .fg(Color::hex("#A3A3A3")) + .draw(ctx) + .margin_horiz(10), Widget::row(vec![ // Little indirect, but the handler of this action is actually the ContextualActions // for SandboxMode.