UI fixes
This commit is contained in:
@@ -53,12 +53,13 @@ Renderable :: struct {
|
|||||||
MAX_CHILDREN :: 16;
|
MAX_CHILDREN :: 16;
|
||||||
|
|
||||||
Entity :: struct {
|
Entity :: struct {
|
||||||
|
name: string;
|
||||||
|
|
||||||
id: Entity_Id; @Hide @DontSerialize
|
id: Entity_Id; @Hide @DontSerialize
|
||||||
type : Type;
|
type : Type;
|
||||||
|
|
||||||
enabled: bool = true;
|
enabled: bool = true;
|
||||||
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
parent: *Entity; @DontSerialize
|
parent: *Entity; @DontSerialize
|
||||||
children: [MAX_CHILDREN] *Entity; @DontSerialize
|
children: [MAX_CHILDREN] *Entity; @DontSerialize
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ Editor :: struct {
|
|||||||
last_right_mouse_click_time: float;
|
last_right_mouse_click_time: float;
|
||||||
|
|
||||||
menu_position: Vector2;
|
menu_position: Vector2;
|
||||||
|
hide_ui: bool;
|
||||||
|
|
||||||
icons : struct {
|
icons : struct {
|
||||||
play: Texture_Handle;
|
play: Texture_Handle;
|
||||||
|
|||||||
@@ -121,21 +121,19 @@ editor_ui :: () {
|
|||||||
entity := engine.editor.selected_entities[0];
|
entity := engine.editor.selected_entities[0];
|
||||||
//ui_slider(*slider_value, 0.0, 1.0);
|
//ui_slider(*slider_value, 0.0, 1.0);
|
||||||
|
|
||||||
ui_textfield("Name", *entity.name);
|
|
||||||
|
|
||||||
ui_label(tprint("Id: %", entity.id));
|
ui_label(tprint("Id: %", entity.id));
|
||||||
|
|
||||||
updated := ui_vector_field("Position", *entity.transform.position);
|
//updated := ui_vector_field("Position", *entity.transform.position);
|
||||||
euler_rotation := quaternion_to_euler_v3(entity.transform.orientation);
|
//euler_rotation := quaternion_to_euler_v3(entity.transform.orientation);
|
||||||
euler_rotation *= RADIANS_TO_DEGREES;
|
//euler_rotation *= RADIANS_TO_DEGREES;
|
||||||
updated |= ui_vector_field("Rotation", *euler_rotation);
|
//updated |= ui_vector_field("Rotation", *euler_rotation);
|
||||||
euler_rotation *= DEGREES_TO_RADIANS;
|
//euler_rotation *= DEGREES_TO_RADIANS;
|
||||||
entity.transform.orientation = euler_to_quaternion(euler_rotation);
|
//entity.transform.orientation = euler_to_quaternion(euler_rotation);
|
||||||
updated |= ui_vector_field("Scale", *entity.transform.scale);
|
//updated |= ui_vector_field("Scale", *entity.transform.scale);
|
||||||
|
|
||||||
if updated {
|
//if updated {
|
||||||
update_matrix(*entity.transform);
|
// update_matrix(*entity.transform);
|
||||||
}
|
//}
|
||||||
|
|
||||||
entity_ui(entity);
|
entity_ui(entity);
|
||||||
}
|
}
|
||||||
@@ -148,7 +146,9 @@ text_fun : string;
|
|||||||
slider_value : float = 0.0;
|
slider_value : float = 0.0;
|
||||||
|
|
||||||
base_editor_update :: () {
|
base_editor_update :: () {
|
||||||
editor_ui();
|
if !engine.editor.hide_ui {
|
||||||
|
editor_ui();
|
||||||
|
}
|
||||||
|
|
||||||
camera := *engine.editor.camera;
|
camera := *engine.editor.camera;
|
||||||
|
|
||||||
@@ -173,37 +173,39 @@ base_editor_update :: () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if key_pressed(.CTRL) && key_down(.Z) {
|
if !engine.editor.focused_widget {
|
||||||
undo();
|
if key_pressed(.CTRL) && key_down(.Z) {
|
||||||
}
|
undo();
|
||||||
|
|
||||||
if key_pressed(.CTRL) && key_down(.S) {
|
|
||||||
save_scene(engine.current_scene, "../assets/scenes/");
|
|
||||||
//show_message("Saved scene");
|
|
||||||
}
|
|
||||||
|
|
||||||
if key_down(.DELETE) || key_down(.BACKSPACE) {
|
|
||||||
for engine.editor.selected_entities {
|
|
||||||
mark_entity_deleted(it);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.editor.transform_gizmo.selected_axis = .NONE;
|
if key_pressed(.CTRL) && key_down(.S) {
|
||||||
engine.editor.selected_entities.count = 0;
|
save_scene(engine.current_scene, "../assets/scenes/");
|
||||||
}
|
//show_message("Saved scene");
|
||||||
|
|
||||||
if key_pressed(.CTRL) && key_down(.D) {
|
|
||||||
duplicated_entities: [..] *Entity;
|
|
||||||
duplicated_entities.allocator = temp;
|
|
||||||
|
|
||||||
for e: engine.editor.selected_entities {
|
|
||||||
array_add(*duplicated_entities, duplicate_entity(e));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.editor.selected_entities.count = 0;
|
if key_down(.DELETE) || key_down(.BACKSPACE) {
|
||||||
|
for engine.editor.selected_entities {
|
||||||
|
mark_entity_deleted(it);
|
||||||
|
}
|
||||||
|
|
||||||
for e: duplicated_entities {
|
engine.editor.transform_gizmo.selected_axis = .NONE;
|
||||||
array_add(*engine.editor.selected_entities, e);
|
engine.editor.selected_entities.count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if key_pressed(.CTRL) && key_down(.D) {
|
||||||
|
duplicated_entities: [..] *Entity;
|
||||||
|
duplicated_entities.allocator = temp;
|
||||||
|
|
||||||
|
for e: engine.editor.selected_entities {
|
||||||
|
array_add(*duplicated_entities, duplicate_entity(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.editor.selected_entities.count = 0;
|
||||||
|
|
||||||
|
for e: duplicated_entities {
|
||||||
|
array_add(*engine.editor.selected_entities, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,7 +262,7 @@ base_editor_update :: () {
|
|||||||
engine.editor.menu_position.y = cast(float)engine.renderer.render_target_height - mouse_position.y;
|
engine.editor.menu_position.y = cast(float)engine.renderer.render_target_height - mouse_position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !key_pressed(.CTRL) {
|
if !engine.editor.focused_widget && !key_pressed(.CTRL) {
|
||||||
if key_down(.W) {
|
if key_down(.W) {
|
||||||
engine.editor.transform_gizmo.transform_type = .TRANSLATION;
|
engine.editor.transform_gizmo.transform_type = .TRANSLATION;
|
||||||
}
|
}
|
||||||
@@ -278,6 +280,10 @@ base_editor_update :: () {
|
|||||||
update_view_matrix(camera);
|
update_view_matrix(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if key_pressed(.CTRL) && key_down(.U) {
|
||||||
|
engine.editor.hide_ui = !engine.editor.hide_ui;
|
||||||
|
}
|
||||||
|
|
||||||
if key_pressed(.CTRL) && key_down(.E) {
|
if key_pressed(.CTRL) && key_down(.E) {
|
||||||
new_mode := ifx engine.mode == .EDITING then Engine_Mode.PLAYING else .EDITING;
|
new_mode := ifx engine.mode == .EDITING then Engine_Mode.PLAYING else .EDITING;
|
||||||
switch_engine_mode(new_mode);
|
switch_engine_mode(new_mode);
|
||||||
|
|||||||
27
ui/ui.jai
27
ui/ui.jai
@@ -480,6 +480,21 @@ ui_init :: () {
|
|||||||
|
|
||||||
// # BEGIN # LAYOUT ALGORITHM
|
// # BEGIN # LAYOUT ALGORITHM
|
||||||
ui_figure_out_sizes :: () {
|
ui_figure_out_sizes :: () {
|
||||||
|
if ui_state.currently_moving_window {
|
||||||
|
ui_state.currently_moving_window.offset.x += xx engine.input.mouse.delta_x;
|
||||||
|
ui_state.currently_moving_window.offset.y += xx engine.input.mouse.delta_y;
|
||||||
|
ui_state.currently_moving_window.offset.x -= xx min(0, ui_state.currently_moving_window.position.x + ui_state.currently_moving_window.offset.x);
|
||||||
|
ui_state.currently_moving_window.offset.y -= xx min(0, ui_state.currently_moving_window.position.y + ui_state.currently_moving_window.offset.y);
|
||||||
|
|
||||||
|
if !key_pressed(.MOUSE_LEFT) ui_state.currently_moving_window = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for *window: ui_state.windows {
|
||||||
|
if window.last_used_frame_index != ui_state.frame_index continue;
|
||||||
|
window.actual_position = window.position + window.offset;
|
||||||
|
}
|
||||||
|
|
||||||
// SET ALL PIXEL AND TEXT SIZES
|
// SET ALL PIXEL AND TEXT SIZES
|
||||||
for *box : ui_state.boxes {
|
for *box : ui_state.boxes {
|
||||||
if box.semantic_size[0].size_kind == {
|
if box.semantic_size[0].size_kind == {
|
||||||
@@ -1206,17 +1221,7 @@ ui_update_input :: () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ui_state.currently_moving_window.offset.x += xx engine.input.mouse.delta_x;
|
|
||||||
ui_state.currently_moving_window.offset.y += xx engine.input.mouse.delta_y;
|
|
||||||
ui_state.currently_moving_window.offset.x -= xx min(0, ui_state.currently_moving_window.position.x + ui_state.currently_moving_window.offset.x);
|
|
||||||
ui_state.currently_moving_window.offset.y -= xx min(0, ui_state.currently_moving_window.position.y + ui_state.currently_moving_window.offset.y);
|
|
||||||
|
|
||||||
if !key_pressed(.MOUSE_LEFT) ui_state.currently_moving_window = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for *window: ui_state.windows {
|
|
||||||
if window.last_used_frame_index != ui_state.frame_index continue;
|
|
||||||
window.actual_position = window.position + window.offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for *box: ui_state.boxes {
|
for *box: ui_state.boxes {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ ui_textfield :: (label: string, text: *string, identifier: s64 = 0, loc := #call
|
|||||||
ui_set_next_border_color(.{0.3,0.3,0.3,1.0});
|
ui_set_next_border_color(.{0.3,0.3,0.3,1.0});
|
||||||
ui_set_next_size_x(.PCT, 1);
|
ui_set_next_size_x(.PCT, 1);
|
||||||
|
|
||||||
text_size := get_text_size(engine.renderer, <<text, ui_state.fonts.button);
|
text_size := get_text_size(engine.renderer, "E", ui_state.fonts.button);
|
||||||
|
|
||||||
ui_set_next_size_y(.PIXELS, text_size.y); // TODO
|
ui_set_next_size_y(.PIXELS, text_size.y); // TODO
|
||||||
ui_set_next_padding(5);
|
ui_set_next_padding(5);
|
||||||
|
|||||||
Reference in New Issue
Block a user