btn_solid_panel is the same as btn_solid

This commit is contained in:
Michael Kirk 2021-02-23 10:17:32 -08:00
parent dde3ca9f67
commit 62a433ed8d
6 changed files with 42 additions and 68 deletions

View File

@ -700,20 +700,13 @@ fn make_tabs(
// We use "disabled" to denote "currently selected", but we want to style it like
// normal
.disabled(current_tab.variant() == link.variant())
.bg_color(ctx.style().btn_solid_panel.bg, ControlState::Disabled)
.label_color(ctx.style().btn_solid_panel.fg, ControlState::Disabled)
.outline(
2.0,
ctx.style().btn_solid_panel.bg_hover,
ControlState::Disabled,
)
.bg_color(ctx.style().btn_solid.bg, ControlState::Disabled)
.label_color(ctx.style().btn_solid.fg, ControlState::Disabled)
.outline(2.0, ctx.style().btn_solid.bg_hover, ControlState::Disabled)
// Hide the hit area for selectable tabs unless hovered
.bg_color(Color::CLEAR, ControlState::Default)
.outline(0.0, Color::CLEAR, ControlState::Default)
.bg_color(
ctx.style().btn_solid_panel.bg.alpha(0.6),
ControlState::Hovered,
)
.bg_color(ctx.style().btn_solid.bg.alpha(0.6), ControlState::Hovered)
.build_def(ctx),
);
hyperlinks.insert(name.to_string(), link);

View File

@ -100,7 +100,7 @@ impl MainMenu {
Widget::row({
let btn_builder = ctx
.style()
.btn_solid_panel()
.btn_solid()
.image_dims(ScreenDims::new(200.0, 100.0))
.font_size(40)
.font(Font::OverpassBold)

View File

@ -394,7 +394,7 @@ impl ColorScheme {
use widgetry::ButtonStyle;
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.void_background = hex("#200A24");

View File

@ -6,12 +6,6 @@ use crate::{
};
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_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.btn_plain().label_text(text)
@ -44,6 +38,8 @@ pub trait StyledButtons<'a> {
}
fn btn_solid(&self) -> ButtonBuilder<'a>;
fn btn_solid_floating(&self) -> ButtonBuilder<'a>;
fn btn_solid_text(&self, text: &'a str) -> ButtonBuilder<'a> {
self.btn_solid().label_text(text)
}
@ -147,56 +143,36 @@ pub trait StyledButtons<'a> {
}
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> {
self.btn_solid(&self.btn_solid)
basic_button(&self.btn_solid, Some(self.outline_thickness))
}
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> {
plain_button(&self.btn_outline)
basic_button(&self.btn_outline, None)
}
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> {
self.btn_solid(&self.btn_solid_destructive)
basic_button(&self.btn_solid_destructive, Some(self.outline_thickness))
}
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 {
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(
&self,
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"
// button.
self.btn_outline(outline_style)
basic_button(outline_style, Some(self.outline_thickness))
.label_text(text)
.image_path(icon_path)
.image_dims(25.0)
@ -254,13 +230,26 @@ fn dropdown_button<'a>(builder: ButtonBuilder<'a>) -> ButtonBuilder<'a> {
.label_first()
}
pub fn plain_button<'a>(button_style: &ButtonStyle) -> ButtonBuilder<'a> {
ButtonBuilder::new()
fn basic_button<'a>(
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_disabled, ControlState::Disabled)
.image_color(button_style.fg, ControlState::Default)
.image_color(button_style.fg_disabled, ControlState::Disabled)
.bg_color(button_style.bg, ControlState::Default)
.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
}
}

View File

@ -9,13 +9,11 @@ pub struct Style {
pub panel_bg: Color,
pub hotkey_color: Color,
pub loading_tips: Text,
pub btn_solid_panel: ButtonStyle,
pub btn_outline_dark: ButtonStyle,
pub btn_solid: ButtonStyle,
pub btn_outline: 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)]
@ -29,7 +27,7 @@ pub struct ButtonStyle {
}
impl ButtonStyle {
pub fn btn_solid_panel() -> Self {
pub fn btn_solid() -> Self {
ButtonStyle {
fg: hex("#4C4C4C"),
fg_disabled: hex("#4C4C4C").alpha(0.3),
@ -84,17 +82,11 @@ impl Style {
loading_tips: Text::new(),
// 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(),
// legacy day theme
btn_outline: ButtonStyle::btn_outline(),
btn_solid: ButtonStyle::btn_solid_panel(),
btn_solid: ButtonStyle::btn_solid(),
// TODO new day theme
// btn_solid: ButtonStyle::btn_solid_floating(),
// btn_outline: ButtonStyle::btn_outline_dark(),

View File

@ -2,7 +2,8 @@ use geom::Polygon;
use crate::{
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
@ -69,9 +70,8 @@ impl<T: 'static + PartialEq + Clone + std::fmt::Debug> PersistentSplit<T> {
}
fn button_builder<'a>(ctx: &EventCtx) -> ButtonBuilder<'a> {
let outline_style = &ctx.style().btn_outline;
ctx.style()
.btn_outline(outline_style)
.btn_plain()
.outline(0.0, Color::CLEAR, ControlState::Default)
}