diff --git a/game/src/challenges/mod.rs b/game/src/challenges/mod.rs index fc38a34fe4..914933003f 100644 --- a/game/src/challenges/mod.rs +++ b/game/src/challenges/mod.rs @@ -143,8 +143,9 @@ impl ChallengesPicker { ]) .draw(ctx) .centered_horiz(), - Btn::text_bg2("Introduction and tutorial") - .build_def(ctx, None) + ctx.style() + .btn_primary_dark_text("Introduction and tutorial") + .build_def(ctx) .centered_horiz() .bg(app.cs.panel_bg) .padding(16) @@ -159,7 +160,12 @@ impl ChallengesPicker { .map(|(n, _)| n == &name) .unwrap_or(false) { - flex_row.push(Btn::text_bg2(&name).inactive(ctx)); + flex_row.push( + ctx.style() + .btn_primary_dark_text(&name) + .disabled() + .build_def(ctx), + ); } else { flex_row.push( ctx.style() diff --git a/game/src/edit/mod.rs b/game/src/edit/mod.rs index 8b33730002..4c4a2d603f 100644 --- a/game/src/edit/mod.rs +++ b/game/src/edit/mod.rs @@ -437,15 +437,27 @@ impl SaveEdits { fn recalc_btn(&mut self, ctx: &mut EventCtx, app: &App) { if self.current_name.is_empty() { - self.panel - .replace(ctx, "Save", Btn::text_bg2("Save").inactive(ctx)); + self.panel.replace( + ctx, + "Save", + ctx.style() + .btn_primary_dark_text("Save") + .disabled() + .build_def(ctx), + ); self.panel.replace(ctx, "warning", Text::new().draw(ctx)); } else if abstio::file_exists(abstio::path_edits( app.primary.map.get_name(), &self.current_name, )) { - self.panel - .replace(ctx, "Save", Btn::text_bg2("Save").inactive(ctx)); + self.panel.replace( + ctx, + "Save", + ctx.style() + .btn_primary_dark_text("Save") + .disabled() + .build_def(ctx), + ); self.panel.replace( ctx, "warning", @@ -633,16 +645,18 @@ fn make_topcenter(ctx: &mut EventCtx, app: &App) -> Panel { .small_heading() .draw(ctx) .centered_horiz(), - Btn::text_bg2(format!( - "Finish & resume from {}", - app.primary - .suspended_sim - .as_ref() - .unwrap() - .time() - .ampm_tostring() - )) - .build(ctx, "finish editing", Key::Escape), + ctx.style() + .btn_primary_dark_text(&format!( + "Finish & resume from {}", + app.primary + .suspended_sim + .as_ref() + .unwrap() + .time() + .ampm_tostring() + )) + .hotkey(Key::Escape) + .build_widget(ctx, "finish editing"), ])) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .build(ctx) diff --git a/game/src/edit/traffic_signals/mod.rs b/game/src/edit/traffic_signals/mod.rs index 3c60dac20a..9399eeb33c 100644 --- a/game/src/edit/traffic_signals/mod.rs +++ b/game/src/edit/traffic_signals/mod.rs @@ -498,7 +498,10 @@ fn make_top_panel(ctx: &mut EventCtx, app: &App, can_undo: bool, can_redo: bool) .btn_primary_dark_text("Finish") .hotkey(Key::Enter) .build_def(ctx), - Btn::text_bg2("Preview").build_def(ctx, lctrl(Key::P)), + ctx.style() + .btn_primary_dark_text("Preview") + .hotkey(lctrl(Key::P)) + .build_def(ctx), (if can_undo { ctx.style() .btn_plain_light_icon("system/assets/tools/undo.svg") @@ -703,8 +706,9 @@ fn make_side_panel( } col.push( - Btn::text_bg2("Add a new stage") - .build_def(ctx, None) + ctx.style() + .btn_primary_dark_text("Add a new stage") + .build_def(ctx) .centered_horiz(), ); diff --git a/game/src/edit/traffic_signals/picker.rs b/game/src/edit/traffic_signals/picker.rs index 5c458376e3..21a6a7aabd 100644 --- a/game/src/edit/traffic_signals/picker.rs +++ b/game/src/edit/traffic_signals/picker.rs @@ -3,8 +3,8 @@ use std::collections::BTreeSet; use map_gui::ID; use map_model::IntersectionID; use widgetry::{ - hotkeys, Btn, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, - Panel, State, StyledButtons, VerticalAlignment, Widget, + hotkeys, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, + State, StyledButtons, VerticalAlignment, Widget, }; use crate::app::App; @@ -108,7 +108,12 @@ impl State for SignalPicker { fn make_btn(ctx: &mut EventCtx, num: usize) -> Widget { if num == 0 { - return Btn::text_bg2("Edit 0 signals").inactive(ctx).named("edit"); + return ctx + .style() + .btn_primary_dark_text("Edit 0 signals") + .disabled() + .build_def(ctx) + .named("edit"); } let title = if num == 1 { @@ -116,5 +121,8 @@ fn make_btn(ctx: &mut EventCtx, num: usize) -> Widget { } else { format!("Edit {} signals", num) }; - Btn::text_bg2(title).build(ctx, "edit", hotkeys(vec![Key::Enter, Key::E])) + ctx.style() + .btn_primary_dark_text(&title) + .hotkey(hotkeys(vec![Key::Enter, Key::E])) + .build_widget(ctx, "edit") } diff --git a/game/src/info/mod.rs b/game/src/info/mod.rs index 660c789504..ce02d2a727 100644 --- a/game/src/info/mod.rs +++ b/game/src/info/mod.rs @@ -12,7 +12,7 @@ use sim::{ VehicleType, }; use widgetry::{ - Btn, Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, + Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, LinePlot, Outcome, Panel, PlotOptions, Series, TextExt, VerticalAlignment, Widget, }; @@ -695,7 +695,13 @@ fn make_tabs( let mut row = Vec::new(); for (name, link) in tabs { if current_tab.variant() == link.variant() { - row.push(Btn::text_bg2(name).inactive(ctx).centered_vert()); + row.push( + ctx.style() + .btn_primary_dark_text(name) + .disabled() + .build_def(ctx) + .centered_vert(), + ); } else { hyperlinks.insert(name.to_string(), link); row.push( diff --git a/game/src/info/person.rs b/game/src/info/person.rs index c2a4df6090..297db39e9b 100644 --- a/game/src/info/person.rs +++ b/game/src/info/person.rs @@ -325,7 +325,9 @@ pub fn bio( } else { if app.primary.sim.lookup_parked_car(v.id).is_some() { rows.push( - Btn::text_bg2(format!("Owner of {} (parked)", v.id)).build_def(ctx, None), + ctx.style() + .btn_primary_dark_text(&format!("Owner of {} (parked)", v.id)) + .build_def(ctx), ); details .hyperlinks diff --git a/game/src/sandbox/gameplay/freeform.rs b/game/src/sandbox/gameplay/freeform.rs index 8ea02cf706..023c03df18 100644 --- a/game/src/sandbox/gameplay/freeform.rs +++ b/game/src/sandbox/gameplay/freeform.rs @@ -205,14 +205,13 @@ impl ChangeScenario { Line("Each scenario determines what people live and travel around this map").draw(ctx), ]; for (name, label, description) in choices { - let btn = if name == current_scenario { - Btn::text_bg2(label).inactive(ctx) - } else { - Btn::text_bg2(label).build(ctx, name, None) - }; + let mut btn = ctx.style().btn_primary_dark_text(&label); + if name == current_scenario { + btn = btn.disabled(); + } col.push( Widget::row(vec![ - btn, + btn.build_widget(ctx, &name), Text::from(Line(description).secondary()) .wrap_to_pct(ctx, 40) .draw(ctx) diff --git a/game/src/sandbox/gameplay/tutorial.rs b/game/src/sandbox/gameplay/tutorial.rs index f828926ed1..80e49445f2 100644 --- a/game/src/sandbox/gameplay/tutorial.rs +++ b/game/src/sandbox/gameplay/tutorial.rs @@ -851,8 +851,10 @@ impl TutorialState { ])]; if self.current.part == self.stage().messages.len() - 1 { controls.push( - Btn::text_bg2("Try it") - .build_def(ctx, hotkeys(vec![Key::RightArrow, Key::Space, Key::Enter])), + ctx.style() + .btn_primary_dark_text("Try it") + .hotkey(hotkeys(vec![Key::RightArrow, Key::Space, Key::Enter])) + .build_def(ctx), ); } col.push(Widget::col(controls).align_bottom()); diff --git a/game/src/sandbox/misc_tools.rs b/game/src/sandbox/misc_tools.rs index 9ad3b0ff26..077eda2f1b 100644 --- a/game/src/sandbox/misc_tools.rs +++ b/game/src/sandbox/misc_tools.rs @@ -5,8 +5,8 @@ use map_gui::ID; use map_model::IntersectionID; use sim::AgentID; use widgetry::{ - Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, - Panel, State, StyledButtons, VerticalAlignment, Widget, + Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, + State, StyledButtons, VerticalAlignment, Widget, }; use crate::app::{App, Transition}; @@ -151,8 +151,11 @@ impl State for TrafficRecorder { fn make_btn(ctx: &mut EventCtx, num: usize) -> Widget { if num == 0 { - return Btn::text_bg2("Record 0 intersections") - .inactive(ctx) + return ctx + .style() + .btn_primary_dark_text("Record 0 intersections") + .disabled() + .build_def(ctx) .named("record"); } @@ -161,5 +164,8 @@ fn make_btn(ctx: &mut EventCtx, num: usize) -> Widget { } else { format!("Record {} intersections", num) }; - Btn::text_bg2(title).build(ctx, "record", Key::Enter) + ctx.style() + .btn_primary_dark_text(&title) + .hotkey(Key::Enter) + .build_widget(ctx, "record") } diff --git a/game/src/sandbox/time_warp.rs b/game/src/sandbox/time_warp.rs index a958f1aff0..e9aecd8e36 100644 --- a/game/src/sandbox/time_warp.rs +++ b/game/src/sandbox/time_warp.rs @@ -6,8 +6,8 @@ use map_gui::render::DrawOptions; use map_gui::tools::{grey_out_map, PopupMsg}; use map_gui::ID; use widgetry::{ - Btn, Checkbox, Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, - Panel, Slider, State, StyledButtons, Text, UpdateType, Widget, + Checkbox, Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, + Slider, State, StyledButtons, Text, UpdateType, Widget, }; use crate::app::{App, FindDelayedIntersections, ShowEverything, Transition}; @@ -35,7 +35,10 @@ impl JumpToTime { panel: Panel::new(Widget::col(vec![ ctx.style().btn_close_widget(ctx), Widget::custom_row(vec![ - Btn::text_bg2("Jump to time").inactive(ctx), + ctx.style() + .btn_primary_dark_text("Jump to time") + .disabled() + .build_def(ctx), ctx.style() .btn_primary_dark_text("Jump to delay") .hotkey(Key::D) @@ -171,7 +174,10 @@ impl JumpToDelay { .btn_primary_dark_text("Jump to time") .hotkey(Key::T) .build_def(ctx), - Btn::text_bg2("Jump to delay").inactive(ctx), + ctx.style() + .btn_primary_dark_text("Jump to delay") + .disabled() + .build_def(ctx), ]) .bg(Color::WHITE), Widget::row(vec![ @@ -289,8 +295,10 @@ impl TimeWarpScreen { panel: Panel::new( Widget::col(vec![ Text::new().draw(ctx).named("text"), - Btn::text_bg2("stop now") - .build_def(ctx, Key::Escape) + ctx.style() + .btn_primary_dark_text("stop now") + .hotkey(Key::Escape) + .build_def(ctx) .centered_horiz(), ]) // hardcoded width avoids jiggle due to text updates @@ -466,15 +474,19 @@ fn compare_count(after: usize, before: usize) -> String { } fn build_jump_to_time_btn(ctx: &EventCtx, target: Time) -> Widget { - Btn::text_bg2(format!("Jump to {}", target.ampm_tostring())) - .build(ctx, "jump to time", Key::Enter) + ctx.style() + .btn_primary_dark_text(&format!("Jump to {}", target.ampm_tostring())) + .hotkey(Key::Enter) + .build_widget(ctx, "jump to time") .centered_horiz() .margin_above(16) } fn build_jump_to_delay_button(ctx: &EventCtx, delay: Duration) -> Widget { - Btn::text_bg2(format!("Jump to next {} delay", delay)) - .build(ctx, "jump to delay", Key::Enter) + ctx.style() + .btn_primary_dark_text(&format!("Jump to next {} delay", delay)) + .hotkey(Key::Enter) + .build_widget(ctx, "jump to delay") .centered_horiz() .margin_above(16) } diff --git a/map_editor/src/main.rs b/map_editor/src/main.rs index f39c5dc11b..66cd70f067 100644 --- a/map_editor/src/main.rs +++ b/map_editor/src/main.rs @@ -10,7 +10,7 @@ use map_model::osm; use map_model::raw::OriginalRoad; use widgetry::{ Btn, Canvas, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, - Outcome, Panel, ScreenPt, SharedAppState, Text, Transition, VerticalAlignment, Widget, + Outcome, Panel, ScreenPt, SharedAppState, Text, Transition, VerticalAlignment, Widget, StyledButtons }; mod model; @@ -78,7 +78,9 @@ impl MainState { Text::new().draw(ctx).named("current info"), Widget::col(vec![ Btn::text_fg("quit").build_def(ctx, Key::Escape), - Btn::text_fg("export to OSM").build_def(ctx, None), + ctx.style() + .btn_secondary_light_text("export to OSM") + .build_def(ctx), Btn::text_fg("preview all intersections").build_def(ctx, Key::G), ]), ])) diff --git a/map_gui/src/options.rs b/map_gui/src/options.rs index 0305cad859..35bdbbb6c8 100644 --- a/map_gui/src/options.rs +++ b/map_gui/src/options.rs @@ -1,7 +1,7 @@ use abstutil::CmdArgs; use geom::{Duration, UnitFmt}; use widgetry::{ - Btn, Checkbox, Choice, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, Spinner, State, + Checkbox, Choice, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, Spinner, State, StyledButtons, TextExt, Widget, }; @@ -259,8 +259,10 @@ impl OptionsPanel { ]) .bg(app.cs().section_bg) .padding(8), - Btn::text_bg2("Apply") - .build_def(ctx, Key::Enter) + ctx.style() + .btn_primary_dark_text("Apply") + .hotkey(Key::Enter) + .build_def(ctx) .centered_horiz(), ])) .build(ctx), diff --git a/map_gui/src/tools/ui.rs b/map_gui/src/tools/ui.rs index 936b4e18dc..5fea844d22 100644 --- a/map_gui/src/tools/ui.rs +++ b/map_gui/src/tools/ui.rs @@ -180,7 +180,10 @@ impl PopupMsg { Box::new(PopupMsg { panel: Panel::new(Widget::col(vec![ txt.draw(ctx), - Btn::text_bg2("OK").build_def(ctx, hotkeys(vec![Key::Enter, Key::Escape])), + ctx.style() + .btn_primary_dark_text("OK") + .hotkey(hotkeys(vec![Key::Enter, Key::Escape])) + .build_def(ctx), ])) .build(ctx), unzoomed, diff --git a/osm_viewer/src/viewer.rs b/osm_viewer/src/viewer.rs index e4bd5de109..4caf6d0758 100644 --- a/osm_viewer/src/viewer.rs +++ b/osm_viewer/src/viewer.rs @@ -11,7 +11,7 @@ use map_gui::tools::{ use map_gui::{SimpleApp, ID}; use map_model::osm; use widgetry::{ - lctrl, Btn, Checkbox, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx, + lctrl, Checkbox, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State, StyledButtons, Text, TextExt, Transition, VerticalAlignment, Widget, }; @@ -97,18 +97,18 @@ impl Viewer { let r = app.map.get_parent(l); col.push( Widget::row(vec![ - Btn::text_bg2(format!("Open OSM way {}", r.orig_id.osm_way_id.0)).build( + ctx.style() + .btn_primary_dark_text(&format!( + "Open OSM way {}", + r.orig_id.osm_way_id.0 + )) + .build_widget(ctx, &format!("open {}", r.orig_id.osm_way_id)), + ctx.style().btn_primary_dark_text("Edit OSM way").build_widget( ctx, - format!("open {}", r.orig_id.osm_way_id), - None, - ), - Btn::text_bg2("Edit OSM way").build( - ctx, - format!( + &format!( "open https://www.openstreetmap.org/edit?way={}", r.orig_id.osm_way_id.0 ), - None, ), ]) .evenly_spaced(), @@ -141,21 +141,17 @@ impl Viewer { Some(ID::Intersection(i)) => { let i = app.map.get_i(i); col.push( - Btn::text_bg2(format!("Open OSM node {}", i.orig_id.0)).build( - ctx, - format!("open {}", i.orig_id), - None, - ), + ctx.style() + .btn_primary_dark_text(&format!("Open OSM node {}", i.orig_id.0)) + .build_widget(ctx, &format!("open {}", i.orig_id)), ); } Some(ID::Building(b)) => { let b = app.map.get_b(b); col.push( - Btn::text_bg2(format!("Open OSM ID {}", b.orig_id.inner())).build( - ctx, - format!("open {}", b.orig_id), - None, - ), + ctx.style() + .btn_primary_dark_text(&format!("Open OSM ID {}", b.orig_id.inner())) + .build_widget(ctx, &format!("open {}", b.orig_id)) ); let mut txt = Text::new(); @@ -201,11 +197,9 @@ impl Viewer { Some(ID::ParkingLot(pl)) => { let pl = app.map.get_pl(pl); col.push( - Btn::text_bg2(format!("Open OSM ID {}", pl.osm_id.inner())).build( - ctx, - format!("open {}", pl.osm_id), - None, - ), + ctx.style() + .btn_primary_dark_text(&format!("Open OSM ID {}", pl.osm_id.inner())) + .build_widget(ctx, &format!("open {}", pl.osm_id)), ); col.push( diff --git a/parking_mapper/src/mapper.rs b/parking_mapper/src/mapper.rs index 9c39be9398..fc97b40bd3 100644 --- a/parking_mapper/src/mapper.rs +++ b/parking_mapper/src/mapper.rs @@ -9,7 +9,7 @@ use map_gui::{SimpleApp, ID}; use map_model::{osm, RoadID}; use osm::WayID; use widgetry::{ - Btn, Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, + Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Menu, Outcome, Panel, State, StyledButtons, Text, TextExt, Transition, VerticalAlignment, Widget, }; @@ -179,7 +179,9 @@ impl ParkingMapper { ), ]), Checkbox::checkbox(ctx, "max 3 days parking (default in Seattle)", None, false), - Btn::text_fg("Generate OsmChange file").build_def(ctx, None), + ctx.style() + .btn_secondary_light_text("Generate OsmChange file") + .build_def(ctx), "Select a road".draw_text(ctx).named("info"), ])) .aligned(HorizontalAlignment::Right, VerticalAlignment::Top) diff --git a/santa/src/before_level.rs b/santa/src/before_level.rs index 99b51a1fb2..8c180e2210 100644 --- a/santa/src/before_level.rs +++ b/santa/src/before_level.rs @@ -299,8 +299,10 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel // Don't overwhelm players on the very first level. if app.session.upzones_unlocked == 0 { return Panel::new( - Btn::text_bg2("Start game") - .build_def(ctx, Key::Enter) + ctx.style() + .btn_primary_dark_text("Start game") + .hotkey(Key::Enter) + .build_def(ctx) .container(), ) .aligned( @@ -332,12 +334,16 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel if num_picked == app.session.upzones_unlocked { Btn::text_fg("Randomly choose upzones").inactive(ctx) } else { - Btn::text_fg("Randomly choose upzones").build_def(ctx, None) + ctx.style() + .btn_secondary_light_text("Randomly choose upzones") + .build_def(ctx) }, if num_picked == 0 { Btn::text_fg("Clear upzones").inactive(ctx) } else { - Btn::text_fg("Clear upzones").build_def(ctx, None) + ctx.style() + .btn_secondary_light_text("Clear upzones") + .build_def(ctx) } .align_right(), ]), @@ -347,7 +353,9 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel .hotkey(Key::Enter) .build_def(ctx) } else { - Btn::text_bg2("Finish upzoning before playing").inactive(ctx) + ctx.style() + .btn_primary_dark_text("Finish upzoning before playing") + .disabled().build_def(ctx) }, ])) .aligned( diff --git a/widgetry/src/widgets/button.rs b/widgetry/src/widgets/button.rs index 553ea81bdf..2858cdc47d 100644 --- a/widgetry/src/widgets/button.rs +++ b/widgetry/src/widgets/button.rs @@ -155,21 +155,6 @@ impl Btn { let action = action.into(); BtnBuilder::TextFG(action.clone(), Text::from(Line(action)), None) } - - // The white background. - pub fn text_bg2>(action: I) -> BtnBuilder { - let action = action.into(); - BtnBuilder::TextBG { - action: action.clone(), - maybe_tooltip: None, - - text: Text::from(Line(action).fg(Color::hex("#5B5B5B"))), - // This is sometimes against a white background and could just be None, but some - // callers need the background. - unselected_bg_color: Color::WHITE, - selected_bg_color: Color::grey(0.8), - } - } } #[derive(Clone, Debug, Default)] @@ -692,14 +677,6 @@ struct Label<'a> { pub enum BtnBuilder { TextFG(String, Text, Option), - TextBG { - action: String, - maybe_tooltip: Option, - - text: Text, - unselected_bg_color: Color, - selected_bg_color: Color, - }, } impl BtnBuilder { @@ -709,13 +686,6 @@ impl BtnBuilder { assert!(maybe_tooltip.is_none()); *maybe_tooltip = Some(tooltip); } - BtnBuilder::TextBG { - ref mut maybe_tooltip, - .. - } => { - assert!(maybe_tooltip.is_none()); - *maybe_tooltip = Some(tooltip); - } } self } @@ -758,46 +728,13 @@ impl BtnBuilder { ) .outline(2.0, Color::WHITE) } - BtnBuilder::TextBG { - text, - maybe_tooltip, - unselected_bg_color, - selected_bg_color, - .. - } => { - let (normal, hitbox) = text - .clone() - .batch(ctx) - .container() - .padding(15) - .bg(unselected_bg_color) - .to_geom(ctx, None); - let (hovered, _) = text - .batch(ctx) - .container() - .padding(15) - .bg(selected_bg_color) - .to_geom(ctx, None); - - Button::widget( - ctx, - normal.clone(), - hovered, - normal, - key.into(), - &action.into(), - maybe_tooltip, - hitbox, - false, - ) - } } } // Use the text as the action pub fn build_def>>(self, ctx: &EventCtx, key: MK) -> Widget { match self { - BtnBuilder::TextFG(ref action, _, _) | BtnBuilder::TextBG { ref action, .. } => { + BtnBuilder::TextFG(ref action, _, _) => { assert!(!action.is_empty()); let copy = action.clone(); self.build(ctx, copy, key) @@ -819,26 +756,6 @@ impl BtnBuilder { .0, ) .named(action), - // TODO This'll only work reasonably for text_bg2 - BtnBuilder::TextBG { - text, - unselected_bg_color, - action, - .. - } => { - assert_eq!(unselected_bg_color, Color::WHITE); - Widget::draw_batch( - ctx, - text.render(ctx) - .batch() - .container() - .padding(15) - .bg(Color::grey(0.7)) - .to_geom(ctx, None) - .0, - ) - .named(action) - } } } } diff --git a/widgetry/src/widgets/table.rs b/widgetry/src/widgets/table.rs index e0b0566629..666e432e7b 100644 --- a/widgetry/src/widgets/table.rs +++ b/widgetry/src/widgets/table.rs @@ -2,7 +2,7 @@ use abstutil::prettyprint_usize; use geom::Polygon; use crate::{ - Btn, Color, ControlState, EventCtx, GeomBatch, Key, Line, Panel, StyledButtons, Text, TextExt, + Color, ControlState, EventCtx, GeomBatch, Key, Line, Panel, StyledButtons, Text, TextExt, Widget, }; @@ -100,12 +100,13 @@ impl Table { .iter() .map(|col| { if self.sort_by == col.name { - Btn::text_bg2(format!( - "{} {}", - col.name, - if self.descending { "↓" } else { "↑" } - )) - .build(ctx, &col.name, None) + ctx.style() + .btn_primary_dark_text(&format!( + "{} {}", + col.name, + if self.descending { "↓" } else { "↑" } + )) + .build_widget(ctx, &col.name) } else if let Col::Sortable(_) = col.col { ctx.style().btn_primary_dark_text(&col.name).build_def(ctx) } else {