Skip to content

Commit

Permalink
fixed highlighted text and minor palettes improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Aug 6, 2023
1 parent 5004407 commit a344376
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
5 changes: 1 addition & 4 deletions src/gui/styles/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl button::StyleSheet for ButtonStyleTuple {
let colors = get_colors(self.0);
button::Appearance {
background: Some(match self {
ButtonStyleTuple(_, ButtonType::TabActive) => {
ButtonStyleTuple(_, ButtonType::TabActive | ButtonType::BorderedRoundSelected) => {
Background::Color(mix_colors(colors.primary, colors.buttons))
}
ButtonStyleTuple(_, ButtonType::Starred) => {
Expand All @@ -59,9 +59,6 @@ impl button::StyleSheet for ButtonStyleTuple {
ButtonStyleTuple(_, ButtonType::Neutral | ButtonType::NotStarred) => {
Background::Color(Color::TRANSPARENT)
}
ButtonStyleTuple(_, ButtonType::BorderedRoundSelected) => {
Background::Color(mix_colors(colors.primary, colors.buttons))
}
ButtonStyleTuple(_, ButtonType::Gradient(GradientType::None)) => {
Background::Color(colors.secondary)
}
Expand Down
21 changes: 7 additions & 14 deletions src/gui/styles/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use iced::widget::{Column, Text};
use iced::Color;

use crate::gui::styles::style_constants::get_font;
use crate::gui::styles::types::palette::Palette;
use crate::gui::types::message::Message;
use crate::{get_colors, StyleType};

Expand Down Expand Up @@ -38,21 +37,19 @@ pub struct TextStyleTuple(pub StyleType, pub TextType);

impl From<TextStyleTuple> for iced::theme::Text {
fn from(tuple: TextStyleTuple) -> Self {
let colors = get_colors(tuple.0);
iced::theme::Text::Color(highlight(tuple.1, &colors))
//let colors = get_colors(tuple.0);
iced::theme::Text::Color(highlight(tuple.0, tuple.1))
}
}

/// Returns the weighted average of two colors; color intensity is fixed to 100%
pub fn highlight(element: TextType, colors: &Palette) -> Color {
pub fn highlight(style: StyleType, element: TextType) -> Color {
let colors = get_colors(style);
let color = colors.secondary;
let is_nightly = style.is_nightly();
match element {
TextType::Title => {
let (p1, c) = if colors.text_body.eq(&Color::BLACK) {
(0.9, 0.7)
} else {
(0.6, 1.0)
};
let (p1, c) = if is_nightly { (0.6, 1.0) } else { (0.9, 0.7) };
Color {
r: c * (1.0 - p1) + color.r * p1,
g: c * (1.0 - p1) + color.g * p1,
Expand All @@ -61,11 +58,7 @@ pub fn highlight(element: TextType, colors: &Palette) -> Color {
}
}
TextType::Subtitle => {
let (p1, c) = if colors.text_body.eq(&Color::BLACK) {
(0.6, 0.7)
} else {
(0.4, 1.0)
};
let (p1, c) = if is_nightly { (0.4, 1.0) } else { (0.6, 0.7) };
Color {
r: c * (1.0 - p1) + color.r * p1,
g: c * (1.0 - p1) + color.g * p1,
Expand Down
6 changes: 3 additions & 3 deletions src/gui/styles/types/custom_styles/gruvbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ pub(super) fn gruvbox_light() -> CustomPalette {
text_body: color!(0x282828), // fg
},
extension: PaletteExtension {
starred: color!(0xd79921), // yellow
starred: color!(0xd79921, 0.8), // yellow
chart_badge_alpha: 0.75,
round_borders_alpha: 0.4,
round_containers_alpha: 0.15,
round_borders_alpha: 0.45,
round_containers_alpha: 0.2,
},
}
}
2 changes: 1 addition & 1 deletion src/gui/styles/types/custom_styles/nord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub(super) fn nord_day() -> CustomPalette {
primary: color!(0xeceff4), // nord6
secondary: color!(0x05e81ac), // nord10
outgoing: color!(0xb48ead), // nord15
buttons: color!(0xd8dee9), // nord4
buttons: color!(0x8FBCBB), // nord7
text_headers: color!(0xeceff4), // nord6
text_body: color!(0x2e3440), // nord0
},
Expand Down
4 changes: 2 additions & 2 deletions src/gui/styles/types/custom_styles/solarized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub(super) fn solarized_light() -> CustomPalette {
CustomPalette {
palette: Palette {
primary: color!(0xfdf6e3), // base3
secondary: color!(0xdc322f), // red
outgoing: color!(0x859900), // green
secondary: color!(0x859900), // green
outgoing: color!(0x268bd2), // blue
buttons: color!(0x93a1a1), // base1
text_headers: color!(0xfdf6e3), // base3
text_body: color!(0x002b36), // base03
Expand Down

0 comments on commit a344376

Please sign in to comment.