rename Ctx to DrawCtx

This commit is contained in:
Dustin Carlino 2019-02-09 11:50:39 -08:00
parent 72b044c64f
commit 21e869cb0e
46 changed files with 104 additions and 104 deletions

View File

@ -108,7 +108,7 @@ pub struct RenderingHints {
}
// For plugins and rendering. Not sure what module this should live in, here seems fine.
pub struct Ctx<'a> {
pub struct DrawCtx<'a> {
pub cs: &'a ColorScheme,
pub map: &'a Map,
pub draw_map: &'a DrawMap,

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use counter::Counter;
use ezgui::Color;
@ -33,7 +33,7 @@ impl Plugin for ChokepointsFinder {
true
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
let color = ctx.cs.get_def("chokepoint", Color::RED);
match obj {
ID::Lane(l) if self.lanes.contains(&l) => Some(color),

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::Color;
@ -22,7 +22,7 @@ impl Plugin for OsmClassifier {
true
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
match obj {
ID::Lane(l) => {
if ctx.map.get_l(l).is_driving() {

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, Key};
use map_model::LaneID;
@ -41,7 +41,7 @@ impl Plugin for ShowConnectedRoads {
}
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
if let ID::Lane(id) = obj {
if self.lanes.contains(&id) {
return Some(ctx.cs.get("something associated with something else"));

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, Key, Text};
use map_model::raw_data::StableRoadID;
@ -42,7 +42,7 @@ impl Plugin for DebugObjectsState {
}
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
if self.tooltip_key_held {
if let Some(id) = self.selected {
let txt = tooltip_lines(id, g, ctx);
@ -52,7 +52,7 @@ impl Plugin for DebugObjectsState {
}
}
fn tooltip_lines(obj: ID, g: &mut GfxCtx, ctx: &Ctx) -> Text {
fn tooltip_lines(obj: ID, g: &mut GfxCtx, ctx: &DrawCtx) -> Text {
let (map, sim, draw_map) = (&ctx.map, &ctx.sim, &ctx.draw_map);
let mut txt = Text::new();
match obj {

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use crate::render::calculate_corners;
use ezgui::{GfxCtx, Key, Text};
@ -97,7 +97,7 @@ impl Plugin for DebugPolygon {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
match self.items[self.current] {
Item::Point(pt) => {
g.draw_text_at(Text::from_line(format!("{}", self.current)), pt);

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, Key};
use map_model::{LaneID, Map};
@ -55,7 +55,7 @@ impl Plugin for Floodfiller {
true
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
if let ID::Lane(l) = obj {
if self.visited.contains(&l) {
return Some(ctx.cs.get_def("visited in floodfill", Color::BLUE));

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::PluginCtx;
use ezgui::{Color, GfxCtx, Key};
use geom::Distance;
@ -32,7 +32,7 @@ impl ShowOriginalRoads {
true
}
pub fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
pub fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
for id in &self.roads {
let r = ctx.map.get_r(*id);
// TODO Should be a less tedious way to do this

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, Key};
use geom::Distance;
@ -185,13 +185,13 @@ impl Plugin for SpawnAgent {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
if let Some((_, Some(ref trace))) = self.maybe_goal {
g.draw_polygon(ctx.cs.get("route"), &trace.make_polygons(LANE_THICKNESS));
}
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
match (&self.from, obj) {
(Source::Walking(ref b1), ID::Building(b2)) if *b1 == b2 => {
Some(ctx.cs.get("selected"))

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{choose_edits, choose_scenario, load_ab_test, Plugin, PluginCtx};
use crate::state::{Flags, PerMapUI, PluginsPerMap};
use ezgui::{GfxCtx, LogScroller, Prerender, Wizard, WrappedWizard};
@ -59,7 +59,7 @@ impl Plugin for ABTestManager {
true
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
match self {
ABTestManager::PickABTest(wizard) => {
wizard.draw(g);

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use ezgui::ScreenPt;
use ezgui::{Canvas, Color, GfxCtx, InputResult, ScrollingMenu};
@ -71,7 +71,7 @@ impl Plugin for ColorPicker {
true
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
match self {
ColorPicker::Choosing(menu) => {
menu.draw(g);

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{load_neighborhood_builder, Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, Key, Wizard, WrappedWizard};
use geom::{Circle, Distance, Line, Polygon, Pt2D};
@ -104,7 +104,7 @@ impl Plugin for DrawNeighborhoodState {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
let (raw_pts, current_idx) = match self {
DrawNeighborhoodState::PickNeighborhood(wizard) => {
// TODO is this order wrong?

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{choose_edits, Plugin, PluginCtx};
use crate::state::{Flags, PerMapUI, PluginsPerMap};
use ezgui::{GfxCtx, Prerender, Wizard, WrappedWizard};
@ -48,7 +48,7 @@ impl Plugin for EditsManager {
}
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
self.wizard.draw(g);
}
}

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{
choose_intersection, choose_neighborhood, choose_origin_destination, input_tick,
input_weighted_usize, load_scenario, Plugin, PluginCtx,
@ -70,7 +70,7 @@ impl Plugin for ScenarioManager {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
match self {
ScenarioManager::PickScenario(wizard) => {
wizard.draw(g);

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, Key};
use map_model::{ControlStopSign, IntersectionID, TurnPriority};
@ -65,7 +65,7 @@ impl Plugin for StopSignEditor {
true
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
if let ID::Turn(t) = obj {
if t.parent != self.i {
return None;

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use crate::render::{draw_signal_cycle, draw_signal_diagram, DrawTurn};
use ezgui::{Color, GfxCtx, Key, ScreenPt, Wizard, WrappedWizard};
@ -216,7 +216,7 @@ impl Plugin for TrafficSignalEditor {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
let cycles = &ctx.map.get_traffic_signal(self.i).cycles;
draw_signal_cycle(&cycles[self.current_cycle], g, ctx);
@ -246,7 +246,7 @@ impl Plugin for TrafficSignalEditor {
}
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
if let ID::Turn(t) = obj {
if t.parent != self.i {
return None;

View File

@ -4,7 +4,7 @@ pub mod sim;
pub mod view;
use crate::colors::ColorScheme;
use crate::objects::{Ctx, RenderingHints, ID};
use crate::objects::{DrawCtx, RenderingHints, ID};
use crate::state::{PerMapUI, PluginsPerMap};
use ::sim::{ABTest, OriginDestination, Scenario, Tick};
use abstutil;
@ -16,11 +16,11 @@ use ezgui::{Canvas, Color, GfxCtx, Prerender, UserInput, WrappedWizard};
use map_model::{IntersectionID, Map, Neighborhood, NeighborhoodBuilder};
pub trait Plugin: Any {
fn color_for(&self, _obj: ID, _ctx: &Ctx) -> Option<Color> {
fn color_for(&self, _obj: ID, _ctx: &DrawCtx) -> Option<Color> {
None
}
fn draw(&self, _g: &mut GfxCtx, _ctx: &Ctx) {}
fn draw(&self, _g: &mut GfxCtx, _ctx: &DrawCtx) {}
// True if active, false if done
fn blocking_event(&mut self, _ctx: &mut PluginCtx) -> bool {

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use ezgui::{GfxCtx, Text};
use geom::{Acceleration, Distance, Duration, Speed};
use map_model::{Lane, LaneID, Map, Traversable};
@ -87,7 +87,7 @@ impl World {
draw
}
pub fn draw_tooltips(&self, g: &mut GfxCtx, ctx: &Ctx, time: Duration) {
pub fn draw_tooltips(&self, g: &mut GfxCtx, ctx: &DrawCtx, time: Duration) {
let lane = ctx.map.get_l(LaneID(1250));
for car in vec![&self.leader, &self.follower] {

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use ezgui::GfxCtx;
use geom::Line;
@ -43,7 +43,7 @@ impl Plugin for DiffAllState {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
for line in &self.lines {
g.draw_line(ctx.cs.get("diff agents line"), LANE_THICKNESS, line);
}

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, Key};
use geom::Line;
@ -46,7 +46,7 @@ impl Plugin for DiffTripState {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
if let Some(l) = &self.line {
g.draw_line(
ctx.cs.get_def("diff agents line", Color::YELLOW),

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, HorizontalAlignment, Text, VerticalAlignment};
use sim::{ScoreSummary, Tick};
@ -28,7 +28,7 @@ impl Plugin for ShowScoreState {
true
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
g.draw_blocking_text(
self.txt.clone(),
(HorizontalAlignment::Right, VerticalAlignment::BelowTopMenu),

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::sim::des_model;
use crate::plugins::PluginCtx;
use ezgui::{EventLoopMode, GfxCtx};
@ -87,7 +87,7 @@ impl SimpleModelController {
}
}
pub fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
pub fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
if self.show_tooltips {
self.world.as_ref().unwrap().draw_tooltips(
g,

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use crate::render::DrawTurn;
use ezgui::{Canvas, GfxCtx, ScreenPt, Text, UserInput};
@ -41,7 +41,7 @@ impl Plugin for Legend {
true
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
let zoom = 10.0;
g.fork(Pt2D::new(0.0, 0.0), self.top_left, zoom);

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use abstutil::format_log_record;
use ezgui::{GfxCtx, LogScroller};
@ -39,7 +39,7 @@ impl Plugin for DisplayLogs {
true
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
LOGGER.lock().unwrap().draw(g);
}
}

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use crate::render::DrawMap;
use abstutil;
@ -56,7 +56,7 @@ impl Plugin for NeighborhoodSummary {
}
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
if !self.active {
return;
}

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, InputResult, TextBox};
@ -53,13 +53,13 @@ impl Plugin for SearchState {
true
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
if let SearchState::EnteringSearch(tb) = self {
tb.draw(g);
}
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
if let SearchState::FilterOSM(filter) = self {
let osm_tags = match obj {
ID::Lane(l) => &ctx.map.get_parent(l).osm_tags,

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx};
use geom::{Bounds, Polygon, Pt2D};
@ -39,7 +39,7 @@ impl Plugin for ShowActivityState {
}
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
if let ShowActivityState::Active(_, ref heatmap) = self {
heatmap.draw(g);
}

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use crate::render::ExtraShapeID;
use ezgui::Color;
@ -76,7 +76,7 @@ impl Plugin for ShowAssociatedState {
}
}
fn color_for(&self, obj: ID, ctx: &Ctx) -> Option<Color> {
fn color_for(&self, obj: ID, ctx: &DrawCtx) -> Option<Color> {
let color = ctx
.cs
.get_def("something associated with something else", Color::PURPLE);

View File

@ -1,4 +1,4 @@
use crate::objects::Ctx;
use crate::objects::DrawCtx;
use crate::plugins::{Plugin, PluginCtx};
use ezgui::{Color, GfxCtx, Key};
use map_model::{Trace, LANE_THICKNESS};
@ -60,7 +60,7 @@ impl Plugin for ShowRouteState {
};
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
match self {
ShowRouteState::Active(_, _, Some(ref trace)) => {
g.draw_polygon(

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use crate::render::{draw_signal_diagram, DrawTurn};
use ezgui::{Color, GfxCtx, Key};
@ -75,7 +75,7 @@ impl Plugin for TurnCyclerState {
}
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
match self.state {
State::Inactive => {}
State::ShowLane(l) => {
@ -112,7 +112,7 @@ impl Plugin for TurnCyclerState {
}
}
fn color_turn_type(t: TurnType, ctx: &Ctx) -> Color {
fn color_turn_type(t: TurnType, ctx: &DrawCtx) -> Color {
match t {
TurnType::SharedSidewalkCorner => {
ctx.cs.get_def("shared sidewalk corner turn", Color::BLACK)

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::plugins::{Plugin, PluginCtx};
use crate::render::DrawMap;
use abstutil::elapsed_seconds;
@ -72,7 +72,7 @@ impl Plugin for WarpState {
true
}
fn draw(&self, g: &mut GfxCtx, _ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, _ctx: &DrawCtx) {
if let WarpState::EnteringSearch(tb) = self {
tb.draw(g);
}

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, GfxCtx};
use geom::{Bounds, Polygon, Pt2D};
@ -26,7 +26,7 @@ impl Renderable for DrawArea {
ID::Area(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
let color = match self.area_type {
AreaType::Park => ctx.cs.get_def("park area", Color::GREEN),
AreaType::Swamp => ctx.cs.get_def("swamp area", Color::rgb_f(0.0, 1.0, 0.6)),

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, Distance, Polygon, Pt2D};
@ -49,7 +49,7 @@ impl Renderable for DrawBike {
ID::Car(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color {
g.draw_polygon(color, &self.polygon);
} else {

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, Distance, Line, Polygon, Pt2D};
@ -51,7 +51,7 @@ impl Renderable for DrawBuilding {
ID::Building(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
// Buildings look better without boundaries, actually
//g.draw_polygon(ctx.cs.get_def("building boundary", Color::rgb(0, 100, 0)), &self.boundary_polygon);

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, GfxCtx};
use geom::{Bounds, Distance, PolyLine, Polygon, Pt2D};
@ -41,7 +41,7 @@ impl Renderable for DrawBusStop {
ID::BusStop(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
g.draw_polygon(
opts.color.unwrap_or_else(|| {
ctx.cs

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Angle, Bounds, Circle, Distance, PolyLine, Polygon, Pt2D};
@ -148,7 +148,7 @@ impl Renderable for DrawCar {
ID::Car(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color {
let mut draw = vec![(color, &self.body_polygon)];
for p in &self.window_polygons {

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable, EXTRA_SHAPE_POINT_RADIUS, EXTRA_SHAPE_THICKNESS};
use ezgui::{Color, GfxCtx};
use geom::{Bounds, Circle, Distance, GPSBounds, PolyLine, Polygon, Pt2D};
@ -81,7 +81,7 @@ impl Renderable for DrawExtraShape {
ID::ExtraShape(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
let color = opts
.color
.unwrap_or_else(|| ctx.cs.get_def("extra shape", Color::CYAN));

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{DrawCrosswalk, DrawTurn, RenderOptions, Renderable, MIN_ZOOM_FOR_MARKINGS};
use ezgui::{Color, Drawable, GfxCtx, Prerender, ScreenPt, Text};
use geom::{Bounds, Circle, Distance, Duration, Line, Polygon, Pt2D};
@ -57,7 +57,7 @@ impl DrawIntersection {
}
}
fn draw_traffic_signal(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw_traffic_signal(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
let signal = ctx.map.get_traffic_signal(self.id);
if !ctx.sim.is_in_overtime(self.id) {
let (cycle, _) = signal.current_cycle_and_remaining_time(ctx.sim.time.as_time());
@ -71,7 +71,7 @@ impl Renderable for DrawIntersection {
ID::Intersection(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color {
// Don't draw the sidewalk corners
g.draw_polygon(color, &self.polygon);
@ -170,7 +170,7 @@ pub fn calculate_corners(i: &Intersection, map: &Map) -> Vec<Polygon> {
corners
}
pub fn draw_signal_cycle(cycle: &Cycle, g: &mut GfxCtx, ctx: &Ctx) {
pub fn draw_signal_cycle(cycle: &Cycle, g: &mut GfxCtx, ctx: &DrawCtx) {
if false {
draw_signal_cycle_with_icons(cycle, g, ctx);
return;
@ -203,7 +203,7 @@ pub fn draw_signal_cycle(cycle: &Cycle, g: &mut GfxCtx, ctx: &Ctx) {
}
}
fn draw_signal_cycle_with_icons(cycle: &Cycle, g: &mut GfxCtx, ctx: &Ctx) {
fn draw_signal_cycle_with_icons(cycle: &Cycle, g: &mut GfxCtx, ctx: &DrawCtx) {
for l in &ctx.map.get_i(cycle.parent).incoming_lanes {
let lane = ctx.map.get_l(*l);
// TODO Show a hand or a walking sign for crosswalks
@ -280,7 +280,7 @@ pub fn draw_signal_diagram(
time_left: Option<Duration>,
y1_screen: f64,
g: &mut GfxCtx,
ctx: &Ctx,
ctx: &DrawCtx,
) {
let padding = 5.0;
let zoom = 10.0;

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{
RenderOptions, Renderable, BIG_ARROW_THICKNESS, MIN_ZOOM_FOR_MARKINGS,
PARCEL_BOUNDARY_THICKNESS,
@ -70,7 +70,7 @@ impl DrawLane {
}
}
fn draw_debug(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw_debug(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
let circle_color = ctx
.cs
.get_def("debug line endpoint", Color::rgb_f(0.8, 0.1, 0.1));
@ -92,7 +92,7 @@ impl Renderable for DrawLane {
ID::Lane(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color {
g.draw_polygon(color, &self.polygon);
} else {

View File

@ -12,7 +12,7 @@ mod pedestrian;
mod turn;
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
pub use crate::render::area::DrawArea;
use crate::render::bike::DrawBike;
use crate::render::car::DrawCar;
@ -44,7 +44,7 @@ pub const MIN_ZOOM_FOR_MARKINGS: f64 = 5.0;
// here. For example, trips aren't drawn, so it's meaningless to ask what their bounding box is.
pub trait Renderable {
fn get_id(&self) -> ID;
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx);
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx);
fn get_bounds(&self) -> Bounds;
fn contains_pt(&self, pt: Pt2D) -> bool;
// Higher z-ordered objects are drawn later

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable, PARCEL_BOUNDARY_THICKNESS};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, PolyLine, Polygon, Pt2D};
@ -59,7 +59,7 @@ impl Renderable for DrawParcel {
ID::Parcel(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color {
g.draw_polygon_batch(vec![
(color, &self.fill_polygon),

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, Circle, Distance, Line, Pt2D};
@ -61,7 +61,7 @@ impl Renderable for DrawPedestrian {
ID::Pedestrian(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
if let Some(color) = opts.color {
g.draw_circle(color, &self.circle);
} else {

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, ID};
use crate::objects::{DrawCtx, ID};
use crate::render::{
RenderOptions, Renderable, BIG_ARROW_THICKNESS, CROSSWALK_LINE_THICKNESS,
TURN_ICON_ARROW_LENGTH, TURN_ICON_ARROW_THICKNESS,
@ -74,7 +74,7 @@ impl Renderable for DrawTurn {
ID::Turn(self.id)
}
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
// Some plugins hide icons entirely.
if ctx.hints.hide_turn_icons.contains(&self.id) {
return;

View File

@ -1,5 +1,5 @@
use crate::colors::ColorScheme;
use crate::objects::{Ctx, RenderingHints, ID};
use crate::objects::{DrawCtx, RenderingHints, ID};
use crate::plugins;
use crate::plugins::{debug, edit, view, Plugin, PluginCtx};
use crate::render::DrawMap;
@ -35,7 +35,7 @@ pub trait UIState {
hints: &mut RenderingHints,
recalculate_current_selection: &mut bool,
);
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx);
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx);
}
pub struct DefaultUIState {
@ -94,7 +94,7 @@ impl DefaultUIState {
state
}
pub fn color_obj(&self, id: ID, ctx: &Ctx) -> Option<Color> {
pub fn color_obj(&self, id: ID, ctx: &DrawCtx) -> Option<Color> {
match id {
ID::Turn(_) => {}
_ => {
@ -392,7 +392,7 @@ impl UIState for DefaultUIState {
}
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
if let Some(ref plugin) = self.primary_plugins.search {
plugin.draw(g, ctx);
if plugin.is_blocking() {

View File

@ -1,4 +1,4 @@
use crate::objects::{Ctx, RenderingHints};
use crate::objects::{DrawCtx, RenderingHints};
use crate::plugins::view::legend::Legend;
use crate::state::{DefaultUIState, Flags, PerMapUI, UIState};
use ezgui::{Canvas, EventCtx, GfxCtx, LogScroller, Prerender, Text};
@ -93,7 +93,7 @@ impl UIState for TutorialState {
}
}
fn draw(&self, g: &mut GfxCtx, ctx: &Ctx) {
fn draw(&self, g: &mut GfxCtx, ctx: &DrawCtx) {
match self.state {
State::GiveInstructions(ref scroller) => {
scroller.draw(g);

View File

@ -1,6 +1,6 @@
use abstutil;
//use cpuprofiler;
use crate::objects::{Ctx, RenderingHints, ID};
use crate::objects::{DrawCtx, RenderingHints, ID};
use crate::render::{draw_vehicle, AgentCache, DrawPedestrian, RenderOptions, Renderable};
use crate::state::UIState;
use ezgui::{
@ -260,7 +260,7 @@ impl<S: UIState> GUI<RenderingHints> for UI<S> {
let objects =
self.get_renderables_back_to_front(g.get_screen_bounds(), &g.prerender, &mut cache);
let ctx = Ctx {
let ctx = DrawCtx {
cs: &state.cs,
map: &state.primary.map,
draw_map: &state.primary.draw_map,