From aeefd0226e186b7e68fcb4364b8c0fd234530d54 Mon Sep 17 00:00:00 2001 From: foxnne Date: Fri, 17 Jan 2025 14:06:10 -0600 Subject: [PATCH] Remove useage of content_scale in editor code --- src/Pixi.zig | 48 +++++++++------------ src/editor/Editor.zig | 17 ++++++++ src/editor/Sidebar.zig | 2 +- src/editor/artboard/Artboard.zig | 37 ++++++++++++---- src/editor/artboard/canvas.zig | 19 -------- src/editor/artboard/flipbook/menu.zig | 8 ++-- src/editor/artboard/infobar.zig | 10 ++--- src/editor/artboard/menu.zig | 6 +-- src/editor/artboard/rulers.zig | 2 +- src/editor/explorer/Explorer.zig | 8 ++-- src/editor/explorer/animations.zig | 16 +++---- src/editor/explorer/files.zig | 40 ++++++++--------- src/editor/explorer/keyframe_animations.zig | 10 ++--- src/editor/explorer/pack.zig | 6 +-- src/editor/explorer/settings.zig | 28 ++++++------ src/editor/explorer/sprites.zig | 2 +- src/editor/popups/about.zig | 8 ++-- src/editor/popups/animation.zig | 8 ++-- src/editor/popups/export_png.zig | 6 +-- src/editor/popups/file_confirm_close.zig | 10 ++--- src/editor/popups/file_setup.zig | 10 ++--- src/editor/popups/heightmap.zig | 6 +-- src/editor/popups/layer_setup.zig | 8 ++-- src/editor/popups/references.zig | 2 +- src/editor/popups/rename.zig | 8 ++-- src/gfx/camera.zig | 22 +++++----- 26 files changed, 178 insertions(+), 169 deletions(-) diff --git a/src/Pixi.zig b/src/Pixi.zig index 16f1d41..2ec47de 100644 --- a/src/Pixi.zig +++ b/src/Pixi.zig @@ -12,7 +12,6 @@ const imgui_mach = imgui.backends.mach; const Core = mach.Core; pub const App = @This(); pub const Editor = @import("editor/Editor.zig"); -pub const Popups = @import("editor/popups/Popups.zig"); // Global pointers pub var core: *Core = undefined; @@ -132,13 +131,17 @@ pub fn init(_app: *App, _core: *Core, app_mod: mach.Mod(App), _editor: *Editor, pub fn lateInit(editor_mod: mach.Mod(Editor)) !void { const window = core.windows.getValue(app.window); + // Now that we have a valid device, we can initialize our pipelines + try gfx.init(app); + + // Initialize zstbi to load assets zstbi.init(app.allocator); + // Load assets app.loaded_assets = try LoadedAssets.init(app.allocator); - app.mouse = try input.Mouse.initDefault(app.allocator); + app.mouse = try input.Mouse.initDefault(app.allocator); app.packer = try Packer.init(app.allocator); - app.batcher = try gfx.Batcher.init(app.allocator, 1000); app.window_size = .{ @floatFromInt(window.width), @floatFromInt(window.height) }; @@ -147,12 +150,6 @@ pub fn lateInit(editor_mod: mach.Mod(Editor)) !void { app.framebuffer_size[0] / app.window_size[0], app.framebuffer_size[1] / app.window_size[1], }; - // TODO: Remove usage of content_scale if it isn't needed - app.content_scale = .{ 1.0, 1.0 }; - - const scale_factor = app.content_scale[1]; - - try gfx.init(app); imgui.setZigAllocator(&app.allocator); @@ -168,6 +165,7 @@ pub fn lateInit(editor_mod: mach.Mod(Editor)) !void { io.config_flags |= imgui.ConfigFlags_NavEnableKeyboard; io.display_framebuffer_scale = .{ .x = app.content_scale[0], .y = app.content_scale[1] }; io.font_global_scale = 1.0; + var cozette_config: imgui.FontConfig = std.mem.zeroes(imgui.FontConfig); cozette_config.font_data_owned_by_atlas = true; cozette_config.oversample_h = 2; @@ -177,7 +175,7 @@ pub fn lateInit(editor_mod: mach.Mod(Editor)) !void { cozette_config.rasterizer_density = 1.0; cozette_config.ellipsis_char = imgui.UNICODE_CODEPOINT_MAX; - _ = io.fonts.?.addFontFromFileTTF(assets.root ++ "fonts/CozetteVector.ttf", editor.settings.font_size * scale_factor, &cozette_config, null); + _ = io.fonts.?.addFontFromFileTTF(assets.root ++ "fonts/CozetteVector.ttf", editor.settings.font_size, &cozette_config, null); var fa_config: imgui.FontConfig = std.mem.zeroes(imgui.FontConfig); fa_config.merge_mode = true; @@ -190,8 +188,8 @@ pub fn lateInit(editor_mod: mach.Mod(Editor)) !void { fa_config.ellipsis_char = imgui.UNICODE_CODEPOINT_MAX; const ranges: []const u16 = &.{ 0xf000, 0xf976, 0 }; - app.fonts.fa_standard_solid = io.fonts.?.addFontFromFileTTF(assets.root ++ "fonts/fa-solid-900.ttf", editor.settings.font_size * scale_factor, &fa_config, @ptrCast(ranges.ptr)).?; - app.fonts.fa_standard_regular = io.fonts.?.addFontFromFileTTF(assets.root ++ "fonts/fa-regular-400.ttf", editor.settings.font_size * scale_factor, &fa_config, @ptrCast(ranges.ptr)).?; + app.fonts.fa_standard_solid = io.fonts.?.addFontFromFileTTF(assets.root ++ "fonts/fa-solid-900.ttf", editor.settings.font_size, &fa_config, @ptrCast(ranges.ptr)).?; + app.fonts.fa_standard_regular = io.fonts.?.addFontFromFileTTF(assets.root ++ "fonts/fa-regular-400.ttf", editor.settings.font_size, &fa_config, @ptrCast(ranges.ptr)).?; // Initialize the editor which loads our theme editor_mod.call(.lateInit); @@ -217,6 +215,7 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { editor.hotkeys.setHotkeyState(key_release.key, key_release.mods, .release); }, .mouse_scroll => |mouse_scroll| { + // TODO: Fix this in the editor code, we dont want to block mouse input based on popups if (!editor.popups.anyPopupOpen()) { // Only record mouse scrolling for canvases when popups are closed app.mouse.scroll_x = mouse_scroll.xoffset; app.mouse.scroll_y = mouse_scroll.yoffset; @@ -226,7 +225,7 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { app.mouse.magnify = gesture.zoom; }, .mouse_motion => |mouse_motion| { - app.mouse.position = .{ @floatCast(mouse_motion.pos.x * app.content_scale[0]), @floatCast(mouse_motion.pos.y * app.content_scale[1]) }; + app.mouse.position = .{ @floatCast(mouse_motion.pos.x), @floatCast(mouse_motion.pos.y) }; }, .mouse_press => |mouse_press| { app.mouse.setButtonState(mouse_press.button, mouse_press.mods, .press); @@ -235,19 +234,9 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { app.mouse.setButtonState(mouse_release.button, mouse_release.mods, .release); }, .close => { - var should_close = true; - for (editor.open_files.items) |file| { - if (file.dirty()) { - should_close = false; - } - } - - if (!should_close and !editor.popups.file_confirm_close_exit) { - editor.popups.file_confirm_close = true; - editor.popups.file_confirm_close_state = .all; - editor.popups.file_confirm_close_exit = true; - } - app.should_close = should_close; + // Currently, just pass along this message to the editor + // and allow the editor to set the app.should_close or not + editor_mod.call(.close); }, .window_resize => |resize| { const window = core.windows.getValue(app.window); @@ -262,7 +251,7 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { // Currently content scale is set to 1.0x1.0 because the scaling is handled by // zig-imgui. Tested both on Windows (1.0 content scale) and macOS (2.0 content scale) // If we can confirm that this is not needed, we can purge the use of content_scale from editor files - app.content_scale = .{ 1.0, 1.0 }; + //app.content_scale = .{ 1.0, 1.0 }; }, else => {}, @@ -276,6 +265,8 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { // New imgui frame try imgui_mach.newFrame(); imgui.newFrame(); + + // Update times app.delta_time = app.timer.lap(); app.total_time += app.delta_time; @@ -288,6 +279,7 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { // Render imgui imgui.render(); + // Pass commands to the window queue for presenting if (window.swap_chain.getCurrentTextureView()) |back_buffer_view| { defer back_buffer_view.release(); @@ -340,8 +332,8 @@ pub fn tick(app_mod: mach.Mod(App), editor_mod: mach.Mod(Editor)) !void { app.mouse.previous_position = app.mouse.position; + // Finally, close if we should and aren't in the middle of saving if (app.should_close and !editor.saving()) { - // Close! core.exit(); } } diff --git a/src/editor/Editor.zig b/src/editor/Editor.zig index bc28b34..a965c8f 100644 --- a/src/editor/Editor.zig +++ b/src/editor/Editor.zig @@ -29,6 +29,7 @@ pub const mach_systems = .{ .lateInit, .processDialogRequest, .tick, + .close, .deinit, }; @@ -208,6 +209,22 @@ pub fn tick( } } +pub fn close(app: *Pixi, editor: *Editor) void { + var should_close = true; + for (editor.open_files.items) |file| { + if (file.dirty()) { + should_close = false; + } + } + + if (!should_close and !editor.popups.file_confirm_close_exit) { + editor.popups.file_confirm_close = true; + editor.popups.file_confirm_close_state = .all; + editor.popups.file_confirm_close_exit = true; + } + app.should_close = should_close; +} + pub fn setProjectFolder(editor: *Editor, path: [:0]const u8) !void { if (editor.project_folder) |folder| { Pixi.app.allocator.free(folder); diff --git a/src/editor/Sidebar.zig b/src/editor/Sidebar.zig index 09297fa..c10b39e 100644 --- a/src/editor/Sidebar.zig +++ b/src/editor/Sidebar.zig @@ -28,7 +28,7 @@ pub fn draw(app: *Pixi, editor: *Editor) !void { .y = 0.0, }, imgui.Cond_Always); imgui.setNextWindowSize(.{ - .x = editor.settings.sidebar_width * app.content_scale[0], + .x = editor.settings.sidebar_width, .y = app.window_size[1], }, imgui.Cond_None); imgui.pushStyleVarImVec2(imgui.StyleVar_SelectableTextAlign, .{ .x = 0.5, .y = 0.5 }); diff --git a/src/editor/artboard/Artboard.zig b/src/editor/artboard/Artboard.zig index 9287786..8f380b6 100644 --- a/src/editor/artboard/Artboard.zig +++ b/src/editor/artboard/Artboard.zig @@ -35,12 +35,12 @@ pub fn draw(artboard: *Artboard, core: *Core, app: *Pixi, editor: *Editor) !void imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 0.0); defer imgui.popStyleVar(); imgui.setNextWindowPos(.{ - .x = (editor.settings.sidebar_width + editor.settings.explorer_width + editor.settings.explorer_grip) * app.content_scale[0], + .x = editor.settings.sidebar_width + editor.settings.explorer_width + editor.settings.explorer_grip, .y = 0.0, }, imgui.Cond_Always); imgui.setNextWindowSize(.{ - .x = (app.window_size[0] - ((editor.settings.explorer_width + editor.settings.sidebar_width + editor.settings.explorer_grip)) * app.content_scale[0]), - .y = (app.window_size[1] + 5.0) * app.content_scale[1], + .x = app.window_size[0] - editor.settings.explorer_width - editor.settings.sidebar_width - editor.settings.explorer_grip, + .y = app.window_size[1] + 5.0, }, imgui.Cond_None); imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 0.0, .y = 0.5 }); @@ -57,7 +57,26 @@ pub fn draw(artboard: *Artboard, core: *Core, app: *Pixi, editor: *Editor) !void art_flags |= imgui.WindowFlags_NoBringToFrontOnFocus; if (imgui.begin("Art", null, art_flags)) { - try menu.draw(app, core, editor); + try menu.draw(editor); + + defer { + const shadow_color = Pixi.math.Color.initFloats(0.0, 0.0, 0.0, editor.settings.shadow_opacity).toU32(); + // Draw a shadow fading from bottom to top + const pos = imgui.getWindowPos(); + const height = imgui.getWindowHeight(); + const width = imgui.getWindowWidth(); + + if (imgui.getWindowDrawList()) |draw_list| { + draw_list.addRectFilledMultiColor( + .{ .x = pos.x, .y = (pos.y + height) - editor.settings.shadow_length }, + .{ .x = pos.x + width, .y = pos.y + height }, + 0x0, + 0x0, + shadow_color, + shadow_color, + ); + } + } const art_width = imgui.getWindowWidth(); @@ -154,7 +173,7 @@ pub fn draw(artboard: *Artboard, core: *Core, app: *Pixi, editor: *Editor) !void } if (imgui.isItemHovered(imgui.HoveredFlags_DelayNormal)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 4.0 * app.content_scale[0], .y = 4.0 * app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVar(); if (imgui.beginTooltip()) { defer imgui.endTooltip(); @@ -226,7 +245,7 @@ pub fn draw(artboard: *Artboard, core: *Core, app: *Pixi, editor: *Editor) !void if (editor.explorer.pane != .pack) { if (editor.open_files.items.len > 0) { - const flipbook_height = window_height - artboard_height - editor.settings.info_bar_height * app.content_scale[1]; + const flipbook_height = window_height - artboard_height - editor.settings.info_bar_height; var flipbook_flags: imgui.WindowFlags = 0; flipbook_flags |= imgui.WindowFlags_MenuBar; @@ -253,7 +272,7 @@ pub fn draw(artboard: *Artboard, core: *Core, app: *Pixi, editor: *Editor) !void imgui.pushStyleColorImVec4(imgui.Col_ChildBg, Pixi.editor.theme.highlight_primary.toImguiVec4()); defer imgui.popStyleColor(); if (imgui.beginChild("InfoBar", .{ .x = -1.0, .y = 0.0 }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { - infobar.draw(app, core, editor); + infobar.draw(editor); } imgui.endChild(); } @@ -280,8 +299,8 @@ pub fn drawLogoScreen(app: *Pixi, editor: *Editor) !void { @floatFromInt(logo_sprite.source[3]), }; - const w = src[2] * 32.0 * app.content_scale[0]; - const h = src[3] * 32.0 * app.content_scale[0]; + const w = src[2] * 32.0; + const h = src[3] * 32.0; const center: [2]f32 = .{ imgui.getWindowWidth() / 2.0, imgui.getWindowHeight() / 2.0 }; const inv_w = 1.0 / @as(f32, @floatFromInt(app.loaded_assets.atlas_png.image.width)); diff --git a/src/editor/artboard/canvas.zig b/src/editor/artboard/canvas.zig index 5bb913a..91325bc 100644 --- a/src/editor/artboard/canvas.zig +++ b/src/editor/artboard/canvas.zig @@ -8,25 +8,6 @@ const zmath = @import("zmath"); pub fn draw(file: *Pixi.storage.Internal.PixiFile, core: *Core, app: *Pixi, editor: *Editor) !void { const transforming = file.transform_texture != null; - { - const shadow_color = Pixi.math.Color.initFloats(0.0, 0.0, 0.0, editor.settings.shadow_opacity).toU32(); - // Draw a shadow fading from bottom to top - const pos = imgui.getWindowPos(); - const height = imgui.getWindowHeight(); - const width = imgui.getWindowWidth(); - - if (imgui.getWindowDrawList()) |draw_list| { - draw_list.addRectFilledMultiColor( - .{ .x = pos.x, .y = (pos.y + height) - editor.settings.shadow_length * app.content_scale[1] }, - .{ .x = pos.x + width, .y = pos.y + height }, - 0x0, - 0x0, - shadow_color, - shadow_color, - ); - } - } - const window_width = imgui.getWindowWidth(); const window_height = imgui.getWindowHeight(); const file_width = @as(f32, @floatFromInt(file.width)); diff --git a/src/editor/artboard/flipbook/menu.zig b/src/editor/artboard/flipbook/menu.zig index d871d5a..2cc8cd2 100644 --- a/src/editor/artboard/flipbook/menu.zig +++ b/src/editor/artboard/flipbook/menu.zig @@ -35,7 +35,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, mouse_ratio: f32, app: *Pixi, const animation = &file.animations.slice().get(file.selected_animation_index); { // Animation Selection - imgui.setNextItemWidth(imgui.calcTextSize(animation.name).x + 40 * app.content_scale[0]); + imgui.setNextItemWidth(imgui.calcTextSize(animation.name).x + 40); if (imgui.beginCombo("Animation ", animation.name, imgui.ComboFlags_HeightLargest)) { defer imgui.endCombo(); var animation_index: usize = 0; @@ -54,7 +54,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, mouse_ratio: f32, app: *Pixi, const frame = try std.fmt.allocPrintZ(app.allocator, "{d}/{d}", .{ current_frame + 1, animation.length }); defer app.allocator.free(frame); - imgui.setNextItemWidth(imgui.calcTextSize(frame).x + 40 * app.content_scale[0]); + imgui.setNextItemWidth(imgui.calcTextSize(frame).x + 40); if (imgui.beginCombo("Frame ", frame, imgui.ComboFlags_None)) { defer imgui.endCombo(); for (0..animation.length) |i| { @@ -69,7 +69,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, mouse_ratio: f32, app: *Pixi, } { // FPS Selection - imgui.setNextItemWidth(100 * app.content_scale[0]); + imgui.setNextItemWidth(100); var fps = @as(i32, @intCast(animation.fps)); var changed: bool = false; if (imgui.sliderInt( @@ -115,7 +115,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, mouse_ratio: f32, app: *Pixi, const animation = &file.keyframe_animations.slice().get(file.selected_keyframe_animation_index); { // Animation Selection - imgui.setNextItemWidth(imgui.calcTextSize(animation.name).x + 40 * app.content_scale[0]); + imgui.setNextItemWidth(imgui.calcTextSize(animation.name).x + 40); if (imgui.beginCombo("Animation ", animation.name, imgui.ComboFlags_HeightLargest)) { defer imgui.endCombo(); var keyframe_animation_index: usize = 0; diff --git a/src/editor/artboard/infobar.zig b/src/editor/artboard/infobar.zig index 5d061b0..93fd572 100644 --- a/src/editor/artboard/infobar.zig +++ b/src/editor/artboard/infobar.zig @@ -8,18 +8,18 @@ const imgui = @import("zig-imgui"); const spacer: [:0]const u8 = " "; -pub fn draw(app: *Pixi, _: *Core, editor: *Editor) void { +pub fn draw(editor: *Editor) void { imgui.pushStyleColorImVec4(imgui.Col_Text, Pixi.editor.theme.foreground.toImguiVec4()); defer imgui.popStyleColor(); - const h = imgui.getTextLineHeightWithSpacing() + 6.0 * app.content_scale[1]; + const h = imgui.getTextLineHeightWithSpacing() + 6.0; const y = (imgui.getContentRegionAvail().y - h) / 2; - const spacing: f32 = 3.0 * app.content_scale[0]; + const spacing: f32 = 3.0; imgui.setCursorPosY(y); - imgui.setCursorPosX(5.0 * app.content_scale[0]); + imgui.setCursorPosX(5.0); if (editor.project_folder) |path| { - imgui.setCursorPosY(y + 2.0 * app.content_scale[1]); + imgui.setCursorPosY(y + 2.0); imgui.textColored(editor.theme.foreground.toImguiVec4(), Pixi.fa.folder_open); imgui.setCursorPosY(y); imgui.sameLineEx(0.0, spacing); diff --git a/src/editor/artboard/menu.zig b/src/editor/artboard/menu.zig index 431d778..3183a5f 100644 --- a/src/editor/artboard/menu.zig +++ b/src/editor/artboard/menu.zig @@ -7,9 +7,9 @@ const zstbi = @import("zstbi"); const nfd = @import("nfd"); const imgui = @import("zig-imgui"); -pub fn draw(app: *Pixi, _: *Core, editor: *Editor) !void { - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * app.content_scale[0], .y = 10.0 * app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 6.0 * app.content_scale[0], .y = 6.0 * app.content_scale[1] }); +pub fn draw(editor: *Editor) !void { + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 6.0, .y = 6.0 }); defer imgui.popStyleVarEx(2); imgui.pushStyleColorImVec4(imgui.Col_Text, editor.theme.text_secondary.toImguiVec4()); imgui.pushStyleColorImVec4(imgui.Col_PopupBg, editor.theme.foreground.toImguiVec4()); diff --git a/src/editor/artboard/rulers.zig b/src/editor/artboard/rulers.zig index cf77083..9a91514 100644 --- a/src/editor/artboard/rulers.zig +++ b/src/editor/artboard/rulers.zig @@ -30,7 +30,7 @@ pub fn draw(file: *Pixi.storage.Internal.PixiFile, app: *Pixi, _: *Core) !void { defer app.allocator.free(text); draw_list.addText( - .{ .x = tl[0] + offset[0] + (tile_width / 2.0 * file.camera.zoom) - (text_size.x / 2.0), .y = tl[1] + 4.0 * app.content_scale[1] }, + .{ .x = tl[0] + offset[0] + (tile_width / 2.0 * file.camera.zoom) - (text_size.x / 2.0), .y = tl[1] + 4.0 }, Pixi.editor.theme.text_secondary.toU32(), text.ptr, ); diff --git a/src/editor/explorer/Explorer.zig b/src/editor/explorer/Explorer.zig index e463d9b..1d1c40c 100644 --- a/src/editor/explorer/Explorer.zig +++ b/src/editor/explorer/Explorer.zig @@ -51,11 +51,11 @@ pub fn draw(core: *Core, app: *Pixi, editor: *Editor, explorer: *Explorer) !void const explorer_width = editor.settings.explorer_width; imgui.setNextWindowPos(.{ - .x = editor.settings.sidebar_width * app.content_scale[0], + .x = editor.settings.sidebar_width, .y = 0, }, imgui.Cond_Always); imgui.setNextWindowSize(.{ - .x = explorer_width * app.content_scale[0], + .x = explorer_width, .y = app.window_size[1], }, imgui.Cond_None); @@ -72,8 +72,8 @@ pub fn draw(core: *Core, app: *Pixi, editor: *Editor, explorer: *Explorer) !void defer imgui.end(); imgui.popStyleVarEx(3); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * app.content_scale[0], .y = 6.0 * app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 0.0, .y = 8.0 * app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 0.0, .y = 8.0 }); defer imgui.popStyleVarEx(2); imgui.pushStyleColorImVec4(imgui.Col_Separator, editor.theme.text_background.toImguiVec4()); diff --git a/src/editor/explorer/animations.zig b/src/editor/explorer/animations.zig index aa88425..ecd1251 100644 --- a/src/editor/explorer/animations.zig +++ b/src/editor/explorer/animations.zig @@ -21,10 +21,10 @@ pub fn draw(editor: *Editor) !void { file.flipbook_view = .canvas; if (imgui.collapsingHeader(Pixi.fa.screwdriver ++ " Tools", imgui.TreeNodeFlags_DefaultOpen)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 5.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 5.0 }); defer imgui.popStyleVar(); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 8.0 * Pixi.app.content_scale[0], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 8.0, .y = 4.0 }); imgui.pushStyleVarImVec2(imgui.StyleVar_SelectableTextAlign, .{ .x = 0.5, .y = 0.8 }); defer imgui.popStyleVarEx(2); @@ -34,7 +34,7 @@ pub fn draw(editor: *Editor) !void { defer imgui.popStyleColorEx(3); if (imgui.beginChild("AnimationTools", .{ .x = imgui.getWindowWidth(), - .y = editor.settings.animation_edit_height * Pixi.app.content_scale[1], + .y = editor.settings.animation_edit_height, }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); @@ -59,15 +59,15 @@ pub fn draw(editor: *Editor) !void { defer imgui.unindent(); if (imgui.beginChild("Animations", .{ - .x = imgui.getWindowWidth() - editor.settings.explorer_grip * Pixi.app.content_scale[0], + .x = imgui.getWindowWidth() - editor.settings.explorer_grip, .y = 0.0, }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 2.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 6.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 2.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * Pixi.app.content_scale[0], .y = 10.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 2.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); + imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 2.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 }); defer imgui.popStyleVarEx(4); var animation_index: usize = 0; while (animation_index < file.animations.slice().len) : (animation_index += 1) { diff --git a/src/editor/explorer/files.zig b/src/editor/explorer/files.zig index 84d1086..253696a 100644 --- a/src/editor/explorer/files.zig +++ b/src/editor/explorer/files.zig @@ -32,7 +32,7 @@ pub fn draw(editor: *Editor) !void { if (editor.project_folder) |path| { const folder = std.fs.path.basename(path); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 5.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 5.0 }); // Open files const file_count = editor.open_files.items.len; @@ -43,7 +43,7 @@ pub fn draw(editor: *Editor) !void { if (imgui.beginChild("OpenFiles", .{ .x = -1.0, - .y = @as(f32, @floatFromInt(@min(file_count + 1, 6))) * (imgui.getTextLineHeight() + 6.0 * Pixi.app.content_scale[0]), + .y = @as(f32, @floatFromInt(@min(file_count + 1, 6))) * (imgui.getTextLineHeight() + 6.0), }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); imgui.spacing(); @@ -58,10 +58,10 @@ pub fn draw(editor: *Editor) !void { editor.setActiveFile(i); } - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 2.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 6.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * Pixi.app.content_scale[0], .y = 10.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 2.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); + imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 }); imgui.pushID(file.path); if (imgui.beginPopupContextItem()) { try contextMenuFile(editor, file.path); @@ -98,10 +98,10 @@ pub fn draw(editor: *Editor) !void { imgui.indent(); defer imgui.unindent(); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 2.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 6.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * Pixi.app.content_scale[0], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 2.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); + imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 4.0 }); imgui.pushID(path); if (imgui.beginPopupContextItem()) { try contextMenuFolder(editor, path); @@ -142,7 +142,7 @@ pub fn draw(editor: *Editor) !void { imgui.pushStyleColorImVec4(imgui.Col_Text, editor.theme.text_secondary.toImguiVec4()); defer imgui.popStyleColor(); if (imgui.beginChild("Recents", .{ - .x = imgui.getWindowWidth() - editor.settings.explorer_grip * Pixi.app.content_scale[0], + .x = imgui.getWindowWidth() - editor.settings.explorer_grip, .y = 0.0, }, imgui.ChildFlags_None, imgui.WindowFlags_HorizontalScrollbar)) { defer imgui.endChild(); @@ -157,10 +157,10 @@ pub fn draw(editor: *Editor) !void { if (imgui.selectable(label)) { try editor.setProjectFolder(folder); } - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 2.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 6.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * Pixi.app.content_scale[0], .y = 10.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 2.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); + imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 }); defer imgui.popStyleVarEx(4); if (imgui.beginPopupContextItem()) { defer imgui.endPopup(); @@ -171,7 +171,7 @@ pub fn draw(editor: *Editor) !void { } } - imgui.sameLineEx(0.0, 5.0 * Pixi.app.content_scale[0]); + imgui.sameLineEx(0.0, 5.0); imgui.pushStyleColorImVec4(imgui.Col_Text, editor.theme.text_background.toImguiVec4()); imgui.text(folder); imgui.popStyleColor(); @@ -185,10 +185,10 @@ pub fn draw(editor: *Editor) !void { // When reworking, also try to reduce/remove global pointer usage, better to pass in editor or app pointers pub fn recurseFiles(allocator: std.mem.Allocator, root_directory: [:0]const u8) !void { - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 2.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 6.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * Pixi.app.content_scale[0], .y = 10.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 2.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); + imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 16.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 }); defer imgui.popStyleVarEx(4); const recursor = struct { diff --git a/src/editor/explorer/keyframe_animations.zig b/src/editor/explorer/keyframe_animations.zig index 2446c00..7a8cd75 100644 --- a/src/editor/explorer/keyframe_animations.zig +++ b/src/editor/explorer/keyframe_animations.zig @@ -59,16 +59,16 @@ pub fn draw(editor: *Editor) !void { defer imgui.unindent(); if (imgui.beginChild("Animations", .{ - .x = imgui.getWindowWidth() - editor.settings.explorer_grip * Pixi.app.content_scale[0], + .x = imgui.getWindowWidth() - editor.settings.explorer_grip, .y = 0.0, }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 2.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 6.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 2.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 6.0 }); imgui.pushStyleVarImVec2(imgui.StyleVar_SelectableTextAlign, .{ .x = 0.0, .y = 0.5 }); - imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 2.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0 * Pixi.app.content_scale[0], .y = 10.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVar(imgui.StyleVar_IndentSpacing, 2.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 10.0, .y = 10.0 }); defer imgui.popStyleVarEx(5); var animation_index: usize = 0; while (animation_index < file.keyframe_animations.slice().len) : (animation_index += 1) { diff --git a/src/editor/explorer/pack.zig b/src/editor/explorer/pack.zig index 2cb07b0..6974cd7 100644 --- a/src/editor/explorer/pack.zig +++ b/src/editor/explorer/pack.zig @@ -6,7 +6,7 @@ const nfd = @import("nfd"); const imgui = @import("zig-imgui"); pub fn draw(_: *Core, app: *Pixi, editor: *Editor) !void { - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 6.0 * app.content_scale[0], .y = 5.0 * app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 6.0, .y = 5.0 }); defer imgui.popStyleVar(); imgui.pushStyleColorImVec4(imgui.Col_Button, editor.theme.highlight_secondary.toImguiVec4()); imgui.pushStyleColorImVec4(imgui.Col_ButtonActive, editor.theme.highlight_secondary.toImguiVec4()); @@ -143,7 +143,7 @@ pub fn draw(_: *Core, app: *Pixi, editor: *Editor) !void { imgui.pushStyleColorImVec4(imgui.Col_Text, editor.theme.text_secondary.toImguiVec4()); defer imgui.popStyleColor(); if (imgui.beginChild("Recents", .{ - .x = imgui.getWindowWidth() - editor.settings.explorer_grip * app.content_scale[0], + .x = imgui.getWindowWidth() - editor.settings.explorer_grip, .y = 0.0, }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); @@ -159,7 +159,7 @@ pub fn draw(_: *Core, app: *Pixi, editor: *Editor) !void { const exp_out = editor.recents.exports.swapRemove(i); try editor.recents.appendExport(exp_out); } - imgui.sameLineEx(0.0, 5.0 * Pixi.app.content_scale[0]); + imgui.sameLineEx(0.0, 5.0); imgui.pushStyleColorImVec4(imgui.Col_Text, editor.theme.text_background.toImguiVec4()); imgui.text(exp); imgui.popStyleColor(); diff --git a/src/editor/explorer/settings.zig b/src/editor/explorer/settings.zig index 87d79d0..74de363 100644 --- a/src/editor/explorer/settings.zig +++ b/src/editor/explorer/settings.zig @@ -9,7 +9,7 @@ const nfd = @import("nfd"); const imgui = @import("zig-imgui"); pub fn draw(core: *Core, editor: *Editor) !void { - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 6.0 * Pixi.app.content_scale[1], .y = 6.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 6.0, .y = 6.0 }); defer imgui.popStyleVar(); imgui.pushStyleColorImVec4(imgui.Col_Header, editor.theme.highlight_secondary.toImguiVec4()); defer imgui.popStyleColor(); @@ -19,14 +19,14 @@ pub fn draw(core: *Core, editor: *Editor) !void { .y = -1.0, }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); - imgui.pushItemWidth(imgui.getWindowWidth() - editor.settings.explorer_grip * Pixi.app.content_scale[0]); + imgui.pushItemWidth(imgui.getWindowWidth() - editor.settings.explorer_grip); if (imgui.collapsingHeader(Pixi.fa.mouse ++ " Input", imgui.TreeNodeFlags_Framed)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0 * Pixi.app.content_scale[0], .y = 3.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0 * Pixi.app.content_scale[1], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0, .y = 3.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(2); - imgui.pushItemWidth(editor.settings.explorer_width * Pixi.app.content_scale[0] * 0.5); + imgui.pushItemWidth(editor.settings.explorer_width * 0.5); if (imgui.beginCombo("Scheme", @tagName(editor.settings.input_scheme), imgui.ComboFlags_None)) { defer imgui.endCombo(); if (imgui.selectable("mouse")) { @@ -53,11 +53,11 @@ pub fn draw(core: *Core, editor: *Editor) !void { } if (imgui.collapsingHeader(Pixi.fa.th_list ++ " Layout", imgui.TreeNodeFlags_None)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0 * Pixi.app.content_scale[0], .y = 3.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0 * Pixi.app.content_scale[1], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0, .y = 3.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(2); - imgui.pushItemWidth(editor.settings.explorer_width * Pixi.app.content_scale[0] * 0.5); + imgui.pushItemWidth(editor.settings.explorer_width * 0.5); _ = imgui.sliderFloatEx( "Info Height", @@ -95,10 +95,10 @@ pub fn draw(core: *Core, editor: *Editor) !void { } if (imgui.collapsingHeader(Pixi.fa.sliders_h ++ " Configuration", imgui.TreeNodeFlags_None)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0 * Pixi.app.content_scale[0], .y = 3.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0 * Pixi.app.content_scale[1], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0, .y = 3.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(2); - imgui.pushItemWidth(editor.settings.explorer_width * Pixi.app.content_scale[0] * 0.5); + imgui.pushItemWidth(editor.settings.explorer_width * 0.5); _ = imgui.checkbox( "Dropper Auto-switch", @@ -123,8 +123,8 @@ pub fn draw(core: *Core, editor: *Editor) !void { } if (imgui.collapsingHeader(Pixi.fa.paint_roller ++ " Style", imgui.TreeNodeFlags_None)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0 * Pixi.app.content_scale[0], .y = 3.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0 * Pixi.app.content_scale[1], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 3.0, .y = 3.0 }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(2); imgui.pushStyleColorImVec4(imgui.Col_Button, editor.theme.highlight_secondary.toImguiVec4()); @@ -149,7 +149,7 @@ pub fn draw(core: *Core, editor: *Editor) !void { imgui.spacing(); - if (imgui.buttonEx("Save As...", .{ .x = imgui.getWindowWidth() - editor.settings.explorer_grip * Pixi.app.content_scale[0], .y = 0.0 })) { + if (imgui.buttonEx("Save As...", .{ .x = imgui.getWindowWidth() - editor.settings.explorer_grip, .y = 0.0 })) { editor.popups.file_dialog_request = .{ .state = .save, .type = .export_theme, diff --git a/src/editor/explorer/sprites.zig b/src/editor/explorer/sprites.zig index d8e39ce..d3ae805 100644 --- a/src/editor/explorer/sprites.zig +++ b/src/editor/explorer/sprites.zig @@ -96,7 +96,7 @@ pub fn draw(editor: *Editor) !void { } if (imgui.collapsingHeader(Pixi.fa.atlas ++ " Sprites", imgui.TreeNodeFlags_DefaultOpen)) { - imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0 * Pixi.app.content_scale[0], .y = 5.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_FramePadding, .{ .x = 2.0, .y = 5.0 }); defer imgui.popStyleVar(); if (imgui.beginChild("Sprites", .{ .x = 0.0, .y = 0.0 }, imgui.ChildFlags_None, imgui.WindowFlags_ChildWindow)) { defer imgui.endChild(); diff --git a/src/editor/popups/about.zig b/src/editor/popups/about.zig index d1f6c59..7d3d436 100644 --- a/src/editor/popups/about.zig +++ b/src/editor/popups/about.zig @@ -8,8 +8,8 @@ pub fn draw() !void { imgui.openPopup("About", imgui.PopupFlags_None); } else return; - const popup_width = 450 * Pixi.app.content_scale[0]; - const popup_height = 450 * Pixi.app.content_scale[1]; + const popup_width = 450; + const popup_height = 450; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -44,8 +44,8 @@ pub fn draw() !void { @floatFromInt(fox_sprite.source[3]), }; - const w = src[2] * 4.0 * Pixi.app.content_scale[0]; - const h = src[3] * 4.0 * Pixi.app.content_scale[1]; + const w = src[2] * 4.0; + const h = src[3] * 4.0; const center: [2]f32 = .{ imgui.getWindowWidth() / 2.0, imgui.getWindowHeight() / 4.0 }; imgui.setCursorPosX(center[0] - w / 2.0); diff --git a/src/editor/popups/animation.zig b/src/editor/popups/animation.zig index 4482ae9..4ad5f7b 100644 --- a/src/editor/popups/animation.zig +++ b/src/editor/popups/animation.zig @@ -19,8 +19,8 @@ pub fn draw(editor: *Editor) !void { imgui.openPopup(dialog_name, imgui.PopupFlags_None); } else return; - const popup_width = 350 * Pixi.app.content_scale[0]; - const popup_height = 115 * Pixi.app.content_scale[1]; + const popup_width: f32 = 350; + const popup_height: f32 = 115; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -48,8 +48,8 @@ pub fn draw(editor: *Editor) !void { const style = imgui.getStyle(); const spacing = style.item_spacing.x; - const full_width = popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - imgui.calcTextSize("Name").x; - const half_width = (popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - spacing) / 2.0; + const full_width = popup_width - (style.frame_padding.x * 2.0) - imgui.calcTextSize("Name").x; + const half_width = (popup_width - (style.frame_padding.x * 2.0) - spacing) / 2.0; var input_text_flags: imgui.InputTextFlags = 0; input_text_flags |= imgui.InputTextFlags_AutoSelectAll; diff --git a/src/editor/popups/export_png.zig b/src/editor/popups/export_png.zig index 3cbe3a1..39d5808 100644 --- a/src/editor/popups/export_png.zig +++ b/src/editor/popups/export_png.zig @@ -11,8 +11,8 @@ pub fn draw(editor: *Editor) !void { imgui.openPopup("Export to .png...", imgui.PopupFlags_None); } else return; - const popup_width = 350 * Pixi.app.content_scale[0]; - const popup_height = 300 * Pixi.app.content_scale[1]; + const popup_width = 350; + const popup_height = 300; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -40,7 +40,7 @@ pub fn draw(editor: *Editor) !void { const style = imgui.getStyle(); const spacing = style.item_spacing.x; const content = imgui.getContentRegionAvail(); - const half_width = (popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - spacing) / 2.0; + const half_width = (popup_width - (style.frame_padding.x * 2.0) - spacing) / 2.0; const plot_name = switch (editor.popups.export_to_png_state) { .selected_sprite => "Selected Sprite", diff --git a/src/editor/popups/file_confirm_close.zig b/src/editor/popups/file_confirm_close.zig index 8a72782..7427681 100644 --- a/src/editor/popups/file_confirm_close.zig +++ b/src/editor/popups/file_confirm_close.zig @@ -8,8 +8,8 @@ pub fn draw() !void { imgui.openPopup("Confirm close...", imgui.PopupFlags_None); } else return; - const popup_width = 350 * Pixi.app.content_scale[0]; - const popup_height = if (Pixi.editor.popups.file_confirm_close_state == .one) 120 * Pixi.app.content_scale[1] else 250 * Pixi.app.content_scale[1]; + const popup_width: f32 = 350; + const popup_height: f32 = if (Pixi.editor.popups.file_confirm_close_state == .one) 120 else 250; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -37,8 +37,8 @@ pub fn draw() !void { const style = imgui.getStyle(); const spacing = style.item_spacing.x; - const full_width = popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - imgui.calcTextSize("Name").x; - const third_width = (popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - spacing * 2.0) / 3.0; + const full_width = popup_width - (style.frame_padding.x * 2.0) - imgui.calcTextSize("Name").x; + const third_width = (popup_width - (style.frame_padding.x * 2.0) - spacing * 2.0) / 3.0; switch (Pixi.editor.popups.file_confirm_close_state) { .one => { @@ -54,7 +54,7 @@ pub fn draw() !void { imgui.spacing(); if (imgui.beginChild( "OpenFileArea", - .{ .x = 0.0, .y = 120 * Pixi.app.content_scale[1] }, + .{ .x = 0.0, .y = 120 }, imgui.ChildFlags_None, imgui.WindowFlags_None, )) { diff --git a/src/editor/popups/file_setup.zig b/src/editor/popups/file_setup.zig index d08ed86..3826886 100644 --- a/src/editor/popups/file_setup.zig +++ b/src/editor/popups/file_setup.zig @@ -8,8 +8,8 @@ pub fn draw() !void { imgui.openPopup("File Setup...", imgui.PopupFlags_None); } else return; - const popup_width = 350 * Pixi.app.content_scale[0]; - const popup_height = 300 * Pixi.app.content_scale[1]; + const popup_width = 350; + const popup_height = 300; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -32,7 +32,7 @@ pub fn draw() !void { const style = imgui.getStyle(); - const full_width = popup_width - (style.frame_padding.x * 3 * Pixi.app.content_scale[0]) - imgui.calcTextSize("Tile Height").x; + const full_width = popup_width - (style.frame_padding.x * 3) - imgui.calcTextSize("Tile Height").x; const base_name = std.fs.path.basename(&Pixi.editor.popups.file_setup_path); const base_name_index = if (std.mem.indexOf(u8, Pixi.editor.popups.file_setup_path[0..], base_name)) |index| index else 0; @@ -126,8 +126,8 @@ pub fn draw() !void { imgui.textColored(Pixi.editor.theme.highlight_primary.toImguiVec4(), " " ++ Pixi.fa.check); } - const spacing = 5.0 * Pixi.app.content_scale[0]; - const half_width = (popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - spacing) / 2.0; + const spacing = 5.0; + const half_width = (popup_width - (style.frame_padding.x * 2.0) - spacing) / 2.0; if (imgui.buttonEx("Cancel", .{ .x = half_width, .y = 0.0 })) { Pixi.editor.popups.fileSetupClose(); } diff --git a/src/editor/popups/heightmap.zig b/src/editor/popups/heightmap.zig index be14ae4..23f9311 100644 --- a/src/editor/popups/heightmap.zig +++ b/src/editor/popups/heightmap.zig @@ -11,8 +11,8 @@ pub fn draw(editor: *Editor) !void { imgui.openPopup("Heightmap", imgui.PopupFlags_None); } else return; - const popup_width = 350 * Pixi.app.content_scale[0]; - const popup_height = 115 * Pixi.app.content_scale[1]; + const popup_width: f32 = 350; + const popup_height: f32 = 115; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -40,7 +40,7 @@ pub fn draw(editor: *Editor) !void { const style = imgui.getStyle(); const spacing = style.item_spacing.x; - const half_width = (popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - spacing) / 2.0; + const half_width = (popup_width - (style.frame_padding.x * 2.0) - spacing) / 2.0; imgui.textWrapped("There currently is no heightmap layer, would you like to create a heightmap layer?"); diff --git a/src/editor/popups/layer_setup.zig b/src/editor/popups/layer_setup.zig index 92422da..de892e1 100644 --- a/src/editor/popups/layer_setup.zig +++ b/src/editor/popups/layer_setup.zig @@ -17,8 +17,8 @@ pub fn draw(editor: *Editor) !void { imgui.openPopup(dialog_name, imgui.PopupFlags_None); } else return; - const popup_width = 350 * Pixi.app.content_scale[0]; - const popup_height = 115 * Pixi.app.content_scale[1]; + const popup_width: f32 = 350; + const popup_height: f32 = 115; const window_size = Pixi.app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -46,8 +46,8 @@ pub fn draw(editor: *Editor) !void { const style = imgui.getStyle(); const spacing = style.item_spacing.x; - const full_width = popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - imgui.calcTextSize("Name").x; - const half_width = (popup_width - (style.frame_padding.x * 2.0 * Pixi.app.content_scale[0]) - spacing) / 2.0; + const full_width = popup_width - (style.frame_padding.x * 2.0) - imgui.calcTextSize("Name").x; + const half_width = (popup_width - (style.frame_padding.x * 2.0) - spacing) / 2.0; imgui.pushItemWidth(full_width); diff --git a/src/editor/popups/references.zig b/src/editor/popups/references.zig index 3211d95..dc9f430 100644 --- a/src/editor/popups/references.zig +++ b/src/editor/popups/references.zig @@ -10,7 +10,7 @@ var open: bool = false; pub fn draw(editor: *Editor) !void { if (!editor.popups.references) return; - const popup_size = 200 * Pixi.app.content_scale[0]; + const popup_size = 200; const window_size = Pixi.app.window_size; diff --git a/src/editor/popups/rename.zig b/src/editor/popups/rename.zig index 0110611..3314586 100644 --- a/src/editor/popups/rename.zig +++ b/src/editor/popups/rename.zig @@ -17,8 +17,8 @@ pub fn draw(popups: *Popups, app: *Pixi, editor: *Editor) !void { imgui.openPopup(dialog_name, imgui.PopupFlags_None); } else return; - const popup_width = 350 * app.content_scale[0]; - const popup_height = 115 * app.content_scale[1]; + const popup_width: f32 = 350; + const popup_height: f32 = 115; const window_size = app.window_size; const window_center: [2]f32 = .{ window_size[0] / 2.0, window_size[1] / 2.0 }; @@ -42,8 +42,8 @@ pub fn draw(popups: *Popups, app: *Pixi, editor: *Editor) !void { const style = imgui.getStyle(); const spacing = style.item_spacing.x; - const full_width = popup_width - (style.frame_padding.x * 2.0 * app.content_scale[0]) - imgui.calcTextSize("Name").x; - const half_width = (popup_width - (style.frame_padding.x * 2.0 * app.content_scale[0]) - spacing) / 2.0; + const full_width = popup_width - (style.frame_padding.x * 2.0) - imgui.calcTextSize("Name").x; + const half_width = (popup_width - (style.frame_padding.x * 2.0) - spacing) / 2.0; const base_name = std.fs.path.basename(popups.rename_path[0..]); var base_index: usize = 0; diff --git a/src/gfx/camera.zig b/src/gfx/camera.zig index 6c2930c..39dc9b7 100644 --- a/src/gfx/camera.zig +++ b/src/gfx/camera.zig @@ -850,9 +850,9 @@ pub const Camera = struct { } pub fn drawLayerTooltip(camera: Camera, layer_index: usize) !void { - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 8.0 * Pixi.app.content_scale[0], .y = 8.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 8.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 8.0, .y = 8.0 }); + imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 8.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(3); _ = camera; if (imgui.beginTooltip()) { @@ -865,9 +865,9 @@ pub const Camera = struct { } pub fn drawZoomTooltip(camera: Camera, zoom: f32) void { - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 8.0 * Pixi.app.content_scale[0], .y = 8.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 8.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 8.0, .y = 8.0 }); + imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 8.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(3); _ = camera; if (imgui.beginTooltip()) { @@ -879,9 +879,9 @@ pub const Camera = struct { } pub fn drawColorTooltip(camera: Camera, color: [4]u8) !void { - imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 8.0 * Pixi.app.content_scale[0], .y = 8.0 * Pixi.app.content_scale[1] }); - imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 8.0 * Pixi.app.content_scale[0]); - imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0 * Pixi.app.content_scale[0], .y = 4.0 * Pixi.app.content_scale[1] }); + imgui.pushStyleVarImVec2(imgui.StyleVar_WindowPadding, .{ .x = 8.0, .y = 8.0 }); + imgui.pushStyleVar(imgui.StyleVar_WindowRounding, 8.0); + imgui.pushStyleVarImVec2(imgui.StyleVar_ItemSpacing, .{ .x = 4.0, .y = 4.0 }); defer imgui.popStyleVarEx(3); _ = camera; if (imgui.beginTooltip()) { @@ -893,8 +893,8 @@ pub const Camera = struct { .w = @as(f32, @floatFromInt(color[3])) / 255.0, }; _ = imgui.colorButtonEx("Eyedropper", col, imgui.ColorEditFlags_None, .{ - .x = Pixi.editor.settings.eyedropper_preview_size * Pixi.app.content_scale[0], - .y = Pixi.editor.settings.eyedropper_preview_size * Pixi.app.content_scale[1], + .x = Pixi.editor.settings.eyedropper_preview_size, + .y = Pixi.editor.settings.eyedropper_preview_size, }); imgui.text("R: %d", color[0]); imgui.text("G: %d", color[1]);