diff --git a/game/assets/tools/layers.svg b/game/assets/tools/layers.svg
index 430ef750d5..49fcb73bb0 100644
--- a/game/assets/tools/layers.svg
+++ b/game/assets/tools/layers.svg
@@ -1,4 +1,3 @@
diff --git a/game/assets/tools/search.svg b/game/assets/tools/search.svg
index 5a80bfbcb5..db780e6739 100644
--- a/game/assets/tools/search.svg
+++ b/game/assets/tools/search.svg
@@ -1,4 +1,3 @@
diff --git a/game/assets/tools/shortcuts.svg b/game/assets/tools/shortcuts.svg
index c3a0ea0465..0d2a7a17b7 100644
--- a/game/assets/tools/shortcuts.svg
+++ b/game/assets/tools/shortcuts.svg
@@ -1,4 +1,3 @@
diff --git a/game/src/abtest/mod.rs b/game/src/abtest/mod.rs
index 51adb5fbe0..9dd7fc175c 100644
--- a/game/src/abtest/mod.rs
+++ b/game/src/abtest/mod.rs
@@ -1,6 +1,6 @@
pub mod setup;
-use crate::common::{AgentTools, CommonState};
+use crate::common::{AgentTools, CommonState, ToolPanel};
use crate::debug::DebugMode;
use crate::game::{State, Transition};
use crate::render::MIN_ZOOM_FOR_DETAIL;
@@ -45,7 +45,12 @@ impl ABTestMode {
secondary_agent_tools: AgentTools::new(),
diff_trip: None,
diff_all: None,
- common: CommonState::new(ctx, false),
+ // TODO Confirm before leaving state
+ common: CommonState::new(ToolPanel::new(
+ ctx,
+ Box::new(|_, _| Some(Transition::Pop)),
+ None,
+ )),
test_name: test_name.to_string(),
flipped: false,
}
@@ -169,10 +174,6 @@ impl State for ABTestMode {
if let Some(t) = self.common.event(ctx, ui) {
return t;
}
- // TODO Confirm first
- if self.common.tool_panel.home_btn.clicked() {
- return Transition::Pop;
- }
Transition::Keep
}
diff --git a/game/src/common/mod.rs b/game/src/common/mod.rs
index 4348eff8e2..25ef1a32c9 100644
--- a/game/src/common/mod.rs
+++ b/game/src/common/mod.rs
@@ -17,14 +17,13 @@ pub use self::colors::{
ColorLegend, ObjectColorer, ObjectColorerBuilder, RoadColorer, RoadColorerBuilder,
};
pub use self::minimap::Minimap;
-use self::panels::ToolPanel;
+pub use self::panels::ToolPanel;
pub use self::plot::{Histogram, Plot, Series};
pub use self::route_explorer::RouteExplorer;
pub use self::trip_explorer::TripExplorer;
pub use self::warp::Warping;
use crate::game::Transition;
use crate::helpers::ID;
-use crate::options;
use crate::render::DrawOptions;
use crate::ui::UI;
use ezgui::{
@@ -34,14 +33,16 @@ use std::collections::BTreeSet;
pub struct CommonState {
turn_cycler: turn_cycler::TurnCyclerState,
- pub tool_panel: ToolPanel,
+ tool_panel: ToolPanel,
}
impl CommonState {
- pub fn new(ctx: &EventCtx, with_layers: bool) -> CommonState {
+ // TODO Should CommonState even own the ToolPanel? Maybe each State just winds up with some
+ // generic onscreen Composite controls.
+ pub fn new(tool_panel: ToolPanel) -> CommonState {
CommonState {
turn_cycler: turn_cycler::TurnCyclerState::Inactive,
- tool_panel: ToolPanel::new(ctx, with_layers),
+ tool_panel,
}
}
@@ -70,17 +71,8 @@ impl CommonState {
}
}
- self.tool_panel.event(ctx);
- // Up to the caller to reach in and check if home_btn was clicked. Means different stuff in
- // some modes.
- if self.tool_panel.settings_btn.clicked() {
- return Some(Transition::Push(options::open_panel()));
- }
- if self.tool_panel.search_btn.clicked() {
- return Some(Transition::Push(Box::new(navigate::Navigator::new(ui))));
- }
- if self.tool_panel.shortcuts_btn.clicked() {
- return Some(Transition::Push(shortcuts::ChoosingShortcut::new()));
+ if let Some(t) = self.tool_panel.event(ctx, ui) {
+ return Some(t);
}
None
diff --git a/game/src/common/panels.rs b/game/src/common/panels.rs
index 69a3d77295..b56ac70ca6 100644
--- a/game/src/common/panels.rs
+++ b/game/src/common/panels.rs
@@ -1,121 +1,85 @@
-use ezgui::layout::Widget;
-use ezgui::{
- hotkey, layout, Button, Color, DrawBoth, EventCtx, GeomBatch, GfxCtx, JustDraw, Key,
- RewriteColor, ScreenDims, ScreenPt, ScreenRectangle,
-};
-use geom::{Distance, Polygon};
+use crate::common::{navigate, shortcuts};
+use crate::game::Transition;
+use crate::managed::{Callback, Composite, ManagedWidget};
+use crate::options;
+use crate::ui::UI;
+use ezgui::{hotkey, Button, Color, EventCtx, GfxCtx, Key, RewriteColor, ScreenPt};
+// TODO Why wrap at all?
pub struct ToolPanel {
- bg: JustDraw,
- rect: ScreenRectangle,
- pub home_btn: Button,
- pub settings_btn: Button,
- // TODO These three belong by the minimap, but doing the layout change if the minimap is there
- // or not is hard right now.
- pub search_btn: Button,
- pub shortcuts_btn: Button,
- pub layers_btn: Option