Added json config support

This commit is contained in:
Bob Polis 2021-10-06 13:43:11 +02:00
parent 42313b010a
commit d4d77efdff

View File

@ -10,6 +10,7 @@
#define _ScreensaverPlugin_H_ #define _ScreensaverPlugin_H_
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include <nlohmann/json.hpp>
class ScreensaverPlugin { class ScreensaverPlugin {
public: public:
@ -22,9 +23,13 @@ class ScreensaverPlugin {
virtual void update() = 0; // advance state for next frame virtual void update() = 0; // advance state for next frame
virtual void render() = 0; // draw next frame virtual void render() = 0; // draw next frame
void config(const nlohmann::json& data) { _j = data; }
const nlohmann::json& config() const { return _j; }
protected: protected:
cairo_t* _c {nullptr}; cairo_t* _c {nullptr};
cairo_rectangle_t _r {}; cairo_rectangle_t _r {};
nlohmann::json _j {};
void make_black(); void make_black();
cairo_rectangle_t random_rect(); cairo_rectangle_t random_rect();