aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-12 07:59:21 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-12 07:59:46 +0300
commit7e552333a993e83a2dba52392109617e486f5f60 (patch)
tree35b9079787535667fe844e2178ffd6bf42db8626
parent213eafa2032897e7ce3132f179a135a65d327d9b (diff)
downloadniri-7e552333a993e83a2dba52392109617e486f5f60.tar.gz
niri-7e552333a993e83a2dba52392109617e486f5f60.tar.bz2
niri-7e552333a993e83a2dba52392109617e486f5f60.zip
tab indicator: Add corner-radius setting
-rw-r--r--niri-config/src/lib.rs14
-rw-r--r--src/layout/tab_indicator.rs51
-rw-r--r--wiki/Configuration:-Layout.md4
3 files changed, 68 insertions, 1 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 701f5c5a..7d65008e 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -697,6 +697,8 @@ pub struct TabIndicator {
pub position: TabIndicatorPosition,
#[knuffel(child, unwrap(argument), default = Self::default().gaps_between_tabs)]
pub gaps_between_tabs: FloatOrInt<0, 65535>,
+ #[knuffel(child, unwrap(argument), default = Self::default().corner_radius)]
+ pub corner_radius: FloatOrInt<0, 65535>,
#[knuffel(child)]
pub active_color: Option<Color>,
#[knuffel(child)]
@@ -720,6 +722,7 @@ impl Default for TabIndicator {
},
position: TabIndicatorPosition::Left,
gaps_between_tabs: FloatOrInt(0.),
+ corner_radius: FloatOrInt(0.),
active_color: None,
inactive_color: None,
active_gradient: None,
@@ -1234,6 +1237,17 @@ impl From<CornerRadius> for [f32; 4] {
}
}
+impl From<f32> for CornerRadius {
+ fn from(value: f32) -> Self {
+ Self {
+ top_left: value,
+ top_right: value,
+ bottom_right: value,
+ bottom_left: value,
+ }
+ }
+}
+
#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq, Eq)]
pub enum BlockOutFrom {
Screencast,
diff --git a/src/layout/tab_indicator.rs b/src/layout/tab_indicator.rs
index e0e9ce75..182934ad 100644
--- a/src/layout/tab_indicator.rs
+++ b/src/layout/tab_indicator.rs
@@ -180,6 +180,11 @@ impl TabIndicator {
self.shaders.resize_with(count, Default::default);
self.shader_locs.resize_with(count, Default::default);
+ let position = self.config.position;
+ let radius = self.config.corner_radius.0 as f32;
+ let shared_rounded_corners = self.config.gaps_between_tabs.0 == 0.;
+ let mut tabs_left = tab_count;
+
let rects = self.tab_rects(area, count, scale);
for ((shader, loc), (tab, rect)) in zip(
zip(&mut self.shaders, &mut self.shader_locs),
@@ -200,6 +205,50 @@ impl TabIndicator {
color_to *= 0.5;
}
+ let radius = if shared_rounded_corners && tab_count > 1 {
+ if tabs_left == tab_count {
+ // First tab.
+ match position {
+ TabIndicatorPosition::Left | TabIndicatorPosition::Right => CornerRadius {
+ top_left: radius,
+ top_right: radius,
+ bottom_right: 0.,
+ bottom_left: 0.,
+ },
+ TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => CornerRadius {
+ top_left: radius,
+ top_right: 0.,
+ bottom_right: 0.,
+ bottom_left: radius,
+ },
+ }
+ } else if tabs_left == 1 {
+ // Last tab.
+ match position {
+ TabIndicatorPosition::Left | TabIndicatorPosition::Right => CornerRadius {
+ top_left: 0.,
+ top_right: 0.,
+ bottom_right: radius,
+ bottom_left: radius,
+ },
+ TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => CornerRadius {
+ top_left: 0.,
+ top_right: radius,
+ bottom_right: radius,
+ bottom_left: 0.,
+ },
+ }
+ } else {
+ // Tab in the middle.
+ CornerRadius::default()
+ }
+ } else {
+ // Separate tabs, or the only tab.
+ CornerRadius::from(radius)
+ };
+ let radius = radius.fit_to(rect.size.w as f32, rect.size.h as f32);
+ tabs_left -= 1;
+
shader.update(
rect.size,
gradient_area,
@@ -209,7 +258,7 @@ impl TabIndicator {
((tab.gradient.angle as f32) - 90.).to_radians(),
Rectangle::from_size(rect.size),
0.,
- CornerRadius::default(),
+ radius,
scale as f32,
1.,
);
diff --git a/wiki/Configuration:-Layout.md b/wiki/Configuration:-Layout.md
index bc9e4218..d3bd6aaf 100644
--- a/wiki/Configuration:-Layout.md
+++ b/wiki/Configuration:-Layout.md
@@ -63,6 +63,7 @@ layout {
length total-proportion=1.0
position "right"
gaps-between-tabs 2
+ corner-radius 8
active-color "red"
inactive-color "gray"
// active-gradient from="#80c8ff" to="#bbddff" angle=45
@@ -439,6 +440,9 @@ It can be `left`, `right`, `top`, or `bottom`.
`gaps-between-tabs` controls the gap between individual tabs in logical pixels.
+`corner-radius` sets the rounded corner radius for tabs in the indicator in logical pixels.
+When `gaps-between-tabs` is zero, only the first and the last tabs have rounded corners, otherwise all tabs do.
+
`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.