tab indicator: Add gaps-between-tabs
Browse files at this commit0dd8e883b092d4bcd735bec45c8cff3d86a4f991Parent: c31b58e3 changed files +12 -5
niri-config/src/lib.rsmodified+3 -0
| @@ -695,6 +695,8 @@ pub struct TabIndicator { | |||
| 695 | pub length: TabIndicatorLength, | 695 | pub length: TabIndicatorLength, |
| 696 | #[knuffel(child, unwrap(argument), default = Self::default().position)] | 696 | #[knuffel(child, unwrap(argument), default = Self::default().position)] |
| 697 | pub position: TabIndicatorPosition, | 697 | pub position: TabIndicatorPosition, |
| 698 | + #[knuffel(child, unwrap(argument), default = Self::default().gaps_between_tabs)] | ||
| 699 | + pub gaps_between_tabs: FloatOrInt<0, 65535>, | ||
| 698 | #[knuffel(child)] | 700 | #[knuffel(child)] |
| 699 | pub active_color: Option<Color>, | 701 | pub active_color: Option<Color>, |
| 700 | #[knuffel(child)] | 702 | #[knuffel(child)] |
| @@ -717,6 +719,7 @@ impl Default for TabIndicator { | |||
| 717 | total_proportion: Some(0.5), | 719 | total_proportion: Some(0.5), |
| 718 | }, | 720 | }, |
| 719 | position: TabIndicatorPosition::Left, | 721 | position: TabIndicatorPosition::Left, |
| 722 | + gaps_between_tabs: FloatOrInt(0.), | ||
| 720 | active_color: None, | 723 | active_color: None, |
| 721 | inactive_color: None, | 724 | inactive_color: None, |
| 722 | active_gradient: None, | 725 | active_gradient: None, |
src/layout/tab_indicator.rsmodified+6 -5
| @@ -78,6 +78,7 @@ impl TabIndicator { | |||
| 78 | 78 | ||
| 79 | let width = round(self.config.width.0); | 79 | let width = round(self.config.width.0); |
| 80 | let gap = round(self.config.gap.0); | 80 | let gap = round(self.config.gap.0); |
| 81 | + let gaps_between = round(self.config.gaps_between_tabs.0); | ||
| 81 | 82 | ||
| 82 | let side = match self.config.position { | 83 | let side = match self.config.position { |
| 83 | TabIndicatorPosition::Left | TabIndicatorPosition::Right => tile_size.h, | 84 | TabIndicatorPosition::Left | TabIndicatorPosition::Right => tile_size.h, |
| @@ -90,11 +91,11 @@ impl TabIndicator { | |||
| 90 | self.shader_locs.resize_with(count, Default::default); | 91 | self.shader_locs.resize_with(count, Default::default); |
| 91 | 92 | ||
| 92 | let pixel = 1. / scale; | 93 | let pixel = 1. / scale; |
| 93 | - let shortest_length = count as f64 * pixel; | 94 | + let shortest_length = count as f64 * (pixel + gaps_between) - gaps_between; |
| 94 | let length = f64::max(min_length, shortest_length); | 95 | let length = f64::max(min_length, shortest_length); |
| 95 | - let px_per_tab = length / count as f64; | 96 | + let px_per_tab = (length + gaps_between) / count as f64 - gaps_between; |
| 96 | let px_per_tab = floor_logical_in_physical_max1(scale, px_per_tab); | 97 | let px_per_tab = floor_logical_in_physical_max1(scale, px_per_tab); |
| 97 | - let floored_length = count as f64 * px_per_tab; | 98 | + let floored_length = count as f64 * (px_per_tab + gaps_between) - gaps_between; |
| 98 | let mut ones_left = ((length - floored_length) / pixel).max(0.).round() as usize; | 99 | let mut ones_left = ((length - floored_length) / pixel).max(0.).round() as usize; |
| 99 | 100 | ||
| 100 | let mut shader_loc = Point::from((-gap - width, round((side - length) / 2.))); | 101 | let mut shader_loc = Point::from((-gap - width, round((side - length) / 2.))); |
| @@ -119,10 +120,10 @@ impl TabIndicator { | |||
| 119 | 120 | ||
| 120 | match self.config.position { | 121 | match self.config.position { |
| 121 | TabIndicatorPosition::Left | TabIndicatorPosition::Right => { | 122 | TabIndicatorPosition::Left | TabIndicatorPosition::Right => { |
| 122 | - shader_loc.y += px_per_tab | 123 | + shader_loc.y += px_per_tab + gaps_between |
| 123 | } | 124 | } |
| 124 | TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => { | 125 | TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => { |
| 125 | - shader_loc.x += px_per_tab | 126 | + shader_loc.x += px_per_tab + gaps_between |
| 126 | } | 127 | } |
| 127 | } | 128 | } |
| 128 | 129 | ||
wiki/Configuration:-Layout.mdmodified+3 -0
| @@ -62,6 +62,7 @@ layout { | |||
| 62 | width 4 | 62 | width 4 |
| 63 | length total-proportion=1.0 | 63 | length total-proportion=1.0 |
| 64 | position "right" | 64 | position "right" |
| 65 | + gaps-between-tabs 2 | ||
| 65 | active-color "red" | 66 | active-color "red" |
| 66 | inactive-color "gray" | 67 | inactive-color "gray" |
| 67 | // active-gradient from="#80c8ff" to="#bbddff" angle=45 | 68 | // 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 | |||
| 436 | `position` sets the position of the tab indicator relative to the window. | 437 | `position` sets the position of the tab indicator relative to the window. |
| 437 | It can be `left`, `right`, `top`, or `bottom`. | 438 | It can be `left`, `right`, `top`, or `bottom`. |
| 438 | 439 | ||
| 440 | +`gaps-between-tabs` controls the gap between individual tabs. | ||
| 441 | + | ||
| 439 | `active-color`, `inactive-color`, `active-gradient`, `inactive-gradient` let you override the colors for the tabs. | 442 | `active-color`, `inactive-color`, `active-gradient`, `inactive-gradient` let you override the colors for the tabs. |
| 440 | They have the same semantics as the border and focus ring colors and gradients. | 443 | They have the same semantics as the border and focus ring colors and gradients. |
| 441 | 444 | ||