Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/render/renderer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ fn renderSession(
theme: *const colors.Theme,
ui_scale: f32,
) RenderError!void {
try renderSessionContent(renderer, session, view, rect, scale, is_focused, font, term_cols, term_rows, current_time_ms, theme);
try renderSessionContent(renderer, session, view, rect, scale, is_focused, font, term_cols, term_rows, current_time_ms, theme, ui_scale);
renderSessionOverlays(renderer, session, view, rect, is_focused, apply_effects, current_time_ms, is_grid_view, theme, ui_scale);
cache_entry.presented_epoch = session.render_epoch;
}
Expand All @@ -326,6 +326,7 @@ fn renderSessionContent(
term_rows: u16,
_: i64,
theme: *const colors.Theme,
ui_scale: f32,
) RenderError!void {
if (!session.spawned) return;

Expand Down Expand Up @@ -362,7 +363,7 @@ fn renderSessionContent(
const cell_width_actual: c_int = @max(1, @as(c_int, @intFromFloat(@as(f32, @floatFromInt(base_cell_width)) * scale)));
const cell_height_actual: c_int = @max(1, @as(c_int, @intFromFloat(@as(f32, @floatFromInt(base_cell_height)) * scale)));

const padding: c_int = terminal_padding;
const padding: c_int = dpi.scale(terminal_padding, ui_scale);
const drawable_w: c_int = rect.w - padding * 2;
const drawable_h: c_int = rect.h - padding * 2;
if (drawable_w <= 0 or drawable_h <= 0) return;
Expand Down Expand Up @@ -715,7 +716,7 @@ fn renderTerminalScrollbar(
view.terminal_scrollbar.hideNow();
return;
};
const content_rect = terminalContentRect(rect) orelse {
const content_rect = terminalContentRect(rect, ui_scale) orelse {
view.terminal_scrollbar.hideNow();
return;
};
Expand All @@ -733,13 +734,14 @@ fn renderTerminalScrollbar(
view.terminal_scrollbar.markDrawn();
}

fn terminalContentRect(rect: Rect) ?Rect {
const padded_w = rect.w - terminal_padding * 2;
const padded_h = rect.h - terminal_padding * 2;
fn terminalContentRect(rect: Rect, ui_scale: f32) ?Rect {
const padding = dpi.scale(terminal_padding, ui_scale);
const padded_w = rect.w - padding * 2;
const padded_h = rect.h - padding * 2;
if (padded_w <= 0 or padded_h <= 0) return null;
return .{
.x = rect.x + terminal_padding,
.y = rect.y + terminal_padding,
.x = rect.x + padding,
.y = rect.y + padding,
.w = padded_w,
.h = padded_h,
};
Expand Down Expand Up @@ -820,7 +822,7 @@ fn renderGridSessionCached(
_ = c.SDL_SetRenderDrawColor(renderer, theme.background.r, theme.background.g, theme.background.b, 255);
_ = c.SDL_RenderClear(renderer);
const local_rect = Rect{ .x = 0, .y = 0, .w = rect.w, .h = rect.h };
try renderSessionContent(renderer, session, view, local_rect, scale, is_focused, font, term_cols, term_rows, current_time_ms, theme);
try renderSessionContent(renderer, session, view, local_rect, scale, is_focused, font, term_cols, term_rows, current_time_ms, theme, ui_scale);
if (any_waving and render_overlays) {
renderSessionOverlays(renderer, session, view, local_rect, is_focused, apply_effects, current_time_ms, true, theme, ui_scale);
}
Expand Down Expand Up @@ -852,7 +854,7 @@ fn renderGridSessionCached(
return;
}

try renderSessionContent(renderer, session, view, rect, scale, is_focused, font, term_cols, term_rows, current_time_ms, theme);
try renderSessionContent(renderer, session, view, rect, scale, is_focused, font, term_cols, term_rows, current_time_ms, theme, ui_scale);
cache_entry.presented_epoch = session.render_epoch;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/cwd_bar.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const marquee_speed: f32 = 30.0;
const fade_fade_width: c_int = 20;

pub fn reservedHeight(ui_scale: f32) c_int {
return dpi.scale(cwd_bar_height, ui_scale) + renderer_mod.grid_border_thickness;
return dpi.scale(cwd_bar_height, ui_scale) + dpi.scale(renderer_mod.grid_border_thickness, ui_scale);
}

pub fn minCellHeight(ui_scale: f32) c_int {
Expand Down Expand Up @@ -173,7 +173,7 @@ pub const CwdBarComponent = struct {
const cwd_basename = info.cwd_basename orelse return;

const bar_height = dpi.scale(cwd_bar_height, host.ui_scale);
const border_thickness = renderer_mod.grid_border_thickness;
const border_thickness = dpi.scale(renderer_mod.grid_border_thickness, host.ui_scale);
const padding = dpi.scale(cwd_padding, host.ui_scale);
const fade_width = dpi.scale(fade_fade_width, host.ui_scale);

Expand Down
7 changes: 4 additions & 3 deletions src/ui/components/session_interaction.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const input = @import("../../input/mapper.zig");
const open_url = @import("../../os/open.zig");
const geom = @import("../../geom.zig");
const renderer_mod = @import("../../render/renderer.zig");
const dpi = @import("../../dpi.zig");
const session_state = @import("../../session/state.zig");
const url_matcher = @import("../../url_matcher.zig");
const font_mod = @import("../../font.zig");
Expand Down Expand Up @@ -513,7 +514,7 @@ pub const SessionInteractionComponent = struct {
if (!session.spawned) return null;
const terminal = session.terminal orelse return null;
const session_rect = sessionRectForIndex(host, session_idx) orelse return null;
const content_rect = terminalContentRect(session_rect) orelse return null;
const content_rect = terminalContentRect(session_rect, host.ui_scale) orelse return null;
const bar = terminal.screens.active.pages.scrollbar();
const metrics = scrollbar.Metrics.init(
@as(f32, @floatFromInt(bar.total)),
Expand Down Expand Up @@ -1080,8 +1081,8 @@ fn sessionRectForIndex(host: *const types.UiHost, idx: usize) ?geom.Rect {
};
}

fn terminalContentRect(session_rect: geom.Rect) ?geom.Rect {
const padding = renderer_mod.terminal_padding;
fn terminalContentRect(session_rect: geom.Rect, ui_scale: f32) ?geom.Rect {
const padding = dpi.scale(renderer_mod.terminal_padding, ui_scale);
const w = session_rect.w - padding * 2;
const h = session_rect.h - padding * 2;
if (w <= 0 or h <= 0) return null;
Expand Down