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