add sdl2 for debugging

This commit is contained in:
j3d1 2018-10-28 14:01:25 +01:00
parent 6da35ff25d
commit 8fcd668585
7 changed files with 263 additions and 43 deletions

View file

@ -1,9 +1,10 @@
#ifndef _COL_H_
#define _COL_H_
class Node;
typedef void (*drawfun_t)(int offset, int size, Node*);
void draw_menu(int, int, Node*);
class Drawable{
@ -11,7 +12,7 @@ class Drawable{
const int minsize;
const int maxsize;
drawfun_t render;
Drawable(drawfun_t fun, int min = 0, int max=~0): minsize(min), maxsize(max), render(fun){
Drawable(drawfun_t fun, int min = 0, int max=0): minsize(min), maxsize(max), render(fun){
}
};
@ -31,18 +32,20 @@ class Node{
public:
Drawable view;
const char* title_ = 0;
Node(): next_(nullptr), child_(nullptr), parent_(nullptr), view(nullptr){
Node(int min = 24, int max=48): next_(nullptr), child_(nullptr), parent_(nullptr), view(nullptr, min, max){
}
Node(const char* t, drawfun_t fun=draw_menu) : title_(t), view(fun), next_(nullptr), child_(nullptr), parent_(nullptr){
Node(const char* t, drawfun_t fun=draw_menu, int min = 24, int max=48) : title_(t), view(fun, min, max), next_(nullptr), child_(nullptr), parent_(nullptr){
}
template<typename ... Args>
Node(const char* t, Node* n, Args ... ns) : title_(t), view(nullptr){
Node(const char* t, Node* n, Args ... ns) : title_(t), view(draw_menu, 24, 48){
child_ = n;
n->parent_=this;
child_->addNodes(true,ns...);
}
Node* getChild(){
return child_;
}
void p(int i);
};
@ -50,17 +53,33 @@ class Value: public Node{
public:
const char* header;
int state;
Value(const char* t, int val, drawfun_t fun): Node(t, fun), header(t), state(val){
Value(const char* t, int val, drawfun_t fun): Node(t, fun, 64, 96), header(t), state(val){
}
};
class Layout{
class Slot{
private:
int pos_;
int size_;
public:
Node* node;
friend Layout;
};
private:
int menuthrs_;
const int maxwidth_;
int allocated_;
int allocate_(Node*, int);
int expand_(int );
int pack_(int);
public:
Layout(int max) : menuthrs_(max){
static const int maxslots = 10;
Layout(int max) : maxwidth_(max){
}
//slots
int apply(Node*);
Slot slots[maxslots];
void p();
};
#endif

9
inc/example.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef _EXAMPLE_H_
#define _EXAMPLE_H_
void draw_foo(int offset, int size, Node* ptr);
void draw_blub(int offset, int size, Node* ptr);
#endif

View file

@ -1,7 +1,14 @@
#ifndef _HAL_H_
#define _HAL_H_
void print(const char* str);
void print(char str);
void print(int str);
void setup();
void draw(int x, int y);
void render();
#ifndef LINUX
@ -9,3 +16,8 @@ void * operator new(unsigned int size);
void operator delete(void * ptr);
#endif
extern const int SCREEN_WIDTH;
extern const int SCREEN_HEIGHT;
#endif