~mil/mepo

e44f8f716f5a6fbfa9047e0813f13670d9b58bb0 — Miles Alan 3 months ago 18c5e7b
Properly highlight entire segment for active pin in ordered pin groups

E.g. previously if multiple structural pins were present between
instructive pins, then only the first part of the segment would show in
a curve/bend; with this change entire path between each structural pin
is highlighted properly.
1 files changed, 16 insertions(+), 4 deletions(-)

M src/Mepo.zig
M src/Mepo.zig => src/Mepo.zig +16 -4
@@ 338,17 338,29 @@ fn blit_pin(mepo: *@This(), pin: types.Pin, prev_pin: ?types.Pin, pin_group: u8,

fn blit_pins(mepo: *@This()) !void {
    for (mepo.pin_groups) |pin_group, pin_group_i| {
        var ordered_group_active_path = false;
        if (!pin_group.visible) continue;
        var prev_pin: ?*types.Pin = null;
        for (pin_group.pins.items) |*pin, i| {
        for (pin_group.pins.items) |*pin, pin_i| {
            defer prev_pin = pin;

            const color = if (pin_group_i == mepo.pin_group_active and mepo.pin_group_active_item != null and
                ((mepo.pin_groups[pin_group_i].ordered and ordered_group_active_path) or
                (!mepo.pin_groups[pin_group_i].ordered and mepo.pin_group_active_item.? == pin_i))) 0xff0000 else pin_group.color;

            // E.g. ordered_group_active_path just tracks every time
            // an instructive pin is hit so subsequent structural pins
            // highlighted in "active"/red color until next structural pin
            // hit and full "path" of the active segment of an ordered pin
            // group shows continuously as the active color
            if (mepo.pin_group_active_item != null and mepo.pin_groups[pin_group_i].pins.items[pin_i].category == .Instructive)
                ordered_group_active_path = mepo.pin_group_active_item.? == pin_i;

            try mepo.blit_pin(
                pin.*,
                if (prev_pin != null) prev_pin.?.* else null,
                @intCast(u8, pin_group_i),
                .{
                    .value = if (pin_group_i == mepo.pin_group_active and mepo.pin_group_active_item != null and i == mepo.pin_group_active_item.?) 0xff0000 else pin_group.color,
                },
                .{ .value = color },
            );
        }
    }