diff --git a/rustdoc/ltn/rat_run_viewer/struct.BrowseRatRuns.html b/rustdoc/ltn/rat_run_viewer/struct.BrowseRatRuns.html index 20c7954857..6412bb92a6 100644 --- a/rustdoc/ltn/rat_run_viewer/struct.BrowseRatRuns.html +++ b/rustdoc/ltn/rat_run_viewer/struct.BrowseRatRuns.html @@ -1,15 +1,15 @@ BrowseRatRuns in ltn::rat_run_viewer - Rust

Struct ltn::rat_run_viewer::BrowseRatRuns[][src]

pub struct BrowseRatRuns {
+        

Struct BrowseRatRuns

Struct ltn::rat_run_viewer::BrowseRatRuns[][src]

pub struct BrowseRatRuns {
     panel: Panel,
     rat_runs: RatRuns,
-    current_idx: usize,
+    current_idx: Option<usize>,
     draw_path: ToggleZoomed,
     draw_heatmap: ToggleZoomed,
     world: World<FilterableObj>,
     neighborhood: Neighborhood,
-}

Fields

panel: Panelrat_runs: RatRunscurrent_idx: usizedraw_path: ToggleZoomeddraw_heatmap: ToggleZoomedworld: World<FilterableObj>neighborhood: Neighborhood

Implementations

Trait Implementations

Respond to a UI event, such as input or time passing.

-

Draw

+}

Fields

panel: Panelrat_runs: RatRunscurrent_idx: Option<usize>draw_path: ToggleZoomeddraw_heatmap: ToggleZoomedworld: World<FilterableObj>neighborhood: Neighborhood

Implementations

Trait Implementations

Respond to a UI event, such as input or time passing.

+

Draw

Specifies what to draw before draw()

Before this state is popped or replaced, call this.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

diff --git a/rustdoc/map_gui/tools/title_screen/built_info/constant.BUILT_TIME_UTC.html b/rustdoc/map_gui/tools/title_screen/built_info/constant.BUILT_TIME_UTC.html index 9049df2754..16affe1e90 100644 --- a/rustdoc/map_gui/tools/title_screen/built_info/constant.BUILT_TIME_UTC.html +++ b/rustdoc/map_gui/tools/title_screen/built_info/constant.BUILT_TIME_UTC.html @@ -1,5 +1,5 @@ BUILT_TIME_UTC in map_gui::tools::title_screen::built_info - Rust

Constant map_gui::tools::title_screen::built_info::BUILT_TIME_UTC[][src]

pub const BUILT_TIME_UTC: &str = r"Fri, 04 Mar 2022 09:49:57 +0000";
Expand description

The build time in RFC2822, UTC.

+

Constant map_gui::tools::title_screen::built_info::BUILT_TIME_UTC[][src]

pub const BUILT_TIME_UTC: &str = r"Fri, 04 Mar 2022 13:52:24 +0000";
Expand description

The build time in RFC2822, UTC.

\ No newline at end of file diff --git a/rustdoc/src/ltn/rat_run_viewer.rs.html b/rustdoc/src/ltn/rat_run_viewer.rs.html index 2ab253adbb..062aace2c8 100644 --- a/rustdoc/src/ltn/rat_run_viewer.rs.html +++ b/rustdoc/src/ltn/rat_run_viewer.rs.html @@ -275,8 +275,7 @@ 273 274 275 -
use geom::ArrowCap;
-use map_gui::tools::{percentage_bar, ColorNetwork};
+
use map_gui::tools::{percentage_bar, ColorNetwork};
 use map_model::{PathRequest, NORMAL_LANE_THICKNESS};
 use widgetry::mapspace::{ToggleZoomed, World};
 use widgetry::{
@@ -290,7 +289,8 @@
 pub struct BrowseRatRuns {
     panel: Panel,
     rat_runs: RatRuns,
-    current_idx: usize,
+    // When None, show the heatmap of all rat runs
+    current_idx: Option<usize>,
 
     draw_path: ToggleZoomed,
     draw_heatmap: ToggleZoomed,
@@ -322,13 +322,12 @@
         let mut state = BrowseRatRuns {
             panel: Panel::empty(ctx),
             rat_runs,
-            current_idx: 0,
+            current_idx: None,
             draw_path: ToggleZoomed::empty(ctx),
             draw_heatmap: colorer.build(ctx),
             neighborhood,
             world,
         };
-        state.recalculate(ctx, app);
 
         if let Some(req) = start_with_request {
             if let Some(idx) = state
@@ -337,15 +336,12 @@
                 .iter()
                 .position(|path| path.get_req() == &req)
             {
-                state.current_idx = idx;
-                state
-                    .panel
-                    .set_checked("show heatmap of all rat-runs", false);
-                // We need to call recalculate twice -- we can't set the checkbox otherwise.
-                state.recalculate(ctx, app);
+                state.current_idx = Some(idx);
             }
         }
 
+        state.recalculate(ctx, app);
+
         Box::new(state)
     }
 
@@ -376,39 +372,6 @@
                 ctx,
                 app,
                 Widget::col(vec![
-                    Widget::row(vec![
-                        "Rat runs:".text_widget(ctx).centered_vert(),
-                        ctx.style()
-                            .btn_prev()
-                            .disabled(self.current_idx == 0)
-                            .hotkey(Key::LeftArrow)
-                            .build_widget(ctx, "previous rat run"),
-                        Text::from(
-                            Line(format!(
-                                "{}/{}",
-                                self.current_idx + 1,
-                                self.rat_runs.paths.len()
-                            ))
-                            .secondary(),
-                        )
-                        .into_widget(ctx)
-                        .centered_vert(),
-                        ctx.style()
-                            .btn_next()
-                            .disabled(self.current_idx == self.rat_runs.paths.len() - 1)
-                            .hotkey(Key::RightArrow)
-                            .build_widget(ctx, "next rat run"),
-                    ]),
-                    // TODO This should disable the individual path controls, or maybe even be a different
-                    // state entirely...
-                    Toggle::checkbox(
-                        ctx,
-                        "show heatmap of all rat-runs",
-                        Key::R,
-                        self.panel
-                            .maybe_is_checked("show heatmap of all rat-runs")
-                            .unwrap_or(true),
-                    ),
                     percentage_bar(
                         ctx,
                         Text::from(Line(format!(
@@ -417,14 +380,49 @@
                         ))),
                         (quiet_streets as f64) / (total_streets as f64),
                     ),
+                    Widget::row(vec![
+                        "Show rat-runs".text_widget(ctx).centered_vert(),
+                        Toggle::choice(
+                            ctx,
+                            "show rat-runs",
+                            "all (heatmap)",
+                            "individually",
+                            Key::R,
+                            self.current_idx.is_none(),
+                        ),
+                    ]),
+                    if let Some(idx) = self.current_idx {
+                        Widget::row(vec![
+                            ctx.style()
+                                .btn_prev()
+                                .disabled(idx == 0)
+                                .hotkey(Key::LeftArrow)
+                                .build_widget(ctx, "previous rat run"),
+                            Text::from(
+                                Line(format!("{}/{}", idx + 1, self.rat_runs.paths.len()))
+                                    .secondary(),
+                            )
+                            .into_widget(ctx)
+                            .centered_vert(),
+                            ctx.style()
+                                .btn_next()
+                                .disabled(idx == self.rat_runs.paths.len() - 1)
+                                .hotkey(Key::RightArrow)
+                                .build_widget(ctx, "next rat run"),
+                        ])
+                    } else {
+                        Widget::nothing()
+                    },
                 ]),
             )
             .build(ctx);
 
         let mut draw_path = ToggleZoomed::builder();
-        let color = Color::RED;
-        let path = &self.rat_runs.paths[self.current_idx];
-        if let Some(pl) = path.trace(&app.map) {
+        if let Some(pl) = self
+            .current_idx
+            .and_then(|idx| self.rat_runs.paths[idx].trace(&app.map))
+        {
+            let color = Color::RED;
             let shape = pl.make_polygons(3.0 * NORMAL_LANE_THICKNESS);
             draw_path.unzoomed.push(color.alpha(0.8), shape.clone());
             draw_path.zoomed.push(color.alpha(0.5), shape);
@@ -449,18 +447,18 @@
 
 impl State<App> for BrowseRatRuns {
     fn event(&mut self, ctx: &mut EventCtx, app: &mut App) -> Transition {
-        if let Outcome::Clicked(x) = self.panel.event(ctx) {
-            match x.as_ref() {
+        match self.panel.event(ctx) {
+            Outcome::Clicked(x) => match x.as_ref() {
                 "previous rat run" => {
-                    self.current_idx -= 1;
-                    self.panel
-                        .set_checked("show heatmap of all rat-runs", false);
+                    for idx in &mut self.current_idx {
+                        *idx -= 1;
+                    }
                     self.recalculate(ctx, app);
                 }
                 "next rat run" => {
-                    self.current_idx += 1;
-                    self.panel
-                        .set_checked("show heatmap of all rat-runs", false);
+                    for idx in &mut self.current_idx {
+                        *idx += 1;
+                    }
                     self.recalculate(ctx, app);
                 }
                 x => {
@@ -468,7 +466,16 @@
                         .handle_action(ctx, app, x, self.neighborhood.id)
                         .unwrap();
                 }
+            },
+            Outcome::Changed(_) => {
+                if self.panel.is_checked("show rat-runs") {
+                    self.current_idx = None;
+                } else {
+                    self.current_idx = Some(0);
+                }
+                self.recalculate(ctx, app);
             }
+            _ => {}
         }
 
         // TODO Bit weird to allow this while showing individual paths, since we don't draw the
@@ -476,12 +483,9 @@
         let world_outcome = self.world.event(ctx);
         if crate::per_neighborhood::handle_world_outcome(ctx, app, world_outcome) {
             // Reset state, but if possible, preserve the current individual rat run.
-            let current_request = if self.current_idx == 0 {
-                None
-            } else {
-                // TODO Off-by-one? Or we just have no way to show the 0th path?
-                Some(self.rat_runs.paths[self.current_idx].get_req().clone())
-            };
+            let current_request = self
+                .current_idx
+                .map(|idx| self.rat_runs.paths[idx].get_req().clone());
             return Transition::Replace(BrowseRatRuns::new_state(
                 ctx,
                 app,
@@ -496,15 +500,11 @@
     fn draw(&self, g: &mut GfxCtx, app: &App) {
         self.panel.draw(g);
 
-        if self
-            .panel
-            .maybe_is_checked("show heatmap of all rat-runs")
-            .unwrap_or(false)
-        {
+        if self.current_idx.is_some() {
+            self.draw_path.draw(g);
+        } else {
             self.draw_heatmap.draw(g);
             self.world.draw(g);
-        } else {
-            self.draw_path.draw(g);
         }
 
         g.redraw(&self.neighborhood.fade_irrelevant);
diff --git a/rustdoc/src/map_gui/home/runner/work/abstreet/abstreet/target/debug/build/map_gui-49fc0ec202264eb2/out/built.rs.html b/rustdoc/src/map_gui/home/runner/work/abstreet/abstreet/target/debug/build/map_gui-49fc0ec202264eb2/out/built.rs.html
index fdeda8683c..0dbe6ff755 100644
--- a/rustdoc/src/map_gui/home/runner/work/abstreet/abstreet/target/debug/build/map_gui-49fc0ec202264eb2/out/built.rs.html
+++ b/rustdoc/src/map_gui/home/runner/work/abstreet/abstreet/target/debug/build/map_gui-49fc0ec202264eb2/out/built.rs.html
@@ -176,7 +176,7 @@
 pub const RUSTDOC_VERSION: &str = r"rustdoc 1.59.0 (9d1b2106e 2022-02-23)";
 #[doc=r#"The build time in RFC2822, UTC."#]
 #[allow(dead_code)]
-pub const BUILT_TIME_UTC: &str = r"Fri, 04 Mar 2022 09:49:57 +0000";
+pub const BUILT_TIME_UTC: &str = r"Fri, 04 Mar 2022 13:52:24 +0000";
 #[doc=r#"The target architecture, given by `CARGO_CFG_TARGET_ARCH`."#]
 #[allow(dead_code)]
 pub const CFG_TARGET_ARCH: &str = r"x86_64";