aboutsummaryrefslogtreecommitdiff
path: root/src/layout/tab_indicator.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-02-07 09:36:08 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-02-10 07:29:33 -0800
commitc31b58e2c9a786fc8c96bba462190374535e6819 (patch)
tree6b2b1e93b01cf3152c9e62fd483d4a09d02bfb05 /src/layout/tab_indicator.rs
parentb1630457571330335ece184ca5e7a1c1acffb107 (diff)
downloadniri-c31b58e2c9a786fc8c96bba462190374535e6819.tar.gz
niri-c31b58e2c9a786fc8c96bba462190374535e6819.tar.bz2
niri-c31b58e2c9a786fc8c96bba462190374535e6819.zip
tab indicator: Implement place-within-column setting
Diffstat (limited to 'src/layout/tab_indicator.rs')
-rw-r--r--src/layout/tab_indicator.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/layout/tab_indicator.rs b/src/layout/tab_indicator.rs
index 295eecc6..72652369 100644
--- a/src/layout/tab_indicator.rs
+++ b/src/layout/tab_indicator.rs
@@ -174,6 +174,39 @@ impl TabIndicator {
Some(rv).into_iter().flatten()
}
+ /// Extra size occupied by the tab indicator.
+ pub fn extra_size(&self, tab_count: usize, scale: f64) -> Size<f64, Logical> {
+ if self.config.off
+ || !self.config.place_within_column
+ || (self.config.hide_when_single_tab && tab_count == 1)
+ {
+ return Size::from((0., 0.));
+ }
+
+ let round = |logical: f64| round_logical_in_physical(scale, logical);
+ let width = round(self.config.width.0);
+ let gap = round(self.config.gap.0);
+
+ // No, I am *not* falling into the rabbit hole of "what if the tab indicator is wide enough
+ // that it peeks from the other side of the window".
+ let size = f64::max(0., width + gap);
+
+ match self.config.position {
+ TabIndicatorPosition::Left | TabIndicatorPosition::Right => Size::from((size, 0.)),
+ TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => Size::from((0., size)),
+ }
+ }
+
+ /// Offset of the tabbed content due to space occupied by the tab indicator.
+ pub fn content_offset(&self, tab_count: usize, scale: f64) -> Point<f64, Logical> {
+ match self.config.position {
+ TabIndicatorPosition::Left | TabIndicatorPosition::Top => {
+ self.extra_size(tab_count, scale).to_point()
+ }
+ TabIndicatorPosition::Right | TabIndicatorPosition::Bottom => Point::from((0., 0.)),
+ }
+ }
+
pub fn config(&self) -> niri_config::TabIndicator {
self.config
}