diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-10-07 17:40:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 17:40:50 +0300 |
commit | 67db9b228d3b6c63484ca4b8fcae577afc0ee22a (patch) | |
tree | 52e2640140a4786f42d6ac6cf6f081c6dd9b21a2 /alacritty/src/wayland_theme.rs | |
parent | 44a6dba0af03d3b9305ceea31c3289709cc750e3 (diff) | |
download | r-alacritty-67db9b228d3b6c63484ca4b8fcae577afc0ee22a.tar.gz r-alacritty-67db9b228d3b6c63484ca4b8fcae577afc0ee22a.tar.bz2 r-alacritty-67db9b228d3b6c63484ca4b8fcae577afc0ee22a.zip |
Bump glutin to 0.25.0
Fixes #4206.
Fixes #4162.
Fixes #4017.
Fixes #3998.
Fixes #3831.
Fixes #3782.
Fixes #3708.
Fixes #2734.
Fixes #2714.
Fixes #1801.
Diffstat (limited to 'alacritty/src/wayland_theme.rs')
-rw-r--r-- | alacritty/src/wayland_theme.rs | 100 |
1 files changed, 49 insertions, 51 deletions
diff --git a/alacritty/src/wayland_theme.rs b/alacritty/src/wayland_theme.rs index b1d4b44c..b9c4381e 100644 --- a/alacritty/src/wayland_theme.rs +++ b/alacritty/src/wayland_theme.rs @@ -1,26 +1,30 @@ -use glutin::platform::unix::{ButtonState, Theme as WaylandTheme}; +use glutin::platform::unix::{ARGBColor, Button, ButtonState, Element, Theme as WaylandTheme}; use alacritty_terminal::config::Colors; -use alacritty_terminal::term::color::{Rgb, DIM_FACTOR}; +use alacritty_terminal::term::color::Rgb; + +const INACTIVE_OPACITY: u8 = 127; #[derive(Debug, Clone)] pub struct AlacrittyWaylandTheme { - pub background: Rgb, - pub foreground: Rgb, - pub dim_foreground: Rgb, - pub hovered_close_icon: Rgb, - pub hovered_maximize_icon: Rgb, - pub hovered_minimize_icon: Rgb, + pub background: ARGBColor, + pub foreground: ARGBColor, + pub dim_foreground: ARGBColor, + pub hovered_close_icon: ARGBColor, + pub hovered_maximize_icon: ARGBColor, + pub hovered_minimize_icon: ARGBColor, } impl AlacrittyWaylandTheme { pub fn new(colors: &Colors) -> Self { - let hovered_close_icon = colors.normal().red; - let hovered_maximize_icon = colors.normal().green; - let hovered_minimize_icon = colors.normal().yellow; - let foreground = colors.primary.foreground; - let background = colors.primary.background; - let dim_foreground = colors.primary.dim_foreground.unwrap_or(foreground * DIM_FACTOR); + let hovered_close_icon = colors.normal().red.into_rgba(); + let hovered_maximize_icon = colors.normal().green.into_rgba(); + let hovered_minimize_icon = colors.normal().yellow.into_rgba(); + let foreground = colors.search_bar_foreground().into_rgba(); + let background = colors.search_bar_background().into_rgba(); + + let mut dim_foreground = foreground; + dim_foreground.a = INACTIVE_OPACITY; Self { foreground, @@ -31,52 +35,46 @@ impl AlacrittyWaylandTheme { hovered_maximize_icon, } } - - fn color_icon_color(&self, color: Rgb, status: ButtonState) -> [u8; 4] { - match status { - ButtonState::Hovered => [0xff, color.r, color.g, color.b], - ButtonState::Idle => [0xff, self.foreground.r, self.foreground.g, self.foreground.b], - ButtonState::Disabled => { - [0xff, self.dim_foreground.r, self.dim_foreground.g, self.dim_foreground.b] - }, - } - } } impl WaylandTheme for AlacrittyWaylandTheme { - fn primary_color(&self, _window_active: bool) -> [u8; 4] { - [0xff, self.background.r, self.background.g, self.background.b] - } - - fn secondary_color(&self, window_active: bool) -> [u8; 4] { - if window_active { - [0xff, self.foreground.r, self.foreground.g, self.foreground.b] - } else { - [0xff, self.dim_foreground.r, self.dim_foreground.g, self.dim_foreground.b] + fn element_color(&self, element: Element, window_active: bool) -> ARGBColor { + match element { + Element::Bar | Element::Separator => self.background, + Element::Text if window_active => self.foreground, + Element::Text => self.dim_foreground, } } - fn close_button_color(&self, _status: ButtonState) -> [u8; 4] { - [0x00, self.background.r, self.background.g, self.background.b] - } - - fn close_button_icon_color(&self, status: ButtonState) -> [u8; 4] { - self.color_icon_color(self.hovered_close_icon, status) - } - - fn maximize_button_color(&self, _status: ButtonState) -> [u8; 4] { - [0x00, self.background.r, self.background.g, self.background.b] - } + fn button_color( + &self, + button: Button, + state: ButtonState, + foreground: bool, + window_active: bool, + ) -> ARGBColor { + if !foreground { + return ARGBColor { a: 0, r: 0, g: 0, b: 0 }; + } else if !window_active { + return self.dim_foreground; + } - fn maximize_button_icon_color(&self, status: ButtonState) -> [u8; 4] { - self.color_icon_color(self.hovered_maximize_icon, status) + match (state, button) { + (ButtonState::Idle, _) => self.foreground, + (ButtonState::Disabled, _) => self.dim_foreground, + (_, Button::Minimize) => self.hovered_minimize_icon, + (_, Button::Maximize) => self.hovered_maximize_icon, + (_, Button::Close) => self.hovered_close_icon, + } } +} - fn minimize_button_color(&self, _status: ButtonState) -> [u8; 4] { - [0x00, self.background.r, self.background.g, self.background.b] - } +trait IntoARGBColor { + fn into_rgba(self) -> ARGBColor; +} - fn minimize_button_icon_color(&self, status: ButtonState) -> [u8; 4] { - self.color_icon_color(self.hovered_minimize_icon, status) +impl IntoARGBColor for Rgb { + fn into_rgba(self) -> ARGBColor { + ARGBColor { a: 0xff, r: self.r, g: self.g, b: self.b } } } |