Moving matrices up/down

This commit is contained in:
Synthasmagoria 2026-08-22 21:12:54 +02:00
commit dd4bbd3030
2 changed files with 43 additions and 3 deletions

BIN
default

Binary file not shown.

View file

@ -80,6 +80,9 @@ UiButtonRecalculateFinishGroup :: bit_set[UiButtonType]{
.AddTranslationMatrixConfirm, .AddTranslationMatrixConfirm,
.AddScaleMatrixConfirm, .AddScaleMatrixConfirm,
.AddRotationMatrixConfirm, .AddRotationMatrixConfirm,
.MatrixDelete,
.MatrixMoveUp,
.MatrixMoveDown,
} }
UiElementData_Button :: struct { UiElementData_Button :: struct {
@ -722,9 +725,46 @@ program_render_ui_and_handle_focus :: proc(ctx: ^ui.Context, focus_element_id: u
mem.copy(&inputs[data.target_matrix * 9][0], &inputs[data.target_matrix * 9 + 9][0], matrix_inputs_size * amount) mem.copy(&inputs[data.target_matrix * 9][0], &inputs[data.target_matrix * 9 + 9][0], matrix_inputs_size * amount)
} }
program.matrix_count = max(program.matrix_count - 1, 0) program.matrix_count = max(program.matrix_count - 1, 0)
animation_update_last(&program.animation, program_get_master_matrix())
case .MatrixMoveUp: case .MatrixMoveUp:
if data.target_matrix <= 0 {
break;
}
floats := program.matrix_float_pool
inputs := program.matrix_value_string_pool
floats_values_size := size_of(f32) * 9
inputs_buffer_size := size_of(InputFloatField) * 9
floats_moving_matrix := &floats[data.target_matrix * 9]
inputs_moving_matrix := &inputs[data.target_matrix * 9][0]
floats_moved_to_matrix := &floats[data.target_matrix * 9 - 9]
inputs_moved_to_matrix := &inputs[data.target_matrix * 9 - 9][0]
floats_temp := [9]f32{}
inputs_temp := [9]InputFloatField{}
mem.copy(&floats_temp[0], floats_moving_matrix, floats_values_size)
mem.copy(&inputs_temp[0][0], inputs_moving_matrix, inputs_buffer_size)
mem.copy(floats_moving_matrix, floats_moved_to_matrix, floats_values_size)
mem.copy(inputs_moving_matrix, inputs_moved_to_matrix, inputs_buffer_size)
mem.copy(floats_moved_to_matrix, &floats_temp[0], floats_values_size)
mem.copy(inputs_moved_to_matrix, &inputs_temp[0][0], inputs_buffer_size)
case .MatrixMoveDown: case .MatrixMoveDown:
if data.target_matrix + 1 >= program.matrix_count {
break;
}
floats := program.matrix_float_pool
inputs := program.matrix_value_string_pool
floats_values_size := size_of(f32) * 9
inputs_buffer_size := size_of(InputFloatField) * 9
floats_moving_matrix := &floats[data.target_matrix * 9]
inputs_moving_matrix := &inputs[data.target_matrix * 9][0]
floats_moved_to_matrix := &floats[data.target_matrix * 9 + 9]
inputs_moved_to_matrix := &inputs[data.target_matrix * 9 + 9][0]
floats_temp := [9]f32{}
inputs_temp := [9]InputFloatField{}
mem.copy(&floats_temp[0], floats_moving_matrix, floats_values_size)
mem.copy(&inputs_temp[0][0], inputs_moving_matrix, inputs_buffer_size)
mem.copy(floats_moving_matrix, floats_moved_to_matrix, floats_values_size)
mem.copy(inputs_moving_matrix, inputs_moved_to_matrix, inputs_buffer_size)
mem.copy(floats_moved_to_matrix, &floats_temp[0], floats_values_size)
mem.copy(inputs_moved_to_matrix, &inputs_temp[0][0], inputs_buffer_size)
} }
if data.type in UiButtonRecalculateFinishGroup { if data.type in UiButtonRecalculateFinishGroup {
animation_update_last(&program.animation, program_get_master_matrix()) animation_update_last(&program.animation, program_get_master_matrix())
@ -821,13 +861,13 @@ ui_mat3 :: proc(idx: int, mat: []f32, value_strings: []InputFloatField, dimensio
button_config.label = RAYGUI_ICON_UP button_config.label = RAYGUI_ICON_UP
button_data = new(UiElementData_Button, allocator) button_data = new(UiElementData_Button, allocator)
button_data^ = {target_matrix = idx} button_data^ = {target_matrix = idx, type = .MatrixMoveUp}
ui.same_line() ui.same_line()
ui.element(.Button, ui.dimensions_pixels(32.0), button_config, button_data) ui.element(.Button, ui.dimensions_pixels(32.0), button_config, button_data)
button_config.label = RAYGUI_ICON_DOWN button_config.label = RAYGUI_ICON_DOWN
button_data = new(UiElementData_Button, allocator) button_data = new(UiElementData_Button, allocator)
button_data^ = {target_matrix = idx} button_data^ = {target_matrix = idx, type = .MatrixMoveDown}
ui.same_line() ui.same_line()
ui.element(.Button, ui.dimensions_pixels(32.0), button_config, button_data) ui.element(.Button, ui.dimensions_pixels(32.0), button_config, button_data)