tab indicator: Add hide-when-single-tab

This commit is contained in:
Ivan Molodetskikh
2025-02-05 08:09:48 +03:00
parent a451f75917
commit d7d5a7f8f6
3 changed files with 12 additions and 1 deletions
+3
View File
@@ -683,6 +683,8 @@ pub struct ShadowOffset {
pub struct TabIndicator {
#[knuffel(child)]
pub off: bool,
#[knuffel(child)]
pub hide_when_single_tab: bool,
#[knuffel(child, unwrap(argument), default = Self::default().gap)]
pub gap: FloatOrInt<-65535, 65535>,
#[knuffel(child, unwrap(argument), default = Self::default().width)]
@@ -703,6 +705,7 @@ impl Default for TabIndicator {
fn default() -> Self {
Self {
off: false,
hide_when_single_tab: false,
gap: FloatOrInt(5.),
width: FloatOrInt(4.),
length: TabIndicatorLength {
+7 -1
View File
@@ -63,6 +63,13 @@ impl TabIndicator {
return;
}
let count = tabs.clone().count();
if self.config.hide_when_single_tab && count == 1 {
self.shader_locs.clear();
self.shaders.clear();
return;
}
// Tab indicators are rendered relative to the tile geometry.
let tile_geo = Rectangle::new(Point::from((0., 0.)), tile_size);
@@ -74,7 +81,6 @@ impl TabIndicator {
let total_prop = self.config.length.total_proportion.unwrap_or(0.5);
let min_length = round(tile_size.h * total_prop.clamp(0., 2.));
let count = tabs.clone().count();
self.shaders.resize_with(count, Default::default);
self.shader_locs.resize_with(count, Default::default);
+2
View File
@@ -3242,12 +3242,14 @@ prop_compose! {
prop_compose! {
fn arbitrary_tab_indicator()(
off in any::<bool>(),
hide_when_single_tab in any::<bool>(),
width in arbitrary_spacing(),
gap in arbitrary_spacing_neg(),
length in (0f64..2f64),
) -> niri_config::TabIndicator {
niri_config::TabIndicator {
off,
hide_when_single_tab,
width: FloatOrInt(width),
gap: FloatOrInt(gap),
length: TabIndicatorLength { total_proportion: Some(length) },