Added configure method

This commit is contained in:
Bob Polis 2021-10-06 15:14:34 +02:00
parent 3d64d4e69e
commit 0bdf958537
2 changed files with 17 additions and 2 deletions

View File

@ -94,3 +94,17 @@ void ScreensaverPlugin::rounded_rect(const cairo_rectangle_t& rect, double radiu
cairo_line_to(_c, x0, y1);
cairo_arc(_c, x1, y1, radius, M_PI, 1.5 * M_PI);
}
void ScreensaverPlugin::config(const nlohmann::json& data) {
_j = data;
configure();
}
void ScreensaverPlugin::config(nlohmann::json&& data) {
_j = data;
configure();
}
void ScreensaverPlugin::configure() {
// empty default implementation
}

View File

@ -18,13 +18,14 @@ class ScreensaverPlugin {
virtual ~ScreensaverPlugin() = default;
virtual void setup(cairo_t* context, const cairo_rectangle_t& rect);
virtual void configure();
virtual int fps() const;
virtual void update() = 0; // advance state for next frame
virtual void render() = 0; // draw next frame
void config(const nlohmann::json& data) { _j = data; }
void config(nlohmann::json&& data) { _j = data; }
void config(const nlohmann::json& data);
void config(nlohmann::json&& data);
const nlohmann::json& config() const { return _j; }
protected: