mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
btn_solid_panel is the same as btn_solid
This commit is contained in:
parent
dde3ca9f67
commit
62a433ed8d
@ -700,20 +700,13 @@ fn make_tabs(
|
|||||||
// We use "disabled" to denote "currently selected", but we want to style it like
|
// We use "disabled" to denote "currently selected", but we want to style it like
|
||||||
// normal
|
// normal
|
||||||
.disabled(current_tab.variant() == link.variant())
|
.disabled(current_tab.variant() == link.variant())
|
||||||
.bg_color(ctx.style().btn_solid_panel.bg, ControlState::Disabled)
|
.bg_color(ctx.style().btn_solid.bg, ControlState::Disabled)
|
||||||
.label_color(ctx.style().btn_solid_panel.fg, ControlState::Disabled)
|
.label_color(ctx.style().btn_solid.fg, ControlState::Disabled)
|
||||||
.outline(
|
.outline(2.0, ctx.style().btn_solid.bg_hover, ControlState::Disabled)
|
||||||
2.0,
|
|
||||||
ctx.style().btn_solid_panel.bg_hover,
|
|
||||||
ControlState::Disabled,
|
|
||||||
)
|
|
||||||
// Hide the hit area for selectable tabs unless hovered
|
// Hide the hit area for selectable tabs unless hovered
|
||||||
.bg_color(Color::CLEAR, ControlState::Default)
|
.bg_color(Color::CLEAR, ControlState::Default)
|
||||||
.outline(0.0, Color::CLEAR, ControlState::Default)
|
.outline(0.0, Color::CLEAR, ControlState::Default)
|
||||||
.bg_color(
|
.bg_color(ctx.style().btn_solid.bg.alpha(0.6), ControlState::Hovered)
|
||||||
ctx.style().btn_solid_panel.bg.alpha(0.6),
|
|
||||||
ControlState::Hovered,
|
|
||||||
)
|
|
||||||
.build_def(ctx),
|
.build_def(ctx),
|
||||||
);
|
);
|
||||||
hyperlinks.insert(name.to_string(), link);
|
hyperlinks.insert(name.to_string(), link);
|
||||||
|
@ -100,7 +100,7 @@ impl MainMenu {
|
|||||||
Widget::row({
|
Widget::row({
|
||||||
let btn_builder = ctx
|
let btn_builder = ctx
|
||||||
.style()
|
.style()
|
||||||
.btn_solid_panel()
|
.btn_solid()
|
||||||
.image_dims(ScreenDims::new(200.0, 100.0))
|
.image_dims(ScreenDims::new(200.0, 100.0))
|
||||||
.font_size(40)
|
.font_size(40)
|
||||||
.font(Font::OverpassBold)
|
.font(Font::OverpassBold)
|
||||||
|
@ -394,7 +394,7 @@ impl ColorScheme {
|
|||||||
|
|
||||||
use widgetry::ButtonStyle;
|
use widgetry::ButtonStyle;
|
||||||
cs.gui_style.btn_outline = ButtonStyle::btn_outline();
|
cs.gui_style.btn_outline = ButtonStyle::btn_outline();
|
||||||
cs.gui_style.btn_solid = ButtonStyle::btn_solid_panel();
|
cs.gui_style.btn_solid = ButtonStyle::btn_solid();
|
||||||
cs.inner_panel_bg = cs.gui_style.panel_bg.alpha(1.0);
|
cs.inner_panel_bg = cs.gui_style.panel_bg.alpha(1.0);
|
||||||
|
|
||||||
cs.void_background = hex("#200A24");
|
cs.void_background = hex("#200A24");
|
||||||
|
@ -6,12 +6,6 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub trait StyledButtons<'a> {
|
pub trait StyledButtons<'a> {
|
||||||
// Everything above this is deprecated and should be replaced with a call to a method
|
|
||||||
// which chooses a light vs. dark button as is appropriate for the theme. However, we can't
|
|
||||||
// "just" do this without breaking some current layouts.
|
|
||||||
fn btn_solid_panel(&self) -> ButtonBuilder<'a>;
|
|
||||||
fn btn_solid_floating(&self) -> ButtonBuilder<'a>;
|
|
||||||
|
|
||||||
fn btn_plain(&self) -> ButtonBuilder<'a>;
|
fn btn_plain(&self) -> ButtonBuilder<'a>;
|
||||||
fn btn_plain_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
fn btn_plain_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
||||||
self.btn_plain().label_text(text)
|
self.btn_plain().label_text(text)
|
||||||
@ -44,6 +38,8 @@ pub trait StyledButtons<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn btn_solid(&self) -> ButtonBuilder<'a>;
|
fn btn_solid(&self) -> ButtonBuilder<'a>;
|
||||||
|
fn btn_solid_floating(&self) -> ButtonBuilder<'a>;
|
||||||
|
|
||||||
fn btn_solid_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
fn btn_solid_text(&self, text: &'a str) -> ButtonBuilder<'a> {
|
||||||
self.btn_solid().label_text(text)
|
self.btn_solid().label_text(text)
|
||||||
}
|
}
|
||||||
@ -147,56 +143,36 @@ pub trait StyledButtons<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StyledButtons<'a> for Style {
|
impl<'a> StyledButtons<'a> for Style {
|
||||||
fn btn_solid_panel(&self) -> ButtonBuilder<'a> {
|
|
||||||
self.btn_solid(&self.btn_solid_panel)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn btn_solid_floating(&self) -> ButtonBuilder<'a> {
|
|
||||||
self.btn_solid(&self.btn_solid_floating)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn btn_solid(&self) -> ButtonBuilder<'a> {
|
fn btn_solid(&self) -> ButtonBuilder<'a> {
|
||||||
self.btn_solid(&self.btn_solid)
|
basic_button(&self.btn_solid, Some(self.outline_thickness))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn btn_outline(&self) -> ButtonBuilder<'a> {
|
fn btn_outline(&self) -> ButtonBuilder<'a> {
|
||||||
self.btn_outline(&self.btn_outline)
|
basic_button(&self.btn_outline, Some(self.outline_thickness))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn btn_solid_floating(&self) -> ButtonBuilder<'a> {
|
||||||
|
basic_button(&self.btn_solid_floating, Some(self.outline_thickness))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn btn_plain(&self) -> ButtonBuilder<'a> {
|
fn btn_plain(&self) -> ButtonBuilder<'a> {
|
||||||
plain_button(&self.btn_outline)
|
basic_button(&self.btn_outline, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn btn_plain_destructive(&self) -> ButtonBuilder<'a> {
|
fn btn_plain_destructive(&self) -> ButtonBuilder<'a> {
|
||||||
plain_button(&self.btn_outline_destructive)
|
basic_button(&self.btn_outline_destructive, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn btn_solid_destructive(&self) -> ButtonBuilder<'a> {
|
fn btn_solid_destructive(&self) -> ButtonBuilder<'a> {
|
||||||
self.btn_solid(&self.btn_solid_destructive)
|
basic_button(&self.btn_solid_destructive, Some(self.outline_thickness))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn btn_outline_destructive(&self) -> ButtonBuilder<'a> {
|
fn btn_outline_destructive(&self) -> ButtonBuilder<'a> {
|
||||||
self.btn_outline(&self.btn_solid_destructive)
|
basic_button(&self.btn_solid_destructive, Some(self.outline_thickness))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Style {
|
impl<'a> Style {
|
||||||
pub fn btn_solid(&self, button_style: &ButtonStyle) -> ButtonBuilder<'a> {
|
|
||||||
plain_button(button_style).outline(
|
|
||||||
self.outline_thickness,
|
|
||||||
button_style.outline,
|
|
||||||
ControlState::Default,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn btn_outline(&self, button_style: &ButtonStyle) -> ButtonBuilder<'a> {
|
|
||||||
plain_button(button_style).outline(
|
|
||||||
self.outline_thickness,
|
|
||||||
button_style.outline,
|
|
||||||
ControlState::Default,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn btn_light_popup_icon_text(
|
pub fn btn_light_popup_icon_text(
|
||||||
&self,
|
&self,
|
||||||
icon_path: &'a str,
|
icon_path: &'a str,
|
||||||
@ -207,7 +183,7 @@ impl<'a> Style {
|
|||||||
|
|
||||||
// The text is styled like an "outline" button, while the image is styled like a "solid"
|
// The text is styled like an "outline" button, while the image is styled like a "solid"
|
||||||
// button.
|
// button.
|
||||||
self.btn_outline(outline_style)
|
basic_button(outline_style, Some(self.outline_thickness))
|
||||||
.label_text(text)
|
.label_text(text)
|
||||||
.image_path(icon_path)
|
.image_path(icon_path)
|
||||||
.image_dims(25.0)
|
.image_dims(25.0)
|
||||||
@ -254,13 +230,26 @@ fn dropdown_button<'a>(builder: ButtonBuilder<'a>) -> ButtonBuilder<'a> {
|
|||||||
.label_first()
|
.label_first()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn plain_button<'a>(button_style: &ButtonStyle) -> ButtonBuilder<'a> {
|
fn basic_button<'a>(
|
||||||
ButtonBuilder::new()
|
button_style: &ButtonStyle,
|
||||||
|
outline_thickness: Option<f64>,
|
||||||
|
) -> ButtonBuilder<'a> {
|
||||||
|
let mut builder = ButtonBuilder::new()
|
||||||
.label_color(button_style.fg, ControlState::Default)
|
.label_color(button_style.fg, ControlState::Default)
|
||||||
.label_color(button_style.fg_disabled, ControlState::Disabled)
|
.label_color(button_style.fg_disabled, ControlState::Disabled)
|
||||||
.image_color(button_style.fg, ControlState::Default)
|
.image_color(button_style.fg, ControlState::Default)
|
||||||
.image_color(button_style.fg_disabled, ControlState::Disabled)
|
.image_color(button_style.fg_disabled, ControlState::Disabled)
|
||||||
.bg_color(button_style.bg, ControlState::Default)
|
.bg_color(button_style.bg, ControlState::Default)
|
||||||
.bg_color(button_style.bg_hover, ControlState::Hovered)
|
.bg_color(button_style.bg_hover, ControlState::Hovered)
|
||||||
.bg_color(button_style.bg_disabled, ControlState::Disabled)
|
.bg_color(button_style.bg_disabled, ControlState::Disabled);
|
||||||
|
|
||||||
|
if let Some(outline_thickness) = outline_thickness {
|
||||||
|
builder.outline(
|
||||||
|
outline_thickness,
|
||||||
|
button_style.outline,
|
||||||
|
ControlState::Default,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
builder
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,11 @@ pub struct Style {
|
|||||||
pub panel_bg: Color,
|
pub panel_bg: Color,
|
||||||
pub hotkey_color: Color,
|
pub hotkey_color: Color,
|
||||||
pub loading_tips: Text,
|
pub loading_tips: Text,
|
||||||
pub btn_solid_panel: ButtonStyle,
|
pub btn_solid: ButtonStyle,
|
||||||
pub btn_outline_dark: ButtonStyle,
|
pub btn_outline: ButtonStyle,
|
||||||
pub btn_solid_floating: ButtonStyle,
|
pub btn_solid_floating: ButtonStyle,
|
||||||
pub btn_solid_destructive: ButtonStyle,
|
pub btn_solid_destructive: ButtonStyle,
|
||||||
pub btn_outline_destructive: ButtonStyle,
|
pub btn_outline_destructive: ButtonStyle,
|
||||||
pub btn_solid: ButtonStyle,
|
|
||||||
pub btn_outline: ButtonStyle,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -29,7 +27,7 @@ pub struct ButtonStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ButtonStyle {
|
impl ButtonStyle {
|
||||||
pub fn btn_solid_panel() -> Self {
|
pub fn btn_solid() -> Self {
|
||||||
ButtonStyle {
|
ButtonStyle {
|
||||||
fg: hex("#4C4C4C"),
|
fg: hex("#4C4C4C"),
|
||||||
fg_disabled: hex("#4C4C4C").alpha(0.3),
|
fg_disabled: hex("#4C4C4C").alpha(0.3),
|
||||||
@ -84,17 +82,11 @@ impl Style {
|
|||||||
loading_tips: Text::new(),
|
loading_tips: Text::new(),
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
|
|
||||||
// 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: ButtonStyle::btn_solid_panel(),
|
|
||||||
btn_outline_dark: ButtonStyle::btn_outline_dark(),
|
|
||||||
btn_solid_floating: ButtonStyle::btn_solid_floating(),
|
btn_solid_floating: ButtonStyle::btn_solid_floating(),
|
||||||
|
|
||||||
// legacy day theme
|
// legacy day theme
|
||||||
btn_outline: ButtonStyle::btn_outline(),
|
btn_outline: ButtonStyle::btn_outline(),
|
||||||
btn_solid: ButtonStyle::btn_solid_panel(),
|
btn_solid: ButtonStyle::btn_solid(),
|
||||||
|
|
||||||
// TODO new day theme
|
// TODO new day theme
|
||||||
// btn_solid: ButtonStyle::btn_solid_floating(),
|
// btn_solid: ButtonStyle::btn_solid_floating(),
|
||||||
// btn_outline: ButtonStyle::btn_outline_dark(),
|
// btn_outline: ButtonStyle::btn_outline_dark(),
|
||||||
|
@ -2,7 +2,8 @@ use geom::Polygon;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Button, ButtonBuilder, Choice, Color, ControlState, Dropdown, EventCtx, GeomBatch, GfxCtx,
|
Button, ButtonBuilder, Choice, Color, ControlState, Dropdown, EventCtx, GeomBatch, GfxCtx,
|
||||||
JustDraw, MultiKey, Outcome, ScreenDims, ScreenPt, Widget, WidgetImpl, WidgetOutput,
|
JustDraw, MultiKey, Outcome, ScreenDims, ScreenPt, StyledButtons, Widget, WidgetImpl,
|
||||||
|
WidgetOutput,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO Radio buttons in the menu
|
// TODO Radio buttons in the menu
|
||||||
@ -69,9 +70,8 @@ impl<T: 'static + PartialEq + Clone + std::fmt::Debug> PersistentSplit<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn button_builder<'a>(ctx: &EventCtx) -> ButtonBuilder<'a> {
|
fn button_builder<'a>(ctx: &EventCtx) -> ButtonBuilder<'a> {
|
||||||
let outline_style = &ctx.style().btn_outline;
|
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_outline(outline_style)
|
.btn_plain()
|
||||||
.outline(0.0, Color::CLEAR, ControlState::Default)
|
.outline(0.0, Color::CLEAR, ControlState::Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user