Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
e82eric committed Jul 3, 2024
1 parent 203e362 commit 0da8a62
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 157 deletions.
8 changes: 7 additions & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ use crate::tls::{TlsDomainClient, TlsDomainServer};
use crate::units::Dimension;
use crate::unix::UnixDomain;
use crate::wsl::WslDomain;
use crate::{default_config_with_overrides_applied, default_one_point_oh, default_one_point_oh_f64, default_true, default_win32_acrylic_accent_color, GpuInfo, IntegratedTitleButtonColor, KeyMapPreference, LoadedConfig, MouseEventTriggerMods, RgbaColor, SerialDomain, SystemBackdrop, WebGpuPowerPreference, CONFIG_DIRS, CONFIG_FILE_OVERRIDE, CONFIG_OVERRIDES, CONFIG_SKIP, HOME_DIR, FloatBorderConfig};
use crate::{
default_config_with_overrides_applied, default_one_point_oh, default_one_point_oh_f64,
default_true, default_win32_acrylic_accent_color, GpuInfo, IntegratedTitleButtonColor,
KeyMapPreference, LoadedConfig, MouseEventTriggerMods, RgbaColor, SerialDomain, SystemBackdrop,
WebGpuPowerPreference, CONFIG_DIRS, CONFIG_FILE_OVERRIDE, CONFIG_OVERRIDES, CONFIG_SKIP,
HOME_DIR,FloatBorderConfig
};
use anyhow::Context;
use luahelper::impl_lua_conversion_dynamic;
use mlua::FromLua;
Expand Down
13 changes: 9 additions & 4 deletions mux/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,10 @@ impl TabInner {
}
}

if let Some(float_pane) = self.get_float_pane() {
panes.push(float_pane);
}

let active_idx = self.active;
let zoomed_id = self.zoomed.as_ref().map(|p| p.pane_id());
let root_size = self.size;
Expand Down Expand Up @@ -1200,6 +1204,11 @@ impl TabInner {
return;
}

if let Some(float_pane) = &self.float_pane {
let float_size = self.get_float_size();
float_pane.resize(float_size).ok();
}

if let Some(zoomed) = &self.zoomed {
self.size = size;
zoomed.resize(size).ok();
Expand Down Expand Up @@ -1235,10 +1244,6 @@ impl TabInner {

// And then resize the individual panes to match
apply_sizes_from_splits(self.pane.as_mut().unwrap(), &size);
if let Some(float_pane) = &self.float_pane {
let float_size = self.get_float_size();
float_pane.resize(float_size);
}
}

Mux::try_get().map(|mux| mux.notify(MuxNotification::TabResized(self.id)));
Expand Down
145 changes: 131 additions & 14 deletions wezterm-gui/src/termwindow/render/borders.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::quad::TripleLayerQuadAllocator;
use crate::utilsprites::RenderMetrics;
use ::window::ULength;
use config::{ConfigHandle, DimensionContext, FloatBorderConfig};
use config::{ConfigHandle, DimensionContext, FloatBorderConfig, PixelUnit};
use mux::tab::PositionedPane;
use window::parameters::Border;

impl crate::TermWindow {
pub fn paint_window_borders(
Expand Down Expand Up @@ -78,6 +80,128 @@ impl crate::TermWindow {
Ok(())
}

pub fn paint_float_border(
&mut self,
pos: PositionedPane,
layers: &mut TripleLayerQuadAllocator,
) -> anyhow::Result<()> {
let (padding_left, padding_top) = self.padding_left_top();
let config = self.config.float_pane_border.clone();
let float_border = self.get_float_border();

let os_border = self.get_os_border();
let tab_bar_height = if self.show_tab_bar {
self.tab_bar_pixel_height()?
} else {
0.
};

let (top_bar_height, _bottom_bar_height) = if self.config.tab_bar_at_bottom {
(0.0, tab_bar_height)
} else {
(tab_bar_height, 0.0)
};
let top_pixel_y = top_bar_height + padding_top + os_border.top.get() as f32;
let cell_height = self.render_metrics.cell_size.height as f32;
let cell_width = self.render_metrics.cell_size.width as f32;

let background_rect: euclid::Rect<f32, PixelUnit> = {
// We want to fill out to the edges of the splits
let (x, width_delta) = if pos.left == 0 {
(
0.,
padding_left + os_border.left.get() as f32 + (cell_width / 2.0),
)
} else {
(
padding_left + os_border.left.get() as f32 - (cell_width / 2.0)
+ (pos.left as f32 * cell_width),
cell_width,
)
};

let (y, height_delta) = if pos.top == 0 {
(
(top_pixel_y - padding_top),
padding_top + (cell_height / 2.0),
)
} else {
(
top_pixel_y + (pos.top as f32 * cell_height) - (cell_height / 2.0),
cell_height,
)
};
euclid::rect(
x,
y,
// Go all the way to the right edge if we're right-most
if pos.left + pos.width >= self.terminal_size.cols as usize {
self.dimensions.pixel_width as f32 - x
} else {
(pos.width as f32 * cell_width) + width_delta
},
// Go all the way to the bottom if we're bottom-most
if pos.top + pos.height >= self.terminal_size.rows as usize {
self.dimensions.pixel_height as f32 - y
} else {
(pos.height as f32 * cell_height) + height_delta as f32
},
)
};

let pos_y = background_rect.origin.y - float_border.top.get() as f32;
let pos_x = background_rect.origin.x - float_border.left.get() as f32;
let pixel_width = background_rect.size.width + float_border.left.get() as f32;
let pixel_height = background_rect.size.height + float_border.top.get() as f32;

self.filled_rectangle(
layers,
2,
euclid::rect(
pos_x,
pos_y,
float_border.left.get() as f32,
pixel_height + float_border.top.get() as f32,
),
config.left_color.map(|c| c.to_linear()).unwrap_or(os_border.color),
)?;
self.filled_rectangle(
layers,
2,
euclid::rect(
pos_x + float_border.left.get() as f32,
pos_y,
pixel_width,
float_border.top.get() as f32,
),
config.top_color.map(|c| c.to_linear()).unwrap_or(os_border.color),
)?;
self.filled_rectangle(
layers,
2,
euclid::rect(
pos_x + float_border.left.get() as f32,
pos_y + pixel_height,
pixel_width,
float_border.bottom.get() as f32,
),
config.bottom_color.map(|c| c.to_linear()).unwrap_or(os_border.color),
)?;
self.filled_rectangle(
layers,
2,
euclid::rect(
pos_x + pixel_width,
pos_y,
float_border.right.get() as f32,
pixel_height + float_border.top.get() as f32,
),
config.right_color.map(|c| c.to_linear()).unwrap_or(os_border.color),
)?;

Ok(())
}

pub fn get_os_border_impl(
os_parameters: &Option<window::parameters::Parameters>,
config: &ConfigHandle,
Expand Down Expand Up @@ -137,18 +261,13 @@ impl crate::TermWindow {
border
}

pub fn get_os_border_impl2(
os_parameters: &Option<window::parameters::Parameters>,
config: &ConfigHandle,
//refactor with get_os_border_impl?
fn get_float_border_impl(
dimensions: &crate::Dimensions,
render_metrics: &RenderMetrics,
border_config: &FloatBorderConfig
) -> window::parameters::Border {
let mut border = os_parameters
.as_ref()
.and_then(|p| p.border_dimensions.clone())
.unwrap_or_default();

) -> Border {
let mut border= Border::default();
border.left += ULength::new(
border_config
.left_width
Expand Down Expand Up @@ -193,10 +312,8 @@ impl crate::TermWindow {
border
}

pub fn get_float_border(&self) -> window::parameters::Border {
Self::get_os_border_impl2(
&self.os_parameters,
&self.config,
fn get_float_border(&self) -> Border {
Self::get_float_border_impl(
&self.dimensions,
&self.render_metrics,
&self.config.float_pane_border
Expand Down
15 changes: 7 additions & 8 deletions wezterm-gui/src/termwindow/render/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl crate::TermWindow {
.context("filled_rectangle for window background")?;
}

let mut float_layers = float_layer.quad_allocator();
for pos in panes {
if pos.is_active {
self.update_text_cursor(&pos);
Expand All @@ -259,14 +260,12 @@ impl crate::TermWindow {
mux::Mux::get().record_focus_for_current_identity(pos.pane.pane_id());
}
}
self.paint_pane(&pos, &mut layers).context("paint_pane")?;
}

if let Some(float_pane) = self.get_float_pane_to_render() {
let mut float_layers = float_layer.quad_allocator();

self.paint_pane(&float_pane, &mut float_layers).context("paint_pane")?;
self.paint_float_border(float_pane, &mut float_layers).context("paint_float_border")?;
if pos.is_float {
self.paint_pane(&pos, &mut float_layers).context("paint_pane")?;
self.paint_float_border(pos, &mut float_layers).context("paint_float_border")?;
} else {
self.paint_pane(&pos, &mut layers).context("paint_pane")?;
}
}

if let Some(pane) = self.get_active_pane_or_overlay() {
Expand Down
11 changes: 5 additions & 6 deletions wezterm-gui/src/termwindow/render/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl crate::TermWindow {
let window_is_transparent =
!self.window_background.is_empty() || config.window_background_opacity != 1.0;

let mut default_bg = palette
let default_bg = palette
.resolve_bg(ColorAttribute::Default)
.to_linear()
.mul_alpha(if window_is_transparent {
Expand Down Expand Up @@ -159,11 +159,10 @@ impl crate::TermWindow {
layers,
0,
background_rect,
default_bg,
//palette
// .foreground
// .to_linear()
// .mul_alpha(config.window_background_opacity),
palette
.background
.to_linear()
.mul_alpha(config.window_background_opacity),
)
.context("filled_rectangle")?;
quad.set_hsv(if pos.is_active {
Expand Down
Loading

0 comments on commit 0da8a62

Please sign in to comment.