forge
Explore
Log in

Don't you dare go Hollow

tab indicator: Add hide-when-single-tab

Browse files at this commit

d7d5a7f8f6c3faf7e1ea1a36df053769243b51acIvan MolodetskikhParent: a451f75
niri-config/src/lib.rsmodified+3 -0
@@ -683,6 +683,8 @@ pub struct ShadowOffset {
683 pub struct TabIndicator {683 pub struct TabIndicator {
684 #[knuffel(child)]684 #[knuffel(child)]
685 pub off: bool,685 pub off: bool,
686+ #[knuffel(child)]
687+ pub hide_when_single_tab: bool,
686 #[knuffel(child, unwrap(argument), default = Self::default().gap)]688 #[knuffel(child, unwrap(argument), default = Self::default().gap)]
687 pub gap: FloatOrInt<-65535, 65535>,689 pub gap: FloatOrInt<-65535, 65535>,
688 #[knuffel(child, unwrap(argument), default = Self::default().width)]690 #[knuffel(child, unwrap(argument), default = Self::default().width)]
@@ -703,6 +705,7 @@ impl Default for TabIndicator {
703 fn default() -> Self {705 fn default() -> Self {
704 Self {706 Self {
705 off: false,707 off: false,
708+ hide_when_single_tab: false,
706 gap: FloatOrInt(5.),709 gap: FloatOrInt(5.),
707 width: FloatOrInt(4.),710 width: FloatOrInt(4.),
708 length: TabIndicatorLength {711 length: TabIndicatorLength {
src/layout/tab_indicator.rsmodified+7 -1
@@ -63,6 +63,13 @@ impl TabIndicator {
63 return;63 return;
64 }64 }
65 65
66+ let count = tabs.clone().count();
67+ if self.config.hide_when_single_tab && count == 1 {
68+ self.shader_locs.clear();
69+ self.shaders.clear();
70+ return;
71+ }
72+
66 // Tab indicators are rendered relative to the tile geometry.73 // Tab indicators are rendered relative to the tile geometry.
67 let tile_geo = Rectangle::new(Point::from((0., 0.)), tile_size);74 let tile_geo = Rectangle::new(Point::from((0., 0.)), tile_size);
68 75
@@ -74,7 +81,6 @@ impl TabIndicator {
74 let total_prop = self.config.length.total_proportion.unwrap_or(0.5);81 let total_prop = self.config.length.total_proportion.unwrap_or(0.5);
75 let min_length = round(tile_size.h * total_prop.clamp(0., 2.));82 let min_length = round(tile_size.h * total_prop.clamp(0., 2.));
76 83
77- let count = tabs.clone().count();
78 self.shaders.resize_with(count, Default::default);84 self.shaders.resize_with(count, Default::default);
79 self.shader_locs.resize_with(count, Default::default);85 self.shader_locs.resize_with(count, Default::default);
80 86
src/layout/tests.rsmodified+2 -0
@@ -3242,12 +3242,14 @@ prop_compose! {
3242 prop_compose! {3242 prop_compose! {
3243 fn arbitrary_tab_indicator()(3243 fn arbitrary_tab_indicator()(
3244 off in any::<bool>(),3244 off in any::<bool>(),
3245+ hide_when_single_tab in any::<bool>(),
3245 width in arbitrary_spacing(),3246 width in arbitrary_spacing(),
3246 gap in arbitrary_spacing_neg(),3247 gap in arbitrary_spacing_neg(),
3247 length in (0f64..2f64),3248 length in (0f64..2f64),
3248 ) -> niri_config::TabIndicator {3249 ) -> niri_config::TabIndicator {
3249 niri_config::TabIndicator {3250 niri_config::TabIndicator {
3250 off,3251 off,
3252+ hide_when_single_tab,
3251 width: FloatOrInt(width),3253 width: FloatOrInt(width),
3252 gap: FloatOrInt(gap),3254 gap: FloatOrInt(gap),
3253 length: TabIndicatorLength { total_proportion: Some(length) },3255 length: TabIndicatorLength { total_proportion: Some(length) },