diff options
Diffstat (limited to 'dev/gui/gui.zig')
| -rw-r--r-- | dev/gui/gui.zig | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 88ba023b..76af0ec8 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -5028,17 +5028,36 @@ fn laneDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, la const LaneRide = struct { x0: u16, x1: u16, y0: u16, y1: u16, dy: f32, top: f32, bottom: f32 }; /// `lane`'s strip, `w` pixels wide, on grid row `row`, riding a scroll's -/// rows when given one. +/// rows when given one; on its description row an arrow to the text: the +/// strip down to the row's middle, a shaft along it, a head half a strip +/// short of the text. fn laneStrip(g: *Gui, gpa: std.mem.Allocator, lane: pardes.Lane, row: i32, ride: ?*const LaneRide, w: f32, layout: CellLayout, win_w: f32, win_h: f32) !void { const x0 = @round(@as(f32, @floatFromInt(lane.x)) * layout.w + w / 2 + @as(f32, @floatFromInt(lane.level)) * (w + w / 2)); - var y0 = @as(f32, @floatFromInt(row)) * layout.h; - var y1 = y0 + layout.h; - if (ride) |r| { - y0 = @max(y0 - r.dy, r.top); - y1 = @min(y1 - r.dy, r.bottom); - if (y1 <= y0) return; + const top = @as(f32, @floatFromInt(row)) * layout.h; + const Piece = struct { + fn add(gu: *Gui, alloc: std.mem.Allocator, rd: ?*const LaneRide, rgb: [3]u8, x_0: f32, y_0: f32, x_1: f32, y_1: f32, ww: f32, wh: f32) !void { + var a = y_0; + var b = y_1; + if (rd) |r| { + a = @max(a - r.dy, r.top); + b = @min(b - r.dy, r.bottom); + } + if (b > a and x_1 > x_0) try addDecor(gu, alloc, x_0, a, x_1, b, rgb, 1, ww, wh); + } + }; + if (lane.arrow == 0) return Piece.add(g, gpa, ride, lane.rgb, x0, top, x0 + w, top + layout.h, win_w, win_h); + const mid = @round(top + (layout.h - w) / 2); + const tip = @round(@as(f32, @floatFromInt(lane.x + lane.arrow)) * layout.w - w / 2); + const head = @round(w * 1.5); + try Piece.add(g, gpa, ride, lane.rgb, x0, top, x0 + w, mid + w, win_w, win_h); + try Piece.add(g, gpa, ride, lane.rgb, x0 + w, mid, tip - head, mid + w, win_w, win_h); + // The head: a pixel row each, narrowing to the tip. + var dy: f32 = -head; + while (dy < head) : (dy += 1) { + const y = mid + w / 2 + dy; + const len = @round(head * (1 - @abs(dy + 0.5) / head)); + try Piece.add(g, gpa, ride, lane.rgb, tip - head, @round(y), tip - head + len, @round(y) + 1, win_w, win_h); } - try addDecor(g, gpa, x0, y0, x0 + w, y1, lane.rgb, 1, win_w, win_h); } /// Each pane's rule between its tag and body, and its scroll rail: a page |
