Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show tab numbers in CollapsedTab layout #593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontends/rioterm/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.;
Expand Down
18 changes: 15 additions & 3 deletions frontends/rioterm/src/state/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down
Loading