Use btn_primary.* methods instead of btn_primary_*

This commit is contained in:
Michael Kirk 2021-02-27 12:40:10 -08:00 committed by Dustin Carlino
parent 87a1a3f027
commit cee0e5dbbd
29 changed files with 98 additions and 109 deletions

View File

@ -35,7 +35,8 @@ impl FindHome {
)
.flex_wrap(ctx, Percent::int(50)),
ctx.style()
.btn_solid_primary_text("Search")
.btn_solid_primary
.text("Search")
.hotkey(Key::Enter)
.build_def(ctx),
]))

View File

@ -163,7 +163,8 @@ fn make_panel(
Widget::custom_col(vec![
(make_task)(ctx),
ctx.style()
.btn_solid_primary_text("Start")
.btn_solid_primary
.text("Start")
.hotkey(Key::Enter)
.build_def(ctx)
.centered_horiz()
@ -224,7 +225,7 @@ fn make_panel(
Widget::col(vec![
Widget::row(vec![prev.margin_right(40), next]).centered_horiz(),
ButtonStyle::outline_dark_fg()
.outline_text("Skip cutscene")
.text("Skip cutscene")
.build_def(ctx)
.centered_horiz(),
])
@ -265,7 +266,8 @@ impl FYI {
Widget::custom_col(vec![
contents,
ctx.style()
.btn_solid_primary_text("OK")
.btn_solid_primary
.text("OK")
.hotkey(hotkeys(vec![Key::Escape, Key::Space, Key::Enter]))
.build_def(ctx)
.centered_horiz()

View File

@ -168,7 +168,8 @@ impl BulkEdit {
},
Widget::row(vec![
ctx.style()
.btn_solid_primary_text("Finish")
.btn_solid_primary
.text("Finish")
.hotkey(Key::Enter)
.build_def(ctx),
ctx.style()

View File

@ -5,7 +5,7 @@ use map_gui::render::{DrawOptions, DrawUberTurnGroup, BIG_ARROW_THICKNESS};
use map_model::{IntersectionCluster, IntersectionID};
use widgetry::{
DrawBaselayer, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Outcome, Panel, State,
StyledButtons, VerticalAlignment, Widget,
VerticalAlignment, Widget,
};
use crate::app::Transition;
@ -25,7 +25,8 @@ impl ClusterTrafficSignalEditor {
Box::new(ClusterTrafficSignalEditor {
panel: Panel::new(Widget::row(vec![ctx
.style()
.btn_solid_primary_text("Finish")
.btn_solid_primary
.text("Finish")
.hotkey(Key::Escape)
.build_def(ctx)]))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)

View File

@ -99,7 +99,8 @@ impl LaneEditor {
.hotkey(Key::A)
.build_def(ctx),
ctx.style()
.btn_solid_primary_text("Finish")
.btn_solid_primary
.text("Finish")
.hotkey(Key::Escape)
.build_def(ctx),
];

View File

@ -420,7 +420,8 @@ impl SaveEdits {
Widget::nothing()
},
ctx.style()
.btn_solid_primary_text("Save")
.btn_solid_primary
.text("Save")
.disabled(true)
.build_def(ctx),
])
@ -441,7 +442,8 @@ impl SaveEdits {
ctx,
"Save",
ctx.style()
.btn_solid_primary_text("Save")
.btn_solid_primary
.text("Save")
.disabled(true)
.build_def(ctx),
);
@ -454,7 +456,8 @@ impl SaveEdits {
ctx,
"Save",
ctx.style()
.btn_solid_primary_text("Save")
.btn_solid_primary
.text("Save")
.disabled(true)
.build_def(ctx),
);
@ -470,7 +473,8 @@ impl SaveEdits {
ctx,
"Save",
ctx.style()
.btn_solid_primary_text("Save")
.btn_solid_primary
.text("Save")
.hotkey(Key::Enter)
.build_def(ctx),
);
@ -649,7 +653,8 @@ fn make_topcenter(ctx: &mut EventCtx, app: &App) -> Panel {
.draw(ctx)
.centered_horiz(),
ctx.style()
.btn_solid_primary_text(&format!(
.btn_solid_primary
.text(&format!(
"Finish & resume from {}",
app.primary
.suspended_sim

View File

@ -32,7 +32,8 @@ impl RouteEditor {
Spinner::widget(ctx, (1, 120), 60).named("freq_mins"),
]),
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx),
]))

View File

@ -67,7 +67,8 @@ impl StopSignEditor {
.btn_outline_text("convert to traffic signal")
.build_def(ctx),
ctx.style()
.btn_solid_primary_text("Finish")
.btn_solid_primary
.text("Finish")
.hotkey(Key::Escape)
.build_def(ctx),
]))

View File

@ -95,7 +95,8 @@ impl ChangeDuration {
.secondary()
.draw(ctx),
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx),
]))

View File

@ -494,7 +494,8 @@ impl State<App> for TrafficSignalEditor {
fn make_top_panel(ctx: &mut EventCtx, app: &App, can_undo: bool, can_redo: bool) -> Panel {
let row = vec![
ctx.style()
.btn_solid_primary_text("Finish")
.btn_solid_primary
.text("Finish")
.hotkey(Key::Enter)
.build_def(ctx),
ctx.style()

View File

@ -113,7 +113,8 @@ fn make_btn(ctx: &mut EventCtx, num: usize) -> Widget {
_ => format!("Edit {} signals", num),
};
ctx.style()
.btn_solid_primary_text(&title)
.btn_solid_primary
.text(&title)
.disabled(num == 0)
.hotkey(hotkeys(vec![Key::Enter, Key::E]))
.build_widget(ctx, "edit")

View File

@ -64,7 +64,8 @@ impl ZoneEditor {
]),
Widget::custom_row(vec![
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx),
ctx.style()

View File

@ -46,7 +46,8 @@ impl TitleScreen {
// TODO that nicer font
// TODO Any key
ctx.style()
.btn_solid_primary_text("Play")
.btn_solid_primary
.text("Play")
.hotkey(hotkeys(vec![Key::Space, Key::Enter]))
.build_widget(ctx, "start game"),
])
@ -368,7 +369,8 @@ impl Proposals {
}
current_tab.push(
ctx.style()
.btn_solid_primary_text("Try out this proposal")
.btn_solid_primary
.text("Try out this proposal")
.build_def(ctx),
);

View File

@ -323,7 +323,8 @@ impl AgentSpawner {
Spinner::widget(ctx, (1, 1000), 1).named("number"),
]),
ctx.style()
.btn_solid_primary_text("Confirm")
.btn_solid_primary
.text("Confirm")
.disabled(true)
.build_def(ctx),
]))
@ -409,7 +410,8 @@ impl State<App> for AgentSpawner {
ctx,
"Confirm",
ctx.style()
.btn_solid_primary_text("Confirm")
.btn_solid_primary
.text("Confirm")
.disabled(true)
.build_def(ctx),
);
@ -485,7 +487,8 @@ impl State<App> for AgentSpawner {
ctx,
"Confirm",
ctx.style()
.btn_solid_primary_text("Confirm")
.btn_solid_primary
.text("Confirm")
.hotkey(Key::Enter)
.build_def(ctx),
);

View File

@ -281,7 +281,8 @@ impl FinalScore {
ctx.style().btn_outline_text("Try again").build_def(ctx),
if next_mode.is_some() {
ctx.style()
.btn_solid_primary_text("Next challenge")
.btn_solid_primary
.text("Next challenge")
.build_def(ctx)
} else {
Widget::nothing()

View File

@ -227,7 +227,8 @@ impl EditScenarioModifiers {
rows.push(
Widget::row(vec![
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx),
ctx.style()
@ -389,7 +390,8 @@ impl ChangeMode {
]),
Widget::row(vec![
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx),
ctx.style()

View File

@ -844,7 +844,8 @@ impl TutorialState {
if self.current.part == self.stage().messages.len() - 1 {
controls.push(
ctx.style()
.btn_solid_primary_text("Try it")
.btn_solid_primary
.text("Try it")
.hotkey(hotkeys(vec![Key::RightArrow, Key::Space, Key::Enter]))
.build_def(ctx),
);

View File

@ -156,7 +156,8 @@ fn make_btn(ctx: &mut EventCtx, num: usize) -> Widget {
_ => format!("Record {} intersections", num),
};
ctx.style()
.btn_solid_primary_text(&title)
.btn_solid_primary
.text(&title)
.disabled(num == 0)
.hotkey(Key::Enter)
.build_widget(ctx, "record")

View File

@ -445,7 +445,8 @@ impl AgentMeter {
.centered_vert(),
format!("{} trips captured", prettyprint_usize(n)).draw_text(ctx),
ctx.style()
.btn_solid_primary_text("Finish Capture")
.btn_solid_primary
.text("Finish Capture")
.build_def(ctx)
.align_right(),
]));

View File

@ -474,7 +474,8 @@ fn compare_count(after: usize, before: usize) -> String {
fn build_jump_to_time_btn(ctx: &EventCtx, target: Time) -> Widget {
ctx.style()
.btn_solid_primary_text(&format!("Jump to {}", target.ampm_tostring()))
.btn_solid_primary
.text(&format!("Jump to {}", target.ampm_tostring()))
.hotkey(Key::Enter)
.build_widget(ctx, "jump to time")
.centered_horiz()
@ -483,7 +484,8 @@ fn build_jump_to_time_btn(ctx: &EventCtx, target: Time) -> Widget {
fn build_jump_to_delay_button(ctx: &EventCtx, delay: Duration) -> Widget {
ctx.style()
.btn_solid_primary_text(&format!("Jump to next {} delay", delay))
.btn_solid_primary
.text(&format!("Jump to next {} delay", delay))
.hotkey(Key::Enter)
.build_widget(ctx, "jump to delay")
.centered_horiz()

View File

@ -109,7 +109,8 @@ impl EditRoad {
]),
Widget::row(vec![info, controls]),
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx),
];

View File

@ -114,7 +114,8 @@ impl MainState {
.btn_outline_text("adjust boundary")
.build_def(ctx),
ctx.style()
.btn_solid_primary_text("export to OSM")
.btn_solid_primary
.text("export to OSM")
.build_def(ctx),
]),
]))

View File

@ -260,7 +260,8 @@ impl OptionsPanel {
.bg(app.cs().inner_panel_bg)
.padding(8),
ctx.style()
.btn_solid_primary_text("Apply")
.btn_solid_primary
.text("Apply")
.hotkey(Key::Enter)
.build_def(ctx)
.centered_horiz(),

View File

@ -162,7 +162,8 @@ impl PopupMsg {
panel: Panel::new(Widget::col(vec![
txt.draw(ctx),
ctx.style()
.btn_solid_primary_text("OK")
.btn_solid_primary
.text("OK")
.hotkey(hotkeys(vec![Key::Enter, Key::Escape]))
.build_def(ctx),
]))

View File

@ -50,7 +50,8 @@ impl<A: AppLike + 'static> Picker<A> {
}
col.push(
ctx.style()
.btn_solid_primary_text("Sync files")
.btn_solid_primary
.text("Sync files")
.build_def(ctx),
);

View File

@ -197,7 +197,8 @@ impl Results {
Panel::new(Widget::col(vec![
txt.draw(ctx),
ctx.style()
.btn_solid_primary_text("OK")
.btn_solid_primary
.text("OK")
.hotkey(Key::Enter)
.build_def(ctx),
]))

View File

@ -309,7 +309,8 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel
if app.session.upzones_unlocked == 0 {
return Panel::new(
ctx.style()
.btn_solid_primary_text("Start game")
.btn_solid_primary
.text("Start game")
.hotkey(Key::Enter)
.build_def(ctx)
.container(),
@ -352,12 +353,14 @@ fn make_upzone_panel(ctx: &mut EventCtx, app: &App, num_picked: usize) -> Panel
]),
if num_picked == app.session.upzones_unlocked {
ctx.style()
.btn_solid_primary_text("Start game")
.btn_solid_primary
.text("Start game")
.hotkey(Key::Enter)
.build_def(ctx)
} else {
ctx.style()
.btn_solid_primary_text("Finish upzoning before playing")
.btn_solid_primary
.text("Finish upzoning before playing")
.disabled(true)
.build_def(ctx)
},

View File

@ -100,46 +100,6 @@ pub trait StyledButtons<'a> {
.image_dims(ScreenDims::square(18.0))
}
fn btn_plain_primary(&self) -> ButtonBuilder<'a>;
fn btn_plain_primary_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.btn_plain_primary().label_text(text)
}
fn btn_plain_primary_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.btn_plain_primary().image_path(image_path))
}
fn btn_solid_primary(&self) -> ButtonBuilder<'a>;
fn btn_solid_primary_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.btn_solid_primary().label_text(text)
}
fn btn_solid_primary_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.btn_solid_primary().image_path(image_path))
}
fn btn_solid_primary_icon_text(&self, image_path: &'a str, text: &'a str) -> ButtonBuilder<'a> {
self.btn_solid_primary()
.label_text(text)
.image_path(image_path)
.image_dims(ScreenDims::square(18.0))
}
fn btn_outline_primary(&self) -> ButtonBuilder<'a>;
fn btn_outline_primary_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.btn_outline_primary().label_text(text)
}
fn btn_outline_primary_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.btn_outline_primary().image_path(image_path))
}
fn btn_outline_primary_icon_text(
&self,
image_path: &'a str,
text: &'a str,
) -> ButtonBuilder<'a> {
self.btn_outline_primary()
.label_text(text)
.image_path(image_path)
.image_dims(ScreenDims::square(18.0))
}
// Specific UI Elements
/// title: name of previous screen, which you'll return to
@ -210,62 +170,51 @@ impl<'a> StyledButtons<'a> for Style {
fn btn_outline_destructive(&self) -> ButtonBuilder<'a> {
basic_button(&self.btn_solid_destructive, true)
}
fn btn_plain_primary(&self) -> ButtonBuilder<'a> {
basic_button(&self.btn_outline_primary, false)
}
fn btn_solid_primary(&self) -> ButtonBuilder<'a> {
basic_button(&self.btn_solid_primary, true)
}
fn btn_outline_primary(&self) -> ButtonBuilder<'a> {
basic_button(&self.btn_solid_primary, true)
}
}
impl<'a> ButtonStyle {
pub fn plain(&self) -> ButtonBuilder<'a> {
pub fn btn_plain(&self) -> ButtonBuilder<'a> {
basic_button(self, false)
}
pub fn outline(&self) -> ButtonBuilder<'a> {
self.plain().outline(self.outline, ControlState::Default)
pub fn btn(&self) -> ButtonBuilder<'a> {
self.btn_plain()
.outline(self.outline, ControlState::Default)
}
pub fn plain_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.plain().label_text(text)
self.btn_plain().label_text(text)
}
pub fn plain_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.plain().image_path(image_path))
icon_button(self.btn_plain().image_path(image_path))
}
pub fn plain_icon_bytes(&self, labeled_bytes: (&'a str, &'a [u8])) -> ButtonBuilder<'a> {
icon_button(self.plain().image_bytes(labeled_bytes))
icon_button(self.btn_plain().image_bytes(labeled_bytes))
}
pub fn plain_icon_text(&self, image_path: &'a str, text: &'a str) -> ButtonBuilder<'a> {
self.plain()
self.btn_plain()
.label_text(text)
.image_path(image_path)
.image_dims(ScreenDims::square(18.0))
}
pub fn outline_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.outline().label_text(text)
pub fn text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.btn().label_text(text)
}
pub fn outline_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.outline().image_path(image_path))
pub fn icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
icon_button(self.btn().image_path(image_path))
}
pub fn outline_icon_bytes(&self, labeled_bytes: (&'a str, &'a [u8])) -> ButtonBuilder<'a> {
icon_button(self.outline().image_bytes(labeled_bytes))
pub fn icon_bytes(&self, labeled_bytes: (&'a str, &'a [u8])) -> ButtonBuilder<'a> {
icon_button(self.btn().image_bytes(labeled_bytes))
}
pub fn outline_icon_text(&self, image_path: &'a str, text: &'a str) -> ButtonBuilder<'a> {
self.outline()
pub fn icon_text(&self, image_path: &'a str, text: &'a str) -> ButtonBuilder<'a> {
self.btn()
.label_text(text)
.image_path(image_path)
.image_dims(ScreenDims::square(18.0))

View File

@ -420,7 +420,8 @@ fn make_controls(ctx: &mut EventCtx) -> Panel {
],
),
ctx.style()
.btn_outline_primary_text("Apply")
.btn_outline_primary
.text("Apply")
.build_widget(ctx, "apply"),
])
.margin_above(30),