micromenu/inc/node.h

84 lines
1.7 KiB
C
Raw Normal View History

2018-11-05 20:09:01 +00:00
//
// Created by jedi on 11/5/18.
//
#ifndef MGL_DMXMENU_NODE_H
#define MGL_DMXMENU_NODE_H
#include "gfx/canvas.h"
class node {
private:
2018-11-06 15:06:05 +00:00
node *parent_ = nullptr;
node *child_ = nullptr;
node *cursor_ = nullptr;
node *next_ = nullptr;
2018-11-05 20:09:01 +00:00
void addNodes(bool b) {
}
template<class ...Us>
void addNodes(bool b, node *n, Us ... ns) {
next_ = n;
next_->parent_ = parent_;
next_->addNodes(!b, ns...);
}
public:
const char *title_ = 0;
const int minsize;
const int maxsize;
virtual void render(canvas &c) = 0;
2018-11-06 17:30:21 +00:00
explicit node(int min = 24, int max = 48) : next_(nullptr), child_(nullptr), parent_(nullptr), minsize(min),
maxsize(max) {
2018-11-05 20:09:01 +00:00
}
2018-11-06 17:30:21 +00:00
explicit node(const char *t, int min = 24, int max = 48) : title_(t), minsize(min), maxsize(max), next_(nullptr),
child_(nullptr),
parent_(nullptr) {
2018-11-05 20:09:01 +00:00
}
template<typename ... Args>
node(const char *t, node *n, Args ... ns) : title_(t), minsize(24), maxsize(48) {
child_ = n;
2018-11-06 15:06:05 +00:00
cursor_ = n;
2018-11-05 20:09:01 +00:00
n->parent_ = this;
child_->addNodes(true, ns...);
}
node *getChild() {
return child_;
}
2018-11-06 15:06:05 +00:00
node *getNext() {
return next_;
}
node *getCursor() {
return cursor_;
}
2018-11-06 17:30:21 +00:00
node *getParent() {
return parent_;
}
void setCursor(node *c) {
cursor_ = c;
}
2018-11-05 20:09:01 +00:00
};
class value: public node {
public:
const char *header;
int state;
value(const char *t, int val, int min = 64, int max = 96) : node(t, min, max), header(t), state(val) {
}
};
#endif //MGL_DMXMENU_NODE_H