From 88ebc44cbf620b09b0e3e307c2e3890b726ebb82 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 1 Jan 2023 18:56:28 +0100 Subject: [PATCH] Demos: Remove "Mouse" application This was a plain-looking test app for debugging mouse events. Mouse events work now, and if we want mouse testing facilities, they can be added to MouseSettings instead. --- Base/res/apps/Mouse.af | 4 - Base/usr/share/man/man1/Mouse.md | 17 --- Userland/Demos/CMakeLists.txt | 1 - Userland/Demos/Mouse/CMakeLists.txt | 11 -- Userland/Demos/Mouse/main.cpp | 208 ---------------------------- 5 files changed, 241 deletions(-) delete mode 100644 Base/res/apps/Mouse.af delete mode 100644 Base/usr/share/man/man1/Mouse.md delete mode 100644 Userland/Demos/Mouse/CMakeLists.txt delete mode 100644 Userland/Demos/Mouse/main.cpp diff --git a/Base/res/apps/Mouse.af b/Base/res/apps/Mouse.af deleted file mode 100644 index b198299a01a..00000000000 --- a/Base/res/apps/Mouse.af +++ /dev/null @@ -1,4 +0,0 @@ -[App] -Name=Mouse -Executable=/bin/Mouse -Category=Demos diff --git a/Base/usr/share/man/man1/Mouse.md b/Base/usr/share/man/man1/Mouse.md deleted file mode 100644 index a3cca32d491..00000000000 --- a/Base/usr/share/man/man1/Mouse.md +++ /dev/null @@ -1,17 +0,0 @@ -## Name - -![Icon](/res/icons/16x16/app-mouse.png) Mouse - Mouse Demo - -[Open](file:///bin/Mouse) - -## Synopsis - -```**sh -$ Mouse -``` - -## Description - -Mouse is an application that displays interactive graphical mouse. - -It simulates mouse clicks respective of the physical button pressed. It detects and displays corresponding left button, middle button, right button clicks, and middle scroll wheel movements. It also shows side mouse button clicks if supported by the connected mouse. diff --git a/Userland/Demos/CMakeLists.txt b/Userland/Demos/CMakeLists.txt index 7c0655c1604..d62468ad60c 100644 --- a/Userland/Demos/CMakeLists.txt +++ b/Userland/Demos/CMakeLists.txt @@ -5,7 +5,6 @@ add_subdirectory(LibGfxDemo) add_subdirectory(LibGfxScaleDemo) add_subdirectory(Mandelbrot) add_subdirectory(ModelGallery) -add_subdirectory(Mouse) add_subdirectory(Screensaver) add_subdirectory(Starfield) add_subdirectory(Tubes) diff --git a/Userland/Demos/Mouse/CMakeLists.txt b/Userland/Demos/Mouse/CMakeLists.txt deleted file mode 100644 index c680a96f063..00000000000 --- a/Userland/Demos/Mouse/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -serenity_component( - Mouse - TARGETS Mouse -) - -set(SOURCES - main.cpp -) - -serenity_app(Mouse ICON app-mouse) -target_link_libraries(Mouse PRIVATE LibCore LibGUI LibGfx LibIPC LibMain) diff --git a/Userland/Demos/Mouse/main.cpp b/Userland/Demos/Mouse/main.cpp deleted file mode 100644 index 88c8dcddd88..00000000000 --- a/Userland/Demos/Mouse/main.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling - * Copyright (c) 2021, Idan Horowitz - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class MainFrame final : public GUI::Frame { - C_OBJECT(MainFrame); - -public: - virtual void timer_event(Core::TimerEvent&) override - { - - m_show_scroll_wheel = false; - m_double_clicked_buttons = 0; - stop_timer(); - update(); - } - - virtual void paint_event(GUI::PaintEvent& event) override - { - GUI::Painter painter(*this); - painter.add_clip_rect(event.rect()); - painter.fill_rect(frame_inner_rect(), Color::White); - - auto buttons = m_buttons | m_double_clicked_buttons; - - auto primary_secondary_switched = GUI::ConnectionToWindowServer::the().are_mouse_buttons_switched(); - auto primary_pressed = buttons & GUI::MouseButton::Primary; - auto secondary_pressed = buttons & GUI::MouseButton::Secondary; - - Gfx::Path path; - - // draw left button - path.move_to({ 30, 65 }); - path.line_to({ 30, 20 }); - path.line_to({ 65, 12 }); - path.line_to({ 65, 65 }); - if (primary_secondary_switched ? secondary_pressed : primary_pressed) { - auto button_color = primary_secondary_switched ? Color::LightBlue : Color::MidBlue; - painter.fill_path(path, button_color); - } - painter.stroke_path(path, Color::Black, 1); - path.clear(); - - // draw right button - path.move_to({ 95, 65 }); - path.line_to({ 95, 12 }); - path.line_to({ 130, 20 }); - path.line_to({ 130, 65 }); - if (primary_secondary_switched ? primary_pressed : secondary_pressed) { - auto button_color = primary_secondary_switched ? Color::MidBlue : Color::LightBlue; - painter.fill_path(path, button_color); - } - painter.stroke_path(path, Color::Black, 1); - path.clear(); - - // draw middle button - path.move_to({ 65, 65 }); - path.line_to({ 65, 12 }); - path.line_to({ 95, 12 }); - path.line_to({ 95, 65 }); - if (buttons & GUI::MouseButton::Middle) - painter.fill_path(path, Color::Blue); - painter.stroke_path(path, Color::Black, 1); - path.clear(); - - if (m_show_scroll_wheel) { - auto radius = 10; - auto off_x = 80; - auto off_y = 38; - - Gfx::IntPoint p1; - Gfx::IntPoint p2; - Gfx::IntPoint p3; - Gfx::IntPoint p4; - - p1.set_x(radius * AK::cos(AK::Pi * m_wheel_delta_acc / 18.) + off_x); - p1.set_y(radius * AK::sin(AK::Pi * m_wheel_delta_acc / 18.) + off_y); - - p2.set_x(radius * AK::cos(AK::Pi * (m_wheel_delta_acc + 18) / 18.) + off_x); - p2.set_y(radius * AK::sin(AK::Pi * (m_wheel_delta_acc + 18) / 18.) + off_y); - - p3.set_x(radius * AK::cos(AK::Pi * (m_wheel_delta_acc + 9) / 18.) + off_x); - p3.set_y(radius * AK::sin(AK::Pi * (m_wheel_delta_acc + 9) / 18.) + off_y); - - p4.set_x(radius * AK::cos(AK::Pi * (m_wheel_delta_acc + 27) / 18.) + off_x); - p4.set_y(radius * AK::sin(AK::Pi * (m_wheel_delta_acc + 27) / 18.) + off_y); - - painter.draw_line(p1, p2, Color::Red, 2); - painter.draw_line(p3, p4, Color::Red, 2); - } - - // draw mouse outline - path.move_to({ 30, 140 }); - path.line_to({ 30, 65 }); - path.line_to({ 130, 65 }); - path.line_to({ 130, 140 }); - path.line_to({ 30, 140 }); - painter.stroke_path(path, Color::Black, 1); - path.clear(); - - // draw forward button - path.move_to({ 30, 43 }); - path.line_to({ 25, 43 }); - path.line_to({ 25, 60 }); - path.line_to({ 30, 60 }); - if (buttons & GUI::MouseButton::Forward) - painter.fill_rect({ 26, 44, 4, 16 }, Color::Blue); - painter.stroke_path(path, Color::Black, 1); - path.clear(); - - // draw back button - path.move_to({ 30, 70 }); - path.line_to({ 25, 70 }); - path.line_to({ 25, 87 }); - path.line_to({ 30, 87 }); - if (buttons & GUI::MouseButton::Backward) - painter.fill_rect({ 26, 71, 4, 16 }, Color::Blue); - painter.stroke_path(path, Color::Black, 1); - path.clear(); - } - - void mousedown_event(GUI::MouseEvent& event) override - { - m_buttons = event.buttons(); - update(); - } - - void mouseup_event(GUI::MouseEvent& event) override - { - m_buttons = event.buttons(); - update(); - } - - void mousewheel_event(GUI::MouseEvent& event) override - { - m_wheel_delta_acc = (m_wheel_delta_acc + event.wheel_delta_y() + 36) % 36; - m_show_scroll_wheel = true; - update(); - if (has_timer()) - stop_timer(); - start_timer(500); - } - - void doubleclick_event(GUI::MouseEvent& event) override - { - m_double_clicked_buttons |= event.button(); - update(); - if (has_timer()) - stop_timer(); - start_timer(500); - } - -private: - unsigned m_buttons { 0 }; - unsigned m_wheel_delta_acc { 0 }; - bool m_show_scroll_wheel { false }; - unsigned m_double_clicked_buttons { 0 }; -}; - -ErrorOr serenity_main(Main::Arguments arguments) -{ - auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-mouse"sv)); - - TRY(Core::System::pledge("stdio recvfd sendfd rpath")); - TRY(Core::System::unveil("/res", "r")); - TRY(Core::System::unveil(nullptr, nullptr)); - - auto window = TRY(GUI::Window::try_create()); - window->set_title("Mouse demo"); - window->set_icon(app_icon.bitmap_for_size(16)); - window->resize(160, 155); - - auto main_widget = TRY(window->try_set_main_widget()); - main_widget->set_fill_with_background_color(true); - - auto file_menu = TRY(window->try_add_menu("&File")); - TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }))); - - auto help_menu = TRY(window->try_add_menu("&Help")); - TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window))); - TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Mouse Demo", app_icon, window))); - - window->set_resizable(false); - window->show(); - return app->exec(); -}