mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
add "destructive" (red) button styles
This commit is contained in:
parent
bccf389058
commit
def3644eca
@ -28,6 +28,18 @@ impl<'a> StyledButtons<'a> for crate::ColorScheme {
|
||||
self.gui_style.btn_plain_light()
|
||||
}
|
||||
|
||||
fn btn_plain_destructive(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_plain_destructive()
|
||||
}
|
||||
|
||||
fn btn_primary_destructive(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_primary_destructive()
|
||||
}
|
||||
|
||||
fn btn_secondary_destructive(&self) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_secondary_destructive()
|
||||
}
|
||||
|
||||
fn btn_hotkey_light(&self, label: &str, key: Key) -> ButtonBuilder<'a> {
|
||||
self.gui_style.btn_hotkey_light(label, key)
|
||||
}
|
||||
|
@ -82,6 +82,50 @@ pub trait StyledButtons<'a> {
|
||||
icon_button(self.btn_plain_light().image_path(image_path))
|
||||
}
|
||||
|
||||
fn btn_plain_destructive(&self) -> ButtonBuilder<'a>;
|
||||
fn btn_plain_destructive_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
||||
self.btn_plain_destructive().label_text(text)
|
||||
}
|
||||
fn btn_plain_destructive_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
|
||||
icon_button(self.btn_plain_destructive().image_path(image_path))
|
||||
}
|
||||
|
||||
fn btn_primary_destructive(&self) -> ButtonBuilder<'a>;
|
||||
fn btn_primary_destructive_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
||||
self.btn_primary_destructive().label_text(text)
|
||||
}
|
||||
fn btn_primary_destructive_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
|
||||
icon_button(self.btn_primary_destructive().image_path(image_path))
|
||||
}
|
||||
fn btn_primary_destructive_icon_text(
|
||||
&self,
|
||||
image_path: &'a str,
|
||||
text: &'a str,
|
||||
) -> ButtonBuilder<'a> {
|
||||
self.btn_primary_destructive()
|
||||
.label_text(text)
|
||||
.image_path(image_path)
|
||||
.image_dims(ScreenDims::square(18.0))
|
||||
}
|
||||
|
||||
fn btn_secondary_destructive(&self) -> ButtonBuilder<'a>;
|
||||
fn btn_secondary_destructive_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
||||
self.btn_secondary_destructive().label_text(text)
|
||||
}
|
||||
fn btn_secondary_destructive_icon(&self, image_path: &'a str) -> ButtonBuilder<'a> {
|
||||
icon_button(self.btn_secondary_destructive().image_path(image_path))
|
||||
}
|
||||
fn btn_secondary_destructive_icon_text(
|
||||
&self,
|
||||
image_path: &'a str,
|
||||
text: &'a str,
|
||||
) -> ButtonBuilder<'a> {
|
||||
self.btn_secondary_destructive()
|
||||
.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
|
||||
@ -186,6 +230,21 @@ impl<'a> StyledButtons<'a> for Style {
|
||||
let colors = &self.btn_secondary_light;
|
||||
plain_builder(colors)
|
||||
}
|
||||
|
||||
fn btn_plain_destructive(&self) -> ButtonBuilder<'a> {
|
||||
let colors = &self.btn_secondary_destructive;
|
||||
plain_builder(colors)
|
||||
}
|
||||
|
||||
fn btn_primary_destructive(&self) -> ButtonBuilder<'a> {
|
||||
let colors = &self.btn_secondary_destructive;
|
||||
plain_builder(colors).outline(2.0, colors.outline, ControlState::Default)
|
||||
}
|
||||
|
||||
fn btn_secondary_destructive(&self) -> ButtonBuilder<'a> {
|
||||
let colors = &self.btn_secondary_destructive;
|
||||
plain_builder(colors).outline(2.0, colors.outline, ControlState::Default)
|
||||
}
|
||||
}
|
||||
|
||||
fn plain_builder<'a>(color_scheme: &ButtonStyle) -> ButtonBuilder<'a> {
|
||||
|
@ -14,6 +14,8 @@ pub struct Style {
|
||||
pub btn_secondary_dark: ButtonStyle,
|
||||
pub btn_primary_light: ButtonStyle,
|
||||
pub btn_secondary_light: ButtonStyle,
|
||||
pub btn_primary_destructive: ButtonStyle,
|
||||
pub btn_secondary_destructive: ButtonStyle,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -69,6 +71,22 @@ impl Style {
|
||||
bg_disabled: Color::grey(0.9),
|
||||
outline: hex("#F2F2F2"),
|
||||
},
|
||||
btn_primary_destructive: ButtonStyle {
|
||||
fg: hex("#F2F2F2"),
|
||||
fg_disabled: hex("#F2F2F2").alpha(0.3),
|
||||
bg: hex("#FF5E5E").alpha(0.8),
|
||||
bg_hover: hex("#FF5E5E"),
|
||||
bg_disabled: Color::grey(0.1),
|
||||
outline: hex("#FF5E5E").alpha(0.6),
|
||||
},
|
||||
btn_secondary_destructive: ButtonStyle {
|
||||
fg: hex("#FF5E5E"),
|
||||
fg_disabled: hex("#FF5E5E").alpha(0.3),
|
||||
bg: Color::CLEAR,
|
||||
bg_hover: hex("#FF5E5E").alpha(0.1),
|
||||
bg_disabled: Color::grey(0.1),
|
||||
outline: hex("#FF5E5E"),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user