mirror of
https://github.com/wez/wezterm.git
synced 2024-11-28 09:12:19 +03:00
gui: fixup some alignment/layout math for tab bar
bottom placement had mismatched render and hit test locations. Tweak how we generate per-tab info for fancy tab mode.
This commit is contained in:
parent
839fe2d8cc
commit
f511f9f52e
@ -113,25 +113,30 @@ fn compute_tab_title(
|
||||
None => {
|
||||
let title = if let Some(pane) = &tab.active_pane {
|
||||
let mut title = pane.title.clone();
|
||||
let classic_spacing = if config.use_fancy_tab_bar { "" } else { " " };
|
||||
if config.show_tab_index_in_tab_bar {
|
||||
title = format!(
|
||||
" {}: {} ",
|
||||
"{}{}: {}{}",
|
||||
classic_spacing,
|
||||
tab.tab_index
|
||||
+ if config.tab_and_split_indices_are_zero_based {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
},
|
||||
pane.title
|
||||
pane.title,
|
||||
classic_spacing,
|
||||
);
|
||||
}
|
||||
// We have a preferred soft minimum on tab width to make it
|
||||
// easier to click on tab titles, but we'll still go below
|
||||
// this if there are too many tabs to fit the window at
|
||||
// this width.
|
||||
if !config.use_fancy_tab_bar {
|
||||
while unicode_column_width(&title) < 5 {
|
||||
title.push(' ');
|
||||
}
|
||||
}
|
||||
title
|
||||
} else {
|
||||
" no pane ".to_string()
|
||||
@ -223,7 +228,7 @@ impl TabBarState {
|
||||
|
||||
let available_cells =
|
||||
title_width.saturating_sub(number_of_tabs.saturating_sub(1) + new_tab.cells().len());
|
||||
let tab_width_max = if available_cells >= titles_len {
|
||||
let tab_width_max = if config.use_fancy_tab_bar || available_cells >= titles_len {
|
||||
// We can render each title with its full width
|
||||
usize::max_value()
|
||||
} else {
|
||||
@ -264,7 +269,14 @@ impl TabBarState {
|
||||
let tab_start_idx = x;
|
||||
|
||||
let esc = format_as_escapes(tab_title.items.clone()).expect("already parsed ok above");
|
||||
let mut tab_line = parse_status_text(&esc, cell_attrs.clone());
|
||||
let mut tab_line = parse_status_text(
|
||||
&esc,
|
||||
if config.use_fancy_tab_bar {
|
||||
CellAttributes::default()
|
||||
} else {
|
||||
cell_attrs.clone()
|
||||
},
|
||||
);
|
||||
|
||||
let title = tab_line.clone();
|
||||
if tab_line.cells().len() > tab_width_max {
|
||||
|
@ -368,7 +368,7 @@ impl super::TermWindow {
|
||||
};
|
||||
let cell_clusters = item.title.cluster();
|
||||
let shaped = self.cluster_and_shape(&cell_clusters, ¶ms)?;
|
||||
let width: f32 = shaped.iter().map(|s| s.pixel_width).sum();
|
||||
let width = shaped.iter().map(|s| s.pixel_width).sum::<f32>();
|
||||
|
||||
let hover_x_start = pos_x + metrics.cell_width.get() as f32 / 4.;
|
||||
let hover_x_end = hover_x_start + width;
|
||||
@ -418,6 +418,13 @@ impl super::TermWindow {
|
||||
// width += metrics.cell_width.get() as f32 / 2.0;
|
||||
}
|
||||
|
||||
let (is_empty, width) = if is_status && width == 0. {
|
||||
(true, 0.)
|
||||
} else {
|
||||
(false, width + metrics.cell_width.get() as f32 / 2.)
|
||||
};
|
||||
|
||||
if !is_empty {
|
||||
{
|
||||
let mut quad = layers[0].allocate()?;
|
||||
quad.set_position(
|
||||
@ -437,7 +444,7 @@ impl super::TermWindow {
|
||||
self.render_screen_line_opengl(
|
||||
RenderScreenLineOpenGLParams {
|
||||
top_pixel_y: top_y * 2.,
|
||||
left_pixel_x: pos_x,
|
||||
left_pixel_x: pos_x + metrics.cell_width.get() as f32 / 4.,
|
||||
foreground: glyph_color,
|
||||
pre_shaped: Some(&shaped),
|
||||
font: Some(Rc::clone(font)),
|
||||
@ -446,6 +453,7 @@ impl super::TermWindow {
|
||||
},
|
||||
layers,
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok((
|
||||
bg_start + width,
|
||||
@ -558,25 +566,15 @@ impl super::TermWindow {
|
||||
}
|
||||
|
||||
let tab_bar_height = self.tab_bar_pixel_height()?;
|
||||
|
||||
let avail_height = self.dimensions.pixel_height.saturating_sub(
|
||||
(self.config.window_padding.top + self.config.window_padding.bottom) as usize,
|
||||
);
|
||||
let tab_bar_y = if self.config.tab_bar_at_bottom {
|
||||
self.dimensions.pixel_height as f32
|
||||
- self.config.window_padding.bottom as f32
|
||||
- tab_bar_height
|
||||
((self.dimensions.pixel_height as f32) - tab_bar_height).max(0.)
|
||||
} else {
|
||||
0.
|
||||
};
|
||||
|
||||
// Register the tab bar location
|
||||
self.ui_items.append(&mut self.tab_bar.compute_ui_items(
|
||||
if self.config.tab_bar_at_bottom {
|
||||
avail_height - self.render_metrics.cell_size.height as usize
|
||||
} else {
|
||||
0
|
||||
},
|
||||
tab_bar_y as usize,
|
||||
self.render_metrics.cell_size.height as usize,
|
||||
self.render_metrics.cell_size.width as usize,
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user