aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/wayland_theme.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2021-01-24 21:45:36 +0000
committerGitHub <noreply@github.com>2021-01-24 21:45:36 +0000
commit530de00049c2afcc562d36ccdb3e6afa2fe396a5 (patch)
tree3dabbcef3fc4a2041f9027d82243aa0d70928153 /alacritty/src/wayland_theme.rs
parent7291702f6b4fff10f2470f084abe0785b95659a0 (diff)
downloadr-alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.tar.gz
r-alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.tar.bz2
r-alacritty-530de00049c2afcc562d36ccdb3e6afa2fe396a5.zip
Move renderable cell transformation to alacritty
This refactors a large chunk of the alacritty_terminal API to expose all data necessary for rendering uniformly through the `renderable_content` call. This also no longer transforms the cells for rendering by a GUI but instead just reports the content from a terminal emulation perspective. The transformation into renderable cells is now done inside the alacritty crate. Since the terminal itself only ever needs to know about modified color RGB values, the configuration for colors was moved to the alacritty UI code.
Diffstat (limited to 'alacritty/src/wayland_theme.rs')
-rw-r--r--alacritty/src/wayland_theme.rs80
1 files changed, 0 insertions, 80 deletions
diff --git a/alacritty/src/wayland_theme.rs b/alacritty/src/wayland_theme.rs
deleted file mode 100644
index 5d3bd922..00000000
--- a/alacritty/src/wayland_theme.rs
+++ /dev/null
@@ -1,80 +0,0 @@
-use glutin::platform::unix::{ARGBColor, Button, ButtonState, Element, Theme as WaylandTheme};
-
-use alacritty_terminal::config::Colors;
-use alacritty_terminal::term::color::Rgb;
-
-const INACTIVE_OPACITY: u8 = 127;
-
-#[derive(Debug, Clone)]
-pub struct AlacrittyWaylandTheme {
- 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.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,
- background,
- dim_foreground,
- hovered_close_icon,
- hovered_minimize_icon,
- hovered_maximize_icon,
- }
- }
-}
-
-impl WaylandTheme for AlacrittyWaylandTheme {
- 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 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;
- }
-
- 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,
- }
- }
-}
-
-trait IntoARGBColor {
- fn into_rgba(self) -> ARGBColor;
-}
-
-impl IntoARGBColor for Rgb {
- fn into_rgba(self) -> ARGBColor {
- ARGBColor { a: 0xff, r: self.r, g: self.g, b: self.b }
- }
-}