diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index 5551889200..c824145ad3 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -311,15 +311,15 @@ ErrorOr serenity_main(Main::Arguments arguments) window->resize(640 + 4, 480 + 4); window->set_resizable(false); window->set_double_buffering_enabled(true); - auto& widget = window->set_main_widget(); + auto widget = TRY(window->try_set_main_widget()); - auto& time = widget.add(); + auto& time = widget->add(); time.set_visible(false); time.set_foreground_role(ColorRole::HoverHighlight); time.set_relative_rect({ 0, 8, 100, 10 }); time.set_text_alignment(Gfx::TextAlignment::CenterRight); - time.set_x(widget.width() - time.width() - 6); - widget.set_stat_label(time); + time.set_x(widget->width() - time.width() - 6); + widget->set_stat_label(time); auto& file_menu = window->add_menu("&File"); @@ -329,7 +329,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (result.error != 0) return; - if (widget.load_fd_and_close(*result.fd, *result.chosen_file)) { + if (widget->load_fd_and_close(*result.fd, *result.chosen_file)) { auto canonical_path = Core::File::absolute_path(*result.chosen_file); window->set_title(String::formatted("{} - 3D File Viewer", canonical_path)); } @@ -346,13 +346,13 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& rotation_axis_menu = view_menu.add_submenu("Rotation &Axis"); auto rotation_x_action = GUI::Action::create_checkable("&X", [&widget](auto&) { - widget.toggle_rotate_x(); + widget->toggle_rotate_x(); }); auto rotation_y_action = GUI::Action::create_checkable("&Y", [&widget](auto&) { - widget.toggle_rotate_y(); + widget->toggle_rotate_y(); }); auto rotation_z_action = GUI::Action::create_checkable("&Z", [&widget](auto&) { - widget.toggle_rotate_z(); + widget->toggle_rotate_z(); }); rotation_axis_menu.add_action(*rotation_x_action); @@ -367,16 +367,16 @@ ErrorOr serenity_main(Main::Arguments arguments) rotation_speed_actions.set_exclusive(true); auto no_rotation_action = GUI::Action::create_checkable("N&o Rotation", [&widget](auto&) { - widget.set_rotation_speed(0.f); + widget->set_rotation_speed(0.f); }); auto slow_rotation_action = GUI::Action::create_checkable("&Slow", [&widget](auto&) { - widget.set_rotation_speed(30.f); + widget->set_rotation_speed(30.f); }); auto normal_rotation_action = GUI::Action::create_checkable("&Normal", [&widget](auto&) { - widget.set_rotation_speed(60.f); + widget->set_rotation_speed(60.f); }); auto fast_rotation_action = GUI::Action::create_checkable("&Fast", [&widget](auto&) { - widget.set_rotation_speed(90.f); + widget->set_rotation_speed(90.f); }); rotation_speed_actions.add_action(*no_rotation_action); @@ -392,7 +392,7 @@ ErrorOr serenity_main(Main::Arguments arguments) normal_rotation_action->set_checked(true); auto show_frame_rate_action = GUI::Action::create_checkable("Show Frame &Rate", [&widget](auto&) { - widget.toggle_show_frame_rate(); + widget->toggle_show_frame_rate(); }); view_menu.add_action(*show_frame_rate_action); @@ -400,7 +400,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& texture_menu = window->add_menu("&Texture"); auto texture_enabled_action = GUI::Action::create_checkable("&Enable Texture", [&widget](auto& action) { - widget.set_texture_enabled(action.is_checked()); + widget->set_texture_enabled(action.is_checked()); }); texture_enabled_action->set_checked(true); texture_menu.add_action(texture_enabled_action); @@ -410,13 +410,13 @@ ErrorOr serenity_main(Main::Arguments arguments) wrap_s_actions.set_exclusive(true); auto wrap_u_repeat_action = GUI::Action::create_checkable("&Repeat", [&widget](auto&) { - widget.set_wrap_s_mode(GL_REPEAT); + widget->set_wrap_s_mode(GL_REPEAT); }); auto wrap_u_mirrored_repeat_action = GUI::Action::create_checkable("&Mirrored Repeat", [&widget](auto&) { - widget.set_wrap_s_mode(GL_MIRRORED_REPEAT); + widget->set_wrap_s_mode(GL_MIRRORED_REPEAT); }); auto wrap_u_clamp_action = GUI::Action::create_checkable("&Clamp", [&widget](auto&) { - widget.set_wrap_s_mode(GL_CLAMP); + widget->set_wrap_s_mode(GL_CLAMP); }); wrap_s_actions.add_action(*wrap_u_repeat_action); @@ -434,13 +434,13 @@ ErrorOr serenity_main(Main::Arguments arguments) wrap_t_actions.set_exclusive(true); auto wrap_t_repeat_action = GUI::Action::create_checkable("&Repeat", [&widget](auto&) { - widget.set_wrap_t_mode(GL_REPEAT); + widget->set_wrap_t_mode(GL_REPEAT); }); auto wrap_t_mirrored_repeat_action = GUI::Action::create_checkable("&Mirrored Repeat", [&widget](auto&) { - widget.set_wrap_t_mode(GL_MIRRORED_REPEAT); + widget->set_wrap_t_mode(GL_MIRRORED_REPEAT); }); auto wrap_t_clamp_action = GUI::Action::create_checkable("&Clamp", [&widget](auto&) { - widget.set_wrap_t_mode(GL_CLAMP); + widget->set_wrap_t_mode(GL_CLAMP); }); wrap_t_actions.add_action(*wrap_t_repeat_action); @@ -458,23 +458,23 @@ ErrorOr serenity_main(Main::Arguments arguments) texture_scale_actions.set_exclusive(true); auto texture_scale_025_action = GUI::Action::create_checkable("0.25x", [&widget](auto&) { - widget.set_texture_scale(0.25f); + widget->set_texture_scale(0.25f); }); auto texture_scale_05_action = GUI::Action::create_checkable("0.5x", [&widget](auto&) { - widget.set_texture_scale(0.5f); + widget->set_texture_scale(0.5f); }); auto texture_scale_1_action = GUI::Action::create_checkable("1x", [&widget](auto&) { - widget.set_texture_scale(1); + widget->set_texture_scale(1); }); auto texture_scale_2_action = GUI::Action::create_checkable("2x", [&widget](auto&) { - widget.set_texture_scale(2); + widget->set_texture_scale(2); }); auto texture_scale_4_action = GUI::Action::create_checkable("4x", [&widget](auto&) { - widget.set_texture_scale(4); + widget->set_texture_scale(4); }); texture_scale_actions.add_action(*texture_scale_025_action); @@ -496,11 +496,11 @@ ErrorOr serenity_main(Main::Arguments arguments) texture_mag_filter_actions.set_exclusive(true); auto texture_mag_filter_nearest_action = GUI::Action::create_checkable("&Nearest", [&widget](auto&) { - widget.set_mag_filter(GL_NEAREST); + widget->set_mag_filter(GL_NEAREST); }); auto texture_mag_filter_linear_action = GUI::Action::create_checkable("&Linear", [&widget](auto&) { - widget.set_mag_filter(GL_LINEAR); + widget->set_mag_filter(GL_LINEAR); }); texture_mag_filter_actions.add_action(*texture_mag_filter_nearest_action); @@ -517,7 +517,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->show(); auto filename = arguments.argc > 1 ? arguments.argv[1] : "/home/anon/Documents/3D Models/teapot.obj"; - if (widget.load_path(filename)) { + if (widget->load_path(filename)) { auto canonical_path = Core::File::absolute_path(filename); window->set_title(String::formatted("{} - 3D File Viewer", canonical_path)); }