Various fixes
This commit is contained in:
parent
eac5104bbe
commit
c4e0902193
5 changed files with 24 additions and 21 deletions
1
TODO.MD
1
TODO.MD
|
|
@ -1,5 +1,4 @@
|
|||
- Centered justification in UI
|
||||
- Make web build
|
||||
- Center line
|
||||
- Zoom sensitivity
|
||||
- Web read/write
|
||||
|
|
|
|||
|
|
@ -79,9 +79,7 @@ draw_grid :: proc(grid: Grid, area, text_draw, text_clip: rect2, color: rl.Color
|
|||
}
|
||||
}
|
||||
|
||||
if rect_has_point(rect_from_area(tl, br), v2(0)) {
|
||||
origin := matrix3_transform_xy(grid_to_world_matrix, v2(0))
|
||||
rl.DrawLineV({area.x, origin.y}, {area.x + area.width, origin.y}, origin_color)
|
||||
rl.DrawLineV({origin.x, area.y}, {origin.x, area.y + area.height}, origin_color)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ shutdown :: proc() {
|
|||
|
||||
should_run :: proc() -> bool {
|
||||
when ODIN_OS != .JS {
|
||||
if rl.WindowShouldClose() {
|
||||
if program.window_should_close {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import "core:fmt"
|
|||
import "core:math"
|
||||
import "core:math/linalg"
|
||||
import "core:strings"
|
||||
import "core:slice"
|
||||
|
||||
RAYGUI_ICON_NEW :: "#009#"
|
||||
RAYGUI_ICON_SAVE :: "#002#"
|
||||
|
|
@ -295,6 +296,7 @@ Program :: struct {
|
|||
animation: Animation,
|
||||
animation_state: ProgramAnimationState,
|
||||
animation_speed: f32,
|
||||
window_should_close: bool,
|
||||
}
|
||||
|
||||
float_slice_get_mat3 :: proc(floats: []f32, index: int) -> ^mat3 {
|
||||
|
|
@ -370,8 +372,11 @@ program_load_project :: proc(program: ^Program, path: string) -> ProjectReadErro
|
|||
program.matrix_count = int(project.matrix_count)
|
||||
program.grid = project.grid
|
||||
program.animation.shapes = project.shapes
|
||||
for val, i in program.matrix_float_pool[:program.matrix_count * 9] {
|
||||
fmt.bprint(program.matrix_value_string_pool[i][:], val)
|
||||
matrices := slice.reinterpret([]mat3, program.matrix_float_pool[:program.matrix_count * 9])
|
||||
for mat, i in matrices {
|
||||
start := i * 9
|
||||
end := (i + 1) * 9
|
||||
write_matrix_to_values_and_value_strings(program.matrix_float_pool[start:end], program.matrix_value_string_pool[start:end], mat)
|
||||
}
|
||||
program.animation.matrix_count = program.matrix_count
|
||||
return nil
|
||||
|
|
@ -386,7 +391,6 @@ program_show_dialog :: proc(program: ^Program, dialog_type: ProgramDialogType, m
|
|||
mem.set(&program.dialog_data, 0, size_of(program.dialog_data))
|
||||
for i in 0..<len(program.dialog_data.input_float_values) {
|
||||
program.dialog_data.input_float_values[i] = 0.0
|
||||
program.dialog_data.input_float_value_strings[i][0] = '0'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -507,6 +511,9 @@ program_update :: proc() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if rl.WindowShouldClose() {
|
||||
program.window_should_close = true
|
||||
}
|
||||
case .Dialog:
|
||||
ui_overlay_elements = program_build_dialog_ui(&program.ui_overlay_context, program.dialog_type)
|
||||
if program.ui_overlay_queue_focus_first {
|
||||
|
|
@ -546,6 +553,9 @@ program_update :: proc() {
|
|||
program.animation.matrix_count = program.matrix_count
|
||||
program.state = .Normal
|
||||
}
|
||||
if rl.WindowShouldClose() {
|
||||
program.state = .Normal
|
||||
}
|
||||
}
|
||||
|
||||
clear(&program.mouse_draggables)
|
||||
|
|
@ -667,9 +677,9 @@ write_float_to_buffer :: proc(buffer: []byte, value: f32) {
|
|||
fraction := fract(value)
|
||||
if fraction == 0.0 {
|
||||
fmt.bprintf(buffer, "%.0f", value)
|
||||
} else if math.floor(fraction * 10.0) == 1.0 {
|
||||
} else if fract(fraction * 10.0) == 0.0 {
|
||||
fmt.bprintf(buffer, "%.1f", value)
|
||||
} else if math.floor(fraction * 100.0) == 1.0 {
|
||||
} else if fract(fraction * 100.0) == 0.0 {
|
||||
fmt.bprintf(buffer, "%.2f", value)
|
||||
} else {
|
||||
fmt.bprintf(buffer, "%.3f", value)
|
||||
|
|
@ -1116,10 +1126,7 @@ program_render_ui_and_handle_focus :: proc(ctx: ^ui.Context, focus_element_id: u
|
|||
case .CenterView:
|
||||
// TODO (synthas): Could be improved to center the whole animation
|
||||
// TODO (synthas): Reset zoom
|
||||
world_to_grid_matrix := grid_world_to_grid_matrix(program.grid.zoom, program.grid.offset)
|
||||
grid_to_world_matrix := linalg.inverse(world_to_grid_matrix)
|
||||
center := animation_get_center(program.animation) / grid_get_zoom(program.grid.zoom) - program_screen_size() / 2.0
|
||||
program.grid.offset = center
|
||||
program.grid.offset = animation_get_center(program.animation) - program_screen_size() * grid_get_zoom(program.grid.zoom) / 2.0
|
||||
case .ProjectSave:
|
||||
program_save_project_from_project_string_or_open_dialog(&program)
|
||||
case .ProjectSaveAs:
|
||||
|
|
@ -1232,11 +1239,10 @@ ui_mat3 :: proc(idx: int, mat: []f32, value_strings: []InputFloatField, dimensio
|
|||
ui.container_begin(matrix_container_dimensions, matrix_container_config, matrix_container_data)
|
||||
matrix_input_dimensions := ui.Dimensions {ui.Size_Percentage(1.0 / 3.0), ui.Size_Percentage(1.0 / 3.0)}
|
||||
matrix_input_config := ui.ElementConfiguration {margin = 4.0}
|
||||
// column first matrices
|
||||
#unroll for j in 0..<3 {
|
||||
#unroll for i in 0..<3 {
|
||||
#unroll for col in 0..<3 {
|
||||
#unroll for row in 0..<3 {
|
||||
data := new(UiElementData_FloatInput, allocator)
|
||||
index := i * 3 + j
|
||||
index := row * 3 + col
|
||||
data^ = {value = &mat[index], value_string = cstring(&value_strings[index][0]), tag = {.UpdateMatrix}}
|
||||
ui.element(.InputFloat, matrix_input_dimensions, matrix_input_config, data)
|
||||
ui.same_line()
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ draw_triangle :: proc(t: tri2, color: rl.Color) {
|
|||
|
||||
/// ### MATH ### ///
|
||||
fract :: proc(val: f32) -> f32 {
|
||||
return val - math.trunc(val)
|
||||
return abs(val - math.trunc(val))
|
||||
}
|
||||
|
||||
color_to_fcolor :: proc(color: rl.Color) -> [4]f32 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue