From f33148946e2755ed1adcb8a0aff2ebd5d3fca0d1 Mon Sep 17 00:00:00 2001 From: Diwas Rimal Date: Wed, 14 Aug 2024 12:41:30 +0545 Subject: [PATCH] Show tab numbers in CollapsedTab layout --- frontends/rioterm/src/constants.rs | 8 ++++---- frontends/rioterm/src/state/navigation.rs | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/frontends/rioterm/src/constants.rs b/frontends/rioterm/src/constants.rs index 0093644e1d..16d6c7218a 100644 --- a/frontends/rioterm/src/constants.rs +++ b/frontends/rioterm/src/constants.rs @@ -8,16 +8,16 @@ pub const PADDING_Y_WITH_TAB_ON_TOP: f32 = 15.0; pub const PADDING_Y: f32 = 26.; #[cfg(not(any(target_os = "macos")))] -pub const INACTIVE_TAB_WIDTH_SIZE: f32 = 4.; +pub const INACTIVE_TAB_HEIGHT_SIZE: f32 = 4.; #[cfg(target_os = "macos")] -pub const INACTIVE_TAB_WIDTH_SIZE: f32 = 16.; +pub const INACTIVE_TAB_HEIGHT_SIZE: f32 = 16.; #[cfg(not(any(target_os = "macos")))] -pub const ACTIVE_TAB_WIDTH_SIZE: f32 = 8.; +pub const ACTIVE_TAB_HEIGHT_SIZE: f32 = 8.; #[cfg(target_os = "macos")] -pub const ACTIVE_TAB_WIDTH_SIZE: f32 = 26.; +pub const ACTIVE_TAB_HEIGHT_SIZE: f32 = 26.; #[cfg(target_os = "macos")] pub const DEADZONE_START_Y: f64 = 30.; diff --git a/frontends/rioterm/src/state/navigation.rs b/frontends/rioterm/src/state/navigation.rs index 66e72b3a9f..59b5c2255c 100644 --- a/frontends/rioterm/src/state/navigation.rs +++ b/frontends/rioterm/src/state/navigation.rs @@ -150,10 +150,16 @@ impl ScreenNavigation { let position_modifier = 20.; for i in (0..len).rev() { let mut color = self.colors.inactive; - let mut size = INACTIVE_TAB_WIDTH_SIZE; + let mut tab_height = INACTIVE_TAB_HEIGHT_SIZE; + let mut tab_width = 30.; + let tab_number = i + 1; + if i == self.current { color = self.colors.active; - size = ACTIVE_TAB_WIDTH_SIZE; + tab_height = ACTIVE_TAB_HEIGHT_SIZE; + } + if tab_number >= 10 { + tab_width += 15.; } if let Some(name_idx) = titles.get(&i) { @@ -169,8 +175,14 @@ impl ScreenNavigation { let renderable = Rect { position: [initial_position, 0.0], color, - size: [30.0, size], + size: [tab_width, tab_height], }; + self.texts.push(Text::new( + (initial_position + 4., 8.), + (i + 1).to_string(), + 14., + [255., 255., 255., 255.], + )); initial_position -= position_modifier; self.rects.push(renderable); }