1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-21 11:50:42 +03:00

paneselect: adjust padding/styling

This commit is contained in:
Wez Furlong 2022-05-24 06:37:36 -07:00
parent a5162765e9
commit 06db8b51aa
3 changed files with 83 additions and 12 deletions

View File

@ -111,7 +111,7 @@ impl Corners {
top_left: self.top_left.to_pixels(context),
top_right: self.top_right.to_pixels(context),
bottom_left: self.bottom_left.to_pixels(context),
bottom_right: self.bottom_left.to_pixels(context),
bottom_right: self.bottom_right.to_pixels(context),
}
}
}

View File

@ -1,10 +1,14 @@
use crate::color::LinearRgba;
use crate::termwindow::box_model::*;
use crate::termwindow::modal::Modal;
use crate::termwindow::render::{
rgbcolor_to_window_color, BOTTOM_LEFT_ROUNDED_CORNER, BOTTOM_RIGHT_ROUNDED_CORNER,
TOP_LEFT_ROUNDED_CORNER, TOP_RIGHT_ROUNDED_CORNER,
};
use crate::termwindow::DimensionContext;
use crate::utilsprites::RenderMetrics;
use crate::TermWindow;
use config::keyassignment::{KeyAssignment, PaneSelectArguments};
use config::{Dimension, TabBarColors};
use mux::Mux;
use std::cell::{Ref, RefCell};
use wezterm_term::{KeyCode, KeyModifiers, MouseEvent};
@ -54,15 +58,54 @@ impl PaneSelector {
let labels =
crate::overlay::quickselect::compute_labels_for_alphabet(alphabet, panes.len());
let colors = term_window
.config
.colors
.as_ref()
.and_then(|c| c.tab_bar.as_ref())
.cloned()
.unwrap_or_else(TabBarColors::default);
let mut elements = vec![];
for pos in panes {
let caption = labels[pos.index].clone();
let element =
Element::new(&font, ElementContent::Text(caption)).colors(ElementColors {
border: BorderColor::default(),
bg: LinearRgba::with_srgba(0x00, 0x00, 0x00, 0xff).into(),
text: LinearRgba::with_srgba(0xff, 0xff, 0xff, 0xff).into(),
});
let element = Element::new(&font, ElementContent::Text(caption))
.colors(ElementColors {
border: BorderColor::new(
rgbcolor_to_window_color(colors.active_tab.bg_color).into(),
),
bg: rgbcolor_to_window_color(colors.active_tab.bg_color).into(),
text: rgbcolor_to_window_color(colors.active_tab.fg_color).into(),
})
.padding(BoxDimension {
left: Dimension::Cells(0.25),
right: Dimension::Cells(0.25),
top: Dimension::Cells(0.),
bottom: Dimension::Cells(0.),
})
.border(BoxDimension::new(Dimension::Pixels(1.)))
.border_corners(Some(Corners {
top_left: SizedPoly {
width: Dimension::Cells(0.25),
height: Dimension::Cells(0.25),
poly: TOP_LEFT_ROUNDED_CORNER,
},
top_right: SizedPoly {
width: Dimension::Cells(0.25),
height: Dimension::Cells(0.25),
poly: TOP_RIGHT_ROUNDED_CORNER,
},
bottom_left: SizedPoly {
width: Dimension::Cells(0.25),
height: Dimension::Cells(0.25),
poly: BOTTOM_LEFT_ROUNDED_CORNER,
},
bottom_right: SizedPoly {
width: Dimension::Cells(0.25),
height: Dimension::Cells(0.25),
poly: BOTTOM_RIGHT_ROUNDED_CORNER,
},
}));
let dimensions = term_window.dimensions;
let pane_dims = pos.pane.get_dimensions();

View File

@ -43,7 +43,7 @@ use wezterm_term::{CellAttributes, Line, StableRowIndex};
use window::bitmaps::Texture2d;
use window::color::LinearRgba;
const TOP_LEFT_ROUNDED_CORNER: &[Poly] = &[Poly {
pub const TOP_LEFT_ROUNDED_CORNER: &[Poly] = &[Poly {
path: &[
PolyCommand::MoveTo(BlockCoord::One, BlockCoord::One),
PolyCommand::LineTo(BlockCoord::One, BlockCoord::Zero),
@ -57,7 +57,21 @@ const TOP_LEFT_ROUNDED_CORNER: &[Poly] = &[Poly {
style: PolyStyle::Fill,
}];
const TOP_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
pub const BOTTOM_LEFT_ROUNDED_CORNER: &[Poly] = &[Poly {
path: &[
PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
PolyCommand::LineTo(BlockCoord::One, BlockCoord::One),
PolyCommand::QuadTo {
control: (BlockCoord::Zero, BlockCoord::One),
to: (BlockCoord::Zero, BlockCoord::Zero),
},
PolyCommand::Close,
],
intensity: BlockAlpha::Full,
style: PolyStyle::Fill,
}];
pub const TOP_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
path: &[
PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::One),
PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::Zero),
@ -71,6 +85,20 @@ const TOP_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
style: PolyStyle::Fill,
}];
pub const BOTTOM_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
path: &[
PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::One),
PolyCommand::QuadTo {
control: (BlockCoord::One, BlockCoord::One),
to: (BlockCoord::One, BlockCoord::Zero),
},
PolyCommand::Close,
],
intensity: BlockAlpha::Full,
style: PolyStyle::Fill,
}];
const X_BUTTON: &[Poly] = &[
Poly {
path: &[
@ -517,8 +545,8 @@ impl super::TermWindow {
.border(BoxDimension::new(Dimension::Pixels(0.)))
.colors(ElementColors {
border: BorderColor::default(),
bg: rgbcolor_to_window_color(colors.inactive_tab.bg_color).into(),
text: rgbcolor_to_window_color(colors.inactive_tab.fg_color).into(),
bg: rgbcolor_to_window_color(colors.active_tab.bg_color).into(),
text: rgbcolor_to_window_color(colors.active_tab.fg_color).into(),
}),
TabBarItem::NewTabButton => Element::new(
&font,