-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Tools.zig
56 lines (48 loc) · 1.25 KB
/
Tools.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const std = @import("std");
const pixi = @import("pixi.zig");
const Self = @This();
pub const Tool = enum(u32) {
pointer,
pencil,
eraser,
animation,
heightmap,
bucket,
selection,
};
pub const Shape = enum(u32) {
circle,
square,
};
current: Tool = .pointer,
previous: Tool = .pointer,
stroke_size: u8 = 1,
stroke_shape: Shape = .circle,
pub fn set(self: *Self, tool: Tool) void {
if (self.current != tool) {
if (pixi.editor.getFile(pixi.state.open_file_index)) |file| {
if (file.transform_texture != null and tool != .pointer)
return;
switch (tool) {
.heightmap => {
file.heightmap.enable();
if (file.heightmap.layer == null)
return;
},
.pointer => {
file.heightmap.disable();
if (self.current == .selection)
file.selection_layer.clear(true);
},
else => {},
}
}
self.previous = self.current;
self.current = tool;
}
}
pub fn swap(self: *Self) void {
const temp = self.current;
self.current = self.previous;
self.previous = temp;
}