Demos: Rename GradientScreensaver to Gradient

This brings the name in-line with the naming convention used by the
other screensavers 'Starfield' and 'Tubes'.
This commit is contained in:
Cubic Love 2023-04-11 18:20:03 +01:00 committed by Linus Groh
parent 97dc2d1dd5
commit c6af248909
6 changed files with 30 additions and 30 deletions

View file

@ -0,0 +1,5 @@
[App]
Name=Gradient
Executable=/bin/Gradient
Category=Demos/Screensaver
ExcludeFromSystemMenu=true

View file

@ -1,5 +0,0 @@
[App]
Name=Gradient Screensaver
Executable=/bin/GradientScreensaver
Category=Demos/Screensaver
ExcludeFromSystemMenu=true

View file

@ -1,6 +1,6 @@
add_subdirectory(CatDog) add_subdirectory(CatDog)
add_subdirectory(Eyes) add_subdirectory(Eyes)
add_subdirectory(GradientScreensaver) add_subdirectory(Gradient)
add_subdirectory(LibGfxDemo) add_subdirectory(LibGfxDemo)
add_subdirectory(LibGfxScaleDemo) add_subdirectory(LibGfxScaleDemo)
add_subdirectory(Mandelbrot) add_subdirectory(Mandelbrot)

View file

@ -0,0 +1,11 @@
serenity_component(
Gradient
TARGETS Gradient
)
set(SOURCES
Gradient.cpp
)
serenity_app(Gradient ICON app-screensaver)
target_link_libraries(Gradient PRIVATE LibDesktop LibGUI LibCore LibGfx LibMain)

View file

@ -17,13 +17,13 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
class Screensaver final : public Desktop::Screensaver { class Gradient final : public Desktop::Screensaver {
C_OBJECT(Screensaver) C_OBJECT(Gradient)
public: public:
virtual ~Screensaver() override = default; virtual ~Gradient() override = default;
private: private:
Screensaver(int width = 64, int height = 48, int interval = 10000); Gradient(int width = 64, int height = 48, int interval = 10000);
RefPtr<Gfx::Bitmap> m_bitmap; RefPtr<Gfx::Bitmap> m_bitmap;
void draw(); void draw();
@ -31,7 +31,7 @@ private:
virtual void timer_event(Core::TimerEvent&) override; virtual void timer_event(Core::TimerEvent&) override;
}; };
Screensaver::Screensaver(int width, int height, int interval) Gradient::Gradient(int width, int height, int interval)
{ {
on_screensaver_exit = []() { GUI::Application::the()->quit(); }; on_screensaver_exit = []() { GUI::Application::the()->quit(); };
m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { width, height }).release_value_but_fixme_should_propagate_errors(); m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { width, height }).release_value_but_fixme_should_propagate_errors();
@ -41,20 +41,20 @@ Screensaver::Screensaver(int width, int height, int interval)
draw(); draw();
} }
void Screensaver::paint_event(GUI::PaintEvent& event) void Gradient::paint_event(GUI::PaintEvent& event)
{ {
GUI::Painter painter(*this); GUI::Painter painter(*this);
painter.add_clip_rect(event.rect()); painter.add_clip_rect(event.rect());
painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect()); painter.draw_scaled_bitmap(rect(), *m_bitmap, m_bitmap->rect());
} }
void Screensaver::timer_event(Core::TimerEvent&) void Gradient::timer_event(Core::TimerEvent&)
{ {
draw(); draw();
update(); update();
} }
void Screensaver::draw() void Gradient::draw()
{ {
const Color colors[] { const Color colors[] {
Color::Blue, Color::Blue,
@ -95,12 +95,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::unveil(nullptr, nullptr));
auto window = TRY(Desktop::Screensaver::create_window("Screensaver"sv, "app-screensaver"sv)); auto window = TRY(Desktop::Screensaver::create_window("Gradient"sv, "app-screensaver"sv));
auto screensaver_window = TRY(window->set_main_widget<Screensaver>(64, 48, 10000)); auto gradient_widget = TRY(window->set_main_widget<Gradient>(64, 48, 10000));
screensaver_window->set_fill_with_background_color(false); gradient_widget->set_fill_with_background_color(false);
screensaver_window->set_override_cursor(Gfx::StandardCursor::Hidden); gradient_widget->set_override_cursor(Gfx::StandardCursor::Hidden);
screensaver_window->update(); gradient_widget->update();
window->show(); window->show();
window->move_to_front(); window->move_to_front();

View file

@ -1,11 +0,0 @@
serenity_component(
GradientScreensaver
TARGETS GradientScreensaver
)
set(SOURCES
GradientScreensaver.cpp
)
serenity_app(GradientScreensaver ICON app-screensaver)
target_link_libraries(GradientScreensaver PRIVATE LibDesktop LibGUI LibCore LibGfx LibMain)