mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
tab indicator: Add gaps-between-tabs
This commit is contained in:
@@ -695,6 +695,8 @@ pub struct TabIndicator {
|
|||||||
pub length: TabIndicatorLength,
|
pub length: TabIndicatorLength,
|
||||||
#[knuffel(child, unwrap(argument), default = Self::default().position)]
|
#[knuffel(child, unwrap(argument), default = Self::default().position)]
|
||||||
pub position: TabIndicatorPosition,
|
pub position: TabIndicatorPosition,
|
||||||
|
#[knuffel(child, unwrap(argument), default = Self::default().gaps_between_tabs)]
|
||||||
|
pub gaps_between_tabs: FloatOrInt<0, 65535>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub active_color: Option<Color>,
|
pub active_color: Option<Color>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
@@ -717,6 +719,7 @@ impl Default for TabIndicator {
|
|||||||
total_proportion: Some(0.5),
|
total_proportion: Some(0.5),
|
||||||
},
|
},
|
||||||
position: TabIndicatorPosition::Left,
|
position: TabIndicatorPosition::Left,
|
||||||
|
gaps_between_tabs: FloatOrInt(0.),
|
||||||
active_color: None,
|
active_color: None,
|
||||||
inactive_color: None,
|
inactive_color: None,
|
||||||
active_gradient: None,
|
active_gradient: None,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ impl TabIndicator {
|
|||||||
|
|
||||||
let width = round(self.config.width.0);
|
let width = round(self.config.width.0);
|
||||||
let gap = round(self.config.gap.0);
|
let gap = round(self.config.gap.0);
|
||||||
|
let gaps_between = round(self.config.gaps_between_tabs.0);
|
||||||
|
|
||||||
let side = match self.config.position {
|
let side = match self.config.position {
|
||||||
TabIndicatorPosition::Left | TabIndicatorPosition::Right => tile_size.h,
|
TabIndicatorPosition::Left | TabIndicatorPosition::Right => tile_size.h,
|
||||||
@@ -90,11 +91,11 @@ impl TabIndicator {
|
|||||||
self.shader_locs.resize_with(count, Default::default);
|
self.shader_locs.resize_with(count, Default::default);
|
||||||
|
|
||||||
let pixel = 1. / scale;
|
let pixel = 1. / scale;
|
||||||
let shortest_length = count as f64 * pixel;
|
let shortest_length = count as f64 * (pixel + gaps_between) - gaps_between;
|
||||||
let length = f64::max(min_length, shortest_length);
|
let length = f64::max(min_length, shortest_length);
|
||||||
let px_per_tab = length / count as f64;
|
let px_per_tab = (length + gaps_between) / count as f64 - gaps_between;
|
||||||
let px_per_tab = floor_logical_in_physical_max1(scale, px_per_tab);
|
let px_per_tab = floor_logical_in_physical_max1(scale, px_per_tab);
|
||||||
let floored_length = count as f64 * px_per_tab;
|
let floored_length = count as f64 * (px_per_tab + gaps_between) - gaps_between;
|
||||||
let mut ones_left = ((length - floored_length) / pixel).max(0.).round() as usize;
|
let mut ones_left = ((length - floored_length) / pixel).max(0.).round() as usize;
|
||||||
|
|
||||||
let mut shader_loc = Point::from((-gap - width, round((side - length) / 2.)));
|
let mut shader_loc = Point::from((-gap - width, round((side - length) / 2.)));
|
||||||
@@ -119,10 +120,10 @@ impl TabIndicator {
|
|||||||
|
|
||||||
match self.config.position {
|
match self.config.position {
|
||||||
TabIndicatorPosition::Left | TabIndicatorPosition::Right => {
|
TabIndicatorPosition::Left | TabIndicatorPosition::Right => {
|
||||||
shader_loc.y += px_per_tab
|
shader_loc.y += px_per_tab + gaps_between
|
||||||
}
|
}
|
||||||
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => {
|
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => {
|
||||||
shader_loc.x += px_per_tab
|
shader_loc.x += px_per_tab + gaps_between
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ layout {
|
|||||||
width 4
|
width 4
|
||||||
length total-proportion=1.0
|
length total-proportion=1.0
|
||||||
position "right"
|
position "right"
|
||||||
|
gaps-between-tabs 2
|
||||||
active-color "red"
|
active-color "red"
|
||||||
inactive-color "gray"
|
inactive-color "gray"
|
||||||
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
||||||
@@ -436,6 +437,8 @@ By default, the tab indicator has length equal to half of the window size, or `l
|
|||||||
`position` sets the position of the tab indicator relative to the window.
|
`position` sets the position of the tab indicator relative to the window.
|
||||||
It can be `left`, `right`, `top`, or `bottom`.
|
It can be `left`, `right`, `top`, or `bottom`.
|
||||||
|
|
||||||
|
`gaps-between-tabs` controls the gap between individual tabs.
|
||||||
|
|
||||||
`active-color`, `inactive-color`, `active-gradient`, `inactive-gradient` let you override the colors for the tabs.
|
`active-color`, `inactive-color`, `active-gradient`, `inactive-gradient` let you override the colors for the tabs.
|
||||||
They have the same semantics as the border and focus ring colors and gradients.
|
They have the same semantics as the border and focus ring colors and gradients.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user