integrated-title-bar: Replace window button recoloring
also change shape of rounded corners to ovals
This commit is contained in:
1 parent
bcd1b03569
commit
ab52277393
6 files changed
+260
-308
No files matched your search
+29
-143
@@ -372,24 +372,6 @@ pub struct TabBarColors {
|
||||
|
||||
#[dynamic(default)]
|
||||
pub inactive_tab_edge_hover: Option<RgbaColor>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_hide: Option<TabBarColor>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_hide_hover: Option<TabBarColor>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_maximize: Option<TabBarColor>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_maximize_hover: Option<TabBarColor>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_close: Option<TabBarColor>,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub window_close_hover: Option<TabBarColor>,
|
||||
}
|
||||
|
||||
impl TabBarColors {
|
||||
@@ -433,42 +415,6 @@ impl TabBarColors {
|
||||
.unwrap_or_else(default_inactive_tab_edge_hover)
|
||||
}
|
||||
|
||||
pub fn window_hide(&self) -> TabBarColor {
|
||||
self.window_hide
|
||||
.clone()
|
||||
.unwrap_or_else(default_window_hide_color)
|
||||
}
|
||||
|
||||
pub fn window_hide_hover(&self) -> TabBarColor {
|
||||
self.window_hide_hover
|
||||
.clone()
|
||||
.unwrap_or_else(default_window_hide_hover_color)
|
||||
}
|
||||
|
||||
pub fn window_maximize(&self) -> TabBarColor {
|
||||
self.window_maximize
|
||||
.clone()
|
||||
.unwrap_or_else(default_window_maximize_color)
|
||||
}
|
||||
|
||||
pub fn window_maximize_hover(&self) -> TabBarColor {
|
||||
self.window_maximize_hover
|
||||
.clone()
|
||||
.unwrap_or_else(default_window_maximize_hover_color)
|
||||
}
|
||||
|
||||
pub fn window_close(&self) -> TabBarColor {
|
||||
self.window_close
|
||||
.clone()
|
||||
.unwrap_or_else(default_window_close_color)
|
||||
}
|
||||
|
||||
pub fn window_close_hover(&self) -> TabBarColor {
|
||||
self.window_close_hover
|
||||
.clone()
|
||||
.unwrap_or_else(default_window_close_hover_color)
|
||||
}
|
||||
|
||||
pub fn overlay_with(&self, other: &Self) -> Self {
|
||||
macro_rules! overlay {
|
||||
($name:ident) => {
|
||||
@@ -488,12 +434,35 @@ impl TabBarColors {
|
||||
inactive_tab_edge_hover: overlay!(inactive_tab_edge_hover),
|
||||
new_tab: overlay!(new_tab),
|
||||
new_tab_hover: overlay!(new_tab_hover),
|
||||
window_hide: overlay!(window_hide),
|
||||
window_hide_hover: overlay!(window_hide_hover),
|
||||
window_maximize: overlay!(window_maximize),
|
||||
window_maximize_hover: overlay!(window_maximize_hover),
|
||||
window_close: overlay!(window_close),
|
||||
window_close_hover: overlay!(window_close_hover),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, FromDynamic, ToDynamic)]
|
||||
#[dynamic(try_from = "String")]
|
||||
pub enum IntegratedTitleButtonColor {
|
||||
#[default]
|
||||
Auto,
|
||||
Custom(RgbaColor),
|
||||
}
|
||||
|
||||
impl Into<String> for IntegratedTitleButtonColor {
|
||||
fn into(self) -> String {
|
||||
match self {
|
||||
Self::Auto => "auto".to_string(),
|
||||
Self::Custom(color) => color.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for IntegratedTitleButtonColor {
|
||||
type Error = <RgbaColor as TryFrom<String>>::Error;
|
||||
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> {
|
||||
if value.to_lowercase() == "auto" {
|
||||
Ok(Self::Auto)
|
||||
} else {
|
||||
Ok(Self::Custom(RgbaColor::try_from(value)?))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,89 +502,6 @@ fn default_active_tab() -> TabBarColor {
|
||||
}
|
||||
}
|
||||
|
||||
// Colors for window buttons
|
||||
#[cfg(not(any(windows, target_os = "linux")))]
|
||||
fn default_window_button_color() -> TabBarColor {
|
||||
default_inactive_tab()
|
||||
}
|
||||
|
||||
#[cfg(not(any(windows, target_os = "linux")))]
|
||||
fn default_window_button_hover_color() -> TabBarColor {
|
||||
default_inactive_tab_hover()
|
||||
}
|
||||
|
||||
fn default_window_hide_color() -> TabBarColor {
|
||||
default_window_button_color()
|
||||
}
|
||||
|
||||
fn default_window_hide_hover_color() -> TabBarColor {
|
||||
default_window_button_hover_color()
|
||||
}
|
||||
|
||||
fn default_window_maximize_color() -> TabBarColor {
|
||||
default_window_button_color()
|
||||
}
|
||||
|
||||
fn default_window_maximize_hover_color() -> TabBarColor {
|
||||
default_window_button_hover_color()
|
||||
}
|
||||
|
||||
fn default_window_close_color() -> TabBarColor {
|
||||
default_window_button_color()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn default_window_close_hover_color() -> TabBarColor {
|
||||
default_window_button_hover_color()
|
||||
}
|
||||
|
||||
// Windows dependend colors for window buttons
|
||||
#[cfg(windows)]
|
||||
fn default_window_button_color() -> TabBarColor {
|
||||
TabBarColor {
|
||||
bg_color: (0x33, 0x33, 0x33).into(),
|
||||
fg_color: (0xFF, 0xFF, 0xFF).into(),
|
||||
..TabBarColor::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn default_window_button_hover_color() -> TabBarColor {
|
||||
TabBarColor {
|
||||
bg_color: (0x45, 0x45, 0x45).into(),
|
||||
fg_color: (0xFF, 0xFF, 0xFF).into(),
|
||||
..TabBarColor::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn default_window_close_hover_color() -> TabBarColor {
|
||||
TabBarColor {
|
||||
bg_color: (0xFF, 0x00, 0x00).into(),
|
||||
fg_color: (0xFF, 0xFF, 0xFF).into(),
|
||||
..TabBarColor::default()
|
||||
}
|
||||
}
|
||||
|
||||
// Linux dependend colors for window buttons
|
||||
#[cfg(target_os = "linux")]
|
||||
fn default_window_button_color() -> TabBarColor {
|
||||
TabBarColor {
|
||||
bg_color: (0x45, 0x45, 0x45).into(),
|
||||
fg_color: (0xFF, 0xFF, 0xFF).into(),
|
||||
..TabBarColor::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn default_window_button_hover_color() -> TabBarColor {
|
||||
TabBarColor {
|
||||
bg_color: (0x4F, 0x4F, 0x4F).into(),
|
||||
fg_color: (0xFF, 0xFF, 0xFF).into(),
|
||||
..TabBarColor::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, FromDynamic, ToDynamic)]
|
||||
pub struct TabBarStyle {
|
||||
#[dynamic(default = "default_new_tab")]
|
||||
|
||||
@@ -22,9 +22,9 @@ use crate::unix::UnixDomain;
|
||||
use crate::wsl::WslDomain;
|
||||
use crate::{
|
||||
default_config_with_overrides_applied, default_one_point_oh, default_one_point_oh_f64,
|
||||
default_true, GpuInfo, KeyMapPreference, LoadedConfig, MouseEventTriggerMods, RgbaColor,
|
||||
SerialDomain, WebGpuPowerPreference, CONFIG_DIRS, CONFIG_FILE_OVERRIDE, CONFIG_OVERRIDES,
|
||||
CONFIG_SKIP, HOME_DIR,
|
||||
default_true, GpuInfo, IntegratedTitleButtonColor, KeyMapPreference, LoadedConfig,
|
||||
MouseEventTriggerMods, RgbaColor, SerialDomain, WebGpuPowerPreference, CONFIG_DIRS,
|
||||
CONFIG_FILE_OVERRIDE, CONFIG_OVERRIDES, CONFIG_SKIP, HOME_DIR,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use luahelper::impl_lua_conversion_dynamic;
|
||||
@@ -92,6 +92,9 @@ pub struct Config {
|
||||
#[dynamic(default)]
|
||||
pub integrated_title_button_style: IntegratedTitleButtonStyle,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub integrated_title_button_color: IntegratedTitleButtonColor,
|
||||
|
||||
/// When using FontKitXXX font systems, a set of directories to
|
||||
/// search ahead of the standard font locations for fonts.
|
||||
/// Relative paths are taken to be relative to the directory
|
||||
|
||||
@@ -176,7 +176,14 @@ pub type BlockPoint = (BlockCoord, BlockCoord);
|
||||
pub enum PolyCommand {
|
||||
MoveTo(BlockCoord, BlockCoord),
|
||||
LineTo(BlockCoord, BlockCoord),
|
||||
QuadTo { control: BlockPoint, to: BlockPoint },
|
||||
QuadTo {
|
||||
control: BlockPoint,
|
||||
to: BlockPoint,
|
||||
},
|
||||
PushOval {
|
||||
center: BlockPoint,
|
||||
radiuses: BlockPoint,
|
||||
},
|
||||
Close,
|
||||
}
|
||||
|
||||
@@ -200,6 +207,21 @@ impl PolyCommand {
|
||||
x.to_pixel(width, underline_height),
|
||||
y.to_pixel(height, underline_height),
|
||||
),
|
||||
Self::PushOval {
|
||||
center: (x, y),
|
||||
radiuses: (w, h),
|
||||
} => {
|
||||
let x = x.to_pixel(width, underline_height) - width as f32;
|
||||
let y = y.to_pixel(height, underline_height) - height as f32;
|
||||
let w = w.to_pixel(width, underline_height) * 2.0;
|
||||
let h = h.to_pixel(height, underline_height) * 2.0;
|
||||
|
||||
if let Some(oval) = tiny_skia::Rect::from_xywh(x, y, w, h) {
|
||||
pb.push_oval(oval);
|
||||
} else {
|
||||
log::error!("Can't push oval, values: {:?}", self);
|
||||
}
|
||||
}
|
||||
Self::Close => pb.close(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ void main() {
|
||||
// Grayscale poly quad for non-aa text render layers
|
||||
colorMask = texture(atlas_nearest_sampler, o_tex);
|
||||
color = fg_color;
|
||||
color.a = mix(o_fg_color.a, o_fg_color_alt.a, clamp(o_fg_color_mix, 0.0, 1.0));
|
||||
color.a *= colorMask.a;
|
||||
} else if (o_has_color == 0.0) {
|
||||
// the texture is the alpha channel/color mask
|
||||
|
||||
+21
-39
@@ -193,55 +193,37 @@ impl TabBarState {
|
||||
line: &mut Line,
|
||||
colors: &TabBarColors,
|
||||
) {
|
||||
let window_hide = parse_status_text(
|
||||
&config.tab_bar_style.window_hide,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.window_hide().as_cell_attributes()
|
||||
},
|
||||
);
|
||||
let default_cell = if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.new_tab().as_cell_attributes()
|
||||
};
|
||||
|
||||
let default_cell_hover = if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.new_tab_hover().as_cell_attributes()
|
||||
};
|
||||
|
||||
let window_hide =
|
||||
parse_status_text(&config.tab_bar_style.window_hide, default_cell.clone());
|
||||
let window_hide_hover = parse_status_text(
|
||||
&config.tab_bar_style.window_hide_hover,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.window_hide_hover().as_cell_attributes()
|
||||
},
|
||||
default_cell_hover.clone(),
|
||||
);
|
||||
|
||||
let window_maximize = parse_status_text(
|
||||
&config.tab_bar_style.window_maximize,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.window_maximize().as_cell_attributes()
|
||||
},
|
||||
);
|
||||
let window_maximize =
|
||||
parse_status_text(&config.tab_bar_style.window_maximize, default_cell.clone());
|
||||
let window_maximize_hover = parse_status_text(
|
||||
&config.tab_bar_style.window_maximize_hover,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.window_maximize_hover().as_cell_attributes()
|
||||
},
|
||||
default_cell_hover.clone(),
|
||||
);
|
||||
|
||||
let window_close = parse_status_text(
|
||||
&config.tab_bar_style.window_close,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.window_close().as_cell_attributes()
|
||||
},
|
||||
);
|
||||
let window_close =
|
||||
parse_status_text(&config.tab_bar_style.window_close, default_cell.clone());
|
||||
let window_close_hover = parse_status_text(
|
||||
&config.tab_bar_style.window_close_hover,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
colors.window_close_hover().as_cell_attributes()
|
||||
},
|
||||
default_cell_hover.clone(),
|
||||
);
|
||||
|
||||
for button in &config.integrated_title_buttons {
|
||||
|
||||
@@ -53,57 +53,37 @@ use window::color::LinearRgba;
|
||||
use window::{IntegratedTitleButton, IntegratedTitleButtonAlignment};
|
||||
|
||||
pub const TOP_LEFT_ROUNDED_CORNER: &[Poly] = &[Poly {
|
||||
path: &[
|
||||
PolyCommand::MoveTo(BlockCoord::One, BlockCoord::One),
|
||||
PolyCommand::LineTo(BlockCoord::One, BlockCoord::Zero),
|
||||
PolyCommand::QuadTo {
|
||||
control: (BlockCoord::Zero, BlockCoord::Zero),
|
||||
to: (BlockCoord::Zero, BlockCoord::One),
|
||||
},
|
||||
PolyCommand::Close,
|
||||
],
|
||||
path: &[PolyCommand::PushOval {
|
||||
center: (BlockCoord::One, BlockCoord::One),
|
||||
radiuses: (BlockCoord::One, BlockCoord::One),
|
||||
}],
|
||||
intensity: BlockAlpha::Full,
|
||||
style: PolyStyle::Fill,
|
||||
}];
|
||||
|
||||
pub const BOTTOM_LEFT_ROUNDED_CORNER: &[Poly] = &[Poly {
|
||||
path: &[
|
||||
PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
|
||||
PolyCommand::LineTo(BlockCoord::One, BlockCoord::One),
|
||||
PolyCommand::QuadTo {
|
||||
control: (BlockCoord::Zero, BlockCoord::One),
|
||||
to: (BlockCoord::Zero, BlockCoord::Zero),
|
||||
},
|
||||
PolyCommand::Close,
|
||||
],
|
||||
path: &[PolyCommand::PushOval {
|
||||
center: (BlockCoord::One, BlockCoord::Zero),
|
||||
radiuses: (BlockCoord::One, BlockCoord::One),
|
||||
}],
|
||||
intensity: BlockAlpha::Full,
|
||||
style: PolyStyle::Fill,
|
||||
}];
|
||||
|
||||
pub const TOP_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
|
||||
path: &[
|
||||
PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::One),
|
||||
PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::Zero),
|
||||
PolyCommand::QuadTo {
|
||||
control: (BlockCoord::One, BlockCoord::Zero),
|
||||
to: (BlockCoord::One, BlockCoord::One),
|
||||
},
|
||||
PolyCommand::Close,
|
||||
],
|
||||
path: &[PolyCommand::PushOval {
|
||||
center: (BlockCoord::Zero, BlockCoord::One),
|
||||
radiuses: (BlockCoord::One, BlockCoord::One),
|
||||
}],
|
||||
intensity: BlockAlpha::Full,
|
||||
style: PolyStyle::Fill,
|
||||
}];
|
||||
|
||||
pub const BOTTOM_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
|
||||
path: &[
|
||||
PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
|
||||
PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::One),
|
||||
PolyCommand::QuadTo {
|
||||
control: (BlockCoord::One, BlockCoord::One),
|
||||
to: (BlockCoord::One, BlockCoord::Zero),
|
||||
},
|
||||
PolyCommand::Close,
|
||||
],
|
||||
path: &[PolyCommand::PushOval {
|
||||
center: (BlockCoord::Zero, BlockCoord::Zero),
|
||||
radiuses: (BlockCoord::One, BlockCoord::One),
|
||||
}],
|
||||
intensity: BlockAlpha::Full,
|
||||
style: PolyStyle::Fill,
|
||||
}];
|
||||
@@ -147,6 +127,28 @@ const PLUS_BUTTON: &[Poly] = &[
|
||||
];
|
||||
|
||||
mod window_buttons {
|
||||
pub struct WindowButtonColors {
|
||||
pub(super) colors: ElementColors,
|
||||
pub(super) hover_colors: ElementColors,
|
||||
}
|
||||
|
||||
pub(super) fn auto_button_color(
|
||||
background_lightness: f64,
|
||||
foreground: config::IntegratedTitleButtonColor,
|
||||
) -> LinearRgba {
|
||||
use config::IntegratedTitleButtonColor as Color;
|
||||
match foreground {
|
||||
Color::Custom(color) => color.to_linear(),
|
||||
Color::Auto => {
|
||||
if background_lightness > 0.5 {
|
||||
LinearRgba(0.0, 0.0, 0.0, 1.0)
|
||||
} else {
|
||||
LinearRgba(1.0, 1.0, 1.0, 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use super::*;
|
||||
pub(super) mod windows {
|
||||
use super::*;
|
||||
@@ -222,6 +224,38 @@ mod window_buttons {
|
||||
height: size,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn window_button_colors(
|
||||
background_lightness: f64,
|
||||
foreground: config::IntegratedTitleButtonColor,
|
||||
window_button: IntegratedTitleButton,
|
||||
) -> WindowButtonColors {
|
||||
let foreground = auto_button_color(background_lightness, foreground);
|
||||
let colors = ElementColors {
|
||||
border: BorderColor::new(LinearRgba::TRANSPARENT),
|
||||
bg: LinearRgba::TRANSPARENT.into(),
|
||||
text: foreground.into(),
|
||||
};
|
||||
|
||||
let hover_colors = if window_button == IntegratedTitleButton::Close {
|
||||
ElementColors {
|
||||
border: BorderColor::new(LinearRgba::TRANSPARENT),
|
||||
bg: LinearRgba(1.0, 0.0, 0.0, 1.0).into(),
|
||||
text: LinearRgba(1.0, 1.0, 1.0, 1.0).into(),
|
||||
}
|
||||
} else {
|
||||
ElementColors {
|
||||
border: BorderColor::new(LinearRgba::TRANSPARENT),
|
||||
bg: foreground.mul_alpha(0.1).into(),
|
||||
text: foreground.into(),
|
||||
}
|
||||
};
|
||||
|
||||
WindowButtonColors {
|
||||
colors,
|
||||
hover_colors,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) mod gnome {
|
||||
@@ -276,6 +310,26 @@ mod window_buttons {
|
||||
height: size,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn window_button_colors(
|
||||
background_lightness: f64,
|
||||
foreground: config::IntegratedTitleButtonColor,
|
||||
_window_button: IntegratedTitleButton,
|
||||
) -> WindowButtonColors {
|
||||
let foreground = auto_button_color(background_lightness, foreground);
|
||||
WindowButtonColors {
|
||||
colors: ElementColors {
|
||||
border: BorderColor::new(foreground.mul_alpha(0.1)),
|
||||
bg: LinearRgba::TRANSPARENT.into(),
|
||||
text: foreground.into(),
|
||||
},
|
||||
hover_colors: ElementColors {
|
||||
border: BorderColor::new(foreground.mul_alpha(0.15)),
|
||||
bg: LinearRgba::TRANSPARENT.into(),
|
||||
text: foreground.into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,46 +339,40 @@ fn window_button_element(
|
||||
font: &Rc<LoadedFont>,
|
||||
metrics: &RenderMetrics,
|
||||
colors: &TabBarColors,
|
||||
style: window::IntegratedTitleButtonStyle,
|
||||
config: &ConfigHandle,
|
||||
) -> Element {
|
||||
use window::IntegratedTitleButtonStyle as Style;
|
||||
use IntegratedTitleButton as Button;
|
||||
|
||||
let poly = match style {
|
||||
Style::Windows => {
|
||||
use window_buttons::windows::{CLOSE, HIDE, MAXIMIZE, RESTORE};
|
||||
match window_button {
|
||||
Button::Hide => HIDE,
|
||||
Button::Maximize => {
|
||||
if is_maximized {
|
||||
RESTORE
|
||||
} else {
|
||||
MAXIMIZE
|
||||
}
|
||||
}
|
||||
Button::Close => CLOSE,
|
||||
}
|
||||
}
|
||||
let style = config.integrated_title_button_style;
|
||||
|
||||
Style::Gnome => {
|
||||
use window_buttons::gnome::{CLOSE, HIDE, MAXIMIZE, RESTORE};
|
||||
match window_button {
|
||||
Button::Hide => HIDE,
|
||||
Button::Maximize => {
|
||||
if is_maximized {
|
||||
RESTORE
|
||||
} else {
|
||||
MAXIMIZE
|
||||
}
|
||||
}
|
||||
Button::Close => CLOSE,
|
||||
let poly = {
|
||||
let (CLOSE, HIDE, MAXIMIZE, RESTORE) = match style {
|
||||
Style::Windows => {
|
||||
use window_buttons::windows::{CLOSE, HIDE, MAXIMIZE, RESTORE};
|
||||
(CLOSE, HIDE, MAXIMIZE, RESTORE)
|
||||
}
|
||||
}
|
||||
};
|
||||
Style::Gnome => {
|
||||
use window_buttons::gnome::{CLOSE, HIDE, MAXIMIZE, RESTORE};
|
||||
(CLOSE, HIDE, MAXIMIZE, RESTORE)
|
||||
}
|
||||
};
|
||||
let poly = match window_button {
|
||||
Button::Hide => HIDE,
|
||||
Button::Maximize => {
|
||||
if is_maximized {
|
||||
RESTORE
|
||||
} else {
|
||||
MAXIMIZE
|
||||
}
|
||||
}
|
||||
Button::Close => CLOSE,
|
||||
};
|
||||
|
||||
let poly = match style {
|
||||
Style::Windows => window_buttons::windows::sized_poly(poly),
|
||||
Style::Gnome => window_buttons::gnome::sized_poly(poly),
|
||||
match style {
|
||||
Style::Windows => window_buttons::windows::sized_poly(poly),
|
||||
Style::Gnome => window_buttons::gnome::sized_poly(poly),
|
||||
}
|
||||
};
|
||||
|
||||
let element = Element::new(
|
||||
@@ -353,64 +401,74 @@ fn window_button_element(
|
||||
bottom: Dimension::Points(10. * scale),
|
||||
})
|
||||
}
|
||||
Style::Gnome => element
|
||||
.zindex(1)
|
||||
.vertical_align(VerticalAlign::Middle)
|
||||
.padding(BoxDimension {
|
||||
left: Dimension::Pixels(7.),
|
||||
right: Dimension::Pixels(7.),
|
||||
top: Dimension::Pixels(7.),
|
||||
bottom: Dimension::Pixels(7.),
|
||||
})
|
||||
.border(BoxDimension::new(Dimension::Pixels(1.)))
|
||||
.border_corners(Some(Corners {
|
||||
top_left: SizedPoly {
|
||||
width: Dimension::Pixels(14.),
|
||||
height: Dimension::Pixels(14.),
|
||||
poly: TOP_LEFT_ROUNDED_CORNER,
|
||||
},
|
||||
top_right: SizedPoly {
|
||||
width: Dimension::Pixels(14.),
|
||||
height: Dimension::Pixels(14.),
|
||||
poly: TOP_RIGHT_ROUNDED_CORNER,
|
||||
},
|
||||
bottom_left: SizedPoly {
|
||||
width: Dimension::Pixels(14.),
|
||||
height: Dimension::Pixels(14.),
|
||||
poly: BOTTOM_LEFT_ROUNDED_CORNER,
|
||||
},
|
||||
bottom_right: SizedPoly {
|
||||
width: Dimension::Pixels(14.),
|
||||
height: Dimension::Pixels(14.),
|
||||
poly: BOTTOM_RIGHT_ROUNDED_CORNER,
|
||||
},
|
||||
}))
|
||||
.margin(BoxDimension {
|
||||
left: Dimension::Pixels(7.),
|
||||
right: Dimension::Pixels(7.),
|
||||
top: Dimension::Pixels(7.),
|
||||
bottom: Dimension::Pixels(7.),
|
||||
}),
|
||||
Style::Gnome => {
|
||||
let border_corners_size = Dimension::Pixels(12.);
|
||||
element
|
||||
.zindex(1)
|
||||
.vertical_align(VerticalAlign::Middle)
|
||||
.padding(BoxDimension {
|
||||
left: Dimension::Pixels(7.),
|
||||
right: Dimension::Pixels(7.),
|
||||
top: Dimension::Pixels(7.),
|
||||
bottom: Dimension::Pixels(7.),
|
||||
})
|
||||
.border(BoxDimension::new(Dimension::Pixels(1.)))
|
||||
.border_corners(Some(Corners {
|
||||
top_left: SizedPoly {
|
||||
width: border_corners_size,
|
||||
height: border_corners_size,
|
||||
poly: TOP_LEFT_ROUNDED_CORNER,
|
||||
},
|
||||
top_right: SizedPoly {
|
||||
width: border_corners_size,
|
||||
height: border_corners_size,
|
||||
poly: TOP_RIGHT_ROUNDED_CORNER,
|
||||
},
|
||||
bottom_left: SizedPoly {
|
||||
width: border_corners_size,
|
||||
height: border_corners_size,
|
||||
poly: BOTTOM_LEFT_ROUNDED_CORNER,
|
||||
},
|
||||
bottom_right: SizedPoly {
|
||||
width: border_corners_size,
|
||||
height: border_corners_size,
|
||||
poly: BOTTOM_RIGHT_ROUNDED_CORNER,
|
||||
},
|
||||
}))
|
||||
.margin(BoxDimension {
|
||||
left: Dimension::Pixels(7.),
|
||||
right: Dimension::Pixels(7.),
|
||||
top: Dimension::Pixels(7.),
|
||||
bottom: Dimension::Pixels(7.),
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
let (color, hover_colors) = match window_button {
|
||||
Button::Hide => (colors.window_hide(), colors.window_hide_hover()),
|
||||
Button::Maximize => (colors.window_maximize(), colors.window_maximize_hover()),
|
||||
Button::Close => (colors.window_close(), colors.window_close_hover()),
|
||||
let foreground = config.integrated_title_button_color.clone();
|
||||
let background_lightness = {
|
||||
let (r, g, b) = config
|
||||
.window_frame
|
||||
.active_titlebar_bg
|
||||
.to_tuple_rgb8()
|
||||
.clone();
|
||||
|
||||
let max = r.max(g.max(b)) as f64;
|
||||
let min = r.min(g.min(b)) as f64;
|
||||
|
||||
(max + min) / 510.0
|
||||
};
|
||||
|
||||
let window_button_colors_fn = match style {
|
||||
Style::Windows => window_buttons::windows::window_button_colors,
|
||||
Style::Gnome => window_buttons::gnome::window_button_colors,
|
||||
};
|
||||
|
||||
let colors = window_button_colors_fn(background_lightness, foreground, window_button);
|
||||
|
||||
let element = element
|
||||
.item_type(UIItemType::TabBar(TabBarItem::WindowButton(window_button)))
|
||||
.colors(ElementColors {
|
||||
border: BorderColor::new(color.bg_color.to_linear()),
|
||||
bg: color.bg_color.to_linear().into(),
|
||||
text: color.fg_color.to_linear().into(),
|
||||
})
|
||||
.hover_colors(Some(ElementColors {
|
||||
border: BorderColor::new(hover_colors.bg_color.to_linear()),
|
||||
bg: hover_colors.bg_color.to_linear().into(),
|
||||
text: hover_colors.fg_color.to_linear().into(),
|
||||
}));
|
||||
.colors(colors.colors)
|
||||
.hover_colors(Some(colors.hover_colors));
|
||||
|
||||
element
|
||||
}
|
||||
@@ -1083,7 +1141,7 @@ impl super::TermWindow {
|
||||
&font,
|
||||
&metrics,
|
||||
&colors,
|
||||
self.config.integrated_title_button_style,
|
||||
&self.config,
|
||||
),
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user