Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

ui scale display fix, mux fix

RoversX5bae864202a2
diff --git a/wezterm-gui/src/frontend.rs b/wezterm-gui/src/frontend.rs
index ffd04610..a6918db4 100644
--- a/wezterm-gui/src/frontend.rs
+++ b/wezterm-gui/src/frontend.rs
@@ -17,6 +17,10 @@ use std::sync::Arc;
use wezterm_term::{Alert, ClipboardSelection};
use wezterm_toast_notification::*;
+fn should_spawn_reconciled_gui_window(is_domain_owned: bool, workspace: &str) -> bool {
+ !is_domain_owned || crate::workspace_threads::is_thread_workspace_name(workspace)
+}
+
pub struct GuiFrontEnd {
connection: Rc<Connection>,
// Depth counter: > 0 means at least one window is mid-switch (materializing
@@ -439,6 +443,31 @@ impl GuiFrontEnd {
{
continue;
}
+
+ let mux = Mux::get();
+ let Some(mux_window) = mux.get_window(mux_window_id) else {
+ continue;
+ };
+ let is_domain_owned = mux_window.origin_domain().is_some();
+ let window_workspace = mux_window.get_workspace();
+
+ // Client domains mirror every remote mux window locally when
+ // they attach. That includes the server's own startup
+ // `default` window and other background workspaces that do not
+ // belong to a ThinkTerm Space/thread. They must stay available
+ // in the mux for protocol bookkeeping, but automatically
+ // giving them a GUI window creates the stray "local Space with
+ // a remote terminal" window and tangles its lifecycle with the
+ // real thread window.
+ if !should_spawn_reconciled_gui_window(is_domain_owned, window_workspace) {
+ log::debug!(
+ "reconcile: leaving background domain window {} in workspace {:?} hidden",
+ mux_window_id,
+ window_workspace,
+ );
+ continue;
+ }
+
front_end()
.spawned_mux_window
.borrow_mut()
@@ -449,9 +478,6 @@ impl GuiFrontEnd {
// re-point the GUI window at a different mux window and orphan
// the one the domain just created (killing e.g. the in-window
// ConnectionUI mid-authentication).
- let is_domain_owned = Mux::get()
- .get_window(mux_window_id)
- .map_or(false, |w| w.origin_domain().is_some());
let created = if is_domain_owned {
TermWindow::new_window_without_restore(mux_window_id).await
} else {
@@ -725,3 +751,42 @@ pub fn try_new() -> Result<Rc<GuiFrontEnd>, Error> {
Ok(front_end)
}
+
+#[cfg(test)]
+mod tests {
+ use super::should_spawn_reconciled_gui_window;
+
+ #[test]
+ fn reconcile_keeps_local_windows_visible() {
+ assert!(should_spawn_reconciled_gui_window(false, "default"));
+ assert!(should_spawn_reconciled_gui_window(
+ false,
+ "user-created-workspace"
+ ));
+ }
+
+ #[test]
+ fn reconcile_hides_background_domain_windows() {
+ assert!(!should_spawn_reconciled_gui_window(true, "default"));
+ assert!(!should_spawn_reconciled_gui_window(
+ true,
+ "unmanaged-remote-workspace"
+ ));
+ assert!(!should_spawn_reconciled_gui_window(
+ true,
+ "thinkterm:not-a-thread-workspace"
+ ));
+ }
+
+ #[test]
+ fn reconcile_shows_thinkterm_domain_thread_windows() {
+ assert!(should_spawn_reconciled_gui_window(
+ true,
+ "thinkterm:muxdomain-host::space::space-1:thread-2"
+ ));
+ assert!(should_spawn_reconciled_gui_window(
+ true,
+ "thinkterm:muxdomain-host::space::space-1:thread-2:remote-default"
+ ));
+ }
+}
diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rs
index 363594f5..1b1d2c71 100644
--- a/wezterm-gui/src/settings_window.rs
+++ b/wezterm-gui/src/settings_window.rs
@@ -8,9 +8,9 @@ use crate::termwindow::render::corners::{
use crate::termwindow::render::draw::draw_webgpu_layers;
use crate::termwindow::webgpu::WebGpuState;
use crate::ui::{
- rect, ButtonSpec, ControlState, InteractionState, ResizablePaneState, ScrollState,
- ScrollbarSpec, SettingsIcon, SvgIcon, TextInputSpec, TextInputState, UiContext, UiPalette,
- UiTokens, WidgetKind,
+ rect, scale_ui_f32, scale_ui_usize, ButtonSpec, ControlState, InteractionState,
+ ResizablePaneState, ScrollState, ScrollbarSpec, SettingsIcon, SvgIcon, TextInputSpec,
+ TextInputState, UiContext, UiPalette, UiTokens, WidgetKind,
};
use crate::utilsprites::RenderMetrics;
use anyhow::Context;
@@ -685,8 +685,8 @@ struct SettingsUiState {
}
impl SettingsUiState {
- fn new() -> Self {
- let tokens = UiTokens::default();
+ fn new(dpi: usize) -> Self {
+ let tokens = UiTokens::for_dpi(dpi);
Self {
sidebar: ResizablePaneState::new(
tokens.sidebar_default_width,
@@ -1126,6 +1126,14 @@ struct SettingsWindow {
}
impl SettingsWindow {
+ fn ui_px(&self, value: f32) -> f32 {
+ scale_ui_f32(value, self.dimensions.dpi)
+ }
+
+ fn ui_usize(&self, value: usize) -> usize {
+ scale_ui_usize(value, self.dimensions.dpi)
+ }
+
async fn open() -> anyhow::Result<()> {
let config = configuration();
let dpi = window::default_dpi() as usize;
@@ -1148,12 +1156,12 @@ impl SettingsWindow {
.map(|conn| conn.get_appearance())
.unwrap_or(Appearance::Dark);
let dimensions = Dimensions {
- pixel_width: DEFAULT_WIDTH,
- pixel_height: DEFAULT_HEIGHT,
+ pixel_width: scale_ui_usize(DEFAULT_WIDTH, dpi),
+ pixel_height: scale_ui_usize(DEFAULT_HEIGHT, dpi),
dpi,
};
- let mut ui = SettingsUiState::new();
+ let mut ui = SettingsUiState::new(dpi);
ui.font_size_input.text = native_settings
.terminal
.font_size
@@ -1188,8 +1196,8 @@ impl SettingsWindow {
let event_settings = Rc::clone(&settings);
let geometry = RequestedWindowGeometry {
- width: Dimension::Pixels(DEFAULT_WIDTH as f32),
- height: Dimension::Pixels(DEFAULT_HEIGHT as f32),
+ width: Dimension::Pixels(dimensions.pixel_width as f32),
+ height: Dimension::Pixels(dimensions.pixel_height as f32),
x: None,
y: None,
macos_frame_autosave_name: None,
@@ -1261,8 +1269,26 @@ impl SettingsWindow {
window_state,
..
} => {
+ let dpi_changed = self.dimensions.dpi != dimensions.dpi;
self.dimensions = dimensions;
self.window_state = window_state;
+ if dpi_changed {
+ let old_default_width = self.ui.tokens.sidebar_default_width.max(1.0);
+ let tokens = UiTokens::for_dpi(dimensions.dpi);
+ let width_ratio = tokens.sidebar_default_width / old_default_width;
+ self.ui.sidebar = ResizablePaneState::new(
+ self.ui.sidebar.width * width_ratio,
+ tokens.sidebar_min_width,
+ tokens.sidebar_max_width,
+ );
+ self.ui.tokens = tokens;
+ self.fonts
+ .change_scaling(self.fonts.get_font_scale(), dimensions.dpi);
+ self.reload_settings_fonts()?;
+ if let Some(render_state) = self.render_state.as_mut() {
+ render_state.recreate_texture_atlas(&self.fonts, &self.metrics, None)?;
+ }
+ }
if let Some(webgpu) = self.webgpu.as_ref() {
webgpu.resize(dimensions);
}
@@ -1420,7 +1446,12 @@ impl SettingsWindow {
fn scroll_event(&mut self, event: &MouseEvent, window: &Window) -> bool {
let sidebar_width = self.ui.sidebar.width;
- let sidebar_area = rect(0.0, HEADER_HEIGHT, sidebar_width, self.content_bottom());
+ let sidebar_area = rect(
+ 0.0,
+ self.ui_px(HEADER_HEIGHT),
+ sidebar_width,
+ self.content_bottom(),
+ );
let content_top = self.content_scroll_area_top();
let content_area = rect(
sidebar_width + 1.0,
@@ -2005,6 +2036,10 @@ impl SettingsWindow {
self.title_font = self
.fonts
.title_font_with_size_and_weight(settings_font_size + 4.0, settings_font_weight)?;
+ self.sidebar_title_font = self.fonts.title_font_with_size_and_weight(
+ Self::sidebar_brand_font_size_for_config(&configuration()),
+ SIDEBAR_BRAND_FONT_WEIGHT,
+ )?;
self.metrics = RenderMetrics::with_font_metrics(&self.ui_font.metrics());
Ok(())
}
@@ -2124,27 +2159,35 @@ impl SettingsWindow {
fn settings_row_step(&self) -> f32 {
let cell_height = self.metrics.cell_size.height as f32;
- (cell_height * 2.15 + 42.0).max(116.0).ceil()
+ (cell_height * 2.15 + self.ui_px(42.0))
+ .max(self.ui_px(116.0))
+ .ceil()
}
fn settings_card_top_padding(&self) -> f32 {
let cell_height = self.metrics.cell_size.height as f32;
- (cell_height * 0.62).clamp(22.0, 30.0).ceil()
+ (cell_height * 0.62)
+ .clamp(self.ui_px(22.0), self.ui_px(30.0))
+ .ceil()
}
fn settings_card_bottom_padding(&self) -> f32 {
let cell_height = self.metrics.cell_size.height as f32;
- (cell_height * 0.72).clamp(26.0, 36.0).ceil()
+ (cell_height * 0.72)
+ .clamp(self.ui_px(26.0), self.ui_px(36.0))
+ .ceil()
}
fn settings_row_visual_height(&self) -> f32 {
let cell_height = self.metrics.cell_size.height as f32;
- (cell_height + 46.0).max(CONTROL_HEIGHT + 10.0).ceil()
+ (cell_height + self.ui_px(46.0))
+ .max(self.ui_px(CONTROL_HEIGHT) + self.ui_px(10.0))
+ .ceil()
}
fn settings_row_description_y(&self, y: f32) -> f32 {
let cell_height = self.metrics.cell_size.height as f32;
- y + (cell_height + 8.0).max(34.0)
+ y + (cell_height + self.ui_px(8.0)).max(self.ui_px(34.0))
}
fn settings_section_card_gap(&self) -> f32 {
@@ -2785,7 +2828,7 @@ impl SettingsWindow {
self.settings_window_shows_window_buttons()
&& x >= 0.0
&& x <= self.dimensions.pixel_width as f32
- && (0.0..=SETTINGS_WINDOW_CHROME_HEIGHT).contains(&y)
+ && (0.0..=self.ui_px(SETTINGS_WINDOW_CHROME_HEIGHT)).contains(&y)
}
fn paint_window_chrome(
@@ -2797,12 +2840,13 @@ impl SettingsWindow {
}
let config = configuration();
- let mut right = self.dimensions.pixel_width as f32 - SETTINGS_WINDOW_BUTTON_RIGHT_INSET;
- let y = SETTINGS_WINDOW_BUTTON_TOP_INSET;
+ let mut right =
+ self.dimensions.pixel_width as f32 - self.ui_px(SETTINGS_WINDOW_BUTTON_RIGHT_INSET);
+ let y = self.ui_px(SETTINGS_WINDOW_BUTTON_TOP_INSET);
for button in config.integrated_title_buttons.iter().rev() {
- right -= SETTINGS_WINDOW_BUTTON_SIZE;
+ right -= self.ui_px(SETTINGS_WINDOW_BUTTON_SIZE);
self.paint_window_chrome_button(layers, *button, right, y)?;
- right -= SETTINGS_WINDOW_BUTTON_GAP;
+ right -= self.ui_px(SETTINGS_WINDOW_BUTTON_GAP);
}
Ok(())
@@ -2824,8 +2868,8 @@ impl SettingsWindow {
let button_rect = rect(
x,
y,
- SETTINGS_WINDOW_BUTTON_SIZE,
- SETTINGS_WINDOW_BUTTON_SIZE,
+ self.ui_px(SETTINGS_WINDOW_BUTTON_SIZE),
+ self.ui_px(SETTINGS_WINDOW_BUTTON_SIZE),
);
self.ui_context
.push(button_rect, WidgetKind::Button, action);
@@ -2834,7 +2878,7 @@ impl SettingsWindow {
let pressed = self.ui.interaction.pressed == Some(action);
let close_button = button == IntegratedTitleButton::Close;
let press_inset = if pressed { 1.0 } else { 0.0 };
- let visual_size = SETTINGS_WINDOW_BUTTON_SIZE - press_inset * 2.0;
+ let visual_size = self.ui_px(SETTINGS_WINDOW_BUTTON_SIZE) - press_inset * 2.0;
if hovered {
let fill = if close_button {
@@ -2876,9 +2920,9 @@ impl SettingsWindow {
IntegratedTitleButton::Close => SvgIcon::X,
};
let icon_size = if pressed {
- SETTINGS_WINDOW_BUTTON_ICON_SIZE - 1.0
+ self.ui_px(SETTINGS_WINDOW_BUTTON_ICON_SIZE) - 1.0
} else {
- SETTINGS_WINDOW_BUTTON_ICON_SIZE
+ self.ui_px(SETTINGS_WINDOW_BUTTON_ICON_SIZE)
};
let icon_color = if close_button && hovered {
LinearRgba(1.0, 1.0, 1.0, 1.0)
@@ -2914,12 +2958,13 @@ impl SettingsWindow {
x,
0.0,
width,
- SETTINGS_WINDOW_CHROME_HEIGHT,
+ self.ui_px(SETTINGS_WINDOW_CHROME_HEIGHT),
palette.window_bg,
)?;
- let fade_height = SETTINGS_WINDOW_CHROME_FADE_HEIGHT
- .min((self.content_bottom() - SETTINGS_WINDOW_CHROME_HEIGHT).max(0.0) as usize);
+ let fade_height = self.ui_usize(SETTINGS_WINDOW_CHROME_FADE_HEIGHT).min(
+ (self.content_bottom() - self.ui_px(SETTINGS_WINDOW_CHROME_HEIGHT)).max(0.0) as usize,
+ );
if self.ui.content_scroll.offset > 0.0 && fade_height > 0 {
for step in 0..fade_height {
let progress = (step + 1) as f32 / fade_height as f32;
@@ -2928,7 +2973,7 @@ impl SettingsWindow {
layers,
2,
x,
- SETTINGS_WINDOW_CHROME_HEIGHT + step as f32,
+ self.ui_px(SETTINGS_WINDOW_CHROME_HEIGHT) + step as f32,
width,
1.0,
palette.window_bg.mul_alpha(alpha),
@@ -2974,7 +3019,7 @@ impl SettingsWindow {
let tokens = self.ui.tokens;
let sidebar_width = self.ui.sidebar.width;
let sidebar_icon_size = ((self.metrics.cell_size.height as f32 + 8.0)
- .clamp(24.0, 34.0)
+ .clamp(self.ui_px(24.0), self.ui_px(34.0))
.round()) as usize;
self.draw_text(
@@ -2989,7 +3034,7 @@ impl SettingsWindow {
let search_rect = rect(
tokens.sidebar_padding,
- SIDEBAR_SEARCH_Y,
+ self.ui_px(SIDEBAR_SEARCH_Y),
sidebar_width - tokens.sidebar_padding * 2.0,
tokens.control_height,
);
@@ -3015,7 +3060,7 @@ impl SettingsWindow {
)?;
if !self.ui.search.is_empty() {
let clear_size = 34.0;
- let clear_icon_size = 24.0;
+ let clear_icon_size = self.ui_px(24.0);
let clear_rect = rect(
search_rect.origin.x + search_rect.size.width - clear_size - 10.0,
search_rect.origin.y + (search_rect.size.height - clear_size) / 2.0,
@@ -3077,10 +3122,10 @@ impl SettingsWindow {
)?;
let sections = self.filtered_sections();
- let list_top = SIDEBAR_LIST_TOP;
+ let list_top = self.ui_px(SIDEBAR_LIST_TOP);
let list_bottom = (self.dimensions.pixel_height as f32 - 16.0).max(list_top);
let list_height = list_bottom - list_top;
- let content_extent = sections.len() as f32 * NAV_ROW_STEP + 8.0;
+ let content_extent = sections.len() as f32 * self.ui_px(NAV_ROW_STEP) + 8.0;
self.ui
.sidebar_scroll
.set_extents(list_height, content_extent.max(list_height));
@@ -3105,8 +3150,8 @@ impl SettingsWindow {
}
for section in sections {
- if y + NAV_ROW_HEIGHT < list_top || y > list_bottom {
- y += NAV_ROW_STEP;
+ if y + self.ui_px(NAV_ROW_HEIGHT) < list_top || y > list_bottom {
+ y += self.ui_px(NAV_ROW_STEP);
continue;
}
let action = SettingsAction::Select(section);
@@ -3132,14 +3177,14 @@ impl SettingsWindow {
row_x,
row_y,
row_width,
- NAV_ROW_HEIGHT,
+ self.ui_px(NAV_ROW_HEIGHT),
row_bg,
- NAV_ROW_RADIUS,
+ self.ui_px(NAV_ROW_RADIUS),
)?;
}
self.ui_context.push(
- rect(row_x, row_y, row_width, NAV_ROW_HEIGHT),
+ rect(row_x, row_y, row_width, self.ui_px(NAV_ROW_HEIGHT)),
WidgetKind::SidebarRow,
action,
);
@@ -3152,7 +3197,7 @@ impl SettingsWindow {
layers,
section.icon().svg(),
row_x + 14.0,
- row_y + (NAV_ROW_HEIGHT - sidebar_icon_size as f32) / 2.0,
+ row_y + (self.ui_px(NAV_ROW_HEIGHT) - sidebar_icon_size as f32) / 2.0,
sidebar_icon_size as f32,
text_color,
)?;
@@ -3160,12 +3205,12 @@ impl SettingsWindow {
layers,
&nav_font,
row_x + 56.0,
- self.control_text_y(row_y, NAV_ROW_HEIGHT),
+ self.control_text_y(row_y, self.ui_px(NAV_ROW_HEIGHT)),
section.label(),
text_color,
row_width - 76.0,
)?;
- y += NAV_ROW_STEP;
+ y += self.ui_px(NAV_ROW_STEP);
}
self.paint_scrollbar(
@@ -3206,7 +3251,7 @@ impl SettingsWindow {
layers,
&title_font,
x,
- CONTENT_TITLE_Y - scroll,
+ self.ui_px(CONTENT_TITLE_Y) - scroll,
self.selected.label(),
palette.title,
max_width,
@@ -3263,7 +3308,7 @@ impl SettingsWindow {
let ui_font = Rc::clone(&self.ui_font);
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
// Each settings card owns its row count because rows are painted manually.
// General currently paints seven rows below; the count drives card height and scroll extent.
let row_count = 7;
@@ -3366,7 +3411,7 @@ impl SettingsWindow {
let config = configuration();
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
let theme_row_count = 4;
let typography_row_count = 6;
let app_icon_note_space = self.metrics.cell_size.height as f32 + 10.0;
@@ -3511,7 +3556,7 @@ impl SettingsWindow {
let config = configuration();
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
// Each settings card owns its row count because rows are painted manually.
// Terminal currently paints eight rows below; the count drives card height and scroll extent.
let row_count = 8;
@@ -3525,11 +3570,11 @@ impl SettingsWindow {
let reset_button_y = if open_quotes_width + button_gap + reset_quotes_width <= max_width {
button_y
} else {
- button_y + CONTROL_HEIGHT + 14.0
+ button_y + self.ui_px(CONTROL_HEIGHT) + 14.0
};
self.ui.content_scroll.set_extents(
self.content_viewport_extent(),
- self.settings_content_extent(reset_button_y + scroll + CONTROL_HEIGHT),
+ self.settings_content_extent(reset_button_y + scroll + self.ui_px(CONTROL_HEIGHT)),
);
let font_size = format!("{:.1} pt", config.font_size);
let font_family = Self::effective_font_family(&config);
@@ -3681,13 +3726,13 @@ impl SettingsWindow {
let ui_font = Rc::clone(&self.ui_font);
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
let (card_y, first_row_y) = self.settings_card_geometry(section_y, 4);
let card_height = self.settings_card_height(4);
let button_y = card_y + card_height + self.settings_section_card_gap();
self.ui.content_scroll.set_extents(
self.content_viewport_extent(),
- self.settings_content_extent(button_y + scroll + CONTROL_HEIGHT),
+ self.settings_content_extent(button_y + scroll + self.ui_px(CONTROL_HEIGHT)),
);
self.draw_text(
@@ -3800,7 +3845,7 @@ impl SettingsWindow {
layers,
&ui_font,
x,
- CONTENT_SECTION_Y - scroll,
+ self.ui_px(CONTENT_SECTION_Y) - scroll,
"Live settings UI components. The left side is rendered with the same primitives as the real window.",
palette.secondary_text,
max_width,
@@ -3809,7 +3854,7 @@ impl SettingsWindow {
layers,
0,
x,
- CONTENT_RULE_Y - scroll,
+ self.ui_px(CONTENT_RULE_Y) - scroll,
max_width,
1.0,
palette.rule,
@@ -4033,7 +4078,7 @@ impl SettingsWindow {
let ui_font = Rc::clone(&self.ui_font);
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
let row_count = 15;
let (card_y, first_row_y) = self.settings_card_geometry(section_y, row_count);
let card_height = self.settings_card_height(row_count);
@@ -4119,8 +4164,9 @@ impl SettingsWindow {
})
.unwrap_or_else(|| "No stage samples".to_string());
let resource_lines = self.memory_resource_lines();
- let input_button_y = button_y + CONTROL_HEIGHT + 16.0;
- let resource_card_y = input_button_y + CONTROL_HEIGHT + self.settings_section_card_gap();
+ let input_button_y = button_y + self.ui_px(CONTROL_HEIGHT) + 16.0;
+ let resource_card_y =
+ input_button_y + self.ui_px(CONTROL_HEIGHT) + self.settings_section_card_gap();
let resource_line_height = 30.0;
let resource_card_height = 88.0 + resource_line_height * resource_lines.len() as f32;
self.ui.content_scroll.set_extents(
@@ -4407,16 +4453,16 @@ impl SettingsWindow {
x,
y + 28.0,
width.min(420.0),
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
palette.search_bg,
palette.search_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
x + 18.0,
- self.control_text_y(y + 28.0, CONTROL_HEIGHT),
+ self.control_text_y(y + 28.0, self.ui_px(CONTROL_HEIGHT)),
"Search settings...",
palette.muted_text,
width.min(420.0) - 36.0,
@@ -4443,9 +4489,9 @@ impl SettingsWindow {
x,
y,
row_width,
- NAV_ROW_HEIGHT,
+ self.ui_px(NAV_ROW_HEIGHT),
palette.nav_selected_bg,
- NAV_ROW_RADIUS,
+ self.ui_px(NAV_ROW_RADIUS),
)?;
} else {
self.draw_rounded_rect(
@@ -4454,16 +4500,16 @@ impl SettingsWindow {
x,
y,
row_width,
- NAV_ROW_HEIGHT,
+ self.ui_px(NAV_ROW_HEIGHT),
palette.nav_hover_bg,
- NAV_ROW_RADIUS,
+ self.ui_px(NAV_ROW_RADIUS),
)?;
}
self.draw_text(
layers,
&ui_font,
x + 16.0,
- self.control_text_y(y, NAV_ROW_HEIGHT),
+ self.control_text_y(y, self.ui_px(NAV_ROW_HEIGHT)),
label,
if selected {
palette.selected_text
@@ -4497,16 +4543,16 @@ impl SettingsWindow {
x,
y,
width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
bg,
palette.control_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&Rc::clone(&self.ui_font),
x + 18.0,
- self.control_text_y(y, CONTROL_HEIGHT),
+ self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),
label,
if accent {
palette.selected_text
@@ -4533,16 +4579,16 @@ impl SettingsWindow {
x,
y,
width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
palette.control_bg,
palette.control_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&Rc::clone(&self.ui_font),
x + 14.0,
- self.control_text_y(y, CONTROL_HEIGHT),
+ self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),
value,
palette.text,
width - 42.0,
@@ -4551,7 +4597,7 @@ impl SettingsWindow {
layers,
&Rc::clone(&self.ui_font),
x + width - 28.0,
- self.control_text_y(y, CONTROL_HEIGHT),
+ self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),
"v",
palette.muted_text,
14.0,
@@ -4647,7 +4693,7 @@ impl SettingsWindow {
let ui_font = Rc::clone(&self.ui_font);
let scroll = self.ui.content_scroll.offset;
let row_step = self.settings_row_step();
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
let field_count = self.compatibility_import.fields.len();
let row_count = 4 + field_count.max(1);
let (card_y, first_row_y) = self.settings_card_geometry(section_y, row_count);
@@ -4655,7 +4701,9 @@ impl SettingsWindow {
let buttons_y = card_y + card_height + self.settings_section_card_gap();
self.ui.content_scroll.set_extents(
self.content_viewport_extent(),
- self.settings_content_extent(buttons_y + scroll + CONTROL_HEIGHT * 2.0 + 14.0),
+ self.settings_content_extent(
+ buttons_y + scroll + self.ui_px(CONTROL_HEIGHT) * 2.0 + 14.0,
+ ),
);
let thinkterm_path = Self::thinkterm_compatible_config_path();
let thinkterm_source = if thinkterm_path.exists() {
@@ -4829,7 +4877,7 @@ impl SettingsWindow {
"Import Selected",
SettingsAction::ImportSelectedFields,
)?;
- let open_buttons_y = buttons_y + CONTROL_HEIGHT + 14.0;
+ let open_buttons_y = buttons_y + self.ui_px(CONTROL_HEIGHT) + 14.0;
self.draw_button(
layers,
x,
@@ -4868,7 +4916,7 @@ impl SettingsWindow {
layers,
font,
x,
- CONTENT_SECTION_Y - scroll,
+ self.ui_px(CONTENT_SECTION_Y) - scroll,
body,
palette.secondary_text,
max_width,
@@ -4877,7 +4925,7 @@ impl SettingsWindow {
layers,
0,
x,
- CONTENT_RULE_Y - scroll,
+ self.ui_px(CONTENT_RULE_Y) - scroll,
max_width,
1.0,
palette.rule,
@@ -4925,16 +4973,16 @@ impl SettingsWindow {
control_x,
control_y,
control_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
palette.control_bg,
palette.control_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
control_x + 14.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
value,
palette.text,
control_width - 26.0,
@@ -4967,7 +5015,12 @@ impl SettingsWindow {
let control_x = x + width - control_width;
let control_y = y + 4.0;
let text_width = (control_x - x - 24.0).max(width * 0.45);
- let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ let control_rect = rect(
+ control_x,
+ control_y,
+ control_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
self.ui_context
.push(control_rect, WidgetKind::Button, action);
@@ -5002,16 +5055,16 @@ impl SettingsWindow {
control_x,
control_y,
control_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
bg,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
control_x + 14.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
if enabled { "On" } else { "Off" },
palette.text,
control_width - 26.0,
@@ -5044,7 +5097,12 @@ impl SettingsWindow {
let control_x = x + width - control_width;
let control_y = y + 4.0;
let text_width = (control_x - x - 24.0).max(width * 0.45);
- let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ let control_rect = rect(
+ control_x,
+ control_y,
+ control_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
self.ui_context
.push(control_rect, WidgetKind::Button, action);
@@ -5079,16 +5137,16 @@ impl SettingsWindow {
control_x,
control_y,
control_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
bg,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
control_x + 14.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
value,
palette.text,
control_width - 26.0,
@@ -5224,17 +5282,17 @@ impl SettingsWindow {
value_x,
preview_y,
value_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
palette.control_bg,
palette.control_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
let preview = self.text_with_ellipsis(&ui_font, &field.preview, value_width - 28.0);
self.draw_text(
layers,
&ui_font,
value_x + 14.0,
- self.control_text_y(preview_y, CONTROL_HEIGHT),
+ self.control_text_y(preview_y, self.ui_px(CONTROL_HEIGHT)),
&preview,
palette.text,
value_width - 28.0,
@@ -5303,8 +5361,9 @@ impl SettingsWindow {
};
let control_x = x + width - control_width;
let control_y = y + 4.0;
- let dynamic_icon_size = (self.metrics.cell_size.height as f32 + 4.0).clamp(24.0, 34.0);
- let reset_size = CONTROL_HEIGHT;
+ let dynamic_icon_size =
+ (self.metrics.cell_size.height as f32 + 4.0).clamp(self.ui_px(24.0), self.ui_px(34.0));
+ let reset_size = self.ui_px(CONTROL_HEIGHT);
let reset_gap = 14.0;
let reset_x = (control_x - reset_gap - reset_size).max(x + width * 0.62);
let text_width = (reset_x - x - 24.0).max(width * 0.40);
@@ -5335,19 +5394,24 @@ impl SettingsWindow {
control_x,
control_y,
control_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
palette.control_bg,
palette.control_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
let button_width = 62.0_f32.min(control_width * 0.28);
- let minus_rect = rect(control_x, control_y, button_width, CONTROL_HEIGHT);
+ let minus_rect = rect(
+ control_x,
+ control_y,
+ button_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
let plus_rect = rect(
control_x + control_width - button_width,
control_y,
button_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
);
self.ui_context
.push(minus_rect, WidgetKind::Button, decrease_action);
@@ -5369,7 +5433,7 @@ impl SettingsWindow {
button_rect.size.width - 8.0,
button_rect.size.height - 8.0,
palette.control_hover_bg,
- CONTROL_RADIUS - 4.0,
+ self.ui_px(CONTROL_RADIUS) - 4.0,
)?;
}
self.draw_svg_icon(
@@ -5395,7 +5459,7 @@ impl SettingsWindow {
layers,
&ui_font,
value_x + 8.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
&value_label,
palette.text,
value_width - 16.0,
@@ -5448,7 +5512,12 @@ impl SettingsWindow {
} else {
palette.control_border
};
- let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ let control_rect = rect(
+ control_x,
+ control_y,
+ control_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
self.ui_context
.push(control_rect, WidgetKind::TextInput, action);
@@ -5468,10 +5537,10 @@ impl SettingsWindow {
control_x,
control_y,
control_width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
bg,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
let display = if value.trim().is_empty() {
@@ -5498,16 +5567,16 @@ impl SettingsWindow {
control_x + 12.0,
control_y + 6.0,
selection_width + 8.0,
- CONTROL_HEIGHT - 12.0,
+ self.ui_px(CONTROL_HEIGHT) - 12.0,
palette.nav_selected_bg.mul_alpha(0.56),
- CONTROL_RADIUS - 4.0,
+ self.ui_px(CONTROL_RADIUS) - 4.0,
)?;
}
self.draw_text(
layers,
&ui_font,
control_x + 16.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
display,
text_color,
control_width - 32.0,
@@ -5525,7 +5594,7 @@ impl SettingsWindow {
caret_x - 1.0,
control_y + 8.0,
3.0,
- CONTROL_HEIGHT - 16.0,
+ self.ui_px(CONTROL_HEIGHT) - 16.0,
palette.nav_selected_bg,
)?;
}
@@ -5550,7 +5619,12 @@ impl SettingsWindow {
let (control_x, control_y, control_width) = self.theme_mode_control_geometry(x, y, width);
let text_width = (control_x - x - 24.0).max(width * 0.45);
let action = SettingsAction::ToggleThemeModeMenu;
- let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ let control_rect = rect(
+ control_x,
+ control_y,
+ control_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
let open = self.ui.open_dropdown == Some(SettingsDropdown::ThemeMode);
let hovered = self.ui.interaction.hovered == Some(action);
let pressed = self.ui.interaction.pressed == Some(action);
@@ -5596,13 +5670,13 @@ impl SettingsWindow {
control_rect.size.height,
bg,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
control_x + 16.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
self.native_settings.appearance.theme_mode.label(),
palette.text,
control_width - 60.0,
@@ -5611,7 +5685,7 @@ impl SettingsWindow {
layers,
SvgIcon::ChevronDown,
control_x + control_width - 38.0,
- control_y + (CONTROL_HEIGHT - 22.0) / 2.0,
+ control_y + (self.ui_px(CONTROL_HEIGHT) - 22.0) / 2.0,
22.0,
palette.secondary_text,
)?;
@@ -5638,7 +5712,12 @@ impl SettingsWindow {
let (control_x, control_y, control_width) = self.dropdown_control_geometry(x, y, width);
let text_width = (control_x - x - 24.0).max(width * 0.45);
let action = SettingsAction::ToggleAppIconMenu;
- let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ let control_rect = rect(
+ control_x,
+ control_y,
+ control_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
let open = self.ui.open_dropdown == Some(SettingsDropdown::AppIcon);
let hovered = self.ui.interaction.hovered == Some(action);
let pressed = self.ui.interaction.pressed == Some(action);
@@ -5685,13 +5764,13 @@ impl SettingsWindow {
control_rect.size.height,
bg,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
control_x + 16.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
self.native_settings.appearance.app_icon.label(),
palette.text,
control_width - 60.0,
@@ -5700,7 +5779,7 @@ impl SettingsWindow {
layers,
SvgIcon::ChevronDown,
control_x + control_width - 38.0,
- control_y + (CONTROL_HEIGHT - 22.0) / 2.0,
+ control_y + (self.ui_px(CONTROL_HEIGHT) - 22.0) / 2.0,
22.0,
palette.secondary_text,
)?;
@@ -5725,7 +5804,12 @@ impl SettingsWindow {
let (control_x, control_y, control_width) = self.dropdown_control_geometry(x, y, width);
let text_width = (control_x - x - 24.0).max(width * 0.45);
let action = SettingsAction::ToggleMainRendererMenu;
- let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);
+ let control_rect = rect(
+ control_x,
+ control_y,
+ control_width,
+ self.ui_px(CONTROL_HEIGHT),
+ );
let open = self.ui.open_dropdown == Some(SettingsDropdown::MainRenderer);
let hovered = self.ui.interaction.hovered == Some(action);
let pressed = self.ui.interaction.pressed == Some(action);
@@ -5771,13 +5855,13 @@ impl SettingsWindow {
control_rect.size.height,
bg,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&ui_font,
control_x + 16.0,
- self.control_text_y(control_y, CONTROL_HEIGHT),
+ self.control_text_y(control_y, self.ui_px(CONTROL_HEIGHT)),
self.current_main_renderer().label(),
palette.text,
control_width - 60.0,
@@ -5786,7 +5870,7 @@ impl SettingsWindow {
layers,
SvgIcon::ChevronDown,
control_x + control_width - 38.0,
- control_y + (CONTROL_HEIGHT - 22.0) / 2.0,
+ control_y + (self.ui_px(CONTROL_HEIGHT) - 22.0) / 2.0,
22.0,
palette.secondary_text,
)?;
@@ -5868,7 +5952,7 @@ impl SettingsWindow {
let scroll = self.ui.content_scroll.offset;
let card_padding = 36.0;
- let section_y = CONTENT_SECTION_Y - scroll;
+ let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;
let row_count = match self.selected {
SettingsSection::General => 7,
SettingsSection::Appearance => 4,
@@ -5900,19 +5984,19 @@ impl SettingsWindow {
SettingsDropdown::ThemeMode => self.paint_theme_mode_menu(
layers,
control_x,
- control_y + CONTROL_HEIGHT + 8.0,
+ control_y + self.ui_px(CONTROL_HEIGHT) + 8.0,
control_width,
),
SettingsDropdown::AppIcon => self.paint_app_icon_menu(
layers,
control_x,
- control_y + CONTROL_HEIGHT + 8.0,
+ control_y + self.ui_px(CONTROL_HEIGHT) + 8.0,
control_width,
),
SettingsDropdown::MainRenderer => self.paint_main_renderer_menu(
layers,
control_x,
- control_y + CONTROL_HEIGHT + 8.0,
+ control_y + self.ui_px(CONTROL_HEIGHT) + 8.0,
control_width,
),
}
@@ -6020,7 +6104,7 @@ impl SettingsWindow {
menu_height,
menu_bg,
palette.control_border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
let mut row_y = y + menu_padding;
@@ -6075,7 +6159,7 @@ impl SettingsWindow {
fn content_scroll_area_top(&self) -> f32 {
if self.settings_window_shows_window_buttons() {
- SETTINGS_WINDOW_CHROME_HEIGHT
+ self.ui_px(SETTINGS_WINDOW_CHROME_HEIGHT)
} else {
0.0
}
@@ -6087,9 +6171,9 @@ impl SettingsWindow {
fn sidebar_title_y(&self) -> f32 {
if self.settings_window_shows_window_buttons() {
- SIDEBAR_TITLE_Y_WITH_CUSTOM_CHROME
+ self.ui_px(SIDEBAR_TITLE_Y_WITH_CUSTOM_CHROME)
} else {
- SIDEBAR_TITLE_Y
+ self.ui_px(SIDEBAR_TITLE_Y)
}
}
@@ -6256,7 +6340,7 @@ impl SettingsWindow {
let button = ButtonSpec {
label,
action,
- rect: rect(x, y, width, CONTROL_HEIGHT),
+ rect: rect(x, y, width, self.ui_px(CONTROL_HEIGHT)),
state: if self.ui.interaction.pressed == Some(action) {
ControlState::Pressed
} else if self.ui.interaction.hovered == Some(action) {
@@ -6278,16 +6362,16 @@ impl SettingsWindow {
x,
y,
width,
- CONTROL_HEIGHT,
+ self.ui_px(CONTROL_HEIGHT),
background,
border,
- CONTROL_RADIUS,
+ self.ui_px(CONTROL_RADIUS),
)?;
self.draw_text(
layers,
&Rc::clone(&self.ui_font),
x + 14.0,
- self.control_text_y(y, CONTROL_HEIGHT),
+ self.control_text_y(y, self.ui_px(CONTROL_HEIGHT)),
button.label,
palette.text,
width - 36.0,
@@ -6317,9 +6401,10 @@ impl SettingsWindow {
LinearRgba::TRANSPARENT
};
if bg.3 > 0.0 {
- self.draw_rounded_rect(layers, 0, x, y, size, size, bg, CONTROL_RADIUS)?;
+ self.draw_rounded_rect(layers, 0, x, y, size, size, bg, self.ui_px(CONTROL_RADIUS))?;
}
- let icon_size = (self.metrics.cell_size.height as f32 + 4.0).clamp(24.0, 34.0);
+ let icon_size =
+ (self.metrics.cell_size.height as f32 + 4.0).clamp(self.ui_px(24.0), self.ui_px(34.0));
self.draw_svg_icon(
layers,
icon,
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 2a0b5b3a..ae1f0757 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -1418,7 +1418,7 @@ impl TermWindow {
pixel_cell: render_metrics.cell_size.width as f32,
};
let padding_left = config.window_padding.left.evaluate_as_pixels(h_context) as usize;
- let workspace_sidebar_width = ui::workspace_sidebar_width_for_metrics(&render_metrics);
+ let workspace_sidebar_width = ui::workspace_sidebar_width_for_metrics(&render_metrics, dpi as usize);
let padding_right = resize::effective_right_padding(&config, h_context) as usize;
let v_context = DimensionContext {
dpi: dpi as f32,
@@ -1612,7 +1612,7 @@ impl TermWindow {
workspace_sidebar_collapsed: !native_settings.onboarding.show_left_sidebar_by_default,
workspace_sidebar_scroll_offset: 0.0,
workspace_sidebar_scrollbar_visible_until: None,
- right_sidebar_width: ui::right_sidebar_width_for_metrics(&render_metrics),
+ right_sidebar_width: ui::right_sidebar_width_for_metrics(&render_metrics, dpi as usize),
right_sidebar_collapsed: true,
right_sidebar_mode: RightSidebarMode::Snippets,
right_sidebar_snippet_view: RightSidebarSnippetView::List,
@@ -1644,8 +1644,8 @@ impl TermWindow {
right_sidebar_file_browse_rows: Vec::new(),
right_sidebar_file_browse_cache_key: None,
right_sidebar_file_selected: None,
- right_sidebar_file_tree_width: ui::right_sidebar_width_for_metrics(&render_metrics),
- right_sidebar_file_preview_width: ui::right_sidebar_file_preview_width(),
+ right_sidebar_file_tree_width: ui::right_sidebar_width_for_metrics(&render_metrics, dpi as usize),
+ right_sidebar_file_preview_width: ui::right_sidebar_file_preview_width(dpi as usize),
right_sidebar_file_preview_generation: 0,
right_sidebar_file_preview_lines: Vec::new(),
right_sidebar_file_preview_max_columns: 0,
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index d82d1e19..b76cfdec 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -78,7 +78,7 @@ impl super::TermWindow {
let cell_width = self.render_metrics.cell_size.width.max(1) as f32;
(self.config.tab_max_width as f32 * cell_width)
.max(cell_width * 15.0)
- .max(176.0)
+ .max(self.ui_f32(176.0))
.ceil()
}
@@ -91,6 +91,7 @@ impl super::TermWindow {
integrated_title_button_alignment: self.config.integrated_title_button_alignment,
integrated_title_button_style: self.config.integrated_title_button_style,
cell_width: self.render_metrics.cell_size.width.max(1) as f32,
+ dpi: self.dimensions.dpi,
}
}
@@ -127,16 +128,17 @@ impl super::TermWindow {
pub(super) fn window_tab_trailing_action_reserved_width(&self) -> usize {
let sidebar_actions_width = if self.right_sidebar_width() > 0 {
- WINDOW_TAB_ACTION_RESERVED_WIDTH
+ self.ui_px(WINDOW_TAB_ACTION_RESERVED_WIDTH)
+ if !cfg!(target_os = "macos") {
- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE + WINDOW_TAB_LEADING_ACTION_GAP
+ self.ui_px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP)
} else {
0
}
} else {
- WINDOW_TAB_ACTION_RESERVED_WIDTH
- + WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE
- + WINDOW_TAB_LEADING_ACTION_GAP
+ self.ui_px(WINDOW_TAB_ACTION_RESERVED_WIDTH)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP)
};
sidebar_actions_width
@@ -149,8 +151,9 @@ impl super::TermWindow {
!= IntegratedTitleButtonStyle::MacOsNative
{
self.config.integrated_title_buttons.len()
- * (WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE + WINDOW_TAB_LEADING_ACTION_GAP / 2)
- + WINDOW_TAB_LEADING_ACTION_GAP
+ * (self.ui_px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) / 2)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP)
} else {
0
}
@@ -158,9 +161,9 @@ impl super::TermWindow {
pub(super) fn pane_nav_tab_left_inset(&self, pane_left: usize) -> usize {
if pane_left == 0 && self.workspace_sidebar_width() > 0 {
- TAB_ROW_START_PADDING
+ self.ui_px(TAB_ROW_START_PADDING)
} else {
- PANE_NAV_INSET
+ self.ui_px(PANE_NAV_INSET)
}
}
@@ -175,7 +178,7 @@ impl super::TermWindow {
.saturating_sub(border.right.get() as usize)
.saturating_sub(left_padding.max(0.0) as usize)
.saturating_sub(if self.config.use_fancy_tab_bar {
- TAB_ROW_START_PADDING + self.window_tab_trailing_action_reserved_width()
+ self.ui_px(TAB_ROW_START_PADDING) + self.window_tab_trailing_action_reserved_width()
} else {
0
})
@@ -199,7 +202,7 @@ impl super::TermWindow {
let tab_width = self.window_tab_width_pixels();
let tab_gap = if self.config.use_fancy_tab_bar {
- WINDOW_TAB_GAP as f32
+ self.ui_px(WINDOW_TAB_GAP) as f32
} else {
0.0
};
@@ -256,18 +259,20 @@ impl super::TermWindow {
}
let nav_height = pane_nav_bar_height_for_metrics(self.render_metrics);
- let icon_size = nav_height.saturating_sub(PANE_NAV_INSET * 2).clamp(20, 24);
+ let icon_size = nav_height
+ .saturating_sub(self.ui_px(PANE_NAV_INSET) * 2)
+ .clamp(self.ui_px(20), self.ui_px(24));
let button_size = nav_height
- .saturating_sub(TAB_VERTICAL_PADDING * 2)
+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)
.max(icon_size);
- let controls_width = (button_size + PANE_NAV_BUTTON_GAP)
+ let controls_width = (button_size + self.ui_px(PANE_NAV_BUTTON_GAP))
.saturating_mul(2)
- .saturating_add(PANE_NAV_INSET)
+ .saturating_add(self.ui_px(PANE_NAV_INSET))
.saturating_add(self.pane_nav_tab_left_inset(pane_left));
let viewport_width = (pane_width as usize).saturating_sub(controls_width).max(1) as f32;
let tab_width = self.window_tab_width_pixels();
let total_width = tab_count as f32 * tab_width
- + tab_count.saturating_sub(1) as f32 * PANE_NAV_TAB_GAP as f32;
+ + tab_count.saturating_sub(1) as f32 * self.ui_px(PANE_NAV_TAB_GAP) as f32;
(total_width - viewport_width).max(0.0)
}
@@ -966,12 +971,9 @@ impl super::TermWindow {
);
context.invalidate();
}
- if completed_drag
- .as_ref()
- .is_some_and(|(item, _)| {
- matches!(item.item_type, UIItemType::RightSidebarFileRow(_))
- })
- {
+ if completed_drag.as_ref().is_some_and(|(item, _)| {
+ matches!(item.item_type, UIItemType::RightSidebarFileRow(_))
+ }) {
if let Some(state) = self.right_sidebar_file_drag.take() {
if state.active {
self.drop_right_sidebar_file_drag(state, &event, x, y);
@@ -3432,9 +3434,9 @@ impl super::TermWindow {
let space_client_domain =
crate::workspace_threads::client_domain_for_space(&self.active_space_id);
if let Some(domain_name) = space_client_domain.as_deref() {
- let attached = mux.get_domain_by_name(domain_name).map_or(false, |d| {
- d.state() == mux::domain::DomainState::Attached
- });
+ let attached = mux
+ .get_domain_by_name(domain_name)
+ .map_or(false, |d| d.state() == mux::domain::DomainState::Attached);
if !attached {
// Attach on demand (auth prompts go through the ConnectionUI),
// then re-run this activation once the domain is live.
diff --git a/wezterm-gui/src/termwindow/onboarding.rs b/wezterm-gui/src/termwindow/onboarding.rs
index 39db8db8..df12d04e 100644
--- a/wezterm-gui/src/termwindow/onboarding.rs
+++ b/wezterm-gui/src/termwindow/onboarding.rs
@@ -612,7 +612,7 @@ impl OnboardingView {
_cursor_on: bool,
) -> anyhow::Result<()> {
self.widgets.clear();
- let tokens = UiTokens::default();
+ let tokens = UiTokens::for_dpi(ctx.dimensions.dpi);
ctx.draw_rect(
layers,
0,
diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
index 4d3d7889..207b3b5c 100644
--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
@@ -65,13 +65,13 @@ impl crate::TermWindow {
let content_top_spacer = if self.config.tab_bar_at_bottom {
0
} else {
- WINDOW_TAB_TOP_SPACER.min(row_height)
+ self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height)
};
let content_row_y = row_y + content_top_spacer;
let content_row_height = row_height.saturating_sub(content_top_spacer);
let icon_size = fancy_tab_icon_size(&metrics, content_row_height as f32) as usize;
let button_size = content_row_height
- .saturating_sub(TAB_VERTICAL_PADDING * 2)
+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)
.max(icon_size);
let row_width = self
.dimensions
@@ -81,7 +81,7 @@ impl crate::TermWindow {
.max(1);
let row_right = row_x + row_width;
let viewport_left = (row_x as f32 + self.window_tab_left_padding_pixels()).ceil() as usize
- + TAB_ROW_START_PADDING;
+ + self.ui_px(TAB_ROW_START_PADDING);
let viewport_right =
row_right.saturating_sub(self.window_tab_trailing_action_reserved_width());
let viewport_width = viewport_right.saturating_sub(viewport_left);
@@ -154,7 +154,7 @@ impl crate::TermWindow {
let cv_active = self.active_content_view_shown_in_tab_bar();
let show_mux_tabs = !self.active_content_view_is_remote_thread();
- let tab_step = tab_width + WINDOW_TAB_GAP;
+ let tab_step = tab_width + self.ui_px(WINDOW_TAB_GAP);
let mut tab_sequence_idx = 0usize;
if show_mux_tabs {
for item in self.tab_bar.items() {
@@ -246,13 +246,13 @@ impl crate::TermWindow {
}
}
- let mut action_right = row_right.saturating_sub(WINDOW_TAB_INSET + 2);
+ let mut action_right = row_right.saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2);
if self.fancy_tab_bar_shows_window_buttons() {
let window_button_right = if self.right_sidebar_width() > 0 {
self.dimensions
.pixel_width
.saturating_sub(border.right.get() as usize)
- .saturating_sub(WINDOW_TAB_INSET + 2)
+ .saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2)
} else {
action_right
};
@@ -289,7 +289,7 @@ impl crate::TermWindow {
} else {
let right_sidebar_toggle_x = action_button_x;
let new_button_x = right_sidebar_toggle_x
- .saturating_sub(WINDOW_TAB_LEADING_ACTION_GAP + button_size);
+ .saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) + button_size);
self.paint_window_tab_new_button(
layers,
&mut ui_items,
@@ -315,8 +315,8 @@ impl crate::TermWindow {
}
} else {
let right_sidebar_toggle_x = action_right.saturating_sub(button_size);
- let new_button_x =
- right_sidebar_toggle_x.saturating_sub(WINDOW_TAB_LEADING_ACTION_GAP + button_size);
+ let new_button_x = right_sidebar_toggle_x
+ .saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) + button_size);
self.paint_window_tab_new_button(
layers,
&mut ui_items,
@@ -377,12 +377,12 @@ impl crate::TermWindow {
let action_button_size = if is_sidebar_toggle {
self.window_tab_sidebar_toggle_button_size()
} else {
- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE
+ self.ui_px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)
};
let action_icon_size = if is_sidebar_toggle {
self.window_tab_sidebar_toggle_icon_size()
} else {
- WINDOW_TAB_LEADING_ACTION_ICON_SIZE
+ self.ui_px(WINDOW_TAB_LEADING_ACTION_ICON_SIZE)
};
let button_size = if is_fullscreen_sidebar_toggle {
action_button_size
@@ -395,11 +395,12 @@ impl crate::TermWindow {
let button_y = if self.config.tab_bar_at_bottom {
row_y + (row_height.saturating_sub(button_size) / 2)
} else if is_fullscreen_sidebar_toggle {
- row_y.saturating_sub(WINDOW_TAB_TOP_SPACER)
- + SIDEBAR_INSET
- + WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET
+ row_y.saturating_sub(self.ui_px(WINDOW_TAB_TOP_SPACER))
+ + self.ui_px(SIDEBAR_INSET)
+ + self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET)
} else if !cfg!(target_os = "macos") {
- row_y.saturating_sub(WINDOW_TAB_TOP_SPACER) + SIDEBAR_INSET
+ row_y.saturating_sub(self.ui_px(WINDOW_TAB_TOP_SPACER))
+ + self.ui_px(SIDEBAR_INSET)
} else {
row_y + (row_height.saturating_sub(button_size) / 2)
};
@@ -414,7 +415,7 @@ impl crate::TermWindow {
muted_fg,
)?;
}
- button_x += action_button_size + WINDOW_TAB_LEADING_ACTION_GAP;
+ button_x += action_button_size + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP);
}
Ok(())
@@ -455,7 +456,7 @@ impl crate::TermWindow {
0.12
},
),
- SIDEBAR_INSET as f32,
+ self.ui_px(SIDEBAR_INSET) as f32,
)
.context("window sidebar toggle hover")?;
}
@@ -492,7 +493,7 @@ impl crate::TermWindow {
foreground: LinearRgba,
muted_fg: LinearRgba,
) -> anyhow::Result<usize> {
- let gap = WINDOW_TAB_LEADING_ACTION_GAP / 2;
+ let gap = self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) / 2;
for button in self.config.integrated_title_buttons.iter().rev() {
action_right = action_right.saturating_sub(button_size);
self.paint_window_tab_window_button(
@@ -510,7 +511,7 @@ impl crate::TermWindow {
action_right = action_right.saturating_sub(gap);
}
- Ok(action_right.saturating_sub(WINDOW_TAB_LEADING_ACTION_GAP / 2))
+ Ok(action_right.saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) / 2))
}
#[allow(clippy::too_many_arguments)]
@@ -668,7 +669,7 @@ impl crate::TermWindow {
} else {
LinearRgba::TRANSPARENT
},
- WINDOW_TAB_RADIUS,
+ self.ui_f32(WINDOW_TAB_RADIUS),
CAPSULE_BORDER_WIDTH,
)
.context("window tab surface")?;
@@ -682,7 +683,7 @@ impl crate::TermWindow {
});
let tab_left = tab_left.max(0.0) as usize;
- let icon_x = tab_left + WINDOW_TAB_INSET;
+ let icon_x = tab_left + self.ui_px(WINDOW_TAB_INSET);
let icon_y = row_y + (row_height.saturating_sub(icon_size) / 2);
if icon_x >= viewport_left && icon_x.saturating_add(icon_size) <= viewport_right {
self.paint_fancy_tab_icon(
@@ -697,7 +698,7 @@ impl crate::TermWindow {
let close_x = tab_left
.saturating_add(tab_width)
- .saturating_sub(button_size + TAB_CLOSE_RIGHT_GAP);
+ .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));
let close_y = row_y + (row_height.saturating_sub(button_size) / 2);
let close_slot_reserved = self.config.show_close_tab_button_in_tabs && !is_renaming;
let show_close = close_slot_reserved && (active || is_hovered);
@@ -715,7 +716,7 @@ impl crate::TermWindow {
} else {
0.12
};
- let hover_inset = TAB_CLOSE_HOVER_INSET.min(button_size / 2);
+ let hover_inset = self.ui_px(TAB_CLOSE_HOVER_INSET).min(button_size / 2);
let hover_size = button_size.saturating_sub(hover_inset * 2);
self.fill_rounded_rectangle(
layers,
@@ -753,21 +754,21 @@ impl crate::TermWindow {
)?;
}
- let mut text_x = icon_x + icon_size + WINDOW_TAB_ICON_GAP;
+ let mut text_x = icon_x + icon_size + self.ui_px(WINDOW_TAB_ICON_GAP);
if let Some(status) = item.status {
let status_x = text_x;
if status_x >= viewport_left && status_x.saturating_add(icon_size) <= viewport_right {
self.paint_status_icon(layers, 2, status, status_x, icon_y, icon_size, foreground)
.context("window tab status icon")?;
}
- text_x = status_x + icon_size + WINDOW_TAB_ICON_GAP;
+ text_x = status_x + icon_size + self.ui_px(WINDOW_TAB_ICON_GAP);
}
let text_right = if close_slot_reserved {
- close_x.saturating_sub(WINDOW_TAB_ICON_GAP)
+ close_x.saturating_sub(self.ui_px(WINDOW_TAB_ICON_GAP))
} else {
tab_left
.saturating_add(tab_width)
- .saturating_sub(WINDOW_TAB_INSET)
+ .saturating_sub(self.ui_px(WINDOW_TAB_INSET))
}
.min(viewport_right);
let text_width = text_right.saturating_sub(text_x);
@@ -857,7 +858,7 @@ impl crate::TermWindow {
} else {
LinearRgba::TRANSPARENT
},
- WINDOW_TAB_RADIUS,
+ self.ui_f32(WINDOW_TAB_RADIUS),
CAPSULE_BORDER_WIDTH,
)
.context("content view tab surface")?;
@@ -871,7 +872,7 @@ impl crate::TermWindow {
});
let tab_left = tab_left.max(0.0) as usize;
- let icon_x = tab_left + WINDOW_TAB_INSET;
+ let icon_x = tab_left + self.ui_px(WINDOW_TAB_INSET);
let icon_y = row_y + (row_height.saturating_sub(icon_size) / 2);
if icon_x >= viewport_left && icon_x.saturating_add(icon_size) <= viewport_right {
self.paint_fancy_tab_icon(
@@ -886,7 +887,7 @@ impl crate::TermWindow {
let close_x = tab_left
.saturating_add(tab_width)
- .saturating_sub(button_size + TAB_CLOSE_RIGHT_GAP);
+ .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));
let close_y = row_y + (row_height.saturating_sub(button_size) / 2);
let show_close =
close_x >= viewport_left && close_x.saturating_add(button_size) <= viewport_right;
@@ -914,13 +915,13 @@ impl crate::TermWindow {
)?;
}
- let text_x = icon_x + icon_size + WINDOW_TAB_ICON_GAP;
+ let text_x = icon_x + icon_size + self.ui_px(WINDOW_TAB_ICON_GAP);
let text_right = if show_close {
- close_x.saturating_sub(WINDOW_TAB_ICON_GAP)
+ close_x.saturating_sub(self.ui_px(WINDOW_TAB_ICON_GAP))
} else {
tab_left
.saturating_add(tab_width)
- .saturating_sub(WINDOW_TAB_INSET)
+ .saturating_sub(self.ui_px(WINDOW_TAB_INSET))
}
.min(viewport_right);
let text_width = text_right.saturating_sub(text_x);
@@ -1457,9 +1458,10 @@ impl crate::TermWindow {
}
fn fancy_tab_icon_size(metrics: &RenderMetrics, tab_bar_height: f32) -> f32 {
- let from_bar = (tab_bar_height - 14.0).max(1.0);
+ let cell_height = metrics.cell_size.height.max(1) as f32;
+ let from_bar = (tab_bar_height - cell_height * 0.45).max(1.0);
let from_font = metrics.cell_size.height as f32 * 0.95;
- from_bar.min(from_font).clamp(18.0, 24.0).floor()
+ from_bar.min(from_font).max(1.0).floor()
}
fn is_legacy_progress_marker(value: &str) -> bool {
diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rs
index 2b24e258..3b2c3e29 100644
--- a/wezterm-gui/src/termwindow/render/pane.rs
+++ b/wezterm-gui/src/termwindow/render/pane.rs
@@ -164,7 +164,7 @@ impl crate::TermWindow {
euclid::rect(x as f32, y as f32, button_size as f32, button_size as f32),
chrome.control_bg,
chrome.control_border,
- PANE_NAV_TAB_RADIUS,
+ self.ui_f32(PANE_NAV_TAB_RADIUS),
CAPSULE_BORDER_WIDTH,
)
.context("collapsed vertical pane tab chip")?;
@@ -220,11 +220,13 @@ impl crate::TermWindow {
// panes the viewport was already shrunk to make room.
let chrome_height = pane_nav_bar_height_for_metrics(self.render_metrics).min(strip_height);
let icon_size = chrome_height
- .saturating_sub(PANE_NAV_INSET * 2)
- .clamp(20, 24);
- let action_icon_size = icon_size.saturating_add(2).clamp(icon_size, 26);
+ .saturating_sub(self.ui_px(PANE_NAV_INSET) * 2)
+ .clamp(self.ui_px(20), self.ui_px(24));
+ let action_icon_size = icon_size
+ .saturating_add(self.ui_px(2))
+ .clamp(icon_size, self.ui_px(26));
let button_size = chrome_height
- .saturating_sub(TAB_VERTICAL_PADDING * 2)
+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)
.max(action_icon_size);
let button_y =
pane_rect.origin.y.max(0.0) as usize + (chrome_height.saturating_sub(button_size) / 2);
@@ -252,11 +254,11 @@ impl crate::TermWindow {
let tab_start = strip_left + COLLAPSED_EDGE_PADDING;
let tab_width = self.window_tab_width_pixels().ceil() as usize;
- let tab_step = tab_width + PANE_NAV_TAB_GAP;
+ let tab_step = tab_width + self.ui_px(PANE_NAV_TAB_GAP);
let total_tab_width = tabs.len().saturating_mul(tab_width).saturating_add(
tabs.len()
.saturating_sub(1)
- .saturating_mul(PANE_NAV_TAB_GAP),
+ .saturating_mul(self.ui_px(PANE_NAV_TAB_GAP)),
);
let max_tab_right = button_x.saturating_sub(COLLAPSED_SECTION_GAP);
let viewport_width = max_tab_right.saturating_sub(tab_start);
@@ -276,7 +278,9 @@ impl crate::TermWindow {
let tab_y = button_y;
let tab_fg = if pos.is_active { foreground } else { muted_fg };
for (idx, tab) in tabs.into_iter().enumerate() {
- if tab_width <= icon_size + PANE_NAV_ICON_GAP + button_size || viewport_width == 0 {
+ if tab_width <= icon_size + self.ui_px(PANE_NAV_ICON_GAP) + button_size
+ || viewport_width == 0
+ {
break;
}
@@ -319,7 +323,7 @@ impl crate::TermWindow {
euclid::rect(visible_left, tab_y as f32, visible_width, tab_height as f32),
tab_surface_color,
tab_border_color,
- PANE_NAV_TAB_RADIUS,
+ self.ui_f32(PANE_NAV_TAB_RADIUS),
CAPSULE_BORDER_WIDTH,
)
.context("collapsed pane nav tab surface")?;
@@ -337,7 +341,7 @@ impl crate::TermWindow {
});
let draw_tab_x = tab_left.max(0.0) as usize;
- let title_icon_x = draw_tab_x + PANE_NAV_INSET;
+ let title_icon_x = draw_tab_x + self.ui_px(PANE_NAV_INSET);
let title_icon_y = tab_y + ((tab_height.saturating_sub(icon_size)) / 2);
let raw_title = self.pane_nav_tab_title(tab.pane_id, &tab.title);
let (title, status) =
@@ -375,7 +379,7 @@ impl crate::TermWindow {
let raw_close_x = draw_tab_x
.saturating_add(tab_width)
- .saturating_sub(button_size + TAB_CLOSE_RIGHT_GAP);
+ .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));
let close_slot_reserved = !is_renaming_tab;
let close_view_left = draw_tab_x.max(tab_start);
let close_view_right = draw_tab_x.saturating_add(tab_width).min(max_tab_right);
@@ -399,7 +403,7 @@ impl crate::TermWindow {
} else {
0.12
};
- let hover_inset = TAB_CLOSE_HOVER_INSET.min(button_size / 2);
+ let hover_inset = self.ui_px(TAB_CLOSE_HOVER_INSET).min(button_size / 2);
let hover_size = button_size.saturating_sub(hover_inset * 2);
self.fill_rounded_rectangle(
layers,
@@ -441,7 +445,7 @@ impl crate::TermWindow {
.title_font_with_size(crate::native_settings::pane_header_font_size())
.context("collapsed pane nav title font")?;
let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());
- let text_x = title_icon_x + icon_size + PANE_NAV_ICON_GAP;
+ let text_x = title_icon_x + icon_size + self.ui_px(PANE_NAV_ICON_GAP);
let text_right = if close_slot_reserved {
if show_close {
close_x
@@ -449,11 +453,11 @@ impl crate::TermWindow {
raw_close_x
}
} else {
- draw_tab_x + tab_width - PANE_NAV_INSET
+ draw_tab_x + tab_width - self.ui_px(PANE_NAV_INSET)
};
let text_width = text_right
.min(max_tab_right)
- .saturating_sub(text_x + PANE_NAV_ICON_GAP);
+ .saturating_sub(text_x + self.ui_px(PANE_NAV_ICON_GAP));
let text_y =
tab_y + ((tab_height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2);
if text_x >= tab_start && text_x < max_tab_right && text_width > 0 {
@@ -560,13 +564,17 @@ impl crate::TermWindow {
},
});
- let icon_size = nav_height.saturating_sub(PANE_NAV_INSET * 2).clamp(20, 24);
- let action_icon_size = icon_size.saturating_add(2).clamp(icon_size, 26);
+ let icon_size = nav_height
+ .saturating_sub(self.ui_px(PANE_NAV_INSET) * 2)
+ .clamp(self.ui_px(20), self.ui_px(24));
+ let action_icon_size = icon_size
+ .saturating_add(self.ui_px(2))
+ .clamp(icon_size, self.ui_px(26));
let button_size = nav_height
- .saturating_sub(TAB_VERTICAL_PADDING * 2)
+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)
.max(action_icon_size);
let button_y = pane_y as usize
- + (nav_height.saturating_sub(button_size) / 2 + PANE_NAV_TAB_TOP_OFFSET)
+ + (nav_height.saturating_sub(button_size) / 2 + self.ui_px(PANE_NAV_TAB_TOP_OFFSET))
.min(nav_height.saturating_sub(button_size));
let mut button_x = (pane_x + pane_width) as usize;
let mut actions = vec![
@@ -586,7 +594,7 @@ impl crate::TermWindow {
PaneNavAction::ToggleZoom,
));
for (icon, action) in actions {
- button_x = button_x.saturating_sub(button_size + PANE_NAV_BUTTON_GAP);
+ button_x = button_x.saturating_sub(button_size + self.ui_px(PANE_NAV_BUTTON_GAP));
// Stop once a button would spill past the pane's left edge (happens
// when the pane is too narrow to hold all the action buttons).
if (button_x as f32) < pane_x {
@@ -609,13 +617,13 @@ impl crate::TermWindow {
let tabs = Mux::get().pane_stack_tabs(pos.pane.pane_id());
let tab_start = pane_x as usize + self.pane_nav_tab_left_inset(pos.left);
let tab_width = self.window_tab_width_pixels().ceil() as usize;
- let tab_step = tab_width + PANE_NAV_TAB_GAP;
+ let tab_step = tab_width + self.ui_px(PANE_NAV_TAB_GAP);
let total_tab_width = tabs.len().saturating_mul(tab_width).saturating_add(
tabs.len()
.saturating_sub(1)
- .saturating_mul(PANE_NAV_TAB_GAP),
+ .saturating_mul(self.ui_px(PANE_NAV_TAB_GAP)),
);
- let max_tab_right = button_x.saturating_sub(PANE_NAV_INSET);
+ let max_tab_right = button_x.saturating_sub(self.ui_px(PANE_NAV_INSET));
let viewport_width = max_tab_right.saturating_sub(tab_start);
let max_scroll = total_tab_width.saturating_sub(viewport_width) as f32;
let scroll_offset = self
@@ -632,7 +640,9 @@ impl crate::TermWindow {
let tab_height = button_size;
let tab_y = button_y;
for (idx, tab) in tabs.into_iter().enumerate() {
- if tab_width <= icon_size + PANE_NAV_ICON_GAP + button_size || viewport_width == 0 {
+ if tab_width <= icon_size + self.ui_px(PANE_NAV_ICON_GAP) + button_size
+ || viewport_width == 0
+ {
break;
}
@@ -675,7 +685,7 @@ impl crate::TermWindow {
euclid::rect(visible_left, tab_y as f32, visible_width, tab_height as f32),
tab_surface_color,
tab_border_color,
- PANE_NAV_TAB_RADIUS,
+ self.ui_f32(PANE_NAV_TAB_RADIUS),
CAPSULE_BORDER_WIDTH,
)
.context("pane nav tab surface")?;
@@ -692,7 +702,7 @@ impl crate::TermWindow {
});
let draw_tab_x = tab_left.max(0.0) as usize;
- let title_icon_x = draw_tab_x + PANE_NAV_INSET;
+ let title_icon_x = draw_tab_x + self.ui_px(PANE_NAV_INSET);
let title_icon_y = tab_y + ((tab_height.saturating_sub(icon_size)) / 2);
let raw_title = self.pane_nav_tab_title(tab.pane_id, &tab.title);
let (title, status) =
@@ -730,7 +740,7 @@ impl crate::TermWindow {
let raw_close_x = draw_tab_x
.saturating_add(tab_width)
- .saturating_sub(button_size + TAB_CLOSE_RIGHT_GAP);
+ .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));
let close_slot_reserved = !is_renaming_tab;
let close_view_left = draw_tab_x.max(tab_start);
let close_view_right = draw_tab_x.saturating_add(tab_width).min(max_tab_right);
@@ -754,7 +764,7 @@ impl crate::TermWindow {
} else {
0.12
};
- let hover_inset = TAB_CLOSE_HOVER_INSET.min(button_size / 2);
+ let hover_inset = self.ui_px(TAB_CLOSE_HOVER_INSET).min(button_size / 2);
let hover_size = button_size.saturating_sub(hover_inset * 2);
self.fill_rounded_rectangle(
layers,
@@ -796,7 +806,7 @@ impl crate::TermWindow {
.title_font_with_size(crate::native_settings::pane_header_font_size())
.context("pane nav title font")?;
let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());
- let text_x = title_icon_x + icon_size + PANE_NAV_ICON_GAP;
+ let text_x = title_icon_x + icon_size + self.ui_px(PANE_NAV_ICON_GAP);
let text_right = if close_slot_reserved {
if show_close {
close_x
@@ -804,11 +814,11 @@ impl crate::TermWindow {
raw_close_x
}
} else {
- draw_tab_x + tab_width - PANE_NAV_INSET
+ draw_tab_x + tab_width - self.ui_px(PANE_NAV_INSET)
};
let text_width = text_right
.min(max_tab_right)
- .saturating_sub(text_x + PANE_NAV_ICON_GAP);
+ .saturating_sub(text_x + self.ui_px(PANE_NAV_ICON_GAP));
let text_y =
tab_y + ((tab_height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2);
if text_x >= tab_start && text_x < max_tab_right && text_width > 0 {
diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rs
index 28a48391..769b08af 100644
--- a/wezterm-gui/src/termwindow/resize.rs
+++ b/wezterm-gui/src/termwindow/resize.rs
@@ -1,5 +1,6 @@
use crate::resize_increment_calculator::ResizeIncrementCalculator;
use crate::termwindow::ui::pane_nav_bar_height_for_metrics;
+use crate::ui::rescale_ui_usize;
use crate::utilsprites::RenderMetrics;
use ::window::{Dimensions, ResizeIncrement, Window, WindowOps, WindowState};
use config::{ConfigHandle, DimensionContext};
@@ -632,6 +633,18 @@ impl super::TermWindow {
let cell_dims = self.current_cell_dimensions();
+ if dpi_changed {
+ let old_dpi = self.dimensions.dpi;
+ let new_dpi = dimensions.dpi;
+ self.workspace_sidebar_width =
+ rescale_ui_usize(self.workspace_sidebar_width, old_dpi, new_dpi);
+ self.right_sidebar_width = rescale_ui_usize(self.right_sidebar_width, old_dpi, new_dpi);
+ self.right_sidebar_file_tree_width =
+ rescale_ui_usize(self.right_sidebar_file_tree_width, old_dpi, new_dpi);
+ self.right_sidebar_file_preview_width =
+ rescale_ui_usize(self.right_sidebar_file_preview_width, old_dpi, new_dpi);
+ }
+
if scale_changed {
self.apply_scale_change(&dimensions, font_scale);
}
diff --git a/wezterm-gui/src/termwindow/ssh_hosts_view.rs b/wezterm-gui/src/termwindow/ssh_hosts_view.rs
index efc4a20b..d5e65f15 100644
--- a/wezterm-gui/src/termwindow/ssh_hosts_view.rs
+++ b/wezterm-gui/src/termwindow/ssh_hosts_view.rs
@@ -660,7 +660,7 @@ impl SshHostsView {
font: &Rc<LoadedFont>,
cursor_on: bool,
) -> anyhow::Result<()> {
- let tokens = UiTokens::default();
+ let tokens = UiTokens::for_dpi(ctx.dimensions.dpi);
self.refresh();
self.widgets.clear();
diff --git a/wezterm-gui/src/termwindow/ui/mod.rs b/wezterm-gui/src/termwindow/ui/mod.rs
index 516a807f..aa67dfd3 100644
--- a/wezterm-gui/src/termwindow/ui/mod.rs
+++ b/wezterm-gui/src/termwindow/ui/mod.rs
@@ -12,8 +12,10 @@ pub use right_sidebar::{right_sidebar_file_preview_width, right_sidebar_width_fo
pub use sidebar::workspace_sidebar_width_for_metrics;
pub fn pane_nav_bar_height_for_metrics(render_metrics: RenderMetrics) -> usize {
- (render_metrics.cell_size.height as usize + tokens::PANE_NAV_EXTRA_HEIGHT)
- .clamp(tokens::PANE_NAV_MIN_HEIGHT, tokens::PANE_NAV_MAX_HEIGHT)
+ // Keep the bar proportional to the DPI-scaled UI font. Fixed physical
+ // pixel clamps made it twice as tall in points on non-Retina displays.
+ let cell_height = render_metrics.cell_size.height.max(1) as usize;
+ (cell_height * 11 / 5).max(cell_height)
}
pub fn terminal_title_for_display(title: &str) -> &str {
diff --git a/wezterm-gui/src/termwindow/ui/platform_chrome.rs b/wezterm-gui/src/termwindow/ui/platform_chrome.rs
index 89a844a9..55d80d8b 100644
--- a/wezterm-gui/src/termwindow/ui/platform_chrome.rs
+++ b/wezterm-gui/src/termwindow/ui/platform_chrome.rs
@@ -5,6 +5,7 @@ use crate::termwindow::ui::tokens::{
WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE, WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE,
WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_LEADING_ACTION_ICON_SIZE,
};
+use crate::ui::{scale_ui_f32, scale_ui_usize};
use window::{
IntegratedTitleButtonAlignment, IntegratedTitleButtonStyle, WindowDecorations, WindowState,
};
@@ -18,9 +19,18 @@ pub struct WindowTabChromeParams {
pub integrated_title_button_alignment: IntegratedTitleButtonAlignment,
pub integrated_title_button_style: IntegratedTitleButtonStyle,
pub cell_width: f32,
+ pub dpi: usize,
}
impl WindowTabChromeParams {
+ fn px(self, value: usize) -> usize {
+ scale_ui_usize(value, self.dpi)
+ }
+
+ fn px_f32(self, value: f32) -> f32 {
+ scale_ui_f32(value, self.dpi)
+ }
+
pub fn leading_action_slot_count(self) -> usize {
if !self.use_fancy_tab_bar || self.workspace_sidebar_width > 0 {
return 0;
@@ -47,11 +57,11 @@ impl WindowTabChromeParams {
if self.leading_action_slot_count() == 0 {
0.0
} else if self.window_state.contains(WindowState::FULL_SCREEN) {
- WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X as f32
+ self.px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X) as f32
} else if cfg!(target_os = "macos") {
- MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH as f32
+ self.px(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH) as f32
} else {
- SIDEBAR_INSET as f32
+ self.px(SIDEBAR_INSET) as f32
}
}
@@ -64,9 +74,9 @@ impl WindowTabChromeParams {
let button_size = if self.shows_sidebar_toggle_action() {
self.sidebar_toggle_button_size()
} else {
- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE
+ self.px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)
};
- (count * (button_size + WINDOW_TAB_LEADING_ACTION_GAP)) as f32
+ (count * (button_size + self.px(WINDOW_TAB_LEADING_ACTION_GAP))) as f32
}
pub fn sidebar_toggle_uses_fullscreen_style(self) -> bool {
@@ -74,11 +84,11 @@ impl WindowTabChromeParams {
}
pub fn sidebar_toggle_button_size(self) -> usize {
- workspace_sidebar_toolbar_button_size(self.window_state)
+ self.px(workspace_sidebar_toolbar_button_size(self.window_state))
}
pub fn sidebar_toggle_icon_size(self) -> usize {
- workspace_sidebar_toolbar_icon_size(self.window_state)
+ self.px(workspace_sidebar_toolbar_icon_size(self.window_state))
}
pub fn left_padding_pixels(self) -> f32 {
@@ -93,7 +103,7 @@ impl WindowTabChromeParams {
};
if cfg!(target_os = "macos") && !self.window_state.contains(WindowState::FULL_SCREEN) {
- return leading_action_padding.max(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH as f32);
+ return leading_action_padding.max(self.px(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH) as f32);
}
if self
@@ -106,7 +116,7 @@ impl WindowTabChromeParams {
if self.window_state.contains(WindowState::FULL_SCREEN) {
leading_action_padding + self.cell_width * 0.5
} else {
- 70.0
+ self.px_f32(70.0)
}
} else {
leading_action_padding
@@ -122,9 +132,10 @@ pub fn workspace_sidebar_content_top(
sidebar_inset: usize,
tab_row_height: usize,
window_state: WindowState,
+ dpi: usize,
) -> usize {
if cfg!(target_os = "macos") && !window_state.contains(WindowState::FULL_SCREEN) {
- panel_y + MACOS_TITLEBAR_CONTENT_TOP_INSET.max(tab_row_height)
+ panel_y + scale_ui_usize(MACOS_TITLEBAR_CONTENT_TOP_INSET, dpi).max(tab_row_height)
} else {
panel_y + sidebar_inset
}
diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
index 15fa18d4..b43dcb9c 100644
--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
@@ -17,8 +17,7 @@ use crate::termwindow::{
RightSidebarOpenWithCacheEntry, RightSidebarSnippetField, RightSidebarSnippetView,
TermWindowNotif, UIItem, UIItemType, UiShapeCacheLookup,
};
-use crate::ui::TextInputState;
-use crate::ui::UiPalette;
+use crate::ui::{scale_ui_usize, unscale_ui_usize, TextInputState, UiPalette};
use crate::utilsprites::RenderMetrics;
use crate::workspace_threads;
use anyhow::Context;
@@ -284,18 +283,23 @@ impl RightSidebarMode {
}
}
-pub fn right_sidebar_width_for_metrics(render_metrics: &RenderMetrics) -> usize {
- let default_width = (render_metrics.cell_size.width as usize * RIGHT_SIDEBAR_WIDTH_CELLS)
- .max(RIGHT_SIDEBAR_MIN_WIDTH);
+pub fn right_sidebar_width_for_metrics(render_metrics: &RenderMetrics, dpi: usize) -> usize {
+ let min_width = scale_ui_usize(RIGHT_SIDEBAR_MIN_WIDTH, dpi);
+ let max_width = scale_ui_usize(RIGHT_SIDEBAR_MAX_WIDTH, dpi);
+ let default_width =
+ (render_metrics.cell_size.width as usize * RIGHT_SIDEBAR_WIDTH_CELLS).max(min_width);
crate::native_settings::right_sidebar_width()
+ .map(|width| scale_ui_usize(width, dpi))
.unwrap_or(default_width)
- .clamp(RIGHT_SIDEBAR_MIN_WIDTH, RIGHT_SIDEBAR_MAX_WIDTH)
+ .clamp(min_width, max_width)
}
-pub fn right_sidebar_file_preview_width() -> usize {
+pub fn right_sidebar_file_preview_width(dpi: usize) -> usize {
+ let min_width = scale_ui_usize(FILE_PREVIEW_PANE_MIN_WIDTH, dpi);
crate::native_settings::right_sidebar_file_preview_width()
- .unwrap_or(FILE_PREVIEW_PANE_DEFAULT_WIDTH)
- .max(FILE_PREVIEW_PANE_MIN_WIDTH)
+ .map(|width| scale_ui_usize(width, dpi))
+ .unwrap_or_else(|| scale_ui_usize(FILE_PREVIEW_PANE_DEFAULT_WIDTH, dpi))
+ .max(min_width)
}
impl crate::TermWindow {
@@ -312,7 +316,10 @@ impl crate::TermWindow {
} else {
self.right_sidebar_width
};
- width.clamp(RIGHT_SIDEBAR_MIN_WIDTH, self.right_sidebar_max_width())
+ width.clamp(
+ self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH),
+ self.right_sidebar_max_width(),
+ )
}
fn right_sidebar_available_width(&self) -> usize {
@@ -325,7 +332,8 @@ impl crate::TermWindow {
fn right_sidebar_file_preview_total_max_width(&self) -> usize {
let available_width = self.right_sidebar_available_width();
let content_width = available_width.saturating_sub(self.workspace_sidebar_width());
- let min_preview_total = RIGHT_SIDEBAR_MIN_WIDTH + FILE_PREVIEW_PANE_MIN_WIDTH;
+ let min_preview_total =
+ self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH) + self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH);
let terminal_reserve = content_width / 5;
content_width
.saturating_sub(terminal_reserve)
@@ -345,16 +353,17 @@ impl crate::TermWindow {
let max_preview_width = self
.right_sidebar_file_preview_total_max_width()
.saturating_sub(self.right_sidebar_tree_width());
- if max_preview_width < FILE_PREVIEW_PANE_MIN_WIDTH {
+ if max_preview_width < self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH) {
return None;
}
let configured_width = if self.right_sidebar_file_preview_width == 0 {
- FILE_PREVIEW_PANE_DEFAULT_WIDTH
+ self.ui_px(FILE_PREVIEW_PANE_DEFAULT_WIDTH)
} else {
self.right_sidebar_file_preview_width
};
- let width = configured_width.clamp(FILE_PREVIEW_PANE_MIN_WIDTH, max_preview_width);
+ let width =
+ configured_width.clamp(self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH), max_preview_width);
Some(width)
}
@@ -374,8 +383,8 @@ impl crate::TermWindow {
pub fn right_sidebar_max_width(&self) -> usize {
let available_width = self.right_sidebar_available_width();
- let proportional_max = (available_width * 2 / 3).max(RIGHT_SIDEBAR_MIN_WIDTH);
- RIGHT_SIDEBAR_MAX_WIDTH.min(proportional_max)
+ let proportional_max = (available_width * 2 / 3).max(self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH));
+ self.ui_px(RIGHT_SIDEBAR_MAX_WIDTH).min(proportional_max)
}
fn right_sidebar_window_button_reserved_width(&self) -> usize {
@@ -390,19 +399,24 @@ impl crate::TermWindow {
}
self.config.integrated_title_buttons.len()
- * (WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE + WINDOW_TAB_LEADING_ACTION_GAP / 2)
- + WINDOW_TAB_LEADING_ACTION_GAP
+ * (self.ui_px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) / 2)
+ + self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP)
}
pub fn set_right_sidebar_width(&mut self, width: usize) {
- self.right_sidebar_width =
- width.clamp(RIGHT_SIDEBAR_MIN_WIDTH, self.right_sidebar_max_width());
+ self.right_sidebar_width = width.clamp(
+ self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH),
+ self.right_sidebar_max_width(),
+ );
}
fn set_right_sidebar_file_tree_width(&mut self, width: usize) -> bool {
let old_width = self.right_sidebar_file_tree_width;
- self.right_sidebar_file_tree_width =
- width.clamp(RIGHT_SIDEBAR_MIN_WIDTH, self.right_sidebar_max_width());
+ self.right_sidebar_file_tree_width = width.clamp(
+ self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH),
+ self.right_sidebar_max_width(),
+ );
old_width != self.right_sidebar_file_tree_width
}
@@ -424,20 +438,22 @@ impl crate::TermWindow {
let max_preview_width = self
.right_sidebar_file_preview_total_max_width()
.saturating_sub(self.right_sidebar_tree_width());
- if max_preview_width < FILE_PREVIEW_PANE_MIN_WIDTH {
+ if max_preview_width < self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH) {
return false;
}
let old_width = self.right_sidebar_file_preview_width;
self.right_sidebar_file_preview_width =
- width.clamp(FILE_PREVIEW_PANE_MIN_WIDTH, max_preview_width);
+ width.clamp(self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH), max_preview_width);
old_width != self.right_sidebar_file_preview_width
}
pub fn persist_right_sidebar_width(&self) {
- let width = self
- .right_sidebar_width
- .clamp(RIGHT_SIDEBAR_MIN_WIDTH, RIGHT_SIDEBAR_MAX_WIDTH);
+ let width = self.right_sidebar_width.clamp(
+ self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH),
+ self.ui_px(RIGHT_SIDEBAR_MAX_WIDTH),
+ );
+ let width = unscale_ui_usize(width, self.dimensions.dpi);
if let Err(err) = crate::native_settings::save_right_sidebar_width(width) {
log::warn!("failed to save right sidebar width: {err:#}");
}
@@ -447,7 +463,8 @@ impl crate::TermWindow {
let width = self
.right_sidebar_file_preview_width()
.unwrap_or(self.right_sidebar_file_preview_width)
- .max(FILE_PREVIEW_PANE_MIN_WIDTH);
+ .max(self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH));
+ let width = unscale_ui_usize(width, self.dimensions.dpi);
if let Err(err) = crate::native_settings::save_right_sidebar_file_preview_width(width) {
log::warn!("failed to save right sidebar file preview width: {err:#}");
}
@@ -550,10 +567,15 @@ impl crate::TermWindow {
preview_horizontal: self.right_sidebar_file_preview_horizontal_offset,
filter: self.right_sidebar_file_applied_filter.clone(),
};
- if !self.right_sidebar_file_view_state_by_root.contains_key(&key) {
- self.right_sidebar_file_view_state_order.push_back(key.clone());
+ if !self
+ .right_sidebar_file_view_state_by_root
+ .contains_key(&key)
+ {
+ self.right_sidebar_file_view_state_order
+ .push_back(key.clone());
}
- self.right_sidebar_file_view_state_by_root.insert(key, state);
+ self.right_sidebar_file_view_state_by_root
+ .insert(key, state);
while self.right_sidebar_file_view_state_order.len() > FILE_VIEW_STATE_CACHE_CAP {
if let Some(old) = self.right_sidebar_file_view_state_order.pop_front() {
self.right_sidebar_file_view_state_by_root.remove(&old);
@@ -583,7 +605,8 @@ impl crate::TermWindow {
self.right_sidebar_file_expanded = state.expanded;
self.right_sidebar_file_tree_scroll_offset = state.tree_scroll;
// Filter: set all three coupled fields so the first frame is consistent.
- self.right_sidebar_file_filter.set_text_end(state.filter.clone());
+ self.right_sidebar_file_filter
+ .set_text_end(state.filter.clone());
self.right_sidebar_file_applied_filter = state.filter;
self.right_sidebar_file_filter_debounce_until = None;
@@ -815,11 +838,11 @@ impl crate::TermWindow {
if !self.right_sidebar_file_preview_active() {
let max_tree_for_preview = self
.right_sidebar_file_preview_total_max_width()
- .saturating_sub(FILE_PREVIEW_PANE_MIN_WIDTH)
- .max(RIGHT_SIDEBAR_MIN_WIDTH);
+ .saturating_sub(self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH))
+ .max(self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH));
self.right_sidebar_file_tree_width = self
.right_sidebar_width
- .clamp(RIGHT_SIDEBAR_MIN_WIDTH, max_tree_for_preview);
+ .clamp(self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH), max_tree_for_preview);
}
self.right_sidebar_file_selected = Some(path.clone());
self.right_sidebar_file_preview_generation =
@@ -939,7 +962,9 @@ impl crate::TermWindow {
}
let colors = Rc::new(full_line_colors_by_byte(line));
{
- let mut cache = self.right_sidebar_file_preview_line_color_cache.borrow_mut();
+ let mut cache = self
+ .right_sidebar_file_preview_line_color_cache
+ .borrow_mut();
let mut order = self
.right_sidebar_file_preview_line_color_cache_order
.borrow_mut();
@@ -1213,8 +1238,9 @@ impl crate::TermWindow {
.right_sidebar_open_with_app
.as_ref()
.map(|app| app.id.clone());
- candidates
- .retain(|candidate| open_with_candidate_allowed(candidate, &custom_ids, saved_id.as_deref()));
+ candidates.retain(|candidate| {
+ open_with_candidate_allowed(candidate, &custom_ids, saved_id.as_deref())
+ });
let mut items: Vec<ContextMenuItem> =
sorted_open_with_candidates(candidates, current_id.as_deref())
@@ -1740,8 +1766,7 @@ impl crate::TermWindow {
let Some(window) = self.window.as_ref().cloned() else {
return;
};
- self.right_sidebar_file_rescan_token =
- self.right_sidebar_file_rescan_token.wrapping_add(1);
+ self.right_sidebar_file_rescan_token = self.right_sidebar_file_rescan_token.wrapping_add(1);
let token = self.right_sidebar_file_rescan_token;
let target = Instant::now() + Duration::from_secs(FILE_INDEX_RESCAN_SECS);
promise::spawn::spawn(async move {
@@ -2390,9 +2415,11 @@ impl crate::TermWindow {
let total_left = total_rect.x;
let total_right = total_rect.x.saturating_add(total_rect.width);
- let min_preview = FILE_PREVIEW_PANE_MIN_WIDTH;
- let max_preview = total_rect.width.saturating_sub(RIGHT_SIDEBAR_MIN_WIDTH);
- let min_tree = RIGHT_SIDEBAR_MIN_WIDTH;
+ let min_preview = self.ui_px(FILE_PREVIEW_PANE_MIN_WIDTH);
+ let max_preview = total_rect
+ .width
+ .saturating_sub(self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH));
+ let min_tree = self.ui_px(RIGHT_SIDEBAR_MIN_WIDTH);
let max_tree = self.right_sidebar_max_width().min(total_rect.width);
let min_split = total_left
.saturating_add(min_preview)
@@ -2437,18 +2464,18 @@ impl crate::TermWindow {
}
let rect = self.right_sidebar_file_preview_rect()?;
- let content_x = rect.x + SIDEBAR_INSET * 2;
- let content_width = rect.width.saturating_sub(SIDEBAR_INSET * 4);
- let content_top = rect.y + SIDEBAR_INSET * 2;
+ let content_x = rect.x + self.ui_px(SIDEBAR_INSET) * 2;
+ let content_width = rect.width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 4);
+ let content_top = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
let content_bottom = rect.y.saturating_add(rect.height);
- let y = content_top + FILE_PREVIEW_HEADER_HEIGHT;
- let bottom = content_bottom.saturating_sub(SIDEBAR_INSET);
+ let y = content_top + self.ui_px(FILE_PREVIEW_HEADER_HEIGHT);
+ let bottom = content_bottom.saturating_sub(self.ui_px(SIDEBAR_INSET));
let visible_height = bottom.saturating_sub(y);
if visible_height == 0 || content_width == 0 {
return None;
}
- let line_height = preview_metrics.cell_size.height as usize + 4;
+ let line_height = preview_metrics.cell_size.height as usize + self.ui_px(4);
let total_height = if self.right_sidebar_file_preview_image.is_some() {
visible_height
} else {
@@ -2482,7 +2509,7 @@ impl crate::TermWindow {
) -> (usize, usize, usize, usize) {
let scrollbar_reserve =
if self.right_sidebar_file_preview_vertical_scrollbar_active(metrics) {
- SIDEBAR_INSET + 4
+ self.ui_px(SIDEBAR_INSET) + 4
} else {
0
};
@@ -2493,11 +2520,12 @@ impl crate::TermWindow {
number_digits,
preview_metrics.cell_size.width.max(1) as usize,
body_width,
+ self.ui_px(SIDEBAR_ICON_GAP),
);
let text_x = metrics
.x
.saturating_add(number_width)
- .saturating_add(SIDEBAR_ICON_GAP);
+ .saturating_add(self.ui_px(SIDEBAR_ICON_GAP));
let text_width = metrics.x.saturating_add(body_width).saturating_sub(text_x);
(body_width, number_width, text_x, text_width)
}
@@ -2560,7 +2588,7 @@ impl crate::TermWindow {
) -> usize {
let horizontal_reserve =
if self.right_sidebar_file_preview_horizontal_scroll_active(preview_metrics) {
- SIDEBAR_INSET + FILE_PREVIEW_SCROLLBAR_THICKNESS
+ self.ui_px(SIDEBAR_INSET) + self.ui_px(FILE_PREVIEW_SCROLLBAR_THICKNESS)
} else {
0
};
@@ -2596,7 +2624,7 @@ impl crate::TermWindow {
return None;
}
- let track_width = FILE_PREVIEW_SCROLLBAR_THICKNESS;
+ let track_width = self.ui_px(FILE_PREVIEW_SCROLLBAR_THICKNESS);
let track_height = visible_height.max(1);
let thumb_height = ((visible_height as f32 / metrics.total_height as f32)
* track_height as f32)
@@ -2644,7 +2672,7 @@ impl crate::TermWindow {
.right_sidebar_file_preview_visible_columns(preview_metrics)
.max(1);
let track_width = text_width.max(1);
- let track_height = FILE_PREVIEW_SCROLLBAR_THICKNESS;
+ let track_height = self.ui_px(FILE_PREVIEW_SCROLLBAR_THICKNESS);
let thumb_width = ((visible_columns as f32 / max_columns as f32) * track_width as f32)
.clamp(28.0, track_width as f32);
let travel = (track_width as f32 - thumb_width).max(1.0);
@@ -2665,13 +2693,17 @@ impl crate::TermWindow {
})
}
- fn right_sidebar_snippet_scroll_height(snippet_count: usize, viewport_height: usize) -> usize {
- let row_height = SNIPPET_CARD_HEIGHT + SNIPPET_ROW_GAP;
+ fn right_sidebar_snippet_scroll_height(
+ &self,
+ snippet_count: usize,
+ viewport_height: usize,
+ ) -> usize {
+ let row_height = self.ui_px(SNIPPET_CARD_HEIGHT) + self.ui_px(SNIPPET_ROW_GAP);
let height = snippet_count
.saturating_mul(row_height)
- .saturating_sub(SNIPPET_ROW_GAP);
+ .saturating_sub(self.ui_px(SNIPPET_ROW_GAP));
if height > viewport_height {
- height.saturating_add(SNIPPET_LIST_BOTTOM_PADDING)
+ height.saturating_add(self.ui_px(SNIPPET_LIST_BOTTOM_PADDING))
} else {
height
}
@@ -2688,23 +2720,28 @@ impl crate::TermWindow {
return None;
}
- let top_bar_y = rect.y + SIDEBAR_INSET * 2;
- let top_bar_height = RIGHT_SIDEBAR_TOP_BAR_HEIGHT.min(
+ let top_bar_y = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
+ let top_bar_height = self.ui_px(RIGHT_SIDEBAR_TOP_BAR_HEIGHT).min(
rect.y
.saturating_add(rect.height)
- .saturating_sub(top_bar_y + SIDEBAR_INSET),
+ .saturating_sub(top_bar_y + self.ui_px(SIDEBAR_INSET)),
);
- let content_top =
- top_bar_y + top_bar_height + RIGHT_SIDEBAR_MODE_HEIGHT + RIGHT_SIDEBAR_SECTION_GAP;
- let list_top =
- content_top + SNIPPET_TOOLBAR_HEIGHT.max(SNIPPET_SEARCH_HEIGHT) + SNIPPET_LIST_TOP_GAP;
+ let content_top = top_bar_y
+ + top_bar_height
+ + self.ui_px(RIGHT_SIDEBAR_MODE_HEIGHT)
+ + self.ui_px(RIGHT_SIDEBAR_SECTION_GAP);
+ let list_top = content_top
+ + self
+ .ui_px(SNIPPET_TOOLBAR_HEIGHT)
+ .max(self.ui_px(SNIPPET_SEARCH_HEIGHT))
+ + self.ui_px(SNIPPET_LIST_TOP_GAP);
let content_bottom = rect.y.saturating_add(rect.height);
- let visible_height = content_bottom.saturating_sub(list_top + SIDEBAR_INSET);
+ let visible_height = content_bottom.saturating_sub(list_top + self.ui_px(SIDEBAR_INSET));
if visible_height == 0 {
return None;
}
let snippet_count = self.filtered_snippet_count();
- let total_height = Self::right_sidebar_snippet_scroll_height(snippet_count, visible_height);
+ let total_height = self.right_sidebar_snippet_scroll_height(snippet_count, visible_height);
Some((list_top, visible_height, total_height))
}
@@ -2739,7 +2776,7 @@ impl crate::TermWindow {
let track_x = rect
.x
.saturating_add(rect.width)
- .saturating_sub(SIDEBAR_INSET / 2 + track_width);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) / 2 + track_width);
Some(RightSidebarSnippetScrollGeometry {
track_x,
@@ -2820,7 +2857,7 @@ impl crate::TermWindow {
.context("right sidebar ui font")?;
let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());
let ui_cell_height = ui_metrics.cell_size.height as usize;
- let icon_size = (ui_cell_height + 6).clamp(20, 24);
+ let icon_size = (ui_cell_height + self.ui_px(6)).clamp(self.ui_px(20), self.ui_px(24));
if self.right_sidebar_mode == RightSidebarMode::Chat {
let _ = self.sync_right_sidebar_file_root_for_current_workspace();
@@ -2880,36 +2917,41 @@ impl crate::TermWindow {
)
.context("right sidebar separator")?;
self.ui_items.push(UIItem {
- x: total_rect.x.saturating_sub(SIDEBAR_RESIZE_HANDLE_WIDTH / 2),
+ x: total_rect
+ .x
+ .saturating_sub(self.ui_px(SIDEBAR_RESIZE_HANDLE_WIDTH) / 2),
y: total_rect.y,
- width: SIDEBAR_RESIZE_HANDLE_WIDTH,
+ width: self.ui_px(SIDEBAR_RESIZE_HANDLE_WIDTH),
height: total_rect.height,
item_type: UIItemType::RightSidebarResize,
});
if self.right_sidebar_file_preview_rect().is_some() {
self.ui_items.push(UIItem {
- x: rect.x.saturating_sub(SIDEBAR_RESIZE_HANDLE_WIDTH / 2),
+ x: rect
+ .x
+ .saturating_sub(self.ui_px(SIDEBAR_RESIZE_HANDLE_WIDTH) / 2),
y: rect.y,
- width: SIDEBAR_RESIZE_HANDLE_WIDTH,
+ width: self.ui_px(SIDEBAR_RESIZE_HANDLE_WIDTH),
height: rect.height,
item_type: UIItemType::RightSidebarFilePreviewResize,
});
}
- let content_x = rect.x + SIDEBAR_INSET * 2;
- let content_width = rect.width.saturating_sub(SIDEBAR_INSET * 4);
- let top_bar_y = rect.y + SIDEBAR_INSET * 2;
- let top_bar_height = RIGHT_SIDEBAR_TOP_BAR_HEIGHT.min(
+ let content_x = rect.x + self.ui_px(SIDEBAR_INSET) * 2;
+ let content_width = rect.width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 4);
+ let top_bar_y = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
+ let top_bar_height = self.ui_px(RIGHT_SIDEBAR_TOP_BAR_HEIGHT).min(
rect.y
.saturating_add(rect.height)
- .saturating_sub(top_bar_y + SIDEBAR_INSET),
+ .saturating_sub(top_bar_y + self.ui_px(SIDEBAR_INSET)),
);
if top_bar_height == 0 {
return Ok(());
}
if cfg!(target_os = "macos") {
- let close_button_size = RIGHT_SIDEBAR_CLOSE_BUTTON_SIZE
+ let close_button_size = self
+ .ui_px(RIGHT_SIDEBAR_CLOSE_BUTTON_SIZE)
.min(top_bar_height)
.min(content_width)
.max(1);
@@ -2917,17 +2959,17 @@ impl crate::TermWindow {
let close_button_right_limit = rect
.x
.saturating_add(rect.width)
- .saturating_sub(SIDEBAR_INSET)
+ .saturating_sub(self.ui_px(SIDEBAR_INSET))
.saturating_sub(close_button_size)
.saturating_sub(window_button_reserve);
let close_button_x = content_x
.saturating_add(content_width)
.saturating_sub(close_button_size)
- .saturating_add(RIGHT_SIDEBAR_CLOSE_BUTTON_X_ADJUST)
+ .saturating_add(self.ui_px(RIGHT_SIDEBAR_CLOSE_BUTTON_X_ADJUST))
.min(close_button_right_limit);
let close_button_y = (top_bar_y
+ (top_bar_height.saturating_sub(close_button_size)) / 2)
- .saturating_sub(RIGHT_SIDEBAR_CLOSE_BUTTON_Y_ADJUST);
+ .saturating_sub(self.ui_px(RIGHT_SIDEBAR_CLOSE_BUTTON_Y_ADJUST));
let close_hovered = self.is_pointer_over_ui_rect(
close_button_x,
close_button_y,
@@ -2972,7 +3014,8 @@ impl crate::TermWindow {
height: close_button_size,
item_type: UIItemType::RightSidebarToggle,
});
- let close_icon_size = RIGHT_SIDEBAR_CLOSE_ICON_SIZE
+ let close_icon_size = self
+ .ui_px(RIGHT_SIDEBAR_CLOSE_ICON_SIZE)
.min(close_visual_size.saturating_sub(4))
.max(1);
self.paint_sidebar_icon(
@@ -2989,11 +3032,11 @@ impl crate::TermWindow {
)?;
}
- let mode_y = top_bar_y + top_bar_height + RIGHT_SIDEBAR_SECTION_GAP;
- let mode_height = RIGHT_SIDEBAR_MODE_HEIGHT.min(
+ let mode_y = top_bar_y + top_bar_height + self.ui_px(RIGHT_SIDEBAR_SECTION_GAP);
+ let mode_height = self.ui_px(RIGHT_SIDEBAR_MODE_HEIGHT).min(
rect.y
.saturating_add(rect.height)
- .saturating_sub(mode_y + SIDEBAR_INSET),
+ .saturating_sub(mode_y + self.ui_px(SIDEBAR_INSET)),
);
if mode_height == 0 {
return Ok(());
@@ -3020,28 +3063,30 @@ impl crate::TermWindow {
RightSidebarMode::Snippets,
];
const MODE_LABEL_CLIP_SLOP: usize = 4;
- let mode_icon_size = (ui_cell_height + 12)
- .clamp(24, 30)
- .min(mode_height.saturating_sub(22))
+ let mode_icon_size = (ui_cell_height + self.ui_px(12))
+ .clamp(self.ui_px(24), self.ui_px(30))
+ .min(mode_height.saturating_sub(self.ui_px(22)))
.max(1);
let active_label_target_width = self
.sidebar_text_width(&ui_font, self.right_sidebar_mode.label())?
.ceil() as usize
+ MODE_LABEL_CLIP_SLOP;
- let inactive_segment_min_width = (mode_icon_size + SIDEBAR_INSET * 4)
- .max(70)
+ let inactive_segment_min_width = (mode_icon_size + self.ui_px(SIDEBAR_INSET) * 4)
+ .max(self.ui_px(70))
.min((content_width / modes.len()).max(1));
let inactive_segment_count = modes.len().saturating_sub(1);
let inactive_segments_min_width =
inactive_segment_min_width.saturating_mul(inactive_segment_count);
- let active_segment_width =
- (mode_icon_size + SIDEBAR_ICON_GAP + active_label_target_width + SIDEBAR_INSET * 6)
- .min(
- content_width
- .saturating_sub(inactive_segments_min_width)
- .max(1),
- )
- .max(1);
+ let active_segment_width = (mode_icon_size
+ + self.ui_px(SIDEBAR_ICON_GAP)
+ + active_label_target_width
+ + self.ui_px(SIDEBAR_INSET) * 6)
+ .min(
+ content_width
+ .saturating_sub(inactive_segments_min_width)
+ .max(1),
+ )
+ .max(1);
let inactive_segments_width = content_width.saturating_sub(active_segment_width);
let inactive_segment_width = if inactive_segment_count > 0 {
inactive_segments_width / inactive_segment_count
@@ -3118,13 +3163,17 @@ impl crate::TermWindow {
let label_width = if active {
segment_width
- .saturating_sub(mode_icon_size + SIDEBAR_ICON_GAP + SIDEBAR_INSET * 2)
+ .saturating_sub(
+ mode_icon_size
+ + self.ui_px(SIDEBAR_ICON_GAP)
+ + self.ui_px(SIDEBAR_INSET) * 2,
+ )
.min(active_label_target_width)
} else {
0
};
let total_width = if active {
- mode_icon_size + SIDEBAR_ICON_GAP + label_width
+ mode_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + label_width
} else {
mode_icon_size
};
@@ -3149,7 +3198,7 @@ impl crate::TermWindow {
&ui_font,
ui_metrics,
mode.label(),
- icon_x + mode_icon_size + SIDEBAR_ICON_GAP,
+ icon_x + mode_icon_size + self.ui_px(SIDEBAR_ICON_GAP),
mode_y + (mode_height.saturating_sub(ui_cell_height)) / 2,
label_width,
foreground,
@@ -3158,7 +3207,7 @@ impl crate::TermWindow {
segment_x = segment_right;
}
- let content_top = mode_y + mode_height + RIGHT_SIDEBAR_SECTION_GAP;
+ let content_top = mode_y + mode_height + self.ui_px(RIGHT_SIDEBAR_SECTION_GAP);
match self.right_sidebar_mode {
RightSidebarMode::Chat => {
let file_font_size = self.right_sidebar_file_preview_font_size();
@@ -3167,7 +3216,8 @@ impl crate::TermWindow {
.title_font_with_size(file_font_size)
.context("right sidebar file font")?;
let file_metrics = RenderMetrics::with_font_metrics(&file_font.metrics());
- let file_icon_size = (file_metrics.cell_size.height as usize + 6).clamp(22, 28);
+ let file_icon_size = (file_metrics.cell_size.height as usize + self.ui_px(6))
+ .clamp(self.ui_px(22), self.ui_px(28));
self.paint_files_sidebar(
layers,
&file_font,
@@ -3203,10 +3253,10 @@ impl crate::TermWindow {
}
let empty_top = content_top;
- let empty_height = RIGHT_SIDEBAR_EMPTY_HEIGHT.min(
+ let empty_height = self.ui_px(RIGHT_SIDEBAR_EMPTY_HEIGHT).min(
rect.y
.saturating_add(rect.height)
- .saturating_sub(empty_top + SIDEBAR_INSET),
+ .saturating_sub(empty_top + self.ui_px(SIDEBAR_INSET)),
);
if empty_height == 0 {
return Ok(());
@@ -3222,15 +3272,15 @@ impl crate::TermWindow {
),
chrome.sidebar_button_bg,
chrome.control_border,
- SIDEBAR_ROW_RADIUS + 6.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 6.0,
CAPSULE_BORDER_WIDTH,
)
.context("right sidebar empty state")?;
let empty_icon_size = icon_size
- .min(22)
+ .min(self.ui_px(22))
.min(empty_height.saturating_sub(20))
.max(1);
- let empty_icon_x = content_x + SIDEBAR_INSET + 2;
+ let empty_icon_x = content_x + self.ui_px(SIDEBAR_INSET) + 2;
let empty_icon_y = empty_top + (empty_height.saturating_sub(empty_icon_size)) / 2;
self.paint_sidebar_icon(
layers,
@@ -3245,9 +3295,11 @@ impl crate::TermWindow {
&ui_font,
ui_metrics,
self.right_sidebar_mode.empty_label(),
- empty_icon_x + empty_icon_size + SIDEBAR_ICON_GAP + 2,
+ empty_icon_x + empty_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + 2,
empty_top + (empty_height.saturating_sub(ui_cell_height)) / 2,
- content_width.saturating_sub(empty_icon_size + SIDEBAR_ICON_GAP + SIDEBAR_INSET * 3),
+ content_width.saturating_sub(
+ empty_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + self.ui_px(SIDEBAR_INSET) * 3,
+ ),
muted_fg,
)?;
@@ -3315,9 +3367,9 @@ impl crate::TermWindow {
)
.context("right sidebar file preview right separator")?;
- let content_x = rect.x + SIDEBAR_INSET * 2;
- let content_width = rect.width.saturating_sub(SIDEBAR_INSET * 4);
- let content_top = rect.y + SIDEBAR_INSET * 2;
+ let content_x = rect.x + self.ui_px(SIDEBAR_INSET) * 2;
+ let content_width = rect.width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 4);
+ let content_top = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
let content_bottom = rect.y.saturating_add(rect.height);
self.paint_files_preview(
layers,
@@ -3473,11 +3525,13 @@ impl crate::TermWindow {
) -> anyhow::Result<()> {
// Reserve room on the right for an icon-only Refresh button so it never
// eats into the filename/search width.
- let refresh_size = (ui_metrics.cell_size.height as usize + 12).clamp(28, 38);
- let refresh_gap = SIDEBAR_INSET;
+ let refresh_size = (ui_metrics.cell_size.height as usize + self.ui_px(12))
+ .clamp(self.ui_px(28), self.ui_px(38));
+ let refresh_gap = self.ui_px(SIDEBAR_INSET);
let filter_width = content_width.saturating_sub(refresh_size + refresh_gap);
let refresh_x = content_x + content_width - refresh_size;
- let refresh_y = content_top + FILE_FILTER_HEIGHT.saturating_sub(refresh_size) / 2;
+ let refresh_y =
+ content_top + self.ui_px(FILE_FILTER_HEIGHT).saturating_sub(refresh_size) / 2;
let filter_input = self.right_sidebar_file_filter.clone();
self.paint_snippet_text_box(
@@ -3490,7 +3544,7 @@ impl crate::TermWindow {
content_x,
content_top,
filter_width,
- FILE_FILTER_HEIGHT,
+ self.ui_px(FILE_FILTER_HEIGHT),
Some(SvgIcon::Search),
"Filter files",
&filter_input,
@@ -3510,7 +3564,7 @@ impl crate::TermWindow {
UIItemType::RightSidebarFileRefresh,
)?;
- let tree_top = content_top + FILE_FILTER_HEIGHT + FILE_TREE_TOP_GAP;
+ let tree_top = content_top + self.ui_px(FILE_FILTER_HEIGHT) + self.ui_px(FILE_TREE_TOP_GAP);
let root = match self.sync_right_sidebar_file_root_for_current_workspace() {
Ok(root) => root,
Err(message) => {
@@ -3631,7 +3685,7 @@ impl crate::TermWindow {
}
let row_metrics = right_sidebar_file_row_metrics(ui_metrics);
- let viewport_bottom = content_bottom.saturating_sub(SIDEBAR_INSET);
+ let viewport_bottom = content_bottom.saturating_sub(self.ui_px(SIDEBAR_INSET));
let visible_height = viewport_bottom.saturating_sub(tree_top);
let total_height = row_count.saturating_mul(row_metrics.row_height);
let max_scroll = total_height.saturating_sub(visible_height) as f32;
@@ -3689,9 +3743,10 @@ impl crate::TermWindow {
}
if max_scroll > 0.0 && scroll_offset > 0.0 {
- let fade_top = content_top + FILE_FILTER_HEIGHT;
- let fade_height = FILE_TREE_TOP_GAP
- .saturating_add(FILE_SCROLL_FADE_HEIGHT)
+ let fade_top = content_top + self.ui_px(FILE_FILTER_HEIGHT);
+ let fade_height = self
+ .ui_px(FILE_TREE_TOP_GAP)
+ .saturating_add(self.ui_px(FILE_SCROLL_FADE_HEIGHT))
.min(viewport_bottom.saturating_sub(fade_top));
self.paint_right_sidebar_file_mask(
layers,
@@ -3711,7 +3766,7 @@ impl crate::TermWindow {
content_x,
content_top,
content_width,
- FILE_FILTER_HEIGHT,
+ self.ui_px(FILE_FILTER_HEIGHT),
Some(SvgIcon::Search),
"Filter files",
&filter_input,
@@ -3747,8 +3802,9 @@ impl crate::TermWindow {
icon_size: usize,
message: &str,
) -> anyhow::Result<()> {
- let height =
- RIGHT_SIDEBAR_EMPTY_HEIGHT.min(content_bottom.saturating_sub(y + SIDEBAR_INSET));
+ let height = self
+ .ui_px(RIGHT_SIDEBAR_EMPTY_HEIGHT)
+ .min(content_bottom.saturating_sub(y + self.ui_px(SIDEBAR_INSET)));
if height == 0 {
return Ok(());
}
@@ -3758,12 +3814,15 @@ impl crate::TermWindow {
euclid::rect(x as f32, y as f32, width as f32, height as f32),
chrome.sidebar_button_bg,
chrome.control_border,
- SIDEBAR_ROW_RADIUS + 6.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 6.0,
CAPSULE_BORDER_WIDTH,
)
.context("right sidebar files message")?;
- let empty_icon_size = icon_size.min(22).min(height.saturating_sub(20)).max(1);
- let icon_x = x + SIDEBAR_INSET + 2;
+ let empty_icon_size = icon_size
+ .min(self.ui_px(22))
+ .min(height.saturating_sub(20))
+ .max(1);
+ let icon_x = x + self.ui_px(SIDEBAR_INSET) + 2;
let icon_y = y + (height.saturating_sub(empty_icon_size)) / 2;
self.paint_sidebar_icon(
layers,
@@ -3778,9 +3837,11 @@ impl crate::TermWindow {
ui_font,
ui_metrics,
message,
- icon_x + empty_icon_size + SIDEBAR_ICON_GAP + 2,
+ icon_x + empty_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + 2,
y + (height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2,
- width.saturating_sub(empty_icon_size + SIDEBAR_ICON_GAP + SIDEBAR_INSET * 3),
+ width.saturating_sub(
+ empty_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + self.ui_px(SIDEBAR_INSET) * 3,
+ ),
muted_fg,
)
}
@@ -3878,7 +3939,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_hover_bg
},
- SIDEBAR_ROW_RADIUS,
+ self.ui_f32(SIDEBAR_ROW_RADIUS),
)
.context("right sidebar file row hover")?;
}
@@ -3896,7 +3957,7 @@ impl crate::TermWindow {
.depth
.saturating_mul(row_metrics.indent_step)
.min(width.saturating_sub(24));
- let chevron_x = x + SIDEBAR_INSET + indent;
+ let chevron_x = x + self.ui_px(SIDEBAR_INSET) + indent;
let icon_y = y + (row_metrics.row_height.saturating_sub(row_icon_size)) / 2;
let chevron_y = y + (row_metrics.row_height.saturating_sub(chevron_size)) / 2;
if row.is_dir {
@@ -3943,7 +4004,7 @@ impl crate::TermWindow {
.saturating_sub(ui_metrics.cell_size.height as usize))
/ 2,
x.saturating_add(width)
- .saturating_sub(text_x + SIDEBAR_INSET),
+ .saturating_sub(text_x + self.ui_px(SIDEBAR_INSET)),
if row.is_dir || is_selected {
foreground
} else {
@@ -3981,7 +4042,8 @@ impl crate::TermWindow {
)?;
let action_gap = 6;
- let available_after_back = content_width.saturating_sub(button_size + SIDEBAR_INSET);
+ let available_after_back =
+ content_width.saturating_sub(button_size + self.ui_px(SIDEBAR_INSET));
// The label is always shown in full. Size the button to fit it, limited
// only by the room left after the two icon buttons, the gaps and a small
// reserved minimum for the filename — no fixed cap, so a wide pane is
@@ -3999,7 +4061,7 @@ impl crate::TermWindow {
let max_open_width =
available_after_back.saturating_sub((button_size * 2) + action_gap * 3 + 72);
let open_button_width = if max_open_width >= 80 {
- desired_open_width.min(max_open_width).max(80)
+ desired_open_width.min(max_open_width).max(self.ui_px(80))
} else {
button_size
};
@@ -4042,8 +4104,8 @@ impl crate::TermWindow {
action_x += button_size + action_gap;
}
- let title_x = content_x + button_size + SIDEBAR_INSET;
- let title_right = actions_x.saturating_sub(SIDEBAR_INSET);
+ let title_x = content_x + button_size + self.ui_px(SIDEBAR_INSET);
+ let title_right = actions_x.saturating_sub(self.ui_px(SIDEBAR_INSET));
let title_width = title_right.saturating_sub(title_x);
let title = file_name_for_path(path);
self.paint_sidebar_text(
@@ -4123,7 +4185,7 @@ impl crate::TermWindow {
}
if arrow_width > 0 {
- let chevron_size = (height * 40 / 100).clamp(14, 18);
+ let chevron_size = (height * 40 / 100).clamp(self.ui_px(14), self.ui_px(18));
self.paint_sidebar_icon(
layers,
SvgIcon::ChevronDown,
@@ -4168,7 +4230,7 @@ impl crate::TermWindow {
height: size,
item_type,
});
- let icon_size = (size * 58 / 100).max(16);
+ let icon_size = (size * 58 / 100).max(self.ui_px(16));
self.paint_sidebar_icon(
layers,
icon,
@@ -4372,7 +4434,8 @@ impl crate::TermWindow {
metrics.x,
metrics.y,
metrics.width,
- FILE_SCROLL_FADE_HEIGHT.min(body_bottom.saturating_sub(metrics.y)),
+ self.ui_px(FILE_SCROLL_FADE_HEIGHT)
+ .min(body_bottom.saturating_sub(metrics.y)),
)?;
}
self.paint_files_preview_header(
@@ -4669,7 +4732,7 @@ impl crate::TermWindow {
)
.context("right sidebar file preview scroll thumb")?;
- let hit_slop = FILE_PREVIEW_SCROLLBAR_HIT_SLOP;
+ let hit_slop = self.ui_px(FILE_PREVIEW_SCROLLBAR_HIT_SLOP);
self.ui_items.push(UIItem {
x: scroll.track_x.saturating_sub(hit_slop),
y: scroll.track_y,
@@ -4730,18 +4793,18 @@ impl crate::TermWindow {
x: scroll.track_x,
y: scroll
.track_y
- .saturating_sub(FILE_PREVIEW_SCROLLBAR_HIT_SLOP),
+ .saturating_sub(self.ui_px(FILE_PREVIEW_SCROLLBAR_HIT_SLOP)),
width: scroll.track_width,
- height: scroll.track_height + FILE_PREVIEW_SCROLLBAR_HIT_SLOP * 2,
+ height: scroll.track_height + self.ui_px(FILE_PREVIEW_SCROLLBAR_HIT_SLOP) * 2,
item_type: UIItemType::RightSidebarFilePreviewHorizontalScrollTrack,
});
self.ui_items.push(UIItem {
x: scroll.thumb_x.round().max(0.0) as usize,
y: scroll
.track_y
- .saturating_sub(FILE_PREVIEW_SCROLLBAR_HIT_SLOP),
+ .saturating_sub(self.ui_px(FILE_PREVIEW_SCROLLBAR_HIT_SLOP)),
width: scroll.thumb_width.round().max(1.0) as usize,
- height: scroll.track_height + FILE_PREVIEW_SCROLLBAR_HIT_SLOP * 2,
+ height: scroll.track_height + self.ui_px(FILE_PREVIEW_SCROLLBAR_HIT_SLOP) * 2,
item_type: UIItemType::RightSidebarFilePreviewHorizontalScrollThumb,
});
@@ -4925,20 +4988,23 @@ impl crate::TermWindow {
icon_size: usize,
) -> anyhow::Result<()> {
let toolbar_y = content_top;
- let new_button_icon_size = (ui_metrics.cell_size.height as usize + 2).clamp(18, 22);
+ let new_button_icon_size = (ui_metrics.cell_size.height as usize + self.ui_px(2))
+ .clamp(self.ui_px(18), self.ui_px(22));
let new_button_label_width =
self.sidebar_text_width(ui_font, "New Snippet")?.ceil() as usize;
- let toolbar_gap = SNIPPET_ROW_GAP;
+ let toolbar_gap = self.ui_px(SNIPPET_ROW_GAP);
let search_is_active = self.right_sidebar_snippet_focus
== Some(RightSidebarSnippetField::Search)
|| !self.right_sidebar_snippet_search.text.is_empty();
- let full_new_button_width =
- new_button_icon_size + SIDEBAR_ICON_GAP + new_button_label_width + SIDEBAR_INSET * 4;
+ let full_new_button_width = new_button_icon_size
+ + self.ui_px(SIDEBAR_ICON_GAP)
+ + new_button_label_width
+ + self.ui_px(SIDEBAR_INSET) * 4;
let min_search_width = 160.min(content_width);
let collapse_new_button = search_is_active
|| content_width < full_new_button_width + toolbar_gap + min_search_width;
let new_button_width = if collapse_new_button {
- SNIPPET_TOOLBAR_HEIGHT.min(content_width)
+ self.ui_px(SNIPPET_TOOLBAR_HEIGHT).min(content_width)
} else {
full_new_button_width.min(content_width)
};
@@ -4957,7 +5023,7 @@ impl crate::TermWindow {
content_x,
toolbar_y,
new_button_width,
- SNIPPET_TOOLBAR_HEIGHT,
+ self.ui_px(SNIPPET_TOOLBAR_HEIGHT),
Some(SvgIcon::CodeXml),
new_button_label,
UIItemType::RightSidebarSnippetNew,
@@ -4981,7 +5047,7 @@ impl crate::TermWindow {
search_x,
search_y,
search_width,
- SNIPPET_SEARCH_HEIGHT,
+ self.ui_px(SNIPPET_SEARCH_HEIGHT),
Some(SvgIcon::Search),
"Search",
&search_input,
@@ -4991,8 +5057,11 @@ impl crate::TermWindow {
)?;
}
- let list_top =
- toolbar_y + SNIPPET_TOOLBAR_HEIGHT.max(SNIPPET_SEARCH_HEIGHT) + SNIPPET_LIST_TOP_GAP;
+ let list_top = toolbar_y
+ + self
+ .ui_px(SNIPPET_TOOLBAR_HEIGHT)
+ .max(self.ui_px(SNIPPET_SEARCH_HEIGHT))
+ + self.ui_px(SNIPPET_LIST_TOP_GAP);
let needle = self
.right_sidebar_snippet_search
.text
@@ -5006,10 +5075,9 @@ impl crate::TermWindow {
|| snippet.body.to_ascii_lowercase().contains(&needle)
})
.collect();
- let row_height = SNIPPET_CARD_HEIGHT + SNIPPET_ROW_GAP;
- let visible_height = content_bottom.saturating_sub(list_top + SIDEBAR_INSET);
- let total_height =
- Self::right_sidebar_snippet_scroll_height(snippets.len(), visible_height);
+ let row_height = self.ui_px(SNIPPET_CARD_HEIGHT) + self.ui_px(SNIPPET_ROW_GAP);
+ let visible_height = content_bottom.saturating_sub(list_top + self.ui_px(SIDEBAR_INSET));
+ let total_height = self.right_sidebar_snippet_scroll_height(snippets.len(), visible_height);
let max_scroll = total_height.saturating_sub(visible_height) as f32;
self.right_sidebar_snippet_scroll_offset = self
.right_sidebar_snippet_scroll_offset
@@ -5017,8 +5085,9 @@ impl crate::TermWindow {
let scroll_offset = self.right_sidebar_snippet_scroll_offset;
if snippets.is_empty() {
- let empty_height = RIGHT_SIDEBAR_EMPTY_HEIGHT
- .min(content_bottom.saturating_sub(list_top + SIDEBAR_INSET));
+ let empty_height = self
+ .ui_px(RIGHT_SIDEBAR_EMPTY_HEIGHT)
+ .min(content_bottom.saturating_sub(list_top + self.ui_px(SIDEBAR_INSET)));
if empty_height == 0 {
return Ok(());
}
@@ -5033,15 +5102,15 @@ impl crate::TermWindow {
),
chrome.sidebar_button_bg,
chrome.control_border,
- SIDEBAR_ROW_RADIUS + 6.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 6.0,
CAPSULE_BORDER_WIDTH,
)
.context("right sidebar snippets empty state")?;
let empty_icon_size = icon_size
- .min(22)
+ .min(self.ui_px(22))
.min(empty_height.saturating_sub(20))
.max(1);
- let empty_icon_x = content_x + SIDEBAR_INSET + 2;
+ let empty_icon_x = content_x + self.ui_px(SIDEBAR_INSET) + 2;
let empty_icon_y = list_top + (empty_height.saturating_sub(empty_icon_size)) / 2;
self.paint_sidebar_icon(
layers,
@@ -5060,21 +5129,22 @@ impl crate::TermWindow {
} else {
"No matching snippets"
},
- empty_icon_x + empty_icon_size + SIDEBAR_ICON_GAP + 2,
+ empty_icon_x + empty_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + 2,
list_top + (empty_height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2,
- content_width
- .saturating_sub(empty_icon_size + SIDEBAR_ICON_GAP + SIDEBAR_INSET * 3),
+ content_width.saturating_sub(
+ empty_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + self.ui_px(SIDEBAR_INSET) * 3,
+ ),
muted_fg,
)?;
return Ok(());
}
let list_top_f = list_top as f32;
- let content_bottom = content_bottom.saturating_sub(SIDEBAR_INSET);
+ let content_bottom = content_bottom.saturating_sub(self.ui_px(SIDEBAR_INSET));
let content_bottom_f = content_bottom as f32;
for (idx, snippet) in snippets.into_iter().enumerate() {
let row_top = list_top_f + (idx * row_height) as f32 - scroll_offset;
- let row_bottom = row_top + SNIPPET_CARD_HEIGHT as f32;
+ let row_bottom = row_top + self.ui_px(SNIPPET_CARD_HEIGHT) as f32;
if row_bottom <= list_top_f {
continue;
}
@@ -5196,13 +5266,13 @@ impl crate::TermWindow {
UIItemType::RightSidebarSnippetBack,
)?;
- let title_x = content_x + back_size + SIDEBAR_INSET;
+ let title_x = content_x + back_size + self.ui_px(SIDEBAR_INSET);
let save_label_width = self.sidebar_text_width(ui_font, "Save")?.ceil() as usize;
- let save_width = (save_label_width + SIDEBAR_INSET * 6)
- .clamp(110, 136)
- .min(content_width.saturating_sub(back_size + SIDEBAR_INSET * 2));
+ let save_width = (save_label_width + self.ui_px(SIDEBAR_INSET) * 6)
+ .clamp(self.ui_px(110), self.ui_px(136))
+ .min(content_width.saturating_sub(back_size + self.ui_px(SIDEBAR_INSET) * 2));
let save_x = content_x + content_width.saturating_sub(save_width);
- let title_width = save_x.saturating_sub(title_x + SIDEBAR_INSET * 2);
+ let title_width = save_x.saturating_sub(title_x + self.ui_px(SIDEBAR_INSET) * 2);
let title_label = match self.right_sidebar_snippet_view {
RightSidebarSnippetView::EditNew => "New Snippet",
RightSidebarSnippetView::EditExisting(_) => "Edit Snippet",
@@ -5239,7 +5309,8 @@ impl crate::TermWindow {
save_x,
header_top,
save_width,
- SNIPPET_SAVE_BUTTON_HEIGHT.min(SNIPPET_EDITOR_HEADER_HEIGHT - 12),
+ self.ui_px(SNIPPET_SAVE_BUTTON_HEIGHT)
+ .min(self.ui_px(SNIPPET_EDITOR_HEADER_HEIGHT) - 12),
None,
"Save",
UIItemType::RightSidebarSnippetSave,
@@ -5247,7 +5318,7 @@ impl crate::TermWindow {
)?;
let field_label_height = ui_metrics.cell_size.height as usize;
- let title_label_y = header_y + SNIPPET_EDITOR_HEADER_HEIGHT;
+ let title_label_y = header_y + self.ui_px(SNIPPET_EDITOR_HEADER_HEIGHT);
self.paint_sidebar_text(
layers,
ui_font,
@@ -5270,7 +5341,7 @@ impl crate::TermWindow {
content_x,
title_y,
content_width,
- SNIPPET_FIELD_HEIGHT,
+ self.ui_px(SNIPPET_FIELD_HEIGHT),
None,
"Describe this action",
&title_input,
@@ -5279,7 +5350,8 @@ impl crate::TermWindow {
false,
)?;
- let body_label_y = title_y + SNIPPET_FIELD_HEIGHT + RIGHT_SIDEBAR_SECTION_GAP + 4;
+ let body_label_y =
+ title_y + self.ui_px(SNIPPET_FIELD_HEIGHT) + self.ui_px(RIGHT_SIDEBAR_SECTION_GAP) + 4;
self.paint_sidebar_text(
layers,
ui_font,
@@ -5291,7 +5363,9 @@ impl crate::TermWindow {
muted_fg,
)?;
let body_y = body_label_y + field_label_height + 8;
- let body_height = SNIPPET_BODY_FIELD_HEIGHT.min(content_bottom.saturating_sub(body_y));
+ let body_height = self
+ .ui_px(SNIPPET_BODY_FIELD_HEIGHT)
+ .min(content_bottom.saturating_sub(body_y));
let body_input = self.right_sidebar_snippet_body.clone();
self.paint_snippet_text_box(
layers,
@@ -5333,7 +5407,7 @@ impl crate::TermWindow {
clip_top: usize,
clip_bottom: usize,
) -> anyhow::Result<()> {
- let card_bottom = y.saturating_add(SNIPPET_CARD_HEIGHT);
+ let card_bottom = y.saturating_add(self.ui_px(SNIPPET_CARD_HEIGHT));
let visible_y = y.max(clip_top);
let visible_bottom = card_bottom.min(clip_bottom);
let visible_height = visible_bottom.saturating_sub(visible_y);
@@ -5361,7 +5435,7 @@ impl crate::TermWindow {
} else {
chrome.control_border.mul_alpha(0.72)
},
- SIDEBAR_ROW_RADIUS + 10.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 10.0,
CAPSULE_BORDER_WIDTH,
)
.context("right sidebar snippet card")?;
@@ -5373,21 +5447,24 @@ impl crate::TermWindow {
item_type: UIItemType::RightSidebarSnippetEdit(snippet.id.clone()),
});
- let card_pad = SIDEBAR_INSET * 2;
+ let card_pad = self.ui_px(SIDEBAR_INSET) * 2;
let text_x = x + card_pad;
let run_button_width = (self.sidebar_text_width(ui_font, "Run")?.ceil() as usize
- + SIDEBAR_INSET * 4)
- .max(SNIPPET_ACTION_BUTTON_MIN_WIDTH);
+ + self.ui_px(SIDEBAR_INSET) * 4)
+ .max(self.ui_px(SNIPPET_ACTION_BUTTON_MIN_WIDTH));
let paste_button_width = (self.sidebar_text_width(ui_font, "Paste")?.ceil() as usize
- + SIDEBAR_INSET * 4)
- .max(SNIPPET_ACTION_BUTTON_MIN_WIDTH);
- let delete_button_size = SNIPPET_ACTION_BUTTON_HEIGHT;
+ + self.ui_px(SIDEBAR_INSET) * 4)
+ .max(self.ui_px(SNIPPET_ACTION_BUTTON_MIN_WIDTH));
+ let delete_button_size = self.ui_px(SNIPPET_ACTION_BUTTON_HEIGHT);
let action_area_width = if hovered {
- run_button_width + paste_button_width + delete_button_size + SIDEBAR_INSET * 2
+ run_button_width
+ + paste_button_width
+ + delete_button_size
+ + self.ui_px(SIDEBAR_INSET) * 2
} else {
0
};
- let title_y = y + SIDEBAR_INSET * 2;
+ let title_y = y + self.ui_px(SIDEBAR_INSET) * 2;
if title_y >= clip_top && title_y < clip_bottom {
self.paint_sidebar_text(
layers,
@@ -5401,7 +5478,8 @@ impl crate::TermWindow {
)?;
}
let preview = snippet_preview(&snippet.body);
- let preview_y = y + SIDEBAR_INSET * 2 + ui_metrics.cell_size.height as usize + 8;
+ let preview_y =
+ y + self.ui_px(SIDEBAR_INSET) * 2 + ui_metrics.cell_size.height as usize + 8;
if preview_y >= clip_top && preview_y < clip_bottom {
self.paint_sidebar_text(
layers,
@@ -5418,9 +5496,9 @@ impl crate::TermWindow {
let fully_visible = y >= clip_top && card_bottom <= clip_bottom;
if hovered && fully_visible {
let delete_x = x + width.saturating_sub(card_pad + delete_button_size);
- let paste_x = delete_x.saturating_sub(SIDEBAR_INSET + paste_button_width);
- let run_x = paste_x.saturating_sub(SIDEBAR_INSET + run_button_width);
- let action_y = y + SIDEBAR_INSET * 2 - 4;
+ let paste_x = delete_x.saturating_sub(self.ui_px(SIDEBAR_INSET) + paste_button_width);
+ let run_x = paste_x.saturating_sub(self.ui_px(SIDEBAR_INSET) + run_button_width);
+ let action_y = y + self.ui_px(SIDEBAR_INSET) * 2 - 4;
self.paint_snippet_button(
layers,
ui_font,
@@ -5431,7 +5509,7 @@ impl crate::TermWindow {
run_x,
action_y,
run_button_width,
- SNIPPET_ACTION_BUTTON_HEIGHT,
+ self.ui_px(SNIPPET_ACTION_BUTTON_HEIGHT),
None,
"Run",
UIItemType::RightSidebarSnippetRun(snippet.id.clone()),
@@ -5447,7 +5525,7 @@ impl crate::TermWindow {
paste_x,
action_y,
paste_button_width,
- SNIPPET_ACTION_BUTTON_HEIGHT,
+ self.ui_px(SNIPPET_ACTION_BUTTON_HEIGHT),
None,
"Paste",
UIItemType::RightSidebarSnippetPaste(snippet.id.clone()),
@@ -5512,7 +5590,7 @@ impl crate::TermWindow {
if is_search_field {
WINDOW_TAB_ADD_BUTTON_RADIUS
} else {
- SIDEBAR_ROW_RADIUS + 4.0
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0
},
CAPSULE_BORDER_WIDTH,
)
@@ -5525,10 +5603,11 @@ impl crate::TermWindow {
item_type: item_type.clone(),
});
- let text_pad = SIDEBAR_INSET + 2;
+ let text_pad = self.ui_px(SIDEBAR_INSET) + 2;
let mut text_x = x + text_pad;
if let Some(icon) = icon {
- let icon_size = (ui_metrics.cell_size.height as usize + 2).clamp(18, 22);
+ let icon_size = (ui_metrics.cell_size.height as usize + self.ui_px(2))
+ .clamp(self.ui_px(18), self.ui_px(22));
self.paint_sidebar_icon(
layers,
icon,
@@ -5537,7 +5616,7 @@ impl crate::TermWindow {
icon_size,
muted_fg,
)?;
- text_x += icon_size + SIDEBAR_ICON_GAP;
+ text_x += icon_size + self.ui_px(SIDEBAR_ICON_GAP);
}
let text_color = if input.text.is_empty() && !focused {
@@ -5552,8 +5631,9 @@ impl crate::TermWindow {
};
if multiline {
let line_height = ui_metrics.cell_size.height as usize + 4;
- let max_lines = height.saturating_sub(SIDEBAR_INSET * 2).max(1) / line_height.max(1);
- let mut line_y = y + SIDEBAR_INSET + 2;
+ let max_lines =
+ height.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2).max(1) / line_height.max(1);
+ let mut line_y = y + self.ui_px(SIDEBAR_INSET) + 2;
let text_width = width.saturating_sub((text_x - x) + text_pad);
let visible_lines = wrap_snippet_text_for_width(text, max_lines.max(1), focused, |s| {
self.sidebar_text_width(ui_font, s).unwrap_or(f32::MAX) / text_width.max(1) as f32
@@ -5585,7 +5665,7 @@ impl crate::TermWindow {
euclid::rect(
caret_x as f32,
last_line_y as f32,
- SNIPPET_CARET_WIDTH,
+ self.ui_f32(SNIPPET_CARET_WIDTH),
(ui_metrics.cell_size.height as f32).max(1.0),
),
chrome.text,
@@ -5611,7 +5691,7 @@ impl crate::TermWindow {
let chars: Vec<char> = input.text.chars().collect();
let cursor = input.cursor.min(chars.len());
let avail = text_area_width as f32;
- let caret_margin = SNIPPET_CARET_WIDTH + 2.0;
+ let caret_margin = self.ui_f32(SNIPPET_CARET_WIDTH) + 2.0;
// Horizontal scroll: push the first visible char forward until
// the caret is back inside the field.
@@ -5680,7 +5760,7 @@ impl crate::TermWindow {
euclid::rect(
text_x as f32 + caret_offset,
baseline_y as f32,
- SNIPPET_CARET_WIDTH,
+ self.ui_f32(SNIPPET_CARET_WIDTH),
(ui_metrics.cell_size.height as f32).max(1.0),
),
chrome.text,
@@ -5756,14 +5836,17 @@ impl crate::TermWindow {
}
let icon_size = icon
- .map(|_| (ui_metrics.cell_size.height as usize + 2).clamp(18, 22))
+ .map(|_| {
+ (ui_metrics.cell_size.height as usize + self.ui_px(2))
+ .clamp(self.ui_px(18), self.ui_px(22))
+ })
.unwrap_or(0);
- let horizontal_pad = SIDEBAR_INSET * 2;
+ let horizontal_pad = self.ui_px(SIDEBAR_INSET) * 2;
let available_label_width = width.saturating_sub(horizontal_pad * 2 + icon_size);
let text_width =
(self.sidebar_text_width(ui_font, label)?.ceil() as usize).min(available_label_width);
let icon_label_gap = if icon.is_some() && text_width > 0 {
- SIDEBAR_ICON_GAP
+ self.ui_px(SIDEBAR_ICON_GAP)
} else {
0
};
@@ -5790,7 +5873,7 @@ impl crate::TermWindow {
label,
text_x,
y + (height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2,
- width.saturating_sub(text_x.saturating_sub(x) + SIDEBAR_INSET),
+ width.saturating_sub(text_x.saturating_sub(x) + self.ui_px(SIDEBAR_INSET)),
color,
)
}
@@ -5825,7 +5908,7 @@ impl crate::TermWindow {
height: size,
item_type,
});
- let icon_size = (size * 58 / 100).max(16);
+ let icon_size = (size * 58 / 100).max(self.ui_px(16));
self.paint_sidebar_icon(
layers,
icon,
@@ -6014,10 +6097,11 @@ fn file_preview_line_number_width(
number_digits: usize,
cell_width: usize,
body_width: usize,
+ icon_gap: usize,
) -> usize {
number_digits
.saturating_mul(cell_width.max(1))
- .saturating_add(SIDEBAR_ICON_GAP * 2)
+ .saturating_add(icon_gap * 2)
.max(36)
.min(body_width / 2)
}
@@ -6125,14 +6209,17 @@ fn preview_visible_line_range(
}
fn right_sidebar_file_row_metrics(ui_metrics: RenderMetrics) -> RightSidebarFileRowMetrics {
- let cell_height = ui_metrics.cell_size.height as usize;
- let row_height = cell_height.saturating_add(18).clamp(38, 58);
- let icon_size = cell_height
- .saturating_add(8)
- .clamp(22, row_height.saturating_sub(8));
- let chevron_size = (icon_size * 72 / 100).clamp(14, 24);
- let indent_step = (icon_size * 58 / 100).clamp(14, 22);
- let icon_gap = (icon_size / 3).clamp(8, 14);
+ // Font metrics already follow the window DPI. Derive the row chrome from
+ // those metrics so the file tree keeps the same logical size across
+ // displays instead of being pinned by physical-pixel clamps.
+ let cell_height = (ui_metrics.cell_size.height as usize).max(1);
+ let row_height = (cell_height * 17 / 10).max(cell_height);
+ let icon_size = (cell_height * 13 / 10)
+ .min(row_height.saturating_sub(1))
+ .max(1);
+ let chevron_size = (icon_size * 72 / 100).max(1);
+ let indent_step = (icon_size * 58 / 100).max(1);
+ let icon_gap = (icon_size / 3).max(1);
RightSidebarFileRowMetrics {
row_height,
icon_size,
@@ -7056,13 +7143,13 @@ fn snippet_cursor_visible(now_ms: u128, blink_ms: u64) -> bool {
#[cfg(test)]
mod tests {
use super::{
- build_right_sidebar_file_index, full_line_colors_by_byte, image_pixels_within_preview_budget,
- load_file_preview, load_file_preview_image, naturalish_cmp, path_key, preview_line_count,
- preview_lines_from_text, preview_plain_lines_from_text,
- preview_text_range, preview_visible_colored, preview_visible_line_range,
+ build_right_sidebar_file_index, full_line_colors_by_byte,
+ image_pixels_within_preview_budget, load_file_preview, load_file_preview_image,
+ naturalish_cmp, open_with_candidate_allowed, path_key, preview_line_count,
+ preview_lines_from_text, preview_plain_lines_from_text, preview_text_range,
+ preview_visible_colored, preview_visible_line_range,
right_sidebar_file_browse_rows_from_index, right_sidebar_file_row_metrics,
- open_with_candidate_allowed, right_sidebar_open_with_cache_key,
- search_right_sidebar_file_index, snippet_cursor_visible,
+ right_sidebar_open_with_cache_key, search_right_sidebar_file_index, snippet_cursor_visible,
snippet_run_buffer, sorted_open_with_candidates, visible_file_row_range,
wrap_snippet_text_for_width, FILE_PREVIEW_HIGHLIGHT_CHAR_LIMIT, FILE_PREVIEW_MAX_BYTES,
};
@@ -7327,15 +7414,17 @@ mod tests {
let normal = right_sidebar_file_row_metrics(test_render_metrics(26, 13));
let large = right_sidebar_file_row_metrics(test_render_metrics(48, 24));
- assert_eq!(small.row_height, 38);
- assert_eq!(small.icon_size, 26);
+ assert_eq!(small.row_height, 30);
+ assert_eq!(small.icon_size, 23);
assert!(normal.row_height > small.row_height);
assert!(normal.icon_size > small.icon_size);
assert!(normal.indent_step >= small.indent_step);
assert!(normal.icon_gap >= small.icon_gap);
- assert_eq!(large.row_height, 58);
- assert_eq!(large.icon_size, 50);
- assert!(large.chevron_size <= 24);
+ assert_eq!(large.row_height, 81);
+ assert_eq!(large.icon_size, 62);
+ assert!(large.row_height > normal.row_height);
+ assert!(large.icon_size > normal.icon_size);
+ assert!(large.chevron_size > normal.chevron_size);
}
#[test]
@@ -7344,7 +7433,7 @@ mod tests {
assert!(image_pixels_within_preview_budget(1920, 1080)); // 2 MP
assert!(image_pixels_within_preview_budget(4096, 2160)); // ~8.8 MP (4K)
assert!(image_pixels_within_preview_budget(4000, 4000)); // 16 MP (== budget)
- // Bombs are rejected, and the u64 product cannot overflow.
+ // Bombs are rejected, and the u64 product cannot overflow.
assert!(!image_pixels_within_preview_budget(8000, 8000)); // 64 MP
assert!(!image_pixels_within_preview_budget(100_000, 100_000));
assert!(!image_pixels_within_preview_budget(u32::MAX, u32::MAX));
@@ -7411,7 +7500,11 @@ mod tests {
cand("/Applications/calibre.app", "calibre", false),
cand("/Applications/Cursor.app", "Cursor", false),
cand("/Applications/Zed.app", "Zed", false),
- cand("/Applications/Visual Studio Code.app", "Visual Studio Code", false),
+ cand(
+ "/Applications/Visual Studio Code.app",
+ "Visual Studio Code",
+ false,
+ ),
cand(
"/Applications/calibre.app/Contents/ebook-viewer.app",
"ebook-viewer",
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index 6a9d37d7..4f0cbed4 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -13,7 +13,7 @@ use crate::termwindow::ui::tokens::{
WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET,
};
use crate::termwindow::{UIItem, UIItemType};
-use crate::ui::UiPalette;
+use crate::ui::{scale_ui_f32, scale_ui_usize, unscale_ui_usize, UiPalette};
use crate::utilsprites::RenderMetrics;
use crate::workspace_threads;
use anyhow::Context;
@@ -107,12 +107,15 @@ struct WorkspaceSidebarLayout {
list_top: usize,
}
-pub fn workspace_sidebar_width_for_metrics(render_metrics: &RenderMetrics) -> usize {
+pub fn workspace_sidebar_width_for_metrics(render_metrics: &RenderMetrics, dpi: usize) -> usize {
+ let min_width = scale_ui_usize(SIDEBAR_MIN_WIDTH, dpi);
+ let max_width = scale_ui_usize(SIDEBAR_MAX_WIDTH, dpi);
let default_width =
- (render_metrics.cell_size.width as usize * SIDEBAR_WIDTH_CELLS).max(SIDEBAR_MIN_WIDTH);
+ (render_metrics.cell_size.width as usize * SIDEBAR_WIDTH_CELLS).max(min_width);
crate::native_settings::workspace_sidebar_width()
+ .map(|width| scale_ui_usize(width, dpi))
.unwrap_or(default_width)
- .clamp(SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH)
+ .clamp(min_width, max_width)
}
fn centered_inner_start(origin: usize, outer: usize, inner: usize) -> usize {
@@ -144,24 +147,28 @@ impl crate::TermWindow {
if self.workspace_sidebar_collapsed {
0
} else {
+ let min_width = scale_ui_usize(SIDEBAR_MIN_WIDTH, self.dimensions.dpi);
self.workspace_sidebar_width
- .clamp(SIDEBAR_MIN_WIDTH, self.workspace_sidebar_max_width())
+ .clamp(min_width, self.workspace_sidebar_max_width())
}
}
pub fn workspace_sidebar_max_width(&self) -> usize {
- SIDEBAR_MAX_WIDTH.min((self.dimensions.pixel_width / 2).max(SIDEBAR_MIN_WIDTH))
+ let min_width = scale_ui_usize(SIDEBAR_MIN_WIDTH, self.dimensions.dpi);
+ scale_ui_usize(SIDEBAR_MAX_WIDTH, self.dimensions.dpi)
+ .min((self.dimensions.pixel_width / 2).max(min_width))
}
pub fn set_workspace_sidebar_width(&mut self, width: usize) {
- self.workspace_sidebar_width =
- width.clamp(SIDEBAR_MIN_WIDTH, self.workspace_sidebar_max_width());
+ let min_width = scale_ui_usize(SIDEBAR_MIN_WIDTH, self.dimensions.dpi);
+ self.workspace_sidebar_width = width.clamp(min_width, self.workspace_sidebar_max_width());
}
pub fn persist_workspace_sidebar_width(&self) {
- let width = self
- .workspace_sidebar_width
- .clamp(SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH);
+ let min_width = scale_ui_usize(SIDEBAR_MIN_WIDTH, self.dimensions.dpi);
+ let max_width = scale_ui_usize(SIDEBAR_MAX_WIDTH, self.dimensions.dpi);
+ let width = self.workspace_sidebar_width.clamp(min_width, max_width);
+ let width = unscale_ui_usize(width, self.dimensions.dpi);
if let Err(err) = crate::native_settings::save_workspace_sidebar_width(width) {
log::warn!("failed to save workspace sidebar width: {err:#}");
}
@@ -388,6 +395,14 @@ impl crate::TermWindow {
}
}
+ pub(crate) fn ui_px(&self, value: usize) -> usize {
+ scale_ui_usize(value, self.dimensions.dpi)
+ }
+
+ pub(crate) fn ui_f32(&self, value: f32) -> f32 {
+ scale_ui_f32(value, self.dimensions.dpi)
+ }
+
fn paint_sidebar_thread_status(
&self,
layers: &mut TripleLayerQuadAllocator,
@@ -398,25 +413,28 @@ impl crate::TermWindow {
chrome: &UiPalette,
foreground: LinearRgba,
) -> anyhow::Result<()> {
- let icon_y = y + ((row_height.saturating_sub(SESSION_STATUS_ICON_SIZE)) / 2);
+ let icon_y = y + ((row_height.saturating_sub(self.ui_px(SESSION_STATUS_ICON_SIZE))) / 2);
if let Some(status) = self.sidebar_thread_status_kind(session) {
let status_size = if matches!(status, UiStatusKind::Running | UiStatusKind::Done) {
- SESSION_STATUS_ACTIVE_ICON_SIZE
+ self.ui_px(SESSION_STATUS_ACTIVE_ICON_SIZE)
} else {
- SESSION_STATUS_ICON_SIZE
+ self.ui_px(SESSION_STATUS_ICON_SIZE)
};
return self.paint_status_icon(
layers,
2,
status,
- centered_inner_start(x, SESSION_STATUS_ICON_SIZE, status_size),
+ centered_inner_start(x, self.ui_px(SESSION_STATUS_ICON_SIZE), status_size),
centered_inner_start(y, row_height, status_size),
status_size,
self.sidebar_thread_status_color(session, status, chrome, foreground),
);
}
- let dot_offset = (SESSION_STATUS_ICON_SIZE.saturating_sub(SESSION_STATUS_DOT_SIZE)) / 2;
+ let dot_offset = (self
+ .ui_px(SESSION_STATUS_ICON_SIZE)
+ .saturating_sub(self.ui_px(SESSION_STATUS_DOT_SIZE)))
+ / 2;
let dot_x = x + dot_offset;
let dot_y = icon_y + dot_offset;
self.fill_rounded_rectangle(
@@ -425,11 +443,11 @@ impl crate::TermWindow {
euclid::rect(
dot_x as f32,
dot_y as f32,
- SESSION_STATUS_DOT_SIZE as f32,
- SESSION_STATUS_DOT_SIZE as f32,
+ self.ui_px(SESSION_STATUS_DOT_SIZE) as f32,
+ self.ui_px(SESSION_STATUS_DOT_SIZE) as f32,
),
self.sidebar_thread_dot_color(session, chrome, foreground),
- SESSION_STATUS_DOT_SIZE as f32 / 2.0,
+ self.ui_px(SESSION_STATUS_DOT_SIZE) as f32 / 2.0,
)
.context("sidebar thread status dot")
}
@@ -438,9 +456,10 @@ impl crate::TermWindow {
let tab_row_height = self.tab_bar_pixel_height().unwrap_or(0.0).ceil() as usize;
platform_chrome::workspace_sidebar_content_top(
panel_y,
- SIDEBAR_INSET,
+ self.ui_px(SIDEBAR_INSET),
tab_row_height,
self.window_state,
+ self.dimensions.dpi,
)
}
@@ -455,48 +474,51 @@ impl crate::TermWindow {
let panel_y = rect.y + panel_margin;
let panel_width = rect.width.saturating_sub(panel_margin * 2).max(1);
let panel_height = rect.height.saturating_sub(panel_margin * 2).max(1);
- let settings_footer_height = SIDEBAR_SETTINGS_FOOTER_HEIGHT.min(panel_height);
+ let settings_footer_height = self.ui_px(SIDEBAR_SETTINGS_FOOTER_HEIGHT).min(panel_height);
let settings_footer_y = panel_y
.saturating_add(panel_height)
.saturating_sub(settings_footer_height);
- let content_bottom = (panel_y + panel_height.saturating_sub(SIDEBAR_INSET))
+ let content_bottom = (panel_y + panel_height.saturating_sub(self.ui_px(SIDEBAR_INSET)))
.min(settings_footer_y.max(panel_y));
let show_sidebar_toolbar =
platform_chrome::workspace_sidebar_shows_toolbar(self.window_state);
let sidebar_toolbar_uses_fullscreen_style =
platform_chrome::workspace_sidebar_toolbar_uses_fullscreen_style(self.window_state);
- let row_height =
- (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(SESSION_ROW_MIN_HEIGHT);
+ let row_height = (ui_cell_height.max(icon_size) + self.ui_px(SIDEBAR_INSET))
+ .max(self.ui_px(SESSION_ROW_MIN_HEIGHT));
let mut y = self.workspace_sidebar_content_top(panel_y);
if show_sidebar_toolbar {
- y += platform_chrome::workspace_sidebar_toolbar_button_size(self.window_state)
- + SIDEBAR_INSET;
+ y += self.ui_px(platform_chrome::workspace_sidebar_toolbar_button_size(
+ self.window_state,
+ )) + self.ui_px(SIDEBAR_INSET);
}
- let top_action_height = row_height.min(48).max(ui_cell_height + SIDEBAR_INSET)
+ let top_action_height = row_height
+ .min(self.ui_px(48))
+ .max(ui_cell_height + self.ui_px(SIDEBAR_INSET))
+ if sidebar_toolbar_uses_fullscreen_style {
- WINDOW_TAB_FULLSCREEN_NEW_SESSION_EXTRA_HEIGHT
+ self.ui_px(WINDOW_TAB_FULLSCREEN_NEW_SESSION_EXTRA_HEIGHT)
} else {
0
};
let top_action_y_offset = if sidebar_toolbar_uses_fullscreen_style {
- WINDOW_TAB_FULLSCREEN_NEW_SESSION_Y_OFFSET
+ self.ui_px(WINDOW_TAB_FULLSCREEN_NEW_SESSION_Y_OFFSET)
} else {
0
};
let space_menu_y = y;
- let space_menu_height = top_action_height + 6;
- y += space_menu_height + SIDEBAR_INSET;
+ let space_menu_height = top_action_height + self.ui_px(6);
+ y += space_menu_height + self.ui_px(SIDEBAR_INSET);
let reconnect_row_height = if self.space_connection_state(&self.active_space_id)
== SpaceConnectionState::Disconnected
{
- ui_cell_height + SIDEBAR_INSET
+ ui_cell_height + self.ui_px(SIDEBAR_INSET)
} else {
0
};
if reconnect_row_height > 0 {
- y += reconnect_row_height + SIDEBAR_INSET;
+ y += reconnect_row_height + self.ui_px(SIDEBAR_INSET);
}
- let list_top = y + top_action_y_offset + top_action_height + SIDEBAR_INSET;
+ let list_top = y + top_action_y_offset + top_action_height + self.ui_px(SIDEBAR_INSET);
WorkspaceSidebarLayout {
panel_x,
@@ -534,7 +556,7 @@ impl crate::TermWindow {
.height as usize
})
.unwrap_or(self.render_metrics.cell_size.height as usize);
- let icon_size = (ui_cell_height + 12).clamp(30, 36);
+ let icon_size = (ui_cell_height + self.ui_px(12)).clamp(self.ui_px(30), self.ui_px(36));
let layout = self.workspace_sidebar_layout(rect, ui_cell_height, icon_size);
let content_bottom = layout.content_bottom;
let list_top = layout.list_top;
@@ -556,7 +578,7 @@ impl crate::TermWindow {
&active_workspace,
&workspaces,
);
- let row_gap = SIDEBAR_ROW_GAP;
+ let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let total_height = Self::workspace_sidebar_scroll_height(
&view,
layout.row_height,
@@ -581,7 +603,7 @@ impl crate::TermWindow {
.height as usize
})
.unwrap_or(self.render_metrics.cell_size.height as usize);
- let icon_size = (ui_cell_height + 12).clamp(30, 36);
+ let icon_size = (ui_cell_height + self.ui_px(12)).clamp(self.ui_px(30), self.ui_px(36));
let layout = self.workspace_sidebar_layout(rect, ui_cell_height, icon_size);
let content_bottom = layout.content_bottom;
let list_top = layout.list_top;
@@ -603,7 +625,7 @@ impl crate::TermWindow {
&active_workspace,
&workspaces,
);
- let row_gap = SIDEBAR_ROW_GAP;
+ let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let total_height = Self::workspace_sidebar_scroll_height(
&view,
layout.row_height,
@@ -625,7 +647,7 @@ impl crate::TermWindow {
let track_x = layout
.panel_x
.saturating_add(layout.panel_width)
- .saturating_sub(SIDEBAR_INSET / 2 + track_width);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) / 2 + track_width);
Some(WorkspaceSidebarScrollGeometry {
track_x,
@@ -657,21 +679,22 @@ impl crate::TermWindow {
ui_cell_height: usize,
register_ui_item: bool,
) -> anyhow::Result<()> {
- let reconnect_in_flight =
- workspace_threads::client_domain_for_space(&self.active_space_id)
- .map_or(false, |name| self.space_reconnects_in_flight.contains(&name));
- let hovered = !reconnect_in_flight
- && self.is_pointer_over_ui_rect(row_x, y, row_width, row_height);
+ let reconnect_in_flight = workspace_threads::client_domain_for_space(&self.active_space_id)
+ .map_or(false, |name| {
+ self.space_reconnects_in_flight.contains(&name)
+ });
+ let hovered =
+ !reconnect_in_flight && self.is_pointer_over_ui_rect(row_x, y, row_width, row_height);
self.fill_rounded_rectangle(
layers,
layer,
euclid::rect(row_x as f32, y as f32, row_width as f32, row_height as f32),
SPACE_DISCONNECTED_COLOR.mul_alpha(if hovered { 0.30 } else { 0.18 }),
- SIDEBAR_ROW_RADIUS,
+ self.ui_f32(SIDEBAR_ROW_RADIUS),
)
.context("sidebar reconnect row")?;
let row_icon_size = ui_cell_height.min(row_height.saturating_sub(6));
- let row_icon_x = row_x + SIDEBAR_INSET;
+ let row_icon_x = row_x + self.ui_px(SIDEBAR_INSET);
let row_icon_y = y + ((row_height.saturating_sub(row_icon_size)) / 2);
self.paint_sidebar_icon(
layers,
@@ -685,8 +708,9 @@ impl crate::TermWindow {
row_icon_size,
SPACE_DISCONNECTED_COLOR,
)?;
- let row_text_x = row_icon_x + row_icon_size + SIDEBAR_ICON_GAP;
- let row_text_max = (row_x + row_width).saturating_sub(row_text_x + SIDEBAR_INSET);
+ let row_text_x = row_icon_x + row_icon_size + self.ui_px(SIDEBAR_ICON_GAP);
+ let row_text_max =
+ (row_x + row_width).saturating_sub(row_text_x + self.ui_px(SIDEBAR_INSET));
let row_label = self.ellipsize_sidebar_text(
ui_font,
if reconnect_in_flight {
@@ -742,7 +766,7 @@ impl crate::TermWindow {
.context("sidebar ui font")?;
let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());
let ui_cell_height = ui_metrics.cell_size.height as usize;
- let icon_size = (ui_cell_height + 12).clamp(30, 36);
+ let icon_size = (ui_cell_height + self.ui_px(12)).clamp(self.ui_px(30), self.ui_px(36));
let layout = self.workspace_sidebar_layout(rect, ui_cell_height, icon_size);
let panel_x = layout.panel_x;
let panel_y = layout.panel_y;
@@ -789,15 +813,15 @@ impl crate::TermWindow {
});
let session_row_height = layout.row_height;
- let item_x = panel_x + SIDEBAR_INSET;
- let item_width = panel_width.saturating_sub(SIDEBAR_INSET * 2 + 1);
+ let item_x = panel_x + self.ui_px(SIDEBAR_INSET);
+ let item_width = panel_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2 + 1);
self.ui_items.push(UIItem {
x: rect
.x
.saturating_add(rect.width)
- .saturating_sub(SIDEBAR_RESIZE_HANDLE_WIDTH / 2),
+ .saturating_sub(self.ui_px(SIDEBAR_RESIZE_HANDLE_WIDTH) / 2),
y: rect.y,
- width: SIDEBAR_RESIZE_HANDLE_WIDTH,
+ width: self.ui_px(SIDEBAR_RESIZE_HANDLE_WIDTH),
height: rect.height,
item_type: UIItemType::WorkspaceSidebarResize,
});
@@ -820,29 +844,32 @@ impl crate::TermWindow {
&workspaces,
);
- let header_icon_size = icon_size.min(32);
- let button_size = (header_icon_size + 8).clamp(32, 40);
+ let header_icon_size = icon_size.min(self.ui_px(32));
+ let button_size = (header_icon_size + self.ui_px(8)).clamp(self.ui_px(32), self.ui_px(40));
let header_y = self.workspace_sidebar_content_top(panel_y);
let show_sidebar_toolbar = layout.show_sidebar_toolbar;
let sidebar_toolbar_uses_fullscreen_style =
platform_chrome::workspace_sidebar_toolbar_uses_fullscreen_style(self.window_state);
- let sidebar_toggle_size =
- platform_chrome::workspace_sidebar_toolbar_button_size(self.window_state);
+ let sidebar_toggle_size = self.ui_px(
+ platform_chrome::workspace_sidebar_toolbar_button_size(self.window_state),
+ );
let sidebar_toggle_x = panel_x
+ if sidebar_toolbar_uses_fullscreen_style {
- WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X
+ self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X)
} else {
- SIDEBAR_INSET
+ self.ui_px(SIDEBAR_INSET)
};
let sidebar_toggle_y = header_y
+ if sidebar_toolbar_uses_fullscreen_style {
- WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET
+ self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET)
} else {
0
};
- let sidebar_toggle_icon_size =
- platform_chrome::workspace_sidebar_toolbar_icon_size(self.window_state)
- .min(sidebar_toggle_size.saturating_sub(2));
+ let sidebar_toggle_icon_size = self
+ .ui_px(platform_chrome::workspace_sidebar_toolbar_icon_size(
+ self.window_state,
+ ))
+ .min(sidebar_toggle_size.saturating_sub(2));
if show_sidebar_toolbar {
let toggle_hovered = self.is_pointer_over_ui_rect(
sidebar_toggle_x,
@@ -861,7 +888,7 @@ impl crate::TermWindow {
sidebar_toggle_size as f32,
),
chrome.sidebar_button_hover_bg,
- SIDEBAR_ROW_RADIUS,
+ self.ui_f32(SIDEBAR_ROW_RADIUS),
)
.context("sidebar toolbar toggle button")?;
}
@@ -883,7 +910,8 @@ impl crate::TermWindow {
if toggle_hovered { foreground } else { muted_fg },
)?;
}
- let section_button_size = SIDEBAR_SECTION_ACTION_SIZE
+ let section_button_size = self
+ .ui_px(SIDEBAR_SECTION_ACTION_SIZE)
.max(button_size)
.min(session_row_height.saturating_sub(8));
let active_project_id = view
@@ -892,10 +920,10 @@ impl crate::TermWindow {
.find(|project| project.is_active)
.map(|project| project.id.clone());
let top_action_y_offset = layout.top_action_y_offset;
- let top_action_total_width = item_width.saturating_sub(SIDEBAR_INSET * 2);
- let top_action_gap = SIDEBAR_ICON_GAP + 4;
+ let top_action_total_width = item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2);
+ let top_action_gap = self.ui_px(SIDEBAR_ICON_GAP) + 4;
let top_action_height = layout.top_action_height;
- let space_menu_x = item_x + SIDEBAR_INSET;
+ let space_menu_x = item_x + self.ui_px(SIDEBAR_INSET);
let space_menu_y = layout.space_menu_y;
let mut push_header_blank = |x: usize, y: usize, width: usize, height: usize| {
if width > 0 && height > 0 {
@@ -964,7 +992,7 @@ impl crate::TermWindow {
space_menu_height as f32,
),
chrome.sidebar_button_hover_bg,
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar space menu button")?;
}
@@ -976,17 +1004,17 @@ impl crate::TermWindow {
item_type: UIItemType::SpaceMenu,
});
let space_icon_size = header_icon_size.min(space_menu_height.saturating_sub(14));
- let space_icon_x = space_menu_x + SIDEBAR_INSET;
+ let space_icon_x = space_menu_x + self.ui_px(SIDEBAR_INSET);
let space_icon_y = space_menu_y + ((space_menu_height.saturating_sub(space_icon_size)) / 2);
let space_action_icon_size = space_icon_size.min(22);
let space_action_icon_x = space_menu_x
.saturating_add(space_menu_width)
- .saturating_sub(SIDEBAR_INSET + space_action_icon_size);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) + space_action_icon_size);
let space_action_icon_y =
space_menu_y + ((space_menu_height.saturating_sub(space_action_icon_size)) / 2);
let space_text_right = space_menu_x
.saturating_add(space_menu_width)
- .saturating_sub(SIDEBAR_INSET + space_action_icon_size + top_action_gap);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) + space_action_icon_size + top_action_gap);
let space_text_x = space_icon_x + space_icon_size + top_action_gap;
let space_name = crate::workspace_threads::active_space_name(&self.active_space_id)
.unwrap_or_else(|| "Default".to_string());
@@ -1051,23 +1079,23 @@ impl crate::TermWindow {
muted_fg
},
)?;
- let mut y = space_menu_y + space_menu_height + SIDEBAR_INSET;
+ let mut y = space_menu_y + space_menu_height + self.ui_px(SIDEBAR_INSET);
if layout.reconnect_row_height > 0 {
self.paint_space_reconnect_row(
layers,
1,
- item_x + SIDEBAR_INSET,
+ item_x + self.ui_px(SIDEBAR_INSET),
y,
- item_width.saturating_sub(SIDEBAR_INSET * 2),
+ item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2),
layout.reconnect_row_height,
&ui_font,
ui_metrics,
ui_cell_height,
true,
)?;
- y += layout.reconnect_row_height + SIDEBAR_INSET;
+ y += layout.reconnect_row_height + self.ui_px(SIDEBAR_INSET);
}
- let top_action_x = item_x + SIDEBAR_INSET;
+ let top_action_x = item_x + self.ui_px(SIDEBAR_INSET);
let top_action_y = y + top_action_y_offset;
let notification_action_size = top_action_height;
let notification_action_x = top_action_x
@@ -1103,7 +1131,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_bg
},
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar add thread button")?;
self.fill_rounded_rectangle(
@@ -1120,7 +1148,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_bg
},
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar notifications button")?;
if let Some(project_id) = active_project_id.clone() {
@@ -1141,7 +1169,7 @@ impl crate::TermWindow {
});
let top_action_icon_size = header_icon_size.min(top_action_height.saturating_sub(14));
let top_action_text_max_width = top_action_width
- .saturating_sub(top_action_icon_size + top_action_gap + SIDEBAR_INSET * 2);
+ .saturating_sub(top_action_icon_size + top_action_gap + self.ui_px(SIDEBAR_INSET) * 2);
let top_action_label =
self.ellipsize_sidebar_text(&ui_font, "New Thread", top_action_text_max_width)?;
let top_action_text_width = self
@@ -1198,7 +1226,7 @@ impl crate::TermWindow {
},
)?;
let list_top = layout.list_top;
- let row_gap = SIDEBAR_ROW_GAP;
+ let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let max_scroll = {
let viewport_height = content_bottom.saturating_sub(list_top);
let total_height = Self::workspace_sidebar_scroll_height(
@@ -1227,10 +1255,10 @@ impl crate::TermWindow {
if label_is_visible {
let label_y = label_top.floor().max(0.0) as usize;
let label_icon_size = header_icon_size.min(ui_cell_height).max(16);
- let label_icon_x = item_x + SIDEBAR_INSET;
+ let label_icon_x = item_x + self.ui_px(SIDEBAR_INSET);
let label_icon_y =
label_y + ((session_row_height.saturating_sub(label_icon_size)) / 2);
- let label_text_x = label_icon_x + label_icon_size + SIDEBAR_ICON_GAP;
+ let label_text_x = label_icon_x + label_icon_size + self.ui_px(SIDEBAR_ICON_GAP);
self.paint_sidebar_icon(
layers,
SvgIcon::Pin,
@@ -1248,16 +1276,19 @@ impl crate::TermWindow {
label_y + ((session_row_height.saturating_sub(ui_cell_height)) / 2),
item_x
.saturating_add(item_width)
- .saturating_sub(label_text_x + SIDEBAR_INSET),
+ .saturating_sub(label_text_x + self.ui_px(SIDEBAR_INSET)),
muted_fg,
)?;
}
virtual_y += session_row_height + row_gap;
- let pinned_x = item_x + SIDEBAR_INSET;
- let pinned_width = item_width.saturating_sub(SIDEBAR_INSET * 2);
- let pinned_status_x = pinned_x + SIDEBAR_INSET;
- let pinned_text_x = pinned_status_x + SESSION_STATUS_ICON_SIZE + SIDEBAR_ICON_GAP + 6;
+ let pinned_x = item_x + self.ui_px(SIDEBAR_INSET);
+ let pinned_width = item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2);
+ let pinned_status_x = pinned_x + self.ui_px(SIDEBAR_INSET);
+ let pinned_text_x = pinned_status_x
+ + self.ui_px(SESSION_STATUS_ICON_SIZE)
+ + self.ui_px(SIDEBAR_ICON_GAP)
+ + 6;
for session in &view.pinned_threads {
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
let row_bottom = row_top + session_row_height as f32;
@@ -1296,7 +1327,7 @@ impl crate::TermWindow {
),
selected_bg,
selected_border,
- SIDEBAR_ROW_RADIUS + 2.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,
CAPSULE_BORDER_WIDTH,
)
.context("sidebar selected pinned thread")?;
@@ -1311,18 +1342,19 @@ impl crate::TermWindow {
session_row_height as f32,
),
chrome.sidebar_row_hover_bg,
- SIDEBAR_ROW_RADIUS + 2.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,
)
.context("sidebar hovered pinned thread")?;
}
let text_y = y + ((session_row_height.saturating_sub(ui_cell_height)) / 2);
- let action_size = session_row_height
- .saturating_sub(8)
- .clamp(SESSION_ACTION_MIN_SIZE, SESSION_ACTION_MAX_SIZE);
+ let action_size = session_row_height.saturating_sub(8).clamp(
+ self.ui_px(SESSION_ACTION_MIN_SIZE),
+ self.ui_px(SESSION_ACTION_MAX_SIZE),
+ );
let delete_x = pinned_x
.saturating_add(pinned_width)
- .saturating_sub(SIDEBAR_INSET + action_size);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) + action_size);
let pin_x = delete_x.saturating_sub(action_size + 4);
let action_y = y + ((session_row_height.saturating_sub(action_size)) / 2);
let text_right = if is_hovered && !is_renaming_session {
@@ -1330,7 +1362,7 @@ impl crate::TermWindow {
} else {
pinned_x
.saturating_add(pinned_width)
- .saturating_sub(SIDEBAR_INSET)
+ .saturating_sub(self.ui_px(SIDEBAR_INSET))
};
self.paint_sidebar_thread_status(
layers,
@@ -1349,7 +1381,7 @@ impl crate::TermWindow {
&title,
pinned_text_x,
text_y,
- text_right.saturating_sub(pinned_text_x + SIDEBAR_INSET),
+ text_right.saturating_sub(pinned_text_x + self.ui_px(SIDEBAR_INSET)),
if is_selected { active_fg } else { foreground },
)?;
@@ -1378,7 +1410,7 @@ impl crate::TermWindow {
item_type,
});
let action_icon_size = action_size
- .saturating_sub(SESSION_ACTION_ICON_INSET)
+ .saturating_sub(self.ui_px(SESSION_ACTION_ICON_INSET))
.max(header_icon_size);
self.paint_sidebar_icon(
layers,
@@ -1402,7 +1434,7 @@ impl crate::TermWindow {
if !view.projects.is_empty() {
if !view.pinned_threads.is_empty() {
- virtual_y += WORKSPACE_SECTION_LABEL_GAP;
+ virtual_y += self.ui_px(WORKSPACE_SECTION_LABEL_GAP);
}
let label_top = list_top_f + virtual_y as f32 - scroll_offset;
let label_bottom = label_top + session_row_height as f32;
@@ -1413,7 +1445,7 @@ impl crate::TermWindow {
label_y + ((session_row_height.saturating_sub(section_button_size)) / 2);
let button_x = item_x
.saturating_add(item_width)
- .saturating_sub(section_button_size + SIDEBAR_INSET);
+ .saturating_sub(section_button_size + self.ui_px(SIDEBAR_INSET));
let button_hovered = !suppress_hover
&& self.is_pointer_over_ui_rect(
button_x,
@@ -1426,9 +1458,9 @@ impl crate::TermWindow {
&ui_font,
ui_metrics,
"Workspaces",
- item_x + SIDEBAR_INSET,
+ item_x + self.ui_px(SIDEBAR_INSET),
label_y + ((session_row_height.saturating_sub(ui_cell_height)) / 2),
- button_x.saturating_sub(item_x + SIDEBAR_INSET * 2),
+ button_x.saturating_sub(item_x + self.ui_px(SIDEBAR_INSET) * 2),
muted_fg,
)?;
self.fill_rounded_rectangle(
@@ -1445,7 +1477,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_bg
},
- SIDEBAR_ROW_RADIUS,
+ self.ui_f32(SIDEBAR_ROW_RADIUS),
)
.context("sidebar new project button")?;
self.ui_items.push(UIItem {
@@ -1455,8 +1487,10 @@ impl crate::TermWindow {
height: section_button_size,
item_type: UIItemType::ProjectNew,
});
- let section_icon_size = (header_icon_size + 4)
- .min(section_button_size.saturating_sub(SIDEBAR_SECTION_ACTION_ICON_INSET));
+ let section_icon_size = (header_icon_size + 4).min(
+ section_button_size
+ .saturating_sub(self.ui_px(SIDEBAR_SECTION_ACTION_ICON_INSET)),
+ );
self.paint_sidebar_icon(
layers,
SvgIcon::FolderPlus,
@@ -1479,13 +1513,13 @@ impl crate::TermWindow {
let hit_height = hit_bottom.saturating_sub(hit_y).max(1);
let disclosure_size = icon_size.min(22);
- let disclosure_x = item_x + SIDEBAR_INSET;
+ let disclosure_x = item_x + self.ui_px(SIDEBAR_INSET);
let project_icon_x = disclosure_x + disclosure_size + 4;
- let project_text_x = project_icon_x + icon_size + SIDEBAR_ICON_GAP;
+ let project_text_x = project_icon_x + icon_size + self.ui_px(SIDEBAR_ICON_GAP);
let project_action_size = section_button_size.min(session_row_height.saturating_sub(8));
let project_action_x = item_x
.saturating_add(item_width)
- .saturating_sub(project_action_size + SIDEBAR_INSET);
+ .saturating_sub(project_action_size + self.ui_px(SIDEBAR_INSET));
let project_text_right = project_action_x;
if row_is_visible {
@@ -1562,7 +1596,7 @@ impl crate::TermWindow {
&project_title,
project_text_x,
text_y,
- project_text_right.saturating_sub(project_text_x + SIDEBAR_INSET),
+ project_text_right.saturating_sub(project_text_x + self.ui_px(SIDEBAR_INSET)),
muted_fg,
)?;
}
@@ -1591,7 +1625,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_bg
},
- SIDEBAR_ROW_RADIUS,
+ self.ui_f32(SIDEBAR_ROW_RADIUS),
)
.context("sidebar new thread button")?;
self.ui_items.push(UIItem {
@@ -1601,8 +1635,10 @@ impl crate::TermWindow {
height: project_action_size,
item_type: UIItemType::WorkspaceThreadNew(project.id.clone()),
});
- let action_icon_size = (header_icon_size + 4)
- .min(project_action_size.saturating_sub(SIDEBAR_SECTION_ACTION_ICON_INSET));
+ let action_icon_size = (header_icon_size + 4).min(
+ project_action_size
+ .saturating_sub(self.ui_px(SIDEBAR_SECTION_ACTION_ICON_INSET)),
+ );
self.paint_sidebar_icon(
layers,
SvgIcon::Plus,
@@ -1620,12 +1656,16 @@ impl crate::TermWindow {
virtual_y += session_row_height + row_gap;
if !project.threads_collapsed {
- let session_x = item_x + SIDEBAR_INSET * 3 + SESSION_ROW_SIDE_PADDING;
- let session_width =
- item_width.saturating_sub(SIDEBAR_INSET * 3 + SESSION_ROW_SIDE_PADDING * 2);
- let session_status_x = session_x + SIDEBAR_INSET + 2;
- let session_text_x =
- session_status_x + SESSION_STATUS_ICON_SIZE + SIDEBAR_ICON_GAP + 6;
+ let session_x =
+ item_x + self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING);
+ let session_width = item_width.saturating_sub(
+ self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING) * 2,
+ );
+ let session_status_x = session_x + self.ui_px(SIDEBAR_INSET) + 2;
+ let session_text_x = session_status_x
+ + self.ui_px(SESSION_STATUS_ICON_SIZE)
+ + self.ui_px(SIDEBAR_ICON_GAP)
+ + 6;
for session in &project.threads {
let row_top = list_top_f + virtual_y as f32 - scroll_offset;
@@ -1650,7 +1690,7 @@ impl crate::TermWindow {
),
selected_bg,
selected_border,
- SIDEBAR_ROW_RADIUS + 2.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,
CAPSULE_BORDER_WIDTH,
)
.context("sidebar selected thread")?;
@@ -1673,12 +1713,13 @@ impl crate::TermWindow {
session_row_height,
);
let is_renaming_session = self.is_renaming_sidebar_thread(&session.id);
- let action_size = session_row_height
- .saturating_sub(8)
- .clamp(SESSION_ACTION_MIN_SIZE, SESSION_ACTION_MAX_SIZE);
+ let action_size = session_row_height.saturating_sub(8).clamp(
+ self.ui_px(SESSION_ACTION_MIN_SIZE),
+ self.ui_px(SESSION_ACTION_MAX_SIZE),
+ );
let delete_x = session_x
.saturating_add(session_width)
- .saturating_sub(SIDEBAR_INSET + action_size);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) + action_size);
let pin_x = delete_x.saturating_sub(action_size + 4);
let action_y = y + ((session_row_height.saturating_sub(action_size)) / 2);
let text_right = if is_hovered && !is_renaming_session {
@@ -1686,9 +1727,10 @@ impl crate::TermWindow {
} else {
session_x
.saturating_add(session_width)
- .saturating_sub(SIDEBAR_INSET)
+ .saturating_sub(self.ui_px(SIDEBAR_INSET))
};
- let text_width = text_right.saturating_sub(session_text_x + SIDEBAR_INSET);
+ let text_width =
+ text_right.saturating_sub(session_text_x + self.ui_px(SIDEBAR_INSET));
if is_hovered && !is_selected && !is_renaming_session {
self.fill_rounded_rectangle(
layers,
@@ -1700,7 +1742,7 @@ impl crate::TermWindow {
session_row_height as f32,
),
chrome.sidebar_row_hover_bg,
- SIDEBAR_ROW_RADIUS + 2.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,
)
.context("sidebar hovered thread")?;
}
@@ -1758,7 +1800,7 @@ impl crate::TermWindow {
item_type,
});
let action_icon_size = action_size
- .saturating_sub(SESSION_ACTION_ICON_INSET)
+ .saturating_sub(self.ui_px(SESSION_ACTION_ICON_INSET))
.max(header_icon_size);
self.paint_sidebar_icon(
layers,
@@ -1781,7 +1823,7 @@ impl crate::TermWindow {
}
if project_idx + 1 < view.projects.len() {
- virtual_y += WORKSPACE_GROUP_EXTRA_GAP;
+ virtual_y += self.ui_px(WORKSPACE_GROUP_EXTRA_GAP);
}
}
@@ -1817,7 +1859,7 @@ impl crate::TermWindow {
sidebar_toggle_size as f32,
),
chrome.sidebar_button_hover_bg,
- SIDEBAR_ROW_RADIUS,
+ self.ui_f32(SIDEBAR_ROW_RADIUS),
)
.context("sidebar toolbar toggle button repaint")?;
}
@@ -1849,7 +1891,7 @@ impl crate::TermWindow {
space_menu_height as f32,
),
chrome.sidebar_button_hover_bg,
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar space menu button repaint")?;
}
@@ -1887,9 +1929,9 @@ impl crate::TermWindow {
self.paint_space_reconnect_row(
layers,
2,
- item_x + SIDEBAR_INSET,
- space_menu_y + space_menu_height + SIDEBAR_INSET,
- item_width.saturating_sub(SIDEBAR_INSET * 2),
+ item_x + self.ui_px(SIDEBAR_INSET),
+ space_menu_y + space_menu_height + self.ui_px(SIDEBAR_INSET),
+ item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2),
layout.reconnect_row_height,
&ui_font,
ui_metrics,
@@ -1918,7 +1960,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_bg
},
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar add thread button repaint")?;
let notification_action_hovered = self.is_pointer_over_ui_rect(
@@ -1941,7 +1983,7 @@ impl crate::TermWindow {
} else {
chrome.sidebar_button_bg
},
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar notifications button repaint")?;
let top_action_fg = if active_project_id.is_some() {
@@ -1984,7 +2026,9 @@ impl crate::TermWindow {
}
if max_scroll > 0.0 && scroll_offset > 0.0 {
- let fade_height = SIDEBAR_TOP_FADE_HEIGHT.min(content_bottom.saturating_sub(list_top));
+ let fade_height = self
+ .ui_px(SIDEBAR_TOP_FADE_HEIGHT)
+ .min(content_bottom.saturating_sub(list_top));
for step in 0..fade_height {
let progress = step as f32 / fade_height as f32;
let alpha = 1.0 - progress * progress * (3.0 - 2.0 * progress);
@@ -2022,7 +2066,8 @@ impl crate::TermWindow {
}
if settings_footer_height > 0 {
- let fade_height = SIDEBAR_SETTINGS_FADE_HEIGHT
+ let fade_height = self
+ .ui_px(SIDEBAR_SETTINGS_FADE_HEIGHT)
.min(settings_footer_y.saturating_sub(panel_y))
.min(content_bottom.saturating_sub(panel_y));
if max_scroll > 0.0 && fade_height > 0 {
@@ -2056,14 +2101,15 @@ impl crate::TermWindow {
)
.context("sidebar settings footer background")?;
- let settings_row_x = item_x + SIDEBAR_SETTINGS_ROW_SIDE_PADDING;
- let settings_row_y = (settings_footer_y + SIDEBAR_SETTINGS_ROW_TOP_PADDING)
- .saturating_sub(SIDEBAR_SETTINGS_ROW_LIFT);
+ let settings_row_x = item_x + self.ui_px(SIDEBAR_SETTINGS_ROW_SIDE_PADDING);
+ let settings_row_y = (settings_footer_y + self.ui_px(SIDEBAR_SETTINGS_ROW_TOP_PADDING))
+ .saturating_sub(self.ui_px(SIDEBAR_SETTINGS_ROW_LIFT));
let settings_row_width =
- item_width.saturating_sub(SIDEBAR_SETTINGS_ROW_SIDE_PADDING * 2);
+ item_width.saturating_sub(self.ui_px(SIDEBAR_SETTINGS_ROW_SIDE_PADDING) * 2);
let settings_row_height = settings_footer_height
.saturating_sub(
- SIDEBAR_SETTINGS_ROW_TOP_PADDING + SIDEBAR_SETTINGS_ROW_BOTTOM_PADDING,
+ self.ui_px(SIDEBAR_SETTINGS_ROW_TOP_PADDING)
+ + self.ui_px(SIDEBAR_SETTINGS_ROW_BOTTOM_PADDING),
)
.max(1);
let settings_action_size = settings_row_height.max(1);
@@ -2072,8 +2118,8 @@ impl crate::TermWindow {
.saturating_sub(settings_action_size);
let settings_action_y = settings_row_y;
// SSH hosts (link-2) button sits just left of the view-options button.
- let ssh_action_x =
- settings_action_x.saturating_sub(settings_action_size + SIDEBAR_INSET / 2);
+ let ssh_action_x = settings_action_x
+ .saturating_sub(settings_action_size + self.ui_px(SIDEBAR_INSET) / 2);
let ssh_action_y = settings_row_y;
let ssh_action_hovered = self.is_pointer_over_ui_rect(
ssh_action_x,
@@ -2083,7 +2129,7 @@ impl crate::TermWindow {
);
let settings_body_width = ssh_action_x
.saturating_sub(settings_row_x)
- .saturating_sub(SIDEBAR_INSET / 2);
+ .saturating_sub(self.ui_px(SIDEBAR_INSET) / 2);
let settings_hovered = self.is_pointer_over_ui_rect(
settings_row_x,
settings_row_y,
@@ -2107,7 +2153,7 @@ impl crate::TermWindow {
settings_row_height as f32,
),
chrome.sidebar_row_hover_bg,
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar settings button hover")?;
}
@@ -2129,7 +2175,7 @@ impl crate::TermWindow {
settings_action_size as f32,
),
chrome.sidebar_button_hover_bg,
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar settings view options hover")?;
}
@@ -2151,7 +2197,7 @@ impl crate::TermWindow {
settings_action_size as f32,
),
chrome.sidebar_button_hover_bg,
- SIDEBAR_ROW_RADIUS + 4.0,
+ self.ui_f32(SIDEBAR_ROW_RADIUS) + 4.0,
)
.context("sidebar ssh hosts hover")?;
}
@@ -2178,10 +2224,11 @@ impl crate::TermWindow {
)?;
}
let settings_icon_size = icon_size.min(settings_row_height.saturating_sub(8));
- let settings_icon_x = settings_row_x + SIDEBAR_SETTINGS_ICON_EXTRA_INSET;
+ let settings_icon_x = settings_row_x + self.ui_px(SIDEBAR_SETTINGS_ICON_EXTRA_INSET);
let settings_icon_y =
settings_row_y + ((settings_row_height.saturating_sub(settings_icon_size)) / 2);
- let settings_text_x = settings_icon_x + settings_icon_size + SIDEBAR_ICON_GAP + 8;
+ let settings_text_x =
+ settings_icon_x + settings_icon_size + self.ui_px(SIDEBAR_ICON_GAP) + 8;
let settings_text_y =
settings_row_y + ((settings_row_height.saturating_sub(ui_cell_height)) / 2);
self.paint_sidebar_icon(
@@ -2199,7 +2246,7 @@ impl crate::TermWindow {
"Settings",
settings_text_x,
settings_text_y,
- settings_action_x.saturating_sub(settings_text_x + SIDEBAR_INSET),
+ settings_action_x.saturating_sub(settings_text_x + self.ui_px(SIDEBAR_INSET)),
foreground,
)?;
let settings_action_icon_size = settings_icon_size;
@@ -2659,7 +2706,9 @@ mod tests {
// Build (advance, cluster) pairs for an ASCII or per-char string where every
// char is one glyph of `advance` px and the cluster is its byte offset.
fn glyphs_per_char(text: &str, advance: f32) -> Vec<(f32, usize)> {
- text.char_indices().map(|(byte, _)| (advance, byte)).collect()
+ text.char_indices()
+ .map(|(byte, _)| (advance, byte))
+ .collect()
}
#[test]
diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rs
index 5d0a12d6..ef62fa72 100644
--- a/wezterm-gui/src/termwindow/ui/tokens.rs
+++ b/wezterm-gui/src/termwindow/ui/tokens.rs
@@ -35,9 +35,6 @@ pub const PANE_NAV_ICON_GAP: usize = 8;
pub const PANE_NAV_BUTTON_GAP: usize = 4;
pub const PANE_NAV_TAB_GAP: usize = 18;
pub const PANE_NAV_TAB_TOP_OFFSET: usize = 4;
-pub const PANE_NAV_EXTRA_HEIGHT: usize = 32;
-pub const PANE_NAV_MIN_HEIGHT: usize = 62;
-pub const PANE_NAV_MAX_HEIGHT: usize = 72;
pub const PANE_NAV_TAB_RADIUS: f32 = 12.0;
pub const PANE_NAV_ACTION_BUTTON_RADIUS: f32 = 999.0;
diff --git a/wezterm-gui/src/ui/tokens.rs b/wezterm-gui/src/ui/tokens.rs
index d7b6796c..31baa844 100644
--- a/wezterm-gui/src/ui/tokens.rs
+++ b/wezterm-gui/src/ui/tokens.rs
@@ -111,6 +111,73 @@ impl Default for UiTokens {
}
}
+impl UiTokens {
+ /// Scale ThinkTerm's custom chrome from its original Retina pixel grid to
+ /// the current window's backing scale. Text already follows the window
+ /// DPI; applying the same ratio to controls keeps their size in points
+ /// stable when a macOS window moves between Retina and non-Retina screens.
+ pub(crate) fn for_dpi(dpi: usize) -> Self {
+ let scale = ui_scale_for_dpi(dpi);
+ let base = Self::default();
+ Self {
+ sidebar_min_width: base.sidebar_min_width * scale,
+ sidebar_max_width: base.sidebar_max_width * scale,
+ sidebar_default_width: base.sidebar_default_width * scale,
+ sidebar_padding: base.sidebar_padding * scale,
+ row_height: base.row_height * scale,
+ row_gap: base.row_gap * scale,
+ control_height: base.control_height * scale,
+ control_radius: base.control_radius * scale,
+ row_radius: base.row_radius * scale,
+ icon_size: base.icon_size * scale,
+ resize_handle_width: base.resize_handle_width * scale,
+ scrollbar_width: base.scrollbar_width * scale,
+ }
+ }
+}
+
+/// ThinkTerm's custom chrome is expressed in design pixels: Retina pixels on
+/// macOS and logical pixels elsewhere. Convert those values to the current
+/// monitor's backing-pixel grid.
+pub(crate) fn ui_scale_for_dpi(dpi: usize) -> f32 {
+ let design_dpi = if cfg!(target_os = "macos") {
+ // The custom chrome was authored on a 2x macOS backing surface.
+ 144.0
+ } else {
+ 96.0
+ };
+ (dpi.max(1) as f32 / design_dpi).clamp(0.5, 4.0)
+}
+
+pub(crate) fn scale_ui_usize(value: usize, dpi: usize) -> usize {
+ if value == 0 {
+ 0
+ } else {
+ ((value as f32 * ui_scale_for_dpi(dpi)).round() as usize).max(1)
+ }
+}
+
+pub(crate) fn scale_ui_f32(value: f32, dpi: usize) -> f32 {
+ value * ui_scale_for_dpi(dpi)
+}
+
+pub(crate) fn unscale_ui_usize(value: usize, dpi: usize) -> usize {
+ if value == 0 {
+ 0
+ } else {
+ ((value as f32 / ui_scale_for_dpi(dpi)).round() as usize).max(1)
+ }
+}
+
+pub(crate) fn rescale_ui_usize(value: usize, old_dpi: usize, new_dpi: usize) -> usize {
+ if value == 0 {
+ 0
+ } else {
+ ((value as f32 * ui_scale_for_dpi(new_dpi) / ui_scale_for_dpi(old_dpi)).round() as usize)
+ .max(1)
+ }
+}
+
fn rgb(red: u8, green: u8, blue: u8) -> LinearRgba {
rgba(red, green, blue, 1.0)
}
@@ -120,3 +187,33 @@ fn rgba(red: u8, green: u8, blue: u8, alpha: f32) -> LinearRgba {
color.3 = alpha;
color
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn design_dpi() -> usize {
+ if cfg!(target_os = "macos") {
+ 144
+ } else {
+ 96
+ }
+ }
+
+ #[test]
+ fn ui_pixels_follow_monitor_dpi() {
+ let design_dpi = design_dpi();
+ assert_eq!(ui_scale_for_dpi(design_dpi), 1.0);
+ assert_eq!(scale_ui_usize(40, design_dpi / 2), 20);
+ assert_eq!(scale_ui_usize(40, design_dpi * 2), 80);
+ }
+
+ #[test]
+ fn ui_widths_round_trip_through_design_pixels() {
+ let design_dpi = design_dpi();
+ let monitor_dpi = design_dpi / 2;
+ let scaled = scale_ui_usize(380, monitor_dpi);
+ assert_eq!(unscale_ui_usize(scaled, monitor_dpi), 380);
+ assert_eq!(rescale_ui_usize(80, design_dpi, monitor_dpi), 40);
+ }
+}
diff --git a/wezterm-gui/src/workspace_threads.rs b/wezterm-gui/src/workspace_threads.rs
index 63116c90..29e9bb69 100644
--- a/wezterm-gui/src/workspace_threads.rs
+++ b/wezterm-gui/src/workspace_threads.rs
@@ -3577,6 +3577,17 @@ fn parse_thread_workspace_name(workspace: &str) -> Option<(String, String)> {
Some((project_id.to_string(), thread_id.to_string()))
}
+/// Whether the workspace is managed by ThinkTerm's Space/thread store.
+///
+/// Client domains mirror every server-side workspace into the local mux,
+/// including implementation-detail workspaces such as the mux server's
+/// startup default window. Keep the recognition rule in one place so GUI
+/// reconciliation cannot mistake one of those background mirrors for a
+/// ThinkTerm thread window.
+pub(crate) fn is_thread_workspace_name(workspace: &str) -> bool {
+ parse_thread_workspace_name(workspace).is_some()
+}
+
/// Rebuild sidebar records for live mux windows of this Space's client
/// domain whose thread workspace has no local record. The remote mux server
/// is the source of truth for a mux-domain Space: when the local store lost