summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/colors.zig67
-rw-r--r--src/config.zig9
-rw-r--r--src/draw.zig18
-rw-r--r--src/gui/gui.zig535
-rw-r--r--src/surface.zig26
-rw-r--r--src/themes/lapis.zig27
-rw-r--r--src/themes/lapis_plain.zig81
7 files changed, 19 insertions, 744 deletions
diff --git a/src/colors.zig b/src/colors.zig
index 90ed7b76..aec2917f 100644
--- a/src/colors.zig
+++ b/src/colors.zig
@@ -110,7 +110,7 @@ test "every native theme's separators stand off its page, and its focus tint off
}
test "every faithful port meets pardes's chrome floors in its own colours, with nothing left to derive" {
- const first = comptime indexOfTheme("lapis_plain") + 1;
+ const first = comptime indexOfTheme("lapis") + 1;
const last = comptime indexOfTheme("helix");
for (themes[first..last]) |*th| {
const chrome = ChromeTheme.fromTheme(th);
@@ -277,42 +277,6 @@ pub fn mix(a: [3]u8, b: [3]u8) [3]u8 {
return out;
}
-/// A theme's ornament, drawn by a pixel shell inside the chrome it already
-/// has (docs/render-pipeline.md §10: no gaps between panes): the lapis
-/// theme's. Sizes are logical pixels. None of it touches a focus indicator:
-/// the dots lie on the page's own ground, the checker in the scroll track
-/// (never its thumb), a tag's plaque inside its band beside its grip (and
-/// the focused one only the more striking), and the shadow under a file
-/// name's own letters.
-pub const Decor = struct {
- /// A dot grid on the page's ground, `page_dot_alpha` of 255 strong, a
- /// dot one logical pixel across (fading out by a pixel and a half) every
- /// `page_dot_px`, fixed to the window.
- page_dots: ?[3]u8 = null,
- page_dot_alpha: u8 = 0x22,
- page_dot_px: u8 = 22,
- /// A checker in the scroll track, squares of `rail_checker_px`, this
- /// colour and the track's.
- rail_checker: ?[3]u8 = null,
- rail_checker_px: u8 = 3,
- /// Every tag drawn as a raised plaque inside its own band (the site's
- /// trail and title bars): a `tag_border` frame round the text, a hard
- /// `tag_shadow` offset down and right by `tag_shadow_px`, both within
- /// the band's rows and columns, never past them; the focused pane's
- /// plaque striped `tag_stripe` and the tag's ground, `tag_stripe_px`
- /// each, its words on plates of the ground. Column and workspace tags
- /// take a quieter one (a one-pixel frame, a shadow of two, no stripes).
- tag_border: ?[3]u8 = null,
- tag_border_px: u8 = 2,
- tag_shadow: ?[3]u8 = null,
- tag_shadow_px: u8 = 5,
- tag_stripe: ?[3]u8 = null,
- tag_stripe_px: u8 = 2,
- /// The file name's offset shadow, down and right, in a pane's tag.
- title_shadow: ?[3]u8 = null,
- title_shadow_px: u8 = 2,
-};
-
pub const Theme = struct {
name: []const u8,
bg: ?[3]u8,
@@ -378,8 +342,6 @@ pub const Theme = struct {
/// in pixels at a 17px tagline, the thumb one narrower (acme's 12px
/// Scrollwid, the default).
rail_px: ?u8 = null,
- /// A pixel shell's ornament (Decor): lapis's.
- decor: ?Decor = null,
};
/// One family, its twelve backgrounds a theme each (`curated`).
@@ -403,7 +365,6 @@ const curated = struct {
pub const orchard_black = @import("themes/orchard_black.zig");
pub const acme = @import("themes/acme.zig");
pub const lapis = @import("themes/lapis.zig");
- pub const lapis_plain = @import("themes/lapis_plain.zig");
// Faithful ports of well-known themes, a family at a time (src/themes/
// <name>.zig says where each value came from): `theme_groups`.
pub const dark_plus = @import("themes/dark_plus.zig");
@@ -483,15 +444,7 @@ fn fold(comptime C: type) [@typeInfo(C).@"struct".decl_names.len]Theme {
var t: Theme = undefined;
const source = @field(C, d).theme;
for (theme_info.field_names, theme_info.field_types, theme_info.field_attrs) |name, T, attrs| {
- @field(t, name) = if (T == ?Decor and @hasField(@TypeOf(source), name)) decor: {
- // A nested literal is folded field by field too.
- var decor: Decor = .{};
- const given = @field(source, name);
- for (@typeInfo(Decor).@"struct".field_names) |g| if (@hasField(@TypeOf(given), g)) {
- @field(decor, g) = @field(given, g);
- };
- break :decor decor;
- } else if (@hasField(@TypeOf(source), name))
+ @field(t, name) = if (@hasField(@TypeOf(source), name))
@field(source, name)
else if (attrs.defaultValue(T)) |value|
value
@@ -573,22 +526,6 @@ test "seoul256's twelve backgrounds ring in their order, after Catppuccin and be
try std.testing.expectEqualStrings("zenbones_light", themes[first + names.len].name);
}
-test "lapis_plain is lapis on flat grounds, framed and shadowed as lapis" {
- const lapis = themes[indexOfTheme("lapis")];
- const plain = themes[indexOfTheme("lapis_plain")];
- try std.testing.expectEqual(indexOfTheme("lapis") + 1, indexOfTheme("lapis_plain"));
- var same = plain;
- same.name = lapis.name;
- same.decor = lapis.decor;
- try std.testing.expectEqualDeep(lapis, same);
- const decor = plain.decor.?;
- try std.testing.expect(decor.page_dots == null and decor.tag_stripe == null);
- try std.testing.expectEqualDeep(lapis.decor.?.tag_border, decor.tag_border);
- try std.testing.expectEqualDeep(lapis.decor.?.tag_shadow, decor.tag_shadow);
- try std.testing.expectEqualDeep(lapis.decor.?.title_shadow, decor.title_shadow);
- try std.testing.expectEqualDeep(lapis.decor.?.rail_checker, decor.rail_checker);
-}
-
/// Original and classic-inspired Pardes palettes precede retained imports.
pub const native_theme_count = 15;
diff --git a/src/config.zig b/src/config.zig
index aea87230..3024fc5a 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -167,7 +167,6 @@ pub const leader_path = paths: {
if (builtins.capabilities.window_blur) table.set(.WindowBlur, null);
if (builtins.capabilities.ligatures) table.set(.Ligatures, null);
if (builtins.capabilities.lift) table.set(.CursorBlink, null);
- if (builtins.capabilities.lift) table.set(.Parallax, null);
table.set(.ProgramEsc, null);
table.set(.Motion, null);
if (builtins.capabilities.lift) table.set(.GripWidth, null);
@@ -724,9 +723,6 @@ pub const Runtime = struct {
/// solid while typing and for half a second after, eased at each edge,
/// solid again after ten idle seconds.
cursor_blink: bool = true,
- /// G13: a theme's page pattern under the bodies (lapis's dots) moves
- /// with the text at a quarter of its speed, a pixel shell's.
- parallax: bool = false,
/// In a raw terminal, Esc goes to the program and Shift-Esc backs out
/// (off, the default: Esc backs out and Shift-Esc is the program's).
program_esc: bool = false,
@@ -871,7 +867,7 @@ pub const Runtime = struct {
/// The message timings a setting word sets, each in milliseconds.
pub const MessageTime = enum { linger, fall, dissolve };
- pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, parallax, program_esc };
+ pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, syntax_bold, pager_color, verbose, message_animation, ligatures, cursor_blink, program_esc };
pub const Action = union(enum) {
toggle: Toggle,
@@ -917,7 +913,7 @@ pub const Runtime = struct {
.grip_width => .lift,
.toggle => |field| switch (field) {
.ligatures => .ligatures,
- .cursor_blink, .parallax => .lift,
+ .cursor_blink => .lift,
else => null,
},
else => null,
@@ -937,7 +933,6 @@ pub const Runtime = struct {
.{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation }, .doc = "A message falls into its row and dissolves out of it, on or off." },
.{ .word = "Ligatures", .action = .{ .toggle = .ligatures }, .doc = "A font's programming ligatures draw across their cells, on or off." },
.{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .doc = "The cursor blinks, solid while typing, on or off." },
- .{ .word = "Parallax", .action = .{ .toggle = .parallax }, .doc = "A theme's page pattern moves with the text at a quarter of its speed, on or off." },
.{ .word = "ProgramEsc", .action = .{ .toggle = .program_esc }, .doc = "In a raw terminal, Esc goes to the program and Shift-Esc backs out, on; off (the default) swaps them." },
.{ .word = "Motion", .action = .motion, .doc = "How animations move: off, crisp, smooth, bouncy or playful." },
.{ .word = "GripWidth", .action = .grip_width, .doc = "The grip and scrollbar width, as a percent of the theme's rail." },
diff --git a/src/draw.zig b/src/draw.zig
index 015d2def..d299b03f 100644
--- a/src/draw.zig
+++ b/src/draw.zig
@@ -373,25 +373,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface {
.grip_dirty = boxDirty(p),
.tag_rule = p.theme().tag_rule,
.rail_px = @intCast(@min(255, @as(u32, p.theme().rail_px orelse 12) * p.settings.grip_width / 100)),
- .name_ink = chrome.tag_name_fg,
- .active_name_ink = if (p.settings.focus_tint) chrome.tag_active_name_fg else chrome.tag_name_fg,
- .fx = @as(u8, @intFromBool(p.settings.parallax)) << 3,
};
- if (p.theme().decor) |decor| {
- s.chrome.decor_dots = decor.page_dots;
- s.chrome.decor_dot_alpha = decor.page_dot_alpha;
- s.chrome.decor_dot_px = decor.page_dot_px;
- s.chrome.decor_checker = decor.rail_checker;
- s.chrome.decor_checker_px = decor.rail_checker_px;
- s.chrome.decor_box_border = decor.tag_border;
- s.chrome.decor_box_border_px = decor.tag_border_px;
- s.chrome.decor_box_shadow = decor.tag_shadow;
- s.chrome.decor_box_shadow_px = decor.tag_shadow_px;
- s.chrome.decor_box_stripe = decor.tag_stripe;
- s.chrome.decor_box_stripe_px = decor.tag_stripe_px;
- s.chrome.decor_title = decor.title_shadow;
- s.chrome.decor_title_px = decor.title_shadow_px;
- }
place(p, s);
// Separators have their own role; a scrollbar need not frame the page.
const whole = s.regions[0].rect;
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 24b15b35..4f82d246 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -425,10 +425,8 @@ const CellInstance = extern struct {
br: f32,
bg: f32,
bb: f32,
- /// The flags (the high bits, ui.vert.glsl), and the theme's dots'
- /// offset (G13's parallax) as a float's bits.
+ /// The flags (the high bits, ui.vert.glsl).
effect: u32 = 0,
- serial: u32 = 0,
/// A clip rectangle in target pixels; x1 < x0 is none (ui.vert.glsl).
clip_x0: f32 = 0,
clip_y0: f32 = 0,
@@ -457,14 +455,7 @@ const ImageInstance = extern struct {
v1: f32,
};
-const clear_bg_bit: u32 = 0x4000_0000;
const opaque_bg_bit: u32 = 0x2000_0000;
-/// Decor that is a checker (decor.frag.glsl).
-const checker_bit: u32 = 0x0800_0000;
-/// A cell on the page's ground under the theme's dots, and a file name's
-/// cell that casts the theme's shadow (ui.frag.glsl, Chrome.decor_*).
-const dotted_bit: u32 = 0x1000_0000;
-const title_bit: u32 = 0x0800_0000;
const PreparedImage = struct {
place: pardes.ImagePlace,
@@ -472,9 +463,9 @@ const PreparedImage = struct {
};
test "the shader instance ABI: the flags after the colours, the clip after them" {
- try std.testing.expectEqual(@as(usize, 80), @sizeOf(CellInstance));
+ try std.testing.expectEqual(@as(usize, 76), @sizeOf(CellInstance));
try std.testing.expectEqual(@as(usize, 56), @offsetOf(CellInstance, "effect"));
- try std.testing.expectEqual(@as(usize, 64), @offsetOf(CellInstance, "clip_x0"));
+ try std.testing.expectEqual(@as(usize, 60), @offsetOf(CellInstance, "clip_x0"));
try std.testing.expectEqual(@as(usize, 32), @sizeOf(ImageInstance));
}
@@ -949,10 +940,6 @@ const Gui = struct {
device: *c.SDL_GPUDevice,
swapchain_format: c.SDL_GPUTextureFormat,
pipeline: *c.SDL_GPUGraphicsPipeline,
- /// The cell pipeline, blending premultiplied over what is drawn under:
- /// for a frame with a theme's tag plaques, whose blank tag cells let
- /// them show (tagPlaques).
- pipeline_over: *c.SDL_GPUGraphicsPipeline,
decor_pipeline: *c.SDL_GPUGraphicsPipeline,
overlay_pipeline: *c.SDL_GPUGraphicsPipeline,
image_pipeline: *c.SDL_GPUGraphicsPipeline,
@@ -1283,9 +1270,6 @@ const Group = struct {
image_count: u32 = 0,
decor_start: u32 = 0,
decor_count: u32 = 0,
- /// The first `under_count` of the group's decor are drawn before its
- /// cells, under them (a theme's tag plaques, whose cells let them show).
- under_count: u32 = 0,
};
/// The frame's draw groups, bottom to top: the page and the panes, the
@@ -1562,7 +1546,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
const atlas_xfer = c.SDL_CreateGPUTransferBuffer(device, &ax_info) orelse return error.GpuCreate;
const pipeline = try makePipeline(device, swapchain_format, vert_spv, frag_spv, 1, 1, cell_input, std.mem.zeroes(c.SDL_GPUColorTargetBlendState));
- const pipeline_over = try makePipeline(device, swapchain_format, vert_spv, frag_spv, 1, 1, cell_input, premultipliedBlend());
const decor_pipeline = try makePipeline(device, swapchain_format, vert_spv, decor_frag_spv, 0, 1, cell_input, backgroundLayerBlend());
const overlay_pipeline = try makePipeline(device, swapchain_format, overlay_vert_spv, overlay_frag_spv, 0, 1, overlay_input, backgroundLayerBlend());
const image_pipeline = try makePipeline(device, swapchain_format, image_vert_spv, image_frag_spv, 1, 1, image_input, backgroundLayerBlend());
@@ -1587,7 +1570,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
.device = device,
.swapchain_format = swapchain_format,
.pipeline = pipeline,
- .pipeline_over = pipeline_over,
.decor_pipeline = decor_pipeline,
.overlay_pipeline = overlay_pipeline,
.image_pipeline = image_pipeline,
@@ -1629,7 +1611,6 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, headless: bool, di
// regrown to; the image ones are released below.
defer {
c.SDL_ReleaseGPUGraphicsPipeline(device, g.pipeline);
- c.SDL_ReleaseGPUGraphicsPipeline(device, g.pipeline_over);
c.SDL_ReleaseGPUGraphicsPipeline(device, g.decor_pipeline);
c.SDL_ReleaseGPUGraphicsPipeline(device, g.overlay_pipeline);
c.SDL_ReleaseGPUTexture(device, g.atlas_tex);
@@ -5422,32 +5403,6 @@ fn renderFrame(
// this frame against the last (the glide follows it from there).
if (g.glide.pending) g.glide.measure(gpa, surface);
if (g.glide.moving()) g.glide.advance(g.glide.now_ns, g.glide.motion);
- cell_decor = CellDecor.of(chrome);
- plaque_through_len = 0;
- // G13: a body's dots follow its text at a quarter of its speed: its
- // first line, and a glide's picture offset, in rows.
- if (chrome.fx & 8 != 0 and chrome.decor_dots != null) for (surface.regionList()) |region| {
- if (region.kind != .body or cell_decor.nbodies == cell_decor.bodies.len) continue;
- var rows: f32 = @floatFromInt(region.line);
- if (g.glide.moving() and g.glide.pane == region.owner) rows += g.glide.follow.offset;
- const period = cell_decor.uniforms[4];
- cell_decor.bodies[cell_decor.nbodies] = bodyPixels(region, layout);
- cell_decor.shifts[cell_decor.nbodies] = @mod(-rows * layout.h * 0.25, period);
- cell_decor.nbodies += 1;
- };
- // Plaques need an opaque window: with WindowOpacity under 100 the cells
- // are drawn as they are, and the plaques not at all.
- cell_decor.plaques_off = backgroundOpacity(g.applied_window_opacity) < 1;
- if (chrome.decor_box_border != null and !cell_decor.plaques_off) {
- cell_decor.grounds = .{ chrome.tag_bg, chrome.tag_focus_bg };
- for (surface.regionList()) |region| {
- if (region.kind != .tag and region.kind != .column_tag and region.kind != .workspace_tag) continue;
- if (cell_decor.nplaques == cell_decor.plaques.len) break;
- const plaque = plaqueBox(g, chrome, surface.regionList(), region, layout, win_w, win_h) orelse continue;
- cell_decor.plaques[cell_decor.nplaques] = plaque.band;
- cell_decor.nplaques += 1;
- }
- }
var groups: Groups = .{};
// While the cursor glides or blinks the cells' cursors are not drawn;
// the focused one is the overlay's quad. One or the other every frame
@@ -5592,25 +5547,6 @@ fn renderFrame(
const scrolling: ?usize = if (g.glide.follow.offset != 0) g.glide.pane else g.scroll_pane;
const held: u16 = if (scrolling) |id| if (core.panes[id]) |pane| pane.context_rows else 0 else 0;
shifted = emitScrollRows(g, instances, cell_total, surface, layout, win_w, win_h, page, held);
- // Over a theme's plaques a see-through cell with no ink blends to
- // the plaque under it, so it draws nothing: its quad goes, and the
- // cells are drawn unblended (a third of the GPU's frame at 4K)
- // unless one see-through cell does have ink, or the page itself is
- // see-through.
- if (cell_decor.nplaques != 0) {
- const space_u = @as(f32, @floatFromInt(g.space_slot.u)) / @as(f32, @floatFromInt(atlas_w));
- const space_v = @as(f32, @floatFromInt(g.space_slot.v)) / @as(f32, @floatFromInt(atlas_h));
- if (plaque_through_len > plaque_through.len) cell_decor.inked_clear = true;
- for (plaque_through[0..@min(plaque_through_len, plaque_through.len)]) |at| {
- const instance = &instances[at];
- // A grip's button takes its cell's ground back (emitSurfaceCell).
- if (instance.effect & clear_bg_bit == 0) continue;
- if (instance.u0 == space_u and instance.v0 == space_v) {
- instance.x1 = instance.x0;
- instance.y1 = instance.y0;
- } else cell_decor.inked_clear = true;
- }
- }
@memcpy(instances[cell_total + shifted ..][0..decor_len], g.decor.items);
c.SDL_UnmapGPUTransferBuffer(g.device, g.vxfer.?);
@@ -5631,18 +5567,9 @@ fn renderFrame(
const whole = c.SDL_Rect{ .x = 0, .y = 0, .w = @intCast(sw), .h = @intCast(sh) };
const decor_base = cell_total + shifted;
for (groups.items[0..groups.len], 0..) |group, index| {
- if (group.under_count != 0 and g.vbuf != null) {
- c.SDL_BindGPUGraphicsPipeline(rp, g.decor_pipeline);
- pushLayerOpacity(cmd, rp, background_opacity);
- const binding = c.SDL_GPUBufferBinding{ .buffer = g.vbuf.?, .offset = (decor_base + group.decor_start) * @sizeOf(CellInstance) };
- c.SDL_BindGPUVertexBuffers(rp, 0, &binding, 1);
- c.SDL_DrawGPUPrimitives(rp, 6, group.under_count, 0, 0);
- }
const has_shifted = index == 0 and shifted != 0;
if ((group.cell_count != 0 or has_shifted) and g.vbuf != null) {
- // Blended over what is under: a theme's plaques show through
- // blank tag cells.
- c.SDL_BindGPUGraphicsPipeline(rp, if (cell_decor.inked_clear) g.pipeline_over else g.pipeline);
+ c.SDL_BindGPUGraphicsPipeline(rp, g.pipeline);
const samp_binding = c.SDL_GPUTextureSamplerBinding{ .texture = g.atlas_tex, .sampler = g.atlas_sampler };
c.SDL_BindGPUFragmentSamplers(rp, 0, &samp_binding, 1);
if (group.cell_count != 0) {
@@ -5660,13 +5587,13 @@ fn renderFrame(
}
}
if (group.image_count != 0) drawNativeImagesGpu(g, rp, group, whole);
- if (group.decor_count > group.under_count and g.vbuf != null) {
+ if (group.decor_count != 0 and g.vbuf != null) {
c.SDL_BindGPUGraphicsPipeline(rp, g.decor_pipeline);
// Ink keeps its colour at any WindowOpacity.
pushLayerOpacity(cmd, rp, if (index == groups.ink) 1 else background_opacity);
- const binding = c.SDL_GPUBufferBinding{ .buffer = g.vbuf.?, .offset = (decor_base + group.decor_start + group.under_count) * @sizeOf(CellInstance) };
+ const binding = c.SDL_GPUBufferBinding{ .buffer = g.vbuf.?, .offset = (decor_base + group.decor_start) * @sizeOf(CellInstance) };
c.SDL_BindGPUVertexBuffers(rp, 0, &binding, 1);
- c.SDL_DrawGPUPrimitives(rp, 6, group.decor_count - group.under_count, 0, 0);
+ c.SDL_DrawGPUPrimitives(rp, 6, group.decor_count, 0, 0);
}
}
drawOverlayGpu(g, cmd, rp, overlay_count);
@@ -5898,9 +5825,6 @@ fn emitTagLayer(g: *Gui, instances: [*]CellInstance, next: *u32, layer: *const p
const y = layer.viewport.y + @as(u16, @intCast(index));
const top = @as(f32, @floatFromInt(y)) * bh;
emitInstance(g, instances, next.*, 0, y, .{ .w = band_right - left, .h = bh, .x_off = left, .y_off = slide }, win_w, win_h, .body, (&background)[0..1], 0, null, false, page);
- // A theme's plaque is drawn under the band: the band's own ground
- // lets it show (tagPlaques).
- if (cell_decor.nplaques != 0 and cell_decor.inPlaque(left + 0.5, top + 0.5)) plaqueThrough(instances, next.*);
if (slide != 0) clipInstance(&instances[next.*], .{ -1e9, top, 1e9, 1e9 }, win_w, win_h);
next.* += 1;
const cells = layer.cells[index * layer.cols ..][0..layer.cols];
@@ -6067,13 +5991,6 @@ fn emitSurfaceCell(
// this underlay at tagline height leaves page-colored gutters between
// adjacent workspace, column and pane tags at TaglineSize < 100.
emitInstance(g, instances, next.*, col, row, body_layout, win_w, win_h, .body, (&band_base)[0..1], 0, null, false, page);
- // Over a theme's plaque the underlay lets it show (tagPlaques),
- // in a grip's cell too where the plaque reaches into it past the
- // button (which is drawn over the cells).
- const cell_x = @as(f32, @floatFromInt(col)) * body_layout.w + body_layout.x_off;
- const cell_y = @as(f32, @floatFromInt(row)) * body_layout.h + body_layout.y_off + 0.5;
- if (cell_decor.nplaques != 0 and cell_decor.inPlaque(if (here.grip) cell_x + body_layout.w - 0.5 else cell_x + 0.5, cell_y))
- plaqueThrough(instances, next.*);
next.* += 1;
// Tag glyphs keep their font size inside a full physical-width grip.
// A pane's grip cells are the cell shells' form (a dirty `*`): the
@@ -6134,7 +6051,6 @@ fn emitSurfaceCell(
base.bg = own[1];
base.bb = own[2];
}
- base.effect &= ~clear_bg_bit;
clipInstance(base, .{ b[0], -1e9, b[2], 1e9 }, win_w, win_h);
// Over it, only its own glyph; the band round it and the ring
// are decor (gripDecor).
@@ -6144,12 +6060,10 @@ fn emitSurfaceCell(
instances[next.*].v0 = @as(f32, @floatFromInt(g.space_slot.v)) / atlas_h;
instances[next.*].v1 = @as(f32, @floatFromInt(g.space_slot.v + g.tagline_height)) / atlas_h;
}
- // Its ground is the fill again (a see-through ground would be
- // written, not blended, in an opaque window).
+ // Its ground is the fill again.
instances[next.*].br = base.br;
instances[next.*].bg = base.bg;
instances[next.*].bb = base.bb;
- instances[next.*].effect &= ~clear_bg_bit;
clipInstance(&instances[next.*], b, win_w, win_h);
} else if (inset > 0) {
instances[next.*].x0 += @as(f32, @floatFromInt(inset)) / win_w * 2;
@@ -6334,27 +6248,6 @@ fn emitInstance(
// A block cursor is foreground UI ink, even though its color is carried
// in the reversed cell background. Keep it visible at WindowOpacity 0.
if (is_cursor) instances[idx].effect |= opaque_bg_bit;
- // The theme's ornament (cell_decor): dots on the page's own ground, a
- // shadow under a file name's letters. Never on a cursor.
- if (!is_cursor) {
- // A blank cell on a tag's ground inside a plaque: the plaque shows.
- if (cell_decor.nplaques != 0 and resolved.role == .tagline and cellCodepoint(&line[at]) == ' ' and
- (std.mem.eql(u8, &resolved.bg, &cell_decor.grounds[0]) or std.mem.eql(u8, &resolved.bg, &cell_decor.grounds[1])) and
- (cell_decor.inPlaque(px0 + 0.5, py0 + 0.5) or cell_decor.inPlaque(px0 + layout.w - 0.5, py0 + 0.5)))
- plaqueThrough(instances, idx);
- if (cell_decor.dots) |dotted| {
- if (std.mem.eql(u8, &resolved.bg, &dotted)) {
- instances[idx].effect |= dotted_bit;
- // G13: the dots under a body move with its text, a quarter
- // as far; the serial slot carries it (the shader reads it
- // as the dots' offset alone).
- instances[idx].serial = @bitCast(cell_decor.parallaxAt(px0 + 0.5, py0 + 0.5));
- }
- }
- if (cell_decor.title) |inks| {
- if (resolved.role == .tagline and (std.mem.eql(u8, &resolved.fg, &inks[0]) or std.mem.eql(u8, &resolved.fg, &inks[1]))) instances[idx].effect |= title_bit;
- }
- }
}
test "block cursor alone overrides transparent cell background" {
@@ -6367,125 +6260,6 @@ test "block cursor alone overrides transparent cell background" {
}
}
-test "lapis dots only the page's own ground and shadows only a file name, never a cursor" {
- var g = testGui(10, 20, 8, 16);
- const page: [3]u8 = .{ 0x0a, 0x10, 0x30 };
- const name: [3]u8 = .{ 0xe8, 0xc4, 0x6a };
- var chrome: pardes.Chrome = .{ .page = page, .decor_dots = .{ 1, 2, 3 }, .decor_dot_alpha = 0x22, .decor_title = .{ 4, 5, 6 }, .name_ink = name, .active_name_ink = name };
- cell_decor = CellDecor.of(&chrome);
- defer cell_decor = .{};
- const on_page: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 200, 200, 200 } }, .bg = .{ .rgb = page } } };
- const selected: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 0, 0, 0 } }, .bg = .{ .rgb = name } } };
- const title: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = name }, .bg = .{ .rgb = .{ 0x0f, 0x1a, 0x4a } }, .font_role = .tagline } };
- const plain_tag: pardes.Cell = .{ .default = false, .style = .{ .fg = .{ .rgb = .{ 0x9a, 0xa6, 0xd9 } }, .bg = .{ .rgb = .{ 0x0f, 0x1a, 0x4a } }, .font_role = .tagline } };
- var instances: [1]CellInstance = undefined;
- const Case = struct { cell: pardes.Cell, role: pardes.FontRole, cursor: bool, dotted: bool, shadowed: bool };
- for ([_]Case{
- .{ .cell = on_page, .role = .body, .cursor = false, .dotted = true, .shadowed = false },
- .{ .cell = on_page, .role = .body, .cursor = true, .dotted = false, .shadowed = false },
- .{ .cell = selected, .role = .body, .cursor = false, .dotted = false, .shadowed = false },
- .{ .cell = title, .role = .tagline, .cursor = false, .dotted = false, .shadowed = true },
- .{ .cell = title, .role = .tagline, .cursor = true, .dotted = false, .shadowed = false },
- .{ .cell = plain_tag, .role = .tagline, .cursor = false, .dotted = false, .shadowed = false },
- }) |case| {
- emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, case.role, (&case.cell)[0..1], 0, null, case.cursor, page);
- try std.testing.expectEqual(case.dotted, instances[0].effect & dotted_bit != 0);
- try std.testing.expectEqual(case.shadowed, instances[0].effect & title_bit != 0);
- }
- // A theme without decor marks nothing.
- chrome = .{ .page = page };
- cell_decor = CellDecor.of(&chrome);
- emitInstance(&g, &instances, 0, 0, 0, fixedCellLayout(&g), 800, 480, .body, (&on_page)[0..1], 0, null, false, page);
- try std.testing.expectEqual(@as(u32, 0), instances[0].effect & (dotted_bit | title_bit));
-}
-
-test "lapis plaques stay in their tag's band, clear of every grip; only the focused one is striped" {
- const gpa = std.testing.allocator;
- const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 });
- defer core.deinit();
- _ = try core.newShell(1, "");
- try std.testing.expect(pardes.layout.splitColumn(core, 0, 1, false));
- try std.testing.expect(core.executeBuiltinLine(0, "Theme lapis"));
- for (0..40) |_| core.update(.tick);
- core.sync();
- const s = try core.render(core.scratch.allocator());
- try std.testing.expect(s.chrome.decor_box_border != null and s.chrome.decor_checker != null and s.chrome.decor_dots != null and s.chrome.decor_title != null);
- var g = testGui(16, 32, 12, 22);
- defer g.decor.deinit(gpa);
- display_scale = 1;
- var groups: Groups = .{};
- try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 1280, 768, true);
- const layout = fixedCellLayout(&g);
- const under = g.decor.items[groups.items[0].decor_start..][0..groups.items[0].under_count];
- try std.testing.expect(under.len != 0);
- var stripes: usize = 0;
- var shadows: usize = 0;
- for (under) |item| {
- const r: [4]f32 = .{ (item.x0 + 1) / 2 * 1280, (1 - item.y0) / 2 * 768, (item.x1 + 1) / 2 * 1280, (1 - item.y1) / 2 * 768 };
- // Inside one tag's band, whole: never on a body, a grip or the
- // next pane. A box stacked under another tag's lays its top frame
- // over their shared edge, its own width up into the band above.
- const home = for (s.regionList()) |region| {
- if (region.kind != .tag and region.kind != .column_tag and region.kind != .workspace_tag) continue;
- const band = plaqueBox(&g, &s.chrome, s.regionList(), region, layout, 1280, 768) orelse continue;
- if (r[0] >= band.band[0] - 0.01 and r[1] >= band.band[1] - band.border - 0.01 and r[2] <= band.band[2] + 0.01 and r[3] <= band.band[3] + 0.01) break region;
- } else return error.PlaqueOutsideItsBand;
- // Clear of every grip's button: a plaque starts flush against it,
- // in the gap between it and the text.
- for (s.regionList()) |grip| {
- if (grip.kind != .grip and grip.kind != .column_grip) continue;
- const column = scrollColumn(&g, &s.chrome, grip.rect.x, layout);
- const gx0 = column[0];
- const gx1 = column[1];
- const gy0 = @as(f32, @floatFromInt(grip.rect.y)) * 32;
- const gy1 = @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * 32;
- try std.testing.expect(r[2] <= gx0 + 0.01 or r[0] >= gx1 - 0.01 or r[3] <= gy0 + 0.01 or r[1] >= gy1 - 0.01);
- }
- if (item.effect & checker_bit != 0) {
- try std.testing.expect(home.kind == .tag and home.active);
- stripes += 1;
- }
- const rgb: [3]u8 = .{ @intFromFloat(@round(item.br * 255)), @intFromFloat(@round(item.bg * 255)), @intFromFloat(@round(item.bb * 255)) };
- if (std.mem.eql(u8, &rgb, &s.chrome.decor_box_shadow.?)) shadows += 1;
- }
- try std.testing.expectEqual(@as(usize, 1), stripes);
- try std.testing.expect(shadows >= 2);
- // Stacked boxes share an edge and line up: a column's box spans its
- // first pane's across, runs down to the edge that pane's frame lies
- // over, and no shadow reaches the next column.
- var stacks: usize = 0;
- for (s.regionList()) |column| {
- if (column.kind != .column_tag) continue;
- const upper = plaqueBox(&g, &s.chrome, s.regionList(), column, layout, 1280, 768).?;
- for (s.regionList()) |tag| {
- if (tag.kind != .tag or tag.rect.y != column.rect.y + column.rect.h or tag.rect.x + tag.rect.w != column.rect.x + column.rect.w) continue;
- const lower = plaqueBox(&g, &s.chrome, s.regionList(), tag, layout, 1280, 768).?;
- try std.testing.expectEqual(upper.box[0], lower.box[0]);
- // Flush against the grips' buttons, which line up too.
- const grip = for (s.regionList()) |part| {
- if (part.kind == .grip and part.owner == tag.owner) break part;
- } else unreachable;
- try std.testing.expectEqual(scrollColumn(&g, &s.chrome, grip.rect.x, layout)[1], lower.box[0]);
- try std.testing.expectEqual(upper.box[2], lower.box[2]);
- try std.testing.expectEqual(upper.band[3], upper.box[3]);
- try std.testing.expectEqual(lower.band[1] - lower.border, lower.box[1]);
- try std.testing.expectEqual(@as(f32, 0), upper.shadow[1]);
- if (lower.band[2] < 1280) try std.testing.expect(lower.box[2] + lower.shadow[0] < lower.band[2]);
- stacks += 1;
- }
- }
- try std.testing.expectEqual(@as(usize, 2), stacks);
- // The scroll track is chequered.
- var checkers: usize = 0;
- for (g.decor.items[groups.items[0].decor_start + groups.items[0].under_count ..]) |item| checkers += @intFromBool(item.effect & checker_bit != 0);
- try std.testing.expect(checkers >= 1);
- // No other theme draws any of it.
- try std.testing.expect(core.executeBuiltinLine(0, "Theme forge"));
- for (0..40) |_| core.update(.tick);
- const plain = try core.render(core.scratch.allocator());
- try std.testing.expect(plain.chrome.decor_box_border == null and plain.chrome.decor_checker == null and plain.chrome.decor_dots == null and plain.chrome.decor_title == null);
-}
-
fn cellCodepoint(cell: *const pardes.Cell) u32 {
const grapheme = cell.grapheme();
return if (cell.default or grapheme.len == 0) ' ' else firstCp(grapheme);
@@ -6785,7 +6559,6 @@ fn testGui(cell_w: u32, cell_h: u32, tagline_width: u32, tagline_height: u32) Gu
.device = undefined,
.swapchain_format = undefined,
.pipeline = undefined,
- .pipeline_over = undefined,
.decor_pipeline = undefined,
.overlay_pipeline = undefined,
.image_pipeline = undefined,
@@ -7276,7 +7049,7 @@ const cell_input: VertexInput = .{ .pitch = @sizeOf(CellInstance), .rate = c.SDL
.{ .location = 1, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "u0") },
.{ .location = 2, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "fr") },
.{ .location = 3, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3, .offset = @offsetOf(CellInstance, "br") },
- .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT2, .offset = @offsetOf(CellInstance, "effect") },
+ .{ .location = 4, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_UINT, .offset = @offsetOf(CellInstance, "effect") },
.{ .location = 5, .buffer_slot = 0, .format = c.SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4, .offset = @offsetOf(CellInstance, "clip_x0") },
} };
@@ -7329,20 +7102,6 @@ pub fn makePipeline(
return c.SDL_CreateGPUGraphicsPipeline(device, &info) orelse error.GpuCreate;
}
-/// Premultiplied over: an opaque cell writes itself exactly, a see-through
-/// one only its ink.
-fn premultipliedBlend() c.SDL_GPUColorTargetBlendState {
- var blend = std.mem.zeroes(c.SDL_GPUColorTargetBlendState);
- blend.src_color_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE;
- blend.dst_color_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
- blend.color_blend_op = c.SDL_GPU_BLENDOP_ADD;
- blend.src_alpha_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE;
- blend.dst_alpha_blendfactor = c.SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
- blend.alpha_blend_op = c.SDL_GPU_BLENDOP_ADD;
- blend.enable_blend = true;
- return blend;
-}
-
fn backgroundLayerBlend() c.SDL_GPUColorTargetBlendState {
var blend = std.mem.zeroes(c.SDL_GPUColorTargetBlendState);
blend.src_color_blendfactor = c.SDL_GPU_BLENDFACTOR_SRC_ALPHA;
@@ -7672,24 +7431,6 @@ fn addDecor(g: *Gui, gpa: std.mem.Allocator, x0_in: f32, y0_in: f32, x1_in: f32,
});
}
-/// A checker (decor.frag.glsl): squares of `px` window pixels in `a` and
-/// `b` from the quad's corner (lapis's scroll track); `stripes`, bands of
-/// `px` across it instead (lapis's focused title bar), `a` first.
-fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f32, a: [3]u8, b: [3]u8, px: f32, stripes: bool, win_w: f32, win_h: f32) !void {
- const first = g.decor.items.len;
- try addDecor(g, gpa, x0, y0, x1, y1, a, 1, win_w, win_h);
- if (g.decor.items.len == first) return;
- const instance = &g.decor.items[first];
- instance.u0 = px;
- instance.u1 = px;
- instance.v0 = if (stripes) 1 else 0;
- instance.v1 = if (stripes) 1 else 0;
- instance.fr = @as(f32, @floatFromInt(b[0])) / 255.0;
- instance.fg = @as(f32, @floatFromInt(b[1])) / 255.0;
- instance.fb = @as(f32, @floatFromInt(b[2])) / 255.0;
- instance.effect |= checker_bit;
-}
-
/// A body region in window pixels.
fn bodyPixels(region: pardes.Region, layout: CellLayout) [4]f32 {
return .{
@@ -7711,9 +7452,6 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
for (groups.items[0..groups.len], 0..) |*group, index| {
group.decor_start = @intCast(g.decor.items.len);
defer group.decor_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start;
- // Under the cells: a theme's tag plaques.
- if (index == 0) try tagPlaques(g, gpa, regions, chrome, layout, win_w, win_h);
- group.under_count = @as(u32, @intCast(g.decor.items.len)) - group.decor_start;
if (index == 0) {
// The grips' buttons before any rule: the rules over their rows
// cut them, and the band round them never covers a rule.
@@ -7833,10 +7571,7 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
// the track edges it.
const column = scrollColumn(g, chrome, rail.rect.x, layout);
try addDecor(g, gpa, x0, y0, x0 + layout.w, y1, page, 1, win_w, win_h);
- if (chrome.decor_checker) |gold|
- try addPattern(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, gold, dp(@floatFromInt(@max(1, chrome.decor_checker_px))), false, win_w, win_h)
- else
- try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, win_w, win_h);
+ try addDecor(g, gpa, column[0], y0, column[1], y1, chrome.scroll_track, 1, win_w, win_h);
if (rail.thumb_h != 0 and rail.thumb_span > 0) {
// In pixels, not rows, and with the picture while it glides
// or lags behind the core's rows (both in rows of the body).
@@ -7899,235 +7634,11 @@ fn updateDisplayScale(window: *c.SDL_Window) void {
display_scale = std.math.clamp(display_scale, 1, 4);
}
-/// A theme's ornament as the cell shader draws it (Chrome.decor_*), for the
-/// frame being built: renderFrame sets it, writing a cell marks the cells
-/// it falls on, and pushLayerOpacity hands the shader its colours and
-/// sizes. ponytail: one window per process, as display_scale.
-var cell_decor: CellDecor = .{};
-/// The cells this frame lets a plaque show through, by instance, for
-/// renderFrame to drop the ones with no ink. Past its length the frame's
-/// cells are blended instead.
-var plaque_through: [16384]u32 = undefined;
-var plaque_through_len: usize = 0;
-
-fn plaqueThrough(instances: [*]CellInstance, at: u32) void {
- instances[at].effect |= clear_bg_bit;
- if (plaque_through_len < plaque_through.len) plaque_through[plaque_through_len] = at;
- plaque_through_len += 1;
-}
-const CellDecor = struct {
- /// The page's ground, when the theme dots it.
- dots: ?[3]u8 = null,
- /// A file name's inks in a tag, when the theme shadows it.
- title: ?[2][3]u8 = null,
- /// UiUniforms after background_opacity (ui.frag.glsl): the dots' colour
- /// and strength, their period and radii, the shadow's colour and offset.
- uniforms: [12]f32 = @splat(0),
- /// The tag plaques' bands (window pixels) and the tag grounds: a blank
- /// tag cell there lets its plaque show through (tagPlaques).
- plaques: [pardes.MAX_TAG_LAYERS][4]f32 = undefined,
- nplaques: usize = 0,
- grounds: [2][3]u8 = .{ .{ 0, 0, 0 }, .{ 0, 0, 0 } },
- plaques_off: bool = false,
- /// A see-through cell over the plaques has ink of its own, so this
- /// frame's cells are blended (renderFrame).
- inked_clear: bool = false,
-
- /// G13: each body's rectangle and how far its dots have moved.
- bodies: [pardes.MAX_PANES][4]f32 = undefined,
- shifts: [pardes.MAX_PANES]f32 = undefined,
- nbodies: usize = 0,
-
- fn parallaxAt(decor: *const CellDecor, x: f32, y: f32) f32 {
- for (decor.bodies[0..decor.nbodies], decor.shifts[0..decor.nbodies]) |band, shift|
- if (x >= band[0] and x < band[2] and y >= band[1] and y < band[3]) return shift;
- return 0;
- }
-
- fn inPlaque(decor: *const CellDecor, x: f32, y: f32) bool {
- for (decor.plaques[0..decor.nplaques]) |band|
- if (x >= band[0] and x < band[2] and y >= band[1] and y < band[3]) return true;
- return false;
- }
-
- fn of(chrome: *const pardes.Chrome) CellDecor {
- var out: CellDecor = .{};
- if (chrome.decor_dots) |rgb| if (chrome.page) |page| {
- out.dots = page;
- out.uniforms[0..4].* = .{ unit(rgb[0]), unit(rgb[1]), unit(rgb[2]), unit(chrome.decor_dot_alpha) };
- out.uniforms[4..8].* = .{ dp(@floatFromInt(@max(2, chrome.decor_dot_px))), 0.75 * display_scale, 1.25 * display_scale, 0 };
- };
- if (chrome.decor_title) |rgb| {
- out.title = .{ chrome.name_ink, chrome.active_name_ink };
- out.uniforms[8..12].* = .{ unit(rgb[0]), unit(rgb[1]), unit(rgb[2]), dp(@floatFromInt(@max(1, chrome.decor_title_px))) };
- }
- return out;
- }
-
- fn unit(v: u8) f32 {
- return @as(f32, @floatFromInt(v)) / 255;
- }
-};
-
/// A logical pixel size in the display's pixels: rounded, at least one.
fn dp(logical: f32) f32 {
return @max(1, @round(logical * display_scale));
}
-/// A theme's tag plaques (Chrome.decor_box_*), drawn under the cells of
-/// group `index`: each pane tag, and with the still panes the column and
-/// workspace tags, becomes a framed box inside its own band with a hard
-/// shadow down and right that stays inside the band too, so it never falls
-/// on a body, a grip or the next pane. The focused pane's box is striped,
-/// its words on plates of the tag's ground (their cells stay opaque; the
-/// spaces between let the stripes through, emitInstance); a column or the
-/// workspace takes a quieter box, a one-pixel frame and a two-pixel shadow.
-fn tagPlaques(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, chrome: *const pardes.Chrome, layout: CellLayout, win_w: f32, win_h: f32) !void {
- const border_rgb = chrome.decor_box_border orelse return;
- if (cell_decor.plaques_off) return;
- const page = chrome.page orelse bg_default;
- // The workspace and column plaques first: a pane's plaque right under
- // them shares their bottom edge (plaqueBox) and draws its frame last.
- for ([_]bool{ false, true }) |panes| for (regions) |tag| {
- const pane = tag.kind == .tag;
- if (pane != panes) continue;
- if (!pane and tag.kind != .column_tag and tag.kind != .workspace_tag) continue;
- if (tag.rect.w == 0 or tag.rect.h == 0) continue;
- const plaque = plaqueBox(g, chrome, regions, tag, layout, win_w, win_h) orelse continue;
- const b = plaque.border;
- const sh = plaque.shadow;
- const fill = if (tag.active) chrome.tag_focus_bg else chrome.tag_bg;
- // The band's own ground, then the shadow, the frame and the fill,
- // each only where the ones over it leave it showing: all four are
- // opaque, so that is the same picture drawn once, not four times.
- const shadow: [4]f32 = .{ plaque.box[0] + sh[0], plaque.box[1] + sh[1], plaque.box[2] + sh[0], plaque.box[3] + sh[1] };
- const inner: [4]f32 = .{ plaque.box[0] + b, plaque.box[1] + b, plaque.box[2] - b, plaque.box[3] - b };
- try addDecorExcept(g, gpa, plaque.band, &.{ plaque.box, shadow }, page, win_w, win_h);
- const shadow_rgb = chrome.decor_box_shadow orelse border_rgb;
- try addDecorExcept(g, gpa, shadow, &.{plaque.box}, if (pane) shadow_rgb else mixRgb(shadow_rgb, page), win_w, win_h);
- try addDecorExcept(g, gpa, plaque.box, &.{inner}, border_rgb, win_w, win_h);
- if (pane and tag.active and chrome.decor_box_stripe != null)
- try addPattern(g, gpa, inner[0], inner[1], inner[2], inner[3], chrome.decor_box_stripe.?, fill, dp(@floatFromInt(@max(1, chrome.decor_box_stripe_px))), true, win_w, win_h)
- else
- try addDecor(g, gpa, inner[0], inner[1], inner[2], inner[3], fill, 1, win_w, win_h);
- };
-}
-
-/// Flat decor over `rect` (window pixels) less each of `holes`: up to four
-/// strips round the first hole's part of it, each less the rest.
-fn addDecorExcept(g: *Gui, gpa: std.mem.Allocator, rect: [4]f32, holes: []const [4]f32, rgb: [3]u8, win_w: f32, win_h: f32) std.mem.Allocator.Error!void {
- if (rect[0] >= rect[2] or rect[1] >= rect[3]) return;
- if (holes.len == 0) return addDecor(g, gpa, rect[0], rect[1], rect[2], rect[3], rgb, 1, win_w, win_h);
- const hole = holes[0];
- const x0 = @max(rect[0], hole[0]);
- const y0 = @max(rect[1], hole[1]);
- const x1 = @min(rect[2], hole[2]);
- const y1 = @min(rect[3], hole[3]);
- if (x0 >= x1 or y0 >= y1) return addDecorExcept(g, gpa, rect, holes[1..], rgb, win_w, win_h);
- for ([_][4]f32{
- .{ rect[0], rect[1], rect[2], y0 },
- .{ rect[0], y1, rect[2], rect[3] },
- .{ rect[0], y0, x0, y1 },
- .{ x1, y0, rect[2], y1 },
- }) |strip| try addDecorExcept(g, gpa, strip, holes[1..], rgb, win_w, win_h);
-}
-
-test "decor less its holes covers each pixel of the rest once and none of the holes" {
- const gpa = std.testing.allocator;
- var g = testGui(1, 1, 1, 1);
- defer g.decor.deinit(gpa);
- const holes = [_][4]f32{ .{ 3, 2, 9, 6 }, .{ 5, 4, 12, 8 }, .{ 30, 30, 40, 40 } };
- try addDecorExcept(&g, gpa, .{ 1, 1, 11, 10 }, &holes, .{ 1, 2, 3 }, 16, 12);
- for (0..12) |y| for (0..16) |x| {
- const px: f32 = @as(f32, @floatFromInt(x)) + 0.5;
- const py: f32 = @as(f32, @floatFromInt(y)) + 0.5;
- var hits: usize = 0;
- for (g.decor.items) |item| {
- const r: [4]f32 = .{ (item.x0 + 1) / 2 * 16, (1 - item.y0) / 2 * 12, (item.x1 + 1) / 2 * 16, (1 - item.y1) / 2 * 12 };
- hits += @intFromBool(px > r[0] and px < r[2] and py > r[1] and py < r[3]);
- }
- const in_rect = px > 1 and px < 11 and py > 1 and py < 10;
- const in_hole = for (holes) |h| {
- if (px > h[0] and px < h[2] and py > h[1] and py < h[3]) break true;
- } else false;
- try std.testing.expectEqual(@as(usize, @intFromBool(in_rect and !in_hole)), hits);
- };
-}
-
-const Plaque = struct { band: [4]f32, box: [4]f32, border: f32, shadow: [2]f32 };
-
-/// A tag's plaque in window pixels: its band (the rows, from after the
-/// grip to the end), the framed box round the tagline's text, and the
-/// frame's and the shadow's widths, the shadow cut to what the band's slack
-/// below the text and its right end leave. Null where there is no room.
-/// Tags stacked on each other (the workspace's over the columns', a
-/// column's over its first pane's) share one edge, the ruled one between
-/// their bands: the upper box runs down to it and casts no shadow down, the
-/// lower one's frame lies over it. Every box in a column spans the same
-/// pixels across, right of the grips, its shadow short of the next column.
-fn plaqueBox(g: *const Gui, chrome: *const pardes.Chrome, regions: []const pardes.Region, tag: pardes.Region, layout: CellLayout, win_w: f32, win_h: f32) ?Plaque {
- const pane = tag.kind == .tag;
- const first = tag.rect.y;
- const last = tag.rect.y + tag.rect.h - 1;
- // Flush against its grip's button, so the two read as one piece: the
- // gap between button and text (the scroll gap) is the plaque's, and so
- // is the cell before its text, so its frame is never under the first
- // letter. A column's plaque starts where the pane's under it does.
- const grip_kind: pardes.Region.Kind = if (tag.kind == .column_tag) .column_grip else .grip;
- const x0 = for (regions) |grip| {
- if (tag.kind != .workspace_tag and grip.kind == grip_kind and grip.owner == tag.owner)
- break scrollColumn(g, chrome, grip.rect.x, layout)[1];
- } else @as(f32, @floatFromInt(tag.rect.x)) * layout.w;
- const x1_cells = @as(f32, @floatFromInt(tag.rect.x + tag.rect.w)) * layout.w;
- const window_edge = win_w - x1_cells < layout.w;
- const x1 = if (window_edge) @max(x1_cells, win_w) else x1_cells;
- const stacked_on = tagBandAt(regions, tag, .above);
- const stacked_under = tagBandAt(regions, tag, .below);
- const row_top = @as(f32, @floatFromInt(first)) * layout.h;
- const row_bottom = @as(f32, @floatFromInt(last + 1)) * layout.h;
- const text_top = row_top + @as(f32, @floatFromInt(taglineBandOffset(first, win_h, g.cell_h, g.tagline_height)));
- const text_bottom = @as(f32, @floatFromInt(last)) * layout.h + @as(f32, @floatFromInt(taglineBandOffset(last, win_h, g.cell_h, g.tagline_height) + g.tagline_height));
- const border = @min(if (pane) dp(@floatFromInt(@max(1, chrome.decor_box_border_px))) else dp(1), @floor(text_top - row_top));
- if (border < 1) return null;
- // The shadow's full offset to the right; down, what the slack under the
- // text leaves (a pixel or three at a tagline under the body's size).
- const want: f32 = if (pane) dp(@floatFromInt(chrome.decor_box_shadow_px)) else dp(2);
- const drop = if (stacked_under) 0 else std.math.clamp(@floor(row_bottom - text_bottom - border), 0, want);
- // Every box ends where a pane's does, short of the next column's rule
- // by a pane frame's width past its shadow, so no shadow meets the rule
- // and a column's box lines up with its panes'; the window's edge needs
- // no gap.
- const pane_shadow = dp(@floatFromInt(chrome.decor_box_shadow_px));
- const gap = @max(0, pane_shadow - want) + if (window_edge) 0 else dp(@floatFromInt(@max(1, chrome.decor_box_border_px)));
- if (x1 - x0 < 4 * border + want + gap) return null;
- return .{
- .band = .{ x0, row_top, x1, row_bottom },
- .box = .{
- x0,
- if (stacked_on) row_top - border else text_top - border,
- x1 - want - gap,
- if (stacked_under) row_bottom else text_bottom + border,
- },
- .border = border,
- .shadow = .{ want, drop },
- };
-}
-
-/// Whether another tag's band (the workspace's, a column's, a pane's) meets
-/// `tag`'s right above or below it, across some of its width.
-fn tagBandAt(regions: []const pardes.Region, tag: pardes.Region, side: enum { above, below }) bool {
- for (regions) |other| {
- if (other.kind != .tag and other.kind != .column_tag and other.kind != .workspace_tag) continue;
- if (other.rect.h == 0 or std.meta.eql(other.rect, tag.rect)) continue;
- const meets = switch (side) {
- .above => other.rect.y + other.rect.h == tag.rect.y,
- .below => tag.rect.y + tag.rect.h == other.rect.y,
- };
- if (meets and other.rect.x < tag.rect.x + tag.rect.w and tag.rect.x < other.rect.x + other.rect.w) return true;
- }
- return false;
-}
-
/// The two short bars on each row of a grip with no mode glyph there,
/// centered in its anchor.
fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, cells: []const pardes.Cell, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
@@ -8142,13 +7653,7 @@ fn gripDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ce
const left = @as(f32, @floatFromInt(grip.rect.x)) * layout.w;
const right = @as(f32, @floatFromInt(grip.rect.x + grip.rect.w)) * layout.w;
try addDecor(g, gpa, left, button[1], button[0], button[3], band, 1, win_w, win_h);
- // Right of it, a theme's plaque starts flush against it (plaqueBox).
- const plaqued = chrome.decor_box_border != null and !cell_decor.plaques_off;
- if (!plaqued) try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, win_w, win_h);
- // Its cells over the plaque's reach are let through (emitInstance):
- // under the button's row, the band goes on as far as the plaque.
- if (plaqued and grip.rect.h > 1)
- try addDecor(g, gpa, left, button[3], button[2], @as(f32, @floatFromInt(grip.rect.y + grip.rect.h)) * layout.h, band, 1, win_w, win_h);
+ try addDecor(g, gpa, button[2], button[1], right, button[3], band, 1, win_w, win_h);
if (grip.kind != .grip) continue;
// acme's button ring, two pixels (ButtonBorder) inside the button:
// the focused one's in its own fill. An unfocused dirty one keeps a
@@ -8453,31 +7958,18 @@ test "decor is read from the regions" {
try std.testing.expectEqual(@as(u32, 0), groups.items[groups.notices].decor_count);
}
-test "a body tells its first line, and lapis's dots under it move a quarter as far" {
+test "a body tells its first line" {
const gpa = std.testing.allocator;
const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 });
defer core.deinit();
const pane = try core.setTestFile(std.mem.asBytes(&@as([80][5]u8, @splat("line\n".*))));
pane.scrollBy(8);
- try std.testing.expect(core.executeBuiltinLine(0, "Theme lapis"));
- core.settings.parallax = true;
- for (0..40) |_| core.update(.tick);
core.sync();
const s = try core.render(core.scratch.allocator());
const body = for (s.regionList()) |region| {
if (region.kind == .body) break region;
} else return error.NoBody;
try std.testing.expectEqual(@as(i32, 8), body.line);
- try std.testing.expect(s.chrome.fx & 8 != 0);
- // The shift the cell shader is handed: a quarter of 8 rows of 20 px,
- // upward, within the dots' period.
- var decor = CellDecor.of(&s.chrome);
- const period = decor.uniforms[4];
- decor.bodies[0] = .{ 0, 0, 800, 480 };
- decor.shifts[0] = @mod(-8.0 * 20.0 * 0.25, period);
- decor.nbodies = 1;
- try std.testing.expectApproxEqAbs(@mod(-40.0, period), decor.parallaxAt(10, 10), 1e-4);
- try std.testing.expectEqual(@as(f32, 0), decor.parallaxAt(900, 10));
}
const CursorBox = struct { x0: f32, y0: f32, x1: f32, y1: f32, rgb: [3]u8, bar: bool };
@@ -8635,8 +8127,7 @@ fn uploadOverlayGpu(g: *Gui, cmd: *c.SDL_GPUCommandBuffer, vertex_count: u32) bo
}
fn pushLayerOpacity(cmd: *c.SDL_GPUCommandBuffer, pass: ?*c.SDL_GPURenderPass, opacity: f32) void {
- var uniforms = [4]f32{ opacity, 0, 0, 0 } ++ @as([12]f32, @splat(0));
- uniforms[4..].* = cell_decor.uniforms;
+ const uniforms = [4]f32{ opacity, 0, 0, 0 };
c.SDL_PushGPUFragmentUniformData(cmd, 0, &uniforms, @sizeOf(@TypeOf(uniforms)));
// The source alpha is geometric/image coverage, not window opacity. Its
// alpha contribution is multiplied by this constant separately, so a
diff --git a/src/surface.zig b/src/surface.zig
index 6e383841..998e3230 100644
--- a/src/surface.zig
+++ b/src/surface.zig
@@ -246,8 +246,7 @@ pub const Region = struct {
/// A notice's index in its pane's `notices`.
notice: u8 = 0,
/// A body's view: the first line it shows (a file's scroll, a
- /// terminal's grid offset), for what a pixel shell moves with the text
- /// (G13's parallax).
+ /// terminal's grid offset).
line: i32 = 0,
/// Cells the column-move rail takes off the right edge while it runs
/// there: layers and pixel shells stop short of them, the grid does not.
@@ -307,29 +306,6 @@ pub const Chrome = struct {
/// The scroll column's width, button and scrollbar alike, in pixels at
/// a 17px tagline (acme's 12 at its font); a pixel shell scales it.
rail_px: u8 = 12,
- /// The theme's ornament (colors.Decor), a pixel shell's alone: the dot
- /// grid on the page, the scroll track's checker, the tags' plaques
- /// (frame, shadow, the focused one's stripes) and the file name's shadow, each null when the theme has none, sizes
- /// in logical pixels. `name_ink` and `active_name_ink` are the file
- /// name's colours in a tag, which the shadow goes under.
- decor_dots: ?[3]u8 = null,
- decor_dot_alpha: u8 = 0,
- decor_dot_px: u8 = 22,
- decor_checker: ?[3]u8 = null,
- decor_checker_px: u8 = 3,
- decor_box_border: ?[3]u8 = null,
- decor_box_border_px: u8 = 2,
- decor_box_shadow: ?[3]u8 = null,
- decor_box_shadow_px: u8 = 5,
- decor_box_stripe: ?[3]u8 = null,
- decor_box_stripe_px: u8 = 2,
- decor_title: ?[3]u8 = null,
- decor_title_px: u8 = 2,
- name_ink: [3]u8 = .{ 0, 0, 0 },
- active_name_ink: [3]u8 = .{ 0, 0, 0 },
- /// A pixel shell's small effects: bit 3 the page pattern's parallax
- /// (G13, Parallax).
- fx: u8 = 0,
};
/// The canonical interface: what a frame of pardes IS. The tui shell writes
diff --git a/src/themes/lapis.zig b/src/themes/lapis.zig
index 46623fc2..95fc86bd 100644
--- a/src/themes/lapis.zig
+++ b/src/themes/lapis.zig
@@ -1,14 +1,7 @@
//! Lapis: 0x4200.cafe's illuminated manuscript (web/theme/lapis.css) as a
//! pardes theme. Ultramarine vellum, gold leaf and vermilion rubrics: the
//! page is lapis-deep, the tags lapis with their names in gold, the text
-//! vellum. The site's ornament comes with it as the theme's `decor`, drawn
-//! inside the existing chrome (docs/render-pipeline.md §10, decision 1):
-//! a gold dot grid on the page under the pane bodies, a gold and lapis
-//! checker in the scroll column, every tag a gold-framed plaque with the
-//! trail's hard vermilion shadow (inside its own band: in a tiled layout a
-//! shadow past it would fall on the next pane or its grip, and no ornament
-//! may cover a focus indicator), the focused one striped like the code
-//! window's title bar, and the file name's vermilion offset shadow.
+//! vellum.
pub const theme = .{
.name = "lapis",
// --lapis-deep, --vellum
@@ -53,24 +46,6 @@ pub const theme = .{
.diagnostic_warning = .{ 0xe8, 0xc4, 0x6a },
.diagnostic_info = .{ 0x9a, 0xc6, 0xff },
.diagnostic_hint = .{ 0xa8, 0xe0, 0xc0 },
- .decor = .{
- .page_dots = .{ 0xe8, 0xc4, 0x6a },
- // #e8c46a22 on the site: a dot a pixel and a half across every 22.
- .page_dot_alpha = 0x22,
- .page_dot_px = 22,
- .rail_checker = .{ 0xe8, 0xc4, 0x6a },
- .rail_checker_px = 3,
- // The trail: a 2px gold frame and a 5px vermilion shadow; the code
- // window's title bar: gold and lapis stripes of 2px.
- .tag_border = .{ 0xe8, 0xc4, 0x6a },
- .tag_border_px = 2,
- .tag_shadow = .{ 0xd4, 0x41, 0x2f },
- .tag_shadow_px = 5,
- .tag_stripe = .{ 0xe8, 0xc4, 0x6a },
- .tag_stripe_px = 2,
- .title_shadow = .{ 0xd4, 0x41, 0x2f },
- .title_shadow_px = 2,
- },
.palette = .{
.{ 0x0a, 0x10, 0x30 },
.{ 0xff, 0x6a, 0x4a },
diff --git a/src/themes/lapis_plain.zig b/src/themes/lapis_plain.zig
deleted file mode 100644
index 5b4c48dd..00000000
--- a/src/themes/lapis_plain.zig
+++ /dev/null
@@ -1,81 +0,0 @@
-//! Lapis plain: lapis (src/themes/lapis.zig) with flat grounds. The page
-//! under the text is lapis-deep with no dot grid, and the focused tag's
-//! plaque is its tint with no gold stripes behind its words; the rest is
-//! lapis's own: every colour, the gold frames and vermilion shadows of the
-//! tag plaques, the gold rules, the checker in the scroll column and the
-//! file name's vermilion offset shadow.
-pub const theme = .{
- .name = "lapis_plain",
- // --lapis-deep, --vellum
- .bg = .{ 0x0a, 0x10, 0x30 },
- .fg = .{ 0xee, 0xe6, 0xd2 },
- // A gold highlight in lapis ink, as the directory's current entry.
- .sel_bg = .{ 0xe8, 0xc4, 0x6a },
- .sel_fg = .{ 0x0f, 0x1a, 0x4a },
- // --lapis, --vellum-dim
- .tag_bg = .{ 0x0f, 0x1a, 0x4a },
- .tag_fg = .{ 0x9a, 0xa6, 0xd9 },
- .tag_name_fg = .{ 0xe8, 0xc4, 0x6a },
- .tag_active_name_fg = .{ 0xf2, 0xd2, 0x80 },
- // The plaques' hover lapis, taken a step further: 1.5:1 off the tag.
- .tag_active_bg = .{ 0x25, 0x39, 0x7d },
- .tag_active_fg = .{ 0xee, 0xe6, 0xd2 },
- .box = .{ 0xe8, 0xc4, 0x6a },
- .box_dim = .{ 0x3a, 0x4a, 0x8a },
- .box_border = .{ 0x9a, 0xa6, 0xd9 },
- .box_dirty = .{ 0xff, 0x6a, 0x4a },
- .column_box = .{ 0xff, 0x6a, 0x4a },
- .column_box_dim = .{ 0x8a, 0x3a, 0x3a },
- // Rubrics: vermilion keywords, gilded strings, the code window's green
- // for numbers, vellum-dim comments.
- .kw = .{ 0xff, 0x6a, 0x4a },
- .str = .{ 0xe8, 0xc4, 0x6a },
- .num = .{ 0xe7, 0xff, 0xe0 },
- .comment = .{ 0x9a, 0xa6, 0xd9 },
- .lineno = .{ 0x5a, 0x6a, 0xa8 },
- .lineno_active = .{ 0x6a, 0x7a, 0xb8 },
- // --lapis-ink under a gold thumb (the page's scrollbar-color).
- .scroll_track = .{ 0x05, 0x0a, 0x24 },
- .scroll_thumb = .{ 0xe8, 0xc4, 0x6a },
- // Gold rules, a vermilion hairline between a tag and its text.
- .border = .{ 0xe8, 0xc4, 0x6a },
- // An empty column is the page, not a slab of gold leaf.
- .empty_col = .{ 0x0a, 0x10, 0x30 },
- .tag_rule = .{ 0xd4, 0x41, 0x2f },
- .search_bg = .{ 0x6a, 0x2a, 0x1c },
- .search_fg = .{ 0xff, 0xd0, 0xb0 },
- .diagnostic_error = .{ 0xff, 0x6a, 0x4a },
- .diagnostic_warning = .{ 0xe8, 0xc4, 0x6a },
- .diagnostic_info = .{ 0x9a, 0xc6, 0xff },
- .diagnostic_hint = .{ 0xa8, 0xe0, 0xc0 },
- .decor = .{
- .rail_checker = .{ 0xe8, 0xc4, 0x6a },
- .rail_checker_px = 3,
- // The trail: a 2px gold frame and a 5px vermilion shadow; the
- // focused plaque filled flat.
- .tag_border = .{ 0xe8, 0xc4, 0x6a },
- .tag_border_px = 2,
- .tag_shadow = .{ 0xd4, 0x41, 0x2f },
- .tag_shadow_px = 5,
- .title_shadow = .{ 0xd4, 0x41, 0x2f },
- .title_shadow_px = 2,
- },
- .palette = .{
- .{ 0x0a, 0x10, 0x30 },
- .{ 0xff, 0x6a, 0x4a },
- .{ 0xa8, 0xe0, 0xc0 },
- .{ 0xe8, 0xc4, 0x6a },
- .{ 0x9a, 0xc6, 0xff },
- .{ 0xd8, 0xa0, 0xe8 },
- .{ 0x8a, 0xd8, 0xd8 },
- .{ 0xee, 0xe6, 0xd2 },
- .{ 0x9a, 0xa6, 0xd9 },
- .{ 0xff, 0x9a, 0x6a },
- .{ 0xc8, 0xf0, 0xd8 },
- .{ 0xff, 0xde, 0x90 },
- .{ 0xc0, 0xdc, 0xff },
- .{ 0xe8, 0xc0, 0xf4 },
- .{ 0xb0, 0xec, 0xec },
- .{ 0xff, 0xf8, 0xe8 },
- },
-};