progress on the packer ui

This commit is contained in:
Stefan Stefanov 2024-04-20 20:51:12 +03:00
parent 8d36f8bbd8
commit dfb286293e
2 changed files with 57 additions and 20 deletions

1
.gitignore vendored
View file

@ -10,6 +10,7 @@ log.txt
*.dylib *.dylib
*.so *.so
*.dSYM *.dSYM
*.a
linux linux
build/ build/

View file

@ -52,6 +52,14 @@ FileDialogType :: enum {
Exit, Exit,
} }
PackerSettings :: struct {
pixel_padding_x: f32,
pixel_padding_y: f32,
padding_enabled: bool,
fix_pixel_bleeding: bool,
output_json: bool,
output_odin: bool,
}
FILE_DIALOG_SIZE :: 1000 FILE_DIALOG_SIZE :: 1000
GameMemory :: struct { GameMemory :: struct {
@ -73,6 +81,8 @@ GameMemory :: struct {
source_files_to_pack: []string, source_files_to_pack: []string,
// What type of file dialog to open // What type of file dialog to open
source_location_type: FileDialogType, source_location_type: FileDialogType,
// Packer settings
packer_settings: PackerSettings,
} }
g_mem: ^GameMemory g_mem: ^GameMemory
@ -167,40 +177,52 @@ draw_screen_target :: proc() {
} }
draw_atlas_settings_and_preview :: proc() { draw_atlas_settings_and_preview :: proc() {
left_half_rect := rl.Rectangle { left_half_rect := rl.Rectangle {
0, x = 0,
0, y = 0,
auto_cast g_mem.window_info.width_scaled / 2, width = auto_cast g_mem.window_info.width_scaled / 3,
auto_cast g_mem.window_info.height_scaled, height = auto_cast g_mem.window_info.height_scaled,
} }
right_half_rect := rl.Rectangle { right_half_rect := rl.Rectangle {
auto_cast g_mem.window_info.width_scaled / 2, x = auto_cast g_mem.window_info.width_scaled / 3,
0, y = 0,
auto_cast g_mem.window_info.width_scaled / 2, width = auto_cast (g_mem.window_info.width_scaled / 3) * 2,
auto_cast g_mem.window_info.height_scaled, height = auto_cast g_mem.window_info.height_scaled,
} }
rl.DrawRectangleRec(left_half_rect, rl.WHITE) rl.DrawRectangleRec(left_half_rect, rl.WHITE)
rl.DrawRectangleRec(right_half_rect, rl.MAROON) rl.DrawRectangleRec(right_half_rect, rl.MAROON)
// font := rl.GuiGetFont() small_offset := 10 * scaling
// text_size := rl.MeasureTextEx(font, "Atlas Packer Settings", auto_cast font.baseSize / scaling, 1) big_offset := 30 * scaling
small_offset := 10 * scaling
elements_height: f32 = 0 elements_height: f32 = 0
rl.GuiLabel(
rl.Rectangle{x = small_offset, y = 0, width = 100 * scaling, height = 25 * scaling}, rl.GuiPanel(left_half_rect, "Atlas Settings")
"Atlas Packer Settings",
)
elements_height += 25 * scaling elements_height += 25 * scaling
rl.GuiLine({y = elements_height, width = left_half_rect.width}, "Packer Settings") rl.GuiLine({y = elements_height, width = left_half_rect.width}, "Packer Settings")
elements_height += small_offset elements_height += small_offset
rl.GuiLine({y = elements_height, width = left_half_rect.width}, "Save Settings")
elements_height += small_offset
if rl.GuiButton( if rl.GuiButton(
{ {
x = small_offset, x = small_offset,
y = elements_height, y = elements_height,
width = left_half_rect.width / 2 - small_offset * 2, width = left_half_rect.width / 2 - small_offset * 2,
height = 25 * scaling, height = small_offset,
},
"Pack",
) {
}
elements_height += small_offset * 2
rl.GuiLine({y = elements_height, width = left_half_rect.width}, "Save Settings")
elements_height += small_offset
if rl.GuiButton(
{
x = small_offset,
y = elements_height,
width = left_half_rect.width / 2 - small_offset * 2,
height = small_offset,
}, },
"Save", "Save",
) { ) {
@ -211,12 +233,26 @@ draw_atlas_settings_and_preview :: proc() {
x = left_half_rect.width / 2, x = left_half_rect.width / 2,
y = elements_height, y = elements_height,
width = left_half_rect.width / 2 - small_offset, width = left_half_rect.width / 2 - small_offset,
height = 25 * scaling, height = small_offset,
}, },
"Save To...", "Save To...",
) { ) {
} }
elements_height = 0
rl.GuiPanel(right_half_rect, "Atlas Preview")
short_edge := min(
right_half_rect.height - big_offset * 2,
right_half_rect.width - big_offset * 2,
)
preview_rect := rl.Rectangle {
x = right_half_rect.x + big_offset,
y = right_half_rect.y + big_offset,
width = short_edge,
height = short_edge,
}
rl.GuiDummyRec(preview_rect, "PREVIEW")
} }
open_file_dialog_and_store_output_paths :: proc() { open_file_dialog_and_store_output_paths :: proc() {