mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 08:24:15 +03:00
rethink rename... keep Style.ButtonStyle, rename button::ButtonStyle->ButtonStateStyle
This commit is contained in:
parent
e6ed2e67de
commit
dde3ca9f67
@ -392,9 +392,9 @@ impl ColorScheme {
|
||||
fn night_mode() -> ColorScheme {
|
||||
let mut cs = ColorScheme::day_mode();
|
||||
|
||||
use widgetry::ButtonTheme;
|
||||
cs.gui_style.btn_outline = ButtonTheme::btn_outline();
|
||||
cs.gui_style.btn_solid = ButtonTheme::btn_solid_panel();
|
||||
use widgetry::ButtonStyle;
|
||||
cs.gui_style.btn_outline = ButtonStyle::btn_outline();
|
||||
cs.gui_style.btn_solid = ButtonStyle::btn_solid_panel();
|
||||
cs.inner_panel_bg = cs.gui_style.panel_bg.alpha(1.0);
|
||||
|
||||
cs.void_background = hex("#200A24");
|
||||
|
@ -41,7 +41,7 @@ pub use crate::geom::{GeomBatch, RewriteColor};
|
||||
pub use crate::input::UserInput;
|
||||
pub use crate::runner::{run, Settings};
|
||||
pub use crate::screen_geom::{ScreenDims, ScreenPt, ScreenRectangle};
|
||||
pub use crate::style::{buttons::StyledButtons, ButtonTheme, Style};
|
||||
pub use crate::style::{buttons::StyledButtons, ButtonStyle, Style};
|
||||
pub use crate::text::{Font, Line, Text, TextExt, TextSpan};
|
||||
pub use crate::tools::warper::Warper;
|
||||
pub use crate::tools::Cached;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use geom::CornerRadii;
|
||||
|
||||
use super::ButtonTheme;
|
||||
use super::ButtonStyle;
|
||||
use crate::{
|
||||
include_labeled_bytes, ButtonBuilder, ControlState, EventCtx, Key, ScreenDims, Style, Widget,
|
||||
};
|
||||
@ -181,7 +181,7 @@ impl<'a> StyledButtons<'a> for Style {
|
||||
}
|
||||
|
||||
impl<'a> Style {
|
||||
pub fn btn_solid(&self, button_style: &ButtonTheme) -> ButtonBuilder<'a> {
|
||||
pub fn btn_solid(&self, button_style: &ButtonStyle) -> ButtonBuilder<'a> {
|
||||
plain_button(button_style).outline(
|
||||
self.outline_thickness,
|
||||
button_style.outline,
|
||||
@ -189,7 +189,7 @@ impl<'a> Style {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn btn_outline(&self, button_style: &ButtonTheme) -> ButtonBuilder<'a> {
|
||||
pub fn btn_outline(&self, button_style: &ButtonStyle) -> ButtonBuilder<'a> {
|
||||
plain_button(button_style).outline(
|
||||
self.outline_thickness,
|
||||
button_style.outline,
|
||||
@ -254,7 +254,7 @@ fn dropdown_button<'a>(builder: ButtonBuilder<'a>) -> ButtonBuilder<'a> {
|
||||
.label_first()
|
||||
}
|
||||
|
||||
pub fn plain_button<'a>(button_style: &ButtonTheme) -> ButtonBuilder<'a> {
|
||||
pub fn plain_button<'a>(button_style: &ButtonStyle) -> ButtonBuilder<'a> {
|
||||
ButtonBuilder::new()
|
||||
.label_color(button_style.fg, ControlState::Default)
|
||||
.label_color(button_style.fg_disabled, ControlState::Disabled)
|
||||
|
@ -9,17 +9,17 @@ pub struct Style {
|
||||
pub panel_bg: Color,
|
||||
pub hotkey_color: Color,
|
||||
pub loading_tips: Text,
|
||||
pub btn_solid_panel: ButtonTheme,
|
||||
pub btn_outline_dark: ButtonTheme,
|
||||
pub btn_solid_floating: ButtonTheme,
|
||||
pub btn_solid_destructive: ButtonTheme,
|
||||
pub btn_outline_destructive: ButtonTheme,
|
||||
pub btn_solid: ButtonTheme,
|
||||
pub btn_outline: ButtonTheme,
|
||||
pub btn_solid_panel: ButtonStyle,
|
||||
pub btn_outline_dark: ButtonStyle,
|
||||
pub btn_solid_floating: ButtonStyle,
|
||||
pub btn_solid_destructive: ButtonStyle,
|
||||
pub btn_outline_destructive: ButtonStyle,
|
||||
pub btn_solid: ButtonStyle,
|
||||
pub btn_outline: ButtonStyle,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ButtonTheme {
|
||||
pub struct ButtonStyle {
|
||||
pub fg: Color,
|
||||
pub fg_disabled: Color,
|
||||
pub outline: Color,
|
||||
@ -28,9 +28,9 @@ pub struct ButtonTheme {
|
||||
pub bg_disabled: Color,
|
||||
}
|
||||
|
||||
impl ButtonTheme {
|
||||
impl ButtonStyle {
|
||||
pub fn btn_solid_panel() -> Self {
|
||||
ButtonTheme {
|
||||
ButtonStyle {
|
||||
fg: hex("#4C4C4C"),
|
||||
fg_disabled: hex("#4C4C4C").alpha(0.3),
|
||||
bg: Color::WHITE.alpha(0.8),
|
||||
@ -41,7 +41,7 @@ impl ButtonTheme {
|
||||
}
|
||||
|
||||
pub fn btn_outline_dark() -> Self {
|
||||
ButtonTheme {
|
||||
ButtonStyle {
|
||||
fg: hex("#4C4C4C"),
|
||||
fg_disabled: hex("#4C4C4C").alpha(0.3),
|
||||
bg: Color::CLEAR,
|
||||
@ -52,7 +52,7 @@ impl ButtonTheme {
|
||||
}
|
||||
|
||||
pub fn btn_solid_floating() -> Self {
|
||||
ButtonTheme {
|
||||
ButtonStyle {
|
||||
fg: hex("#F2F2F2"),
|
||||
fg_disabled: hex("#F2F2F2").alpha(0.3),
|
||||
bg: hex("#003046").alpha(0.8),
|
||||
@ -63,7 +63,7 @@ impl ButtonTheme {
|
||||
}
|
||||
|
||||
pub fn btn_outline() -> Self {
|
||||
ButtonTheme {
|
||||
ButtonStyle {
|
||||
fg: hex("#F2F2F2"),
|
||||
fg_disabled: hex("#F2F2F2").alpha(0.3),
|
||||
bg: Color::CLEAR,
|
||||
@ -87,18 +87,18 @@ impl Style {
|
||||
|
||||
// TODO: light/dark are color scheme details that have leaked into Style
|
||||
// deprecate these and assign the specific colors we want in the color scheme builder
|
||||
btn_solid_panel: ButtonTheme::btn_solid_panel(),
|
||||
btn_outline_dark: ButtonTheme::btn_outline_dark(),
|
||||
btn_solid_floating: ButtonTheme::btn_solid_floating(),
|
||||
btn_solid_panel: ButtonStyle::btn_solid_panel(),
|
||||
btn_outline_dark: ButtonStyle::btn_outline_dark(),
|
||||
btn_solid_floating: ButtonStyle::btn_solid_floating(),
|
||||
|
||||
// legacy day theme
|
||||
btn_outline: ButtonTheme::btn_outline(),
|
||||
btn_solid: ButtonTheme::btn_solid_panel(),
|
||||
btn_outline: ButtonStyle::btn_outline(),
|
||||
btn_solid: ButtonStyle::btn_solid_panel(),
|
||||
|
||||
// TODO new day theme
|
||||
// btn_solid: ButtonTheme::btn_solid_floating(),
|
||||
// btn_outline: ButtonTheme::btn_outline_dark(),
|
||||
btn_solid_destructive: ButtonTheme {
|
||||
// btn_solid: ButtonStyle::btn_solid_floating(),
|
||||
// btn_outline: ButtonStyle::btn_outline_dark(),
|
||||
btn_solid_destructive: ButtonStyle {
|
||||
fg: hex("#F2F2F2"),
|
||||
fg_disabled: hex("#F2F2F2").alpha(0.3),
|
||||
bg: hex("#FF5E5E").alpha(0.8),
|
||||
@ -106,7 +106,7 @@ impl Style {
|
||||
bg_disabled: Color::grey(0.1),
|
||||
outline: hex("#FF5E5E").alpha(0.6),
|
||||
},
|
||||
btn_outline_destructive: ButtonTheme {
|
||||
btn_outline_destructive: ButtonStyle {
|
||||
fg: hex("#FF5E5E"),
|
||||
fg_disabled: hex("#FF5E5E").alpha(0.3),
|
||||
bg: Color::CLEAR,
|
||||
|
@ -136,13 +136,13 @@ pub struct ButtonBuilder<'a> {
|
||||
is_label_before_image: bool,
|
||||
corner_rounding: Option<CornerRounding>,
|
||||
is_disabled: bool,
|
||||
default_style: ButtonStyle<'a>,
|
||||
hover_style: ButtonStyle<'a>,
|
||||
disable_style: ButtonStyle<'a>,
|
||||
default_style: ButtonStateStyle<'a>,
|
||||
hover_style: ButtonStateStyle<'a>,
|
||||
disable_style: ButtonStateStyle<'a>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct ButtonStyle<'a> {
|
||||
struct ButtonStateStyle<'a> {
|
||||
image: Option<Image<'a>>,
|
||||
label: Option<Label<'a>>,
|
||||
outline: Option<(f64, Color)>,
|
||||
@ -526,7 +526,7 @@ impl<'b, 'a: 'b> ButtonBuilder<'a> {
|
||||
|
||||
// private methods
|
||||
|
||||
fn style_mut(&'b mut self, state: ControlState) -> &'b mut ButtonStyle<'a> {
|
||||
fn style_mut(&'b mut self, state: ControlState) -> &'b mut ButtonStateStyle<'a> {
|
||||
match state {
|
||||
ControlState::Default => &mut self.default_style,
|
||||
ControlState::Hovered => &mut self.hover_style,
|
||||
@ -534,7 +534,7 @@ impl<'b, 'a: 'b> ButtonBuilder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn style(&'b self, state: ControlState) -> &'b ButtonStyle<'a> {
|
||||
fn style(&'b self, state: ControlState) -> &'b ButtonStateStyle<'a> {
|
||||
match state {
|
||||
ControlState::Default => &self.default_style,
|
||||
ControlState::Hovered => &self.hover_style,
|
||||
|
Loading…
Reference in New Issue
Block a user