implementation continues...
This commit is contained in:
139
libs/mare/mare.h
139
libs/mare/mare.h
@@ -5,12 +5,14 @@
|
||||
|
||||
extern "C" {
|
||||
#include <DEV_Config.h>
|
||||
#include <EPD_2in9b_V3.h>
|
||||
#include <EPD_2in9_V2.h>
|
||||
#include <fonts.h>
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
namespace Render{
|
||||
|
||||
@@ -36,56 +38,64 @@ namespace Render{
|
||||
Intersect
|
||||
};
|
||||
|
||||
enum class Color {
|
||||
White,
|
||||
Black
|
||||
};
|
||||
|
||||
class Page;
|
||||
class Drawable;
|
||||
|
||||
typedef pos_t dim_t;
|
||||
typedef std::vector<Page*> Pages;
|
||||
typedef std::vector<Drawable*> Drawables;
|
||||
typedef std::vector<std::shared_ptr<Page>> Pages;
|
||||
typedef std::vector<std::shared_ptr<Drawable>> Drawables;
|
||||
|
||||
class Mare {
|
||||
Mare();
|
||||
virtual ~Mare();
|
||||
friend class Drawable;
|
||||
|
||||
Mare(dim_t size);
|
||||
~Mare();
|
||||
|
||||
// getters, setters
|
||||
public:
|
||||
void setSize(const uint16_t x, const uint16_t y);
|
||||
void setSize(const dim_t size);
|
||||
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();
|
||||
const Page& getCurrentPage();
|
||||
|
||||
// drawables, pages
|
||||
public:
|
||||
void addDrawable();
|
||||
void removeDrawable(size_t id);
|
||||
void addPage(uint8_t num);
|
||||
void removePage(uint8_t num);
|
||||
template <class T>
|
||||
void addDrawable(T);
|
||||
void removeDrawable(const size_t id);
|
||||
void addPage();
|
||||
void removePage(const uint8_t num);
|
||||
const Drawables& getDrawables();
|
||||
const Pages& getPages();
|
||||
|
||||
private:
|
||||
void visitDrawables(Drawable* parent);
|
||||
//render
|
||||
private:
|
||||
void render();
|
||||
void setPixel(uint16_t x, uint16_t y, bool value);
|
||||
|
||||
void clearBuffer(uint8_t* buffer, Color col);
|
||||
void visitDrawables(Drawable* parent);
|
||||
void setPixel(uint8_t* img, uint16_t x, uint16_t y, bool value);
|
||||
|
||||
// members
|
||||
private:
|
||||
uint8_t* _screenBufferForeground;
|
||||
uint8_t* _screenBufferBackgrund;
|
||||
dim_t _screenSize;
|
||||
Pages _pages;
|
||||
Drawables _drawables;
|
||||
uint8_t* _screenBufferForeground;
|
||||
uint8_t* _screenBufferBackground;
|
||||
Drawables _drawables; // background drawables for all the pages
|
||||
ScreenRotation _rotation;
|
||||
};
|
||||
|
||||
class Drawable {
|
||||
|
||||
Drawable(const size_t id, const pos_t position, const Drawable* parent);
|
||||
virtual ~Drawable();
|
||||
public:
|
||||
Drawable(const size_t id, const Drawable* parent, const Mare* engine);
|
||||
~Drawable();
|
||||
|
||||
public:
|
||||
virtual void render();
|
||||
@@ -100,27 +110,30 @@ namespace Render{
|
||||
const BlendMode getBlendMode();
|
||||
|
||||
private:
|
||||
const Drawable* _parent;
|
||||
const Mare* _engine;
|
||||
bool _dirty;
|
||||
size_t _id;
|
||||
pos_t _origin;
|
||||
bbox2d_t _bbox;
|
||||
Drawables _children;
|
||||
Drawable* _parent;
|
||||
|
||||
};
|
||||
|
||||
class DrawablePoint: public Drawable {
|
||||
|
||||
DrawablePoint();
|
||||
DrawablePoint(const size_t id, const Drawable* parent, const Mare* engine, dim_t size);
|
||||
~DrawablePoint();
|
||||
|
||||
public:
|
||||
void setSize(dim_t size);
|
||||
const dim_t getSize();
|
||||
|
||||
private:
|
||||
void render();
|
||||
|
||||
// members
|
||||
private:
|
||||
dim_t _size;
|
||||
};
|
||||
|
||||
class DrawableLine: public Drawable {
|
||||
@@ -129,12 +142,21 @@ namespace Render{
|
||||
~DrawableLine();
|
||||
|
||||
public:
|
||||
void setThickness(uint16_t thickness);
|
||||
const uint16_t getThickness();
|
||||
void setRotation(float rotation);
|
||||
const float getRotation();
|
||||
void setLength(uint16_t length);
|
||||
const uint16_t getLength();
|
||||
|
||||
private:
|
||||
void render() {};
|
||||
void render(); // difficult business
|
||||
|
||||
// members
|
||||
private:
|
||||
uint16_t _thickness;
|
||||
uint16_t _lenght;
|
||||
float _rotation;
|
||||
};
|
||||
|
||||
class DrawableRectangle: public Drawable {
|
||||
@@ -151,6 +173,63 @@ namespace Render{
|
||||
private:
|
||||
};
|
||||
|
||||
class DrawableCircle: public Drawable {
|
||||
|
||||
DrawableCircle();
|
||||
~DrawableCircle();
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
void render() {};
|
||||
|
||||
// members
|
||||
private:
|
||||
};
|
||||
|
||||
class DrawableChar: public Drawable {
|
||||
|
||||
DrawableChar();
|
||||
~DrawableChar();
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
void render() {};
|
||||
|
||||
// members
|
||||
private:
|
||||
};
|
||||
|
||||
class DrawableString: public Drawable {
|
||||
|
||||
DrawableString();
|
||||
~DrawableString();
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
void render() {};
|
||||
|
||||
// members
|
||||
private:
|
||||
};
|
||||
|
||||
class DrawableCustom: public Drawable {
|
||||
|
||||
DrawableCustom();
|
||||
~DrawableCustom();
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
void render() {};
|
||||
|
||||
// members
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class Page {
|
||||
|
||||
Page();
|
||||
@@ -159,6 +238,8 @@ namespace Render{
|
||||
public:
|
||||
|
||||
private:
|
||||
Drawables _backDrawables;
|
||||
Drawables _frontDrawables;
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user