UI fixes and new layout features
This commit is contained in:
@@ -33,15 +33,17 @@ pick_scene_view_at :: (camera: Camera, coordinates: Vector2) {
|
||||
|
||||
editor_ui :: () {
|
||||
// Scene picking
|
||||
if key_down(.MOUSE_LEFT) {
|
||||
if engine.current_scene != null {
|
||||
coords := engine.input.normalized_viewport_mouse_position;
|
||||
pick_scene_view_at(engine.editor.camera, .{coords.x, 1.0-coords.y});
|
||||
if !ui_mouse_over_window() {
|
||||
if key_down(.MOUSE_LEFT) {
|
||||
if engine.current_scene != null {
|
||||
coords := engine.input.normalized_viewport_mouse_position;
|
||||
pick_scene_view_at(engine.editor.camera, .{coords.x, 1.0-coords.y});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
ui_window_begin("Create", 100, 5, 200, 200);
|
||||
ui_window_begin("Create", cast(s32)engine.renderer.render_target_width - 200, 5, 200, 200);
|
||||
new_entity := editor_ui_entity_creation();
|
||||
if new_entity != null {
|
||||
set_position(*new_entity.transform, engine.editor.camera.position + engine.editor.camera.forward * 20.0);
|
||||
@@ -83,208 +85,63 @@ editor_ui :: () {
|
||||
}
|
||||
ui_window_end();
|
||||
|
||||
ui_full_size_background();
|
||||
ui_push_parent(ui_state.last_box, alignment=.LEFT, axis=.VERTICAL);
|
||||
ui_window_begin("Settings", 0, cast(s32)engine.renderer.render_target_height-80, 300, 80);
|
||||
{
|
||||
ui_set_next_padding(1);
|
||||
ui_toolbar();
|
||||
ui_push_parent(ui_state.last_box, alignment=.LEFT, axis=.HORIZONTAL);
|
||||
{
|
||||
if ui_toolbar_button("File") {
|
||||
if engine.editor.transform_gizmo.snap_to_grid {
|
||||
if ui_toolbar_button("Snap to grid enabled", .{0.0, 0.4, 0.0, 1.0}) {
|
||||
engine.editor.transform_gizmo.snap_to_grid = false;
|
||||
}
|
||||
|
||||
//ui_space(15, 10);
|
||||
|
||||
if ui_toolbar_button("Edit") {
|
||||
}
|
||||
|
||||
//ui_space(15, 10);
|
||||
|
||||
//if ui_toolbar_button("View") {
|
||||
//}
|
||||
|
||||
ui_space(20, 0);
|
||||
|
||||
if engine.mode == {
|
||||
case .PLAYING; {
|
||||
ui_set_next_background_color(.{0,0.6,0,1});
|
||||
if ui_button_with_texture(engine.editor.icons.stop) {
|
||||
switch_engine_mode(.EDITING);
|
||||
}
|
||||
ui_label(tprint("Playing '%'", engine.current_scene.name), .{0,0.7,0,1});
|
||||
}
|
||||
case .EDITING; {
|
||||
ui_set_next_background_color(.{0.6,0,0,1});
|
||||
if ui_button_with_texture(engine.editor.icons.play) {
|
||||
switch_engine_mode(.PLAYING);
|
||||
}
|
||||
ui_label(tprint("Editing '%'", engine.current_scene.name), .{1,1,1,1});
|
||||
}
|
||||
} else {
|
||||
if ui_toolbar_button("Snap to grid disabled", .{0.4, 0.0, 0.0, 1.0}) {
|
||||
engine.editor.transform_gizmo.snap_to_grid = true;
|
||||
}
|
||||
}
|
||||
ui_pop_parent();
|
||||
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.PCT, 0.965);
|
||||
ui_set_next_background_color(.{0,0,0,1});
|
||||
background := ui_box(.NONE);
|
||||
|
||||
ui_push_parent(ui_state.last_box, alignment=.LEFT, axis=.HORIZONTAL);
|
||||
{
|
||||
ui_set_next_size_x(.PCT, 0.1);
|
||||
ui_set_next_size_y(.PCT, 1.0);
|
||||
ui_set_next_padding(1);
|
||||
first_panel := ui_box(.NONE);
|
||||
ui_push_parent(first_panel, alignment=.LEFT, axis=.VERTICAL);
|
||||
{
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.PCT, 1.0);
|
||||
ui_set_next_background_color(.{0.04, 0.04, 0.04, 1.0});
|
||||
background := ui_box(.DRAW_BACKGROUND|.DRAW_BORDER);
|
||||
|
||||
ui_push_parent(background, alignment=.LEFT, axis=.VERTICAL);
|
||||
{
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_tab_title_bar("ENTITIES");
|
||||
|
||||
//if engine.current_scene != null {
|
||||
// for engine.current_scene.entities {
|
||||
// if it.flags & .DELETED continue;
|
||||
|
||||
// ui_set_next_padding(20);
|
||||
// clicked := false;
|
||||
// selected := array_find(engine.editor.selected_entities, it);
|
||||
// if it.name.count == 0 {
|
||||
// clicked = ui_clickable_label(tprint("%", it.type), selected, it.id);
|
||||
// } else {
|
||||
// clicked = ui_clickable_label(it.name, selected, it.id);
|
||||
// }
|
||||
|
||||
// if clicked {
|
||||
// if !key_pressed(.CTRL) {
|
||||
// engine.editor.selected_entities.count = 0;
|
||||
// array_add(*engine.editor.selected_entities, it);
|
||||
// } else {
|
||||
// if selected {
|
||||
// array_unordered_remove_by_value(*engine.editor.selected_entities, it);
|
||||
// } else {
|
||||
// array_add(*engine.editor.selected_entities, it);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //ui_space(0, 5);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
ui_pop_parent();
|
||||
if engine.editor.transform_gizmo.space == .LOCAL {
|
||||
if ui_toolbar_button("LOCAL", .{0.0, 0.3, 0.0, 1.0}) {
|
||||
engine.editor.transform_gizmo.space = .WORLD;
|
||||
}
|
||||
ui_pop_parent();
|
||||
|
||||
// Scene
|
||||
ui_set_next_size_x(.PCT, 0.7);
|
||||
ui_set_next_size_y(.PCT, 1.0);
|
||||
ui_set_next_padding(1);
|
||||
viewport_layer := ui_box(.NONE);
|
||||
ui_push_parent(viewport_layer, alignment=.LEFT, axis=.VERTICAL);
|
||||
{
|
||||
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_tab_title_bar("SCENE");
|
||||
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_set_next_size_y(.PCT, 0.1);
|
||||
ui_toolbar();
|
||||
ui_push_parent(ui_state.last_box, alignment=.LEFT, axis=.HORIZONTAL);
|
||||
{
|
||||
if engine.editor.transform_gizmo.snap_to_grid {
|
||||
if ui_toolbar_button("Snap to grid enabled", .{0.0, 0.4, 0.0, 1.0}) {
|
||||
engine.editor.transform_gizmo.snap_to_grid = false;
|
||||
}
|
||||
} else {
|
||||
if ui_toolbar_button("Snap to grid disabled", .{0.4, 0.0, 0.0, 1.0}) {
|
||||
engine.editor.transform_gizmo.snap_to_grid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if engine.editor.transform_gizmo.space == .LOCAL {
|
||||
if ui_toolbar_button("LOCAL", .{0.0, 0.3, 0.0, 1.0}) {
|
||||
engine.editor.transform_gizmo.space = .WORLD;
|
||||
}
|
||||
} else {
|
||||
if ui_toolbar_button("WORLD", .{0.0, 0.0, 0.3, 1.0}) {
|
||||
engine.editor.transform_gizmo.space = .LOCAL;
|
||||
}
|
||||
}
|
||||
//ui_space(15, 10)
|
||||
|
||||
ui_space(20, 0);
|
||||
}
|
||||
ui_pop_parent();
|
||||
|
||||
//ui_set_next_size_x(.PCT, 1.0);
|
||||
//ui_set_next_size_y(.PCT, 0.65);
|
||||
|
||||
//state := ui_interactable_texture(get_texture_from_pass("UI Blend Pass"));
|
||||
//engine.input.viewport_mouse_position = state.local_mouse_coordinates;
|
||||
//engine.input.normalized_viewport_mouse_position = state.normalized_local_mouse_coordinates;
|
||||
|
||||
|
||||
//engine.editor.mouse_viewport_state = state;
|
||||
|
||||
//ui_set_next_size_x(.PCT, 1.0);
|
||||
//ui_set_next_size_y(.PCT, 0.25);
|
||||
//ui_tab_title_bar("Create entities");
|
||||
//{
|
||||
// new_entity := editor_ui_entity_creation();
|
||||
// if new_entity != null {
|
||||
// set_position(*new_entity.transform, engine.editor.camera.position + engine.editor.camera.forward * 20.0);
|
||||
// engine.editor.selected_entities.count = 0;
|
||||
// array_add(*engine.editor.selected_entities, new_entity);
|
||||
// }
|
||||
//}
|
||||
} else {
|
||||
if ui_toolbar_button("WORLD", .{0.0, 0.0, 0.3, 1.0}) {
|
||||
engine.editor.transform_gizmo.space = .LOCAL;
|
||||
}
|
||||
ui_pop_parent();
|
||||
|
||||
// Properties
|
||||
ui_set_next_size_x(.PCT, 0.2);
|
||||
ui_set_next_size_y(.PCT, 1.0);
|
||||
ui_set_next_background_color(.{0.04, 0.04, 0.04, 1.0});
|
||||
ui_set_next_padding(1);
|
||||
inspector := ui_box(.DRAW_BACKGROUND | .DRAW_BORDER);
|
||||
ui_push_parent(inspector, alignment=.LEFT, axis=.VERTICAL);
|
||||
{
|
||||
ui_set_next_size_x(.PCT, 1.0);
|
||||
ui_tab_title_bar("PROPERTIES");
|
||||
|
||||
if engine.editor.selected_entities.count == 1 {
|
||||
entity := engine.editor.selected_entities[0];
|
||||
//ui_slider(*slider_value, 0.0, 1.0);
|
||||
|
||||
ui_textfield("Name", *entity.name);
|
||||
|
||||
ui_label(tprint("Id: %", entity.id));
|
||||
|
||||
updated := ui_vector_field("Position", *entity.transform.position);
|
||||
euler_rotation := quaternion_to_euler_v3(entity.transform.orientation);
|
||||
euler_rotation *= RADIANS_TO_DEGREES;
|
||||
updated |= ui_vector_field("Rotation", *euler_rotation);
|
||||
euler_rotation *= DEGREES_TO_RADIANS;
|
||||
entity.transform.orientation = euler_to_quaternion(euler_rotation);
|
||||
updated |= ui_vector_field("Scale", *entity.transform.scale);
|
||||
|
||||
if updated {
|
||||
update_matrix(*entity.transform);
|
||||
}
|
||||
|
||||
entity_ui(entity);
|
||||
}
|
||||
|
||||
}
|
||||
ui_pop_parent();
|
||||
}
|
||||
ui_pop_parent();
|
||||
//ui_space(15, 10)
|
||||
|
||||
ui_space(20, 0);
|
||||
}
|
||||
ui_window_end();
|
||||
|
||||
// Properties
|
||||
{
|
||||
if engine.editor.selected_entities.count == 1 {
|
||||
ui_window_begin("Properties", 200, 200, 400, 500);
|
||||
|
||||
if engine.editor.selected_entities.count == 1 {
|
||||
entity := engine.editor.selected_entities[0];
|
||||
//ui_slider(*slider_value, 0.0, 1.0);
|
||||
|
||||
ui_textfield("Name", *entity.name);
|
||||
|
||||
ui_label(tprint("Id: %", entity.id));
|
||||
|
||||
updated := ui_vector_field("Position", *entity.transform.position);
|
||||
euler_rotation := quaternion_to_euler_v3(entity.transform.orientation);
|
||||
euler_rotation *= RADIANS_TO_DEGREES;
|
||||
updated |= ui_vector_field("Rotation", *euler_rotation);
|
||||
euler_rotation *= DEGREES_TO_RADIANS;
|
||||
entity.transform.orientation = euler_to_quaternion(euler_rotation);
|
||||
updated |= ui_vector_field("Scale", *entity.transform.scale);
|
||||
|
||||
if updated {
|
||||
update_matrix(*entity.transform);
|
||||
}
|
||||
|
||||
entity_ui(entity);
|
||||
}
|
||||
ui_window_end();
|
||||
}
|
||||
}
|
||||
ui_pop_parent();
|
||||
}
|
||||
|
||||
text_fun : string;
|
||||
@@ -310,8 +167,10 @@ base_editor_update :: () {
|
||||
//coordinates := Vector2.{engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.x, 1.0 - engine.editor.mouse_viewport_state.normalized_local_mouse_coordinates.y};
|
||||
ray := normalized_screen_to_ray_v2(engine.editor.camera, coordinates);
|
||||
|
||||
if update_transform_gizmo(ray, coordinates) {
|
||||
engine.editor.should_check_entities = false;
|
||||
if !ui_mouse_over_window() {
|
||||
if update_transform_gizmo(ray, coordinates) {
|
||||
engine.editor.should_check_entities = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user