Skip to content

Commit

Permalink
resizing: Smoothed out window resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
foxnne committed Jan 22, 2024
1 parent 42a129a commit 56c277e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/pixi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,10 @@ pub fn update(app: *App) !bool {
};
content_scale = .{ 1.0, 1.0 };

var set_vsync: bool = false;

var iter = core.pollEvents();
while (iter.next()) |event| {
if (!state.should_close)
_ = imgui_mach.processEvent(event);

switch (event) {
.key_press => |key_press| {
state.hotkeys.setHotkeyState(key_press.key, key_press.mods, .press);
Expand Down Expand Up @@ -296,8 +295,15 @@ pub fn update(app: *App) !bool {
}
state.should_close = should_close;
},
.framebuffer_resize => |_| {
core.setVSync(.none);
set_vsync = true;
},
else => {},
}

if (!state.should_close)
_ = imgui_mach.processEvent(event);
}

try input.process();
Expand All @@ -311,6 +317,11 @@ pub fn update(app: *App) !bool {

imgui.render();

if (set_vsync) {
core.setVSync(.double);
set_vsync = false;
}

if (editor.getFile(state.open_file_index)) |file| {
@memset(core.title[0..], 0);
@memcpy(core.title[0 .. name.len + 3], name ++ " - ");
Expand Down
3 changes: 2 additions & 1 deletion src/storage/internal.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,8 @@ pub const Layer = struct {
color: [4]u8,
};

/// Only used for handling getting the pixels
/// Only used for handling getting the pixels surrounding the origin
/// for stroke sizes larger than 1
pub fn getIndexShapeOffset(self: Layer, origin: [2]usize, current_index: usize) ?ShapeOffsetResult {
const shape = pixi.state.tools.stroke_shape;
const size: i32 = @intCast(pixi.state.tools.stroke_size);
Expand Down

0 comments on commit 56c277e

Please sign in to comment.