Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
check:
uses: fizzyedit/plugin-build-action/.github/workflows/check.yml@v7
with:
zig-version: "0.16.0"
zig-version: "0.17.0"
# secrets:
# build_env: ${{ secrets.MY_BUILD_ENV }} # as in release.yml, if the build needs one
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
permissions:
contents: write
with:
zig-version: "0.16.0"
zig-version: "0.17.0"
2 changes: 1 addition & 1 deletion .github/workflows/sdk-repin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
with:
sdk-version: ${{ github.event.client_payload.version || inputs.sdk-version || '' }}
force: ${{ inputs.force == true }}
zig-version: "0.16.0"
zig-version: "0.17.0"
10 changes: 5 additions & 5 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.name = .pixi,
.version = "0.0.1",
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.paths = .{
"build.zig",
"build.zig.zon",
Expand All @@ -15,8 +15,8 @@
.fingerprint = 0xdef5a52dbae70684,
.dependencies = .{
.assetpack = .{
.url = "https://github.com/foxnne/assetpack/archive/ac7592f3f5988857840d0df4610e1e1fad690e2e.tar.gz",
.hash = "assetpack-0.2.0-5DA2d1ZkAADJanNVdWrUBOGMhOzUENhrUiqXcHADxY2x",
.url = "git+https://github.com/foxnne/assetpack#fbc4392910375d428735ed9852fa2aedabc6ff52",
.hash = "assetpack-0.2.0-5DA2d2hkAACLscFkiyim4xD-Fqum33ndL5V5IFvN_dAS",
},
.icons = .{
.url = "https://github.com/foxnne/zig-lib-icons/archive/db034786a1286ab28dc35aba534c098aa4f1a3aa.tar.gz",
Expand All @@ -27,8 +27,8 @@
// The published SDK, not a path into a checkout: a release has to build from a
// clean clone, and the release asset (never the tag's git archive) is the SDK
// package alone — the monorepo root zon carries the app's own dependencies.
.url = "https://github.com/fizzyedit/fizzy/releases/download/sdk-v0.2.29/fizzy-sdk-v0.2.29.tar.gz",
.hash = "fizzy-0.2.29-SGBwY2sxJgCLLSPt4HLdlMSg7WtcP4K0fdtXI5WwJl2d",
.url = "https://github.com/fizzyedit/fizzy/releases/download/sdk-v0.2.30/fizzy-sdk-v0.2.30.tar.gz",
.hash = "fizzy-0.2.30-SGBwY1QnJwDznUMVnSLATxXgH2e8_Vz7eMwLj9UQ0sVU",
},
},
}
4 changes: 2 additions & 2 deletions plugin.zig.zon
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.id = "pixi",
.name = "Pixi",
.version = "0.1.47",
.min_sdk_version = "0.2.29",
.version = "0.1.48",
.min_sdk_version = "0.2.30",
.description = "Pixel-art editor: sprite and atlas editing for fizzy.",
.tags = .{ "editor", "pixel-art" },
.author = "foxnne",
Expand Down
4 changes: 2 additions & 2 deletions src/Brush.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn deinit(self: *Brush, gpa: std.mem.Allocator) void {
/// The shape of a brush `size` pixels across, centred at `side / 2`: every pixel of a square, or
/// those of a circle, its radius trimmed a little so small circles read round.
pub fn shapeOf(kind: Kind, size: u8) Shape {
var out: Shape = .initEmpty();
var out: Shape = .empty;
const s: i32 = @max(1, size);
const half = @divFloor(s, 2);
var i: i32 = 0;
Expand Down Expand Up @@ -90,7 +90,7 @@ fn covers(shape: *const Shape, o: Offset) bool {
const testing = std.testing;

fn shapeFrom(comptime inside: fn (x: i32, y: i32) bool) Shape {
var s: Shape = .initEmpty();
var s: Shape = .empty;
var y: i32 = -side / 2;
while (y < side / 2) : (y += 1) {
var x: i32 = -side / 2;
Expand Down
42 changes: 21 additions & 21 deletions src/PackJob.zig
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ window: *dvui.Window,

started_at_ns: i128,

phase: std.atomic.Value(u8) = .init(@intFromEnum(Phase.queued)),
phase: std.atomic.Value(u8) = .init(@backingInt(Phase.queued)),

/// Worker reports `(done_inputs, total_inputs)` while in the `loading` / `appending` phases.
progress_num: std.atomic.Value(u32) = .init(0),
Expand Down Expand Up @@ -300,7 +300,7 @@ pub fn workerMain(job: *PackJob) void {
// `.path`-loaded `PackFile`s, collapse carry-overs) lives in `ws` and is freed below.
const work = WorkerState.init(runtime.allocator()) catch |e| {
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};
var ws = work;
Expand All @@ -311,21 +311,21 @@ pub fn workerMain(job: *PackJob) void {
// buffers and `buildAtlas` blits straight from those pointers. `.open` inputs are owned
// by `job.inputs` for the job's full lifetime; `.path`-loaded files are parked in
// `ws.loaded_files` (freed with `ws.deinit`).
job.phase.store(@intFromEnum(Phase.loading), .release);
job.phase.store(@backingInt(Phase.loading), .release);
job.progress_den.store(@intCast(job.inputs.len), .monotonic);

for (job.inputs, 0..) |*input, idx| {
if (job.cancelled.load(.monotonic)) {
job.phase.store(@intFromEnum(Phase.cancelled), .release);
job.phase.store(@backingInt(Phase.cancelled), .release);
return;
}

switch (input.*) {
.open => |*pf| {
job.phase.store(@intFromEnum(Phase.appending), .release);
job.phase.store(@backingInt(Phase.appending), .release);
ws.appendPackFile(pf) catch |e| {
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};
},
Expand All @@ -338,28 +338,28 @@ pub fn workerMain(job: *PackJob) void {
// reachability graph.
if (comptime @import("builtin").target.cpu.arch == .wasm32) {
job.err = error.PathInputsNotSupportedOnWasm;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
}
job.phase.store(@intFromEnum(Phase.loading), .release);
job.phase.store(@backingInt(Phase.loading), .release);
const maybe_pf = PackFile.fromPath(runtime.allocator(), path) catch |e| {
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};
if (maybe_pf) |pf_val| {
ws.loaded_files.append(pf_val) catch |e| {
var tmp = pf_val;
tmp.deinit();
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};
job.phase.store(@intFromEnum(Phase.appending), .release);
job.phase.store(@backingInt(Phase.appending), .release);
const ref = &ws.loaded_files.items[ws.loaded_files.items.len - 1];
ws.appendPackFile(ref) catch |e| {
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};
}
Expand All @@ -372,33 +372,33 @@ pub fn workerMain(job: *PackJob) void {
// Nothing to pack — keep `result_atlas == null`, surface as `ready`. The main thread
// treats null-result the same as the old `packAndClear` early-out: leave the existing
// atlas in place.
job.phase.store(@intFromEnum(Phase.ready), .release);
job.phase.store(@backingInt(Phase.ready), .release);
return;
}

// Try increasing texture sizes until everything fits.
job.phase.store(@intFromEnum(Phase.packing), .release);
job.phase.store(@backingInt(Phase.packing), .release);
const tex_size = ws.packRects() catch |e| {
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
} orelse {
job.err = error.PackFailed;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};

if (job.cancelled.load(.monotonic)) {
job.phase.store(@intFromEnum(Phase.cancelled), .release);
job.phase.store(@backingInt(Phase.cancelled), .release);
return;
}

// Blit each emitted sprite into a fresh atlas pixel buffer at the location chosen by
// `packRects`, then assemble the `Internal.Atlas` value that the main thread will install.
job.phase.store(@intFromEnum(Phase.blitting), .release);
job.phase.store(@backingInt(Phase.blitting), .release);
const atlas = ws.buildAtlas(tex_size) catch |e| {
job.err = e;
job.phase.store(@intFromEnum(Phase.failed), .release);
job.phase.store(@backingInt(Phase.failed), .release);
return;
};

Expand All @@ -408,12 +408,12 @@ pub fn workerMain(job: *PackJob) void {
for (atlas.data.animations) |*anim| runtime.allocator().free(anim.name);
runtime.allocator().free(atlas.data.animations);
runtime.allocator().free(atlas.data.sprites);
job.phase.store(@intFromEnum(Phase.cancelled), .release);
job.phase.store(@backingInt(Phase.cancelled), .release);
return;
}

job.result_atlas = atlas;
job.phase.store(@intFromEnum(Phase.ready), .release);
job.phase.store(@backingInt(Phase.ready), .release);
}

// ----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Tools.zig
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ settings_popover: bool = false,
settings_popover_tool: Tool = .pointer,
settings_popover_from: dvui.Point.Natural = .{},

stroke: Brush.Shape = .initEmpty(),
stroke: Brush.Shape = .empty,
/// `stroke` as offsets to stamp, rebuilt with it.
brush: Brush = .{},
gpa: std.mem.Allocator,
Expand Down
2 changes: 1 addition & 1 deletion src/Transform.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ortho: bool = true,
rendered_key: u64 = 0,

pub fn point(self: *Transform, transform_point: TransformPoint) *dvui.Point {
return &self.data_points[@intFromEnum(transform_point)];
return &self.data_points[@backingInt(transform_point)];
}

/// Accepts the current transform and applies it to the currently selected layer
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/reduce.zig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn anyOpaque(pixels: []const [4]u8) bool {
const V = @Vector(vec_len, u32);
// Alpha is byte 3 of each pixel: the high byte of the u32 on little-endian
// targets, the low byte on big-endian.
const alpha_mask: V = @splat(switch (builtin.cpu.arch.endian()) {
const alpha_mask: V = @splat(switch (builtin.target.cpu.arch.endian()) {
.little => 0xFF00_0000,
.big => 0x0000_00FF,
});
Expand Down
2 changes: 1 addition & 1 deletion src/deps/stbi/zstbi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn packRects(context: *Context, rects: []Rect) usize {
}

pub fn setupHeuristic(context: *Context, heuristic: Heuristic) void {
stbrp_setup_heuristic(context, @as(u32, @intCast(@intFromEnum(heuristic))));
stbrp_setup_heuristic(context, @as(u32, @intCast(@backingInt(heuristic))));
}

pub extern fn stbrp_init_target(context: [*c]Context, width: u32, height: u32, nodes: [*c]Node, num_nodes: usize) void;
Expand Down
10 changes: 5 additions & 5 deletions src/dialogs/Export.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
.margin = .{ .y = 2, .h = 4 },
.padding = .all(6),
.expand = .horizontal,
.color_fill = .{ .color = if (mode == @as(@TypeOf(mode), @enumFromInt(i))) dvui.themeGet().color(.window, .fill).lighten(-4) else dvui.themeGet().color(.control, .fill) },
.box_shadow = if (i != @intFromEnum(mode)) .{
.color_fill = .{ .color = if (mode == @as(@TypeOf(mode), @fromBackingInt(@intCast(i)))) dvui.themeGet().color(.window, .fill).lighten(-4) else dvui.themeGet().color(.control, .fill) },
.box_shadow = if (i != @backingInt(mode)) .{
.color = .black,
.offset = .{ .x = 0.0, .y = 2 },
.fade = 7.0,
Expand All @@ -95,7 +95,7 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
} else null,
});
defer button.deinit();
if (i != @intFromEnum(mode)) {
if (i != @backingInt(mode)) {
button.processEvents();
}

Expand All @@ -120,13 +120,13 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
dvui.labelNoFmt(@src(), name, .{}, .{
.gravity_x = 0.5,
.gravity_y = 0.5,
.color_text = .{ .color = if (mode == @as(@TypeOf(mode), @enumFromInt(i))) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
.color_text = .{ .color = if (mode == @as(@TypeOf(mode), @fromBackingInt(@intCast(i)))) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
.margin = .all(0),
.padding = .all(0),
});

if (button.clicked()) {
mode = @enumFromInt(i);
mode = @fromBackingInt(@intCast(i));
if (mode == .animation) {
anim_frame_index = 0;
dvui.currentWindow().timerRemove(id);
Expand Down
18 changes: 9 additions & 9 deletions src/dialogs/GridLayout.zig
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,8 @@ fn gridLayoutDrawModePill(dlg_id: dvui.Id) void {
.margin = .{ .y = 2, .h = 4 },
.padding = .{ .x = 12, .y = 6, .w = 12, .h = 6 },
.expand = .horizontal,
.color_fill = .{ .color = if (mode == @as(@TypeOf(mode), @enumFromInt(i))) dvui.themeGet().color(.window, .fill).lighten(-4) else dvui.themeGet().color(.control, .fill) },
.box_shadow = if (i != @intFromEnum(mode)) .{
.color_fill = .{ .color = if (mode == @as(@TypeOf(mode), @fromBackingInt(@intCast(i)))) dvui.themeGet().color(.window, .fill).lighten(-4) else dvui.themeGet().color(.control, .fill) },
.box_shadow = if (i != @backingInt(mode)) .{
.color = .black,
.offset = .{ .x = 0.0, .y = 2 },
.fade = 7.0,
Expand All @@ -821,7 +821,7 @@ fn gridLayoutDrawModePill(dlg_id: dvui.Id) void {
} else null,
});
defer button.deinit();
if (i != @intFromEnum(mode)) {
if (i != @backingInt(mode)) {
button.processEvents();
}

Expand All @@ -846,13 +846,13 @@ fn gridLayoutDrawModePill(dlg_id: dvui.Id) void {
dvui.labelNoFmt(@src(), name, .{}, .{
.gravity_x = 0.5,
.gravity_y = 0.5,
.color_text = .{ .color = if (mode == @as(@TypeOf(mode), @enumFromInt(i))) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
.color_text = .{ .color = if (mode == @as(@TypeOf(mode), @fromBackingInt(@intCast(i)))) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
.margin = .all(0),
.padding = .all(0),
});

if (button.clicked()) {
const new_mode: Mode = @enumFromInt(i);
const new_mode: Mode = @fromBackingInt(@intCast(i));
if (new_mode == .slice and mode != .slice) {
if (file_id_for_dialog) |fid| if (runtime.state().docs.fileById(fid)) |tf|
harmonizeSliceStateWithLayer(tf);
Expand Down Expand Up @@ -1595,10 +1595,10 @@ pub fn windowFn(id: dvui.Id) anyerror!void {
defer shell.deinit();

const header_kind: pixi.core.dialogs.DialogHeaderKind = switch (dvui.dataGet(null, id, "_header_kind", u8) orelse 0) {
@intFromEnum(pixi.core.dialogs.DialogHeaderKind.none) => .none,
@intFromEnum(pixi.core.dialogs.DialogHeaderKind.info) => .info,
@intFromEnum(pixi.core.dialogs.DialogHeaderKind.warning) => .warning,
@intFromEnum(pixi.core.dialogs.DialogHeaderKind.err) => .err,
@backingInt(pixi.core.dialogs.DialogHeaderKind.none) => .none,
@backingInt(pixi.core.dialogs.DialogHeaderKind.info) => .info,
@backingInt(pixi.core.dialogs.DialogHeaderKind.warning) => .warning,
@backingInt(pixi.core.dialogs.DialogHeaderKind.err) => .err,
else => .none,
};

Expand Down
12 changes: 6 additions & 6 deletions src/dialogs/NewFile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
defer hbox.deinit();

for (0..2) |i| {
const color = if (i == @intFromEnum(mode)) dvui.themeGet().color(.window, .fill).lighten(-4) else dvui.themeGet().color(.control, .fill);
const color = if (i == @backingInt(mode)) dvui.themeGet().color(.window, .fill).lighten(-4) else dvui.themeGet().color(.control, .fill);
const button_opts: dvui.Options = .{
.padding = .all(6),
.margin = .{ .y = 2, .h = 4 },
.corners = if (i == 0) .{ .tl = .round(100000), .bl = .round(100000) } else .{ .tr = .round(100000), .br = .round(100000) },
.expand = .horizontal,
.color_fill = .{ .color = color },
.color_fill_hover = if (i == @intFromEnum(mode)) .{ .color = color } else null,
.color_fill_hover = if (i == @backingInt(mode)) .{ .color = color } else null,
.id_extra = i,
.box_shadow = if (i != @intFromEnum(mode)) .{
.box_shadow = if (i != @backingInt(mode)) .{
.color = .black,
.offset = .{ .x = 0.0, .y = 2.0 },
.fade = 7.0,
Expand All @@ -80,7 +80,7 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
button.init(@src(), .{}, button_opts);
defer button.deinit();

if (i != @intFromEnum(mode)) {
if (i != @backingInt(mode)) {
button.processEvents();
}

Expand All @@ -90,7 +90,7 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
dvui.labelNoFmt(@src(), "Single", .{}, button_opts.strip().override(button.style()).override(.{
.gravity_x = 0.5,
.gravity_y = 0.5,
.color_text = .{ .color = if (i == @intFromEnum(mode)) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
.color_text = .{ .color = if (i == @backingInt(mode)) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
}));
if (button.clicked()) {
mode = .single;
Expand All @@ -100,7 +100,7 @@ pub fn dialog(id: dvui.Id) anyerror!bool {
dvui.labelNoFmt(@src(), "Grid", .{}, button_opts.strip().override(button.style()).override(.{
.gravity_x = 0.5,
.gravity_y = 0.5,
.color_text = .{ .color = if (i == @intFromEnum(mode)) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
.color_text = .{ .color = if (i == @backingInt(mode)) dvui.themeGet().color(.window, .text) else dvui.themeGet().color(.control, .text) },
}));
if (button.clicked()) {
mode = .grid;
Expand Down
4 changes: 2 additions & 2 deletions src/explorer/tools.zig
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ pub fn drawTools() !void {
.padding = .{ .h = 10.0, .w = 4.0, .x = 4.0, .y = 4.0 },
});
defer toolbox.deinit();
for (0..std.meta.fields(pixi.Tools.Tool).len) |i| {
const tool: pixi.Tools.Tool = @enumFromInt(i);
for (0..std.meta.fieldNames(pixi.Tools.Tool).len) |i| {
const tool: pixi.Tools.Tool = @fromBackingInt(@intCast(i));
const id_extra = i;

const selected = runtime.state().tools.current == tool;
Expand Down
Loading
Loading