mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 19:27:22 +03:00
gui: tighten up fancy tab bar to 1.75 line height
Add bottom alignment for tabs and make them slightly shorter than the right status area; this avoids some pixel gaps.
This commit is contained in:
parent
13ac944e7f
commit
4ca7514029
@ -20,6 +20,18 @@ use wezterm_font::LoadedFont;
|
||||
use wezterm_term::color::{ColorAttribute, ColorPalette};
|
||||
use window::bitmaps::atlas::Sprite;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum VerticalAlign {
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
impl Default for VerticalAlign {
|
||||
fn default() -> VerticalAlign {
|
||||
VerticalAlign::Top
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum DisplayType {
|
||||
Block,
|
||||
@ -202,6 +214,7 @@ impl ElementColors {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Element {
|
||||
pub item_type: Option<UIItemType>,
|
||||
pub vertical_align: VerticalAlign,
|
||||
pub zindex: i8,
|
||||
pub display: DisplayType,
|
||||
pub float: Float,
|
||||
@ -228,6 +241,7 @@ impl Element {
|
||||
margin: BoxDimension::default(),
|
||||
border: BoxDimension::default(),
|
||||
border_corners: None,
|
||||
vertical_align: VerticalAlign::default(),
|
||||
colors: ElementColors::default(),
|
||||
hover_colors: None,
|
||||
font: Rc::clone(font),
|
||||
@ -264,6 +278,11 @@ impl Element {
|
||||
Self::new(font, ElementContent::Children(content))
|
||||
}
|
||||
|
||||
pub fn vertical_align(mut self, align: VerticalAlign) -> Self {
|
||||
self.vertical_align = align;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn item_type(mut self, item_type: UIItemType) -> Self {
|
||||
self.item_type.replace(item_type);
|
||||
self
|
||||
@ -591,6 +610,12 @@ impl super::TermWindow {
|
||||
computed_kids.push(kid);
|
||||
}
|
||||
|
||||
for (kid, child) in computed_kids.iter_mut().zip(kids.iter()) {
|
||||
if child.vertical_align == VerticalAlign::Bottom {
|
||||
kid.translate(euclid::vec2(0., pixel_height - kid.bounds.height()));
|
||||
}
|
||||
}
|
||||
|
||||
computed_kids.sort_by(|a, b| a.zindex.cmp(&b.zindex));
|
||||
|
||||
let content_rect = euclid::rect(0., 0., max_x, pixel_height);
|
||||
|
@ -447,7 +447,7 @@ impl super::TermWindow {
|
||||
.item_type(UIItemType::TabBar(TabBarItem::None))
|
||||
.zindex(-1)
|
||||
.float(Float::Right)
|
||||
.line_height(Some(2.0))
|
||||
.line_height(Some(1.75))
|
||||
.margin(BoxDimension {
|
||||
left: Dimension::Cells(0.),
|
||||
right: Dimension::Cells(0.),
|
||||
@ -468,16 +468,17 @@ impl super::TermWindow {
|
||||
}),
|
||||
TabBarItem::NewTabButton => element
|
||||
.item_type(UIItemType::TabBar(item.item.clone()))
|
||||
.vertical_align(VerticalAlign::Bottom)
|
||||
.margin(BoxDimension {
|
||||
left: Dimension::Cells(0.5),
|
||||
right: Dimension::Cells(0.),
|
||||
top: Dimension::Cells(0.25),
|
||||
top: Dimension::Cells(0.2),
|
||||
bottom: Dimension::Cells(0.),
|
||||
})
|
||||
.padding(BoxDimension {
|
||||
left: Dimension::Cells(0.5),
|
||||
right: Dimension::Cells(0.5),
|
||||
top: Dimension::Cells(0.25),
|
||||
top: Dimension::Cells(0.2),
|
||||
bottom: Dimension::Cells(0.25),
|
||||
})
|
||||
.border(BoxDimension::new(Dimension::Pixels(1.)))
|
||||
@ -495,17 +496,18 @@ impl super::TermWindow {
|
||||
})),
|
||||
TabBarItem::Tab { active, .. } if active => element
|
||||
.item_type(UIItemType::TabBar(item.item.clone()))
|
||||
.vertical_align(VerticalAlign::Bottom)
|
||||
.margin(BoxDimension {
|
||||
left: Dimension::Cells(0.),
|
||||
right: Dimension::Cells(0.),
|
||||
top: Dimension::Cells(0.25),
|
||||
top: Dimension::Cells(0.2),
|
||||
bottom: Dimension::Cells(0.),
|
||||
})
|
||||
.padding(BoxDimension {
|
||||
left: Dimension::Cells(0.5),
|
||||
right: Dimension::Cells(0.5),
|
||||
top: Dimension::Cells(0.25),
|
||||
bottom: Dimension::Cells(0.5),
|
||||
top: Dimension::Cells(0.2),
|
||||
bottom: Dimension::Cells(0.25),
|
||||
})
|
||||
.border(BoxDimension::new(Dimension::Pixels(1.)))
|
||||
.border_corners(Some(Corners {
|
||||
@ -531,17 +533,18 @@ impl super::TermWindow {
|
||||
}),
|
||||
TabBarItem::Tab { .. } => element
|
||||
.item_type(UIItemType::TabBar(item.item.clone()))
|
||||
.vertical_align(VerticalAlign::Bottom)
|
||||
.margin(BoxDimension {
|
||||
left: Dimension::Cells(0.),
|
||||
right: Dimension::Cells(0.),
|
||||
top: Dimension::Cells(0.25),
|
||||
top: Dimension::Cells(0.2),
|
||||
bottom: Dimension::Cells(0.),
|
||||
})
|
||||
.padding(BoxDimension {
|
||||
left: Dimension::Cells(0.5),
|
||||
right: Dimension::Cells(0.5),
|
||||
top: Dimension::Cells(0.25),
|
||||
bottom: Dimension::Cells(0.5),
|
||||
top: Dimension::Cells(0.2),
|
||||
bottom: Dimension::Cells(0.25),
|
||||
})
|
||||
.border(BoxDimension::new(Dimension::Pixels(1.)))
|
||||
.border_corners(Some(Corners {
|
||||
|
Loading…
Reference in New Issue
Block a user