Files
EnergyMonitor_Pico/libs/mare/mare.h
2021-05-20 23:05:55 +02:00

164 lines
3.2 KiB
C++

/*******************************************
* Most Awesome Renderer Ever
*******************************************/
#pragma once
extern "C" {
#include <DEV_Config.h>
#include <EPD_2in9b_V3.h>
#include <fonts.h>
}
#include <vector>
#include <string>
namespace Render{
struct pos_t {
uint16_t x;
uint16_t y;
};
struct bbox2d_t {
uint16_t xMin, Ymin;
uint16_t Xmax, Ymax;
};
enum class ScreenRotation {
Rot0 = 0,
Rot90 = 90,
Rot180 = 180,
Rot270 = 270
};
enum class BlendMode {
Add,
Intersect
};
class Page;
class Drawable;
typedef pos_t dim_t;
typedef std::vector<Page*> Pages;
typedef std::vector<Drawable*> Drawables;
class Mare {
Mare();
virtual ~Mare();
// getters, setters
public:
void setSize(const uint16_t x, const uint16_t y);
const dim_t getSize();
void setRotation(const ScreenRotation r);
const ScreenRotation getRotation();
const Pages& getPages();
const uint8_t getCurrentPage();
void setCurrentPage(const uint8_t p);
const Drawables& getDrawables();
// drawables, pages
public:
void addDrawable();
void removeDrawable(size_t id);
void addPage(uint8_t num);
void removePage(uint8_t num);
private:
void visitDrawables(Drawable* parent);
void render();
void setPixel(uint16_t x, uint16_t y, bool value);
// members
private:
uint8_t* _screenBufferForeground;
uint8_t* _screenBufferBackgrund;
dim_t _screenSize;
Pages _pages;
Drawables _drawables;
ScreenRotation _rotation;
};
class Drawable {
Drawable(const size_t id, const pos_t position, const Drawable* parent);
virtual ~Drawable();
public:
virtual void render();
public:
void setId(const size_t id);
void setOrigin(const pos_t origin);
void setDirty();
void setBlendMode(const BlendMode mode);
const bbox2d_t getBBox();
const BlendMode getBlendMode();
private:
bool _dirty;
size_t _id;
pos_t _origin;
bbox2d_t _bbox;
Drawables _children;
Drawable* _parent;
};
class DrawablePoint: public Drawable {
DrawablePoint();
~DrawablePoint();
public:
private:
void render();
// members
private:
};
class DrawableLine: public Drawable {
DrawableLine();
~DrawableLine();
public:
private:
void render() {};
// members
private:
};
class DrawableRectangle: public Drawable {
DrawableRectangle();
~DrawableRectangle();
public:
private:
void render() {};
// members
private:
};
class Page {
Page();
~Page();
public:
private:
};
}