Refacored: using Default instead of rects

This commit is contained in:
Bob Polis 2021-01-26 16:00:09 +01:00
parent 923331acc7
commit 5ce8eed0c7
3 changed files with 16 additions and 16 deletions

View File

@ -96,7 +96,7 @@ int main(int argc, const char * argv[]) {
} }
if (optind == argc) { if (optind == argc) {
// here when no file args // here when no file args
saver = sc::plugin<ScreensaverPlugin>::get("rects")(); saver = sc::plugin<ScreensaverPlugin>::get("Default")();
} }
for (int i = optind; i < argc; ++i) { for (int i = optind; i < argc; ++i) {
try { try {
@ -134,8 +134,8 @@ int main(int argc, const char * argv[]) {
// setup screen saver module // setup screen saver module
if (!saver) { if (!saver) {
saver = sc::plugin<ScreensaverPlugin>::get("rects")(); saver = sc::plugin<ScreensaverPlugin>::get("Default")();
std::cerr << "screensaver: using standard 'rects' module\n"; std::cerr << "screensaver: using standard 'Default' module\n";
} }
main_saver = saver.get(); main_saver = saver.get();
main_saver->setup(cr, {0, 0, WIDTH, HEIGHT}); main_saver->setup(cr, {0, 0, WIDTH, HEIGHT});

View File

@ -1,18 +1,18 @@
// //
// RectSaver.cpp // Default.cpp
// screensaver // screensaver
// //
// Created by Bob Polis at 2020-10-26 // Created by Bob Polis at 2020-10-26
// Copyright (c) 2020 SwiftCoder. All rights reserved. // Copyright (c) 2020 SwiftCoder. All rights reserved.
// //
#include "RectSaver.hpp" #include "Default.hpp"
#include <libscscreensaver.hpp> #include <libscscreensaver.hpp>
class RectSaver : public ScreensaverPlugin { class Default : public ScreensaverPlugin {
public: public:
RectSaver() = default; Default() = default;
~RectSaver() = default; ~Default() = default;
int fps() const override; int fps() const override;
void update() override; void update() override;
@ -20,18 +20,18 @@ class RectSaver : public ScreensaverPlugin {
}; };
ScreensaverPlugin* create_instance() { ScreensaverPlugin* create_instance() {
return new RectSaver; return new Default;
} }
int RectSaver::fps() const { int Default::fps() const {
return 2; return 2;
} }
void RectSaver::update() { void Default::update() {
} }
void RectSaver::render() { void Default::render() {
cairo_set_source_rgba(_c, random01(), random01(), random01(), random01()); cairo_set_source_rgba(_c, random01(), random01(), random01(), random01());
cairo_rectangle_t rect {random_rect()}; cairo_rectangle_t rect {random_rect()};
cairo_rectangle(_c, rect.x, rect.y, rect.width, rect.height); cairo_rectangle(_c, rect.x, rect.y, rect.width, rect.height);

View File

@ -1,13 +1,13 @@
// //
// RectSaver.hpp // Default.hpp
// screensaver // screensaver
// //
// Created by Bob Polis at 2020-10-26 // Created by Bob Polis at 2020-10-26
// Copyright (c) 2020 SwiftCoder. All rights reserved. // Copyright (c) 2020 SwiftCoder. All rights reserved.
// //
#ifndef _RectSaver_H_ #ifndef _Default_H_
#define _RectSaver_H_ #define _Default_H_
class ScreensaverPlugin; class ScreensaverPlugin;
@ -15,4 +15,4 @@ extern "C" {
ScreensaverPlugin* create_instance(); ScreensaverPlugin* create_instance();
} }
#endif // _RectSaver_H_ #endif // _Default_H_