65 lines
1.4 KiB
C
65 lines
1.4 KiB
C
|
//
|
||
|
// Created by jedi on 11/5/18.
|
||
|
//
|
||
|
|
||
|
#ifndef MGL_DMXMENU_NODE_H
|
||
|
#define MGL_DMXMENU_NODE_H
|
||
|
|
||
|
#include "gfx/canvas.h"
|
||
|
|
||
|
class node {
|
||
|
private:
|
||
|
node *parent_ = 0;
|
||
|
node *child_ = 0;
|
||
|
node *next_ = 0;
|
||
|
|
||
|
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;
|
||
|
|
||
|
node(int min = 24, int max = 48) : next_(nullptr), child_(nullptr), parent_(nullptr), minsize(min), maxsize(max) {
|
||
|
}
|
||
|
|
||
|
node(const char *t, int min = 24, int max = 48) : title_(t), minsize(min), maxsize(max), next_(nullptr),
|
||
|
child_(nullptr),
|
||
|
parent_(nullptr) {
|
||
|
}
|
||
|
|
||
|
template<typename ... Args>
|
||
|
node(const char *t, node *n, Args ... ns) : title_(t), minsize(24), maxsize(48) {
|
||
|
child_ = n;
|
||
|
n->parent_ = this;
|
||
|
child_->addNodes(true, ns...);
|
||
|
}
|
||
|
|
||
|
node *getChild() {
|
||
|
return child_;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
|
||
|
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
|