micromenu/inc/gfx/layout.h

52 lines
792 B
C
Raw Normal View History

2018-11-05 20:09:01 +00:00
//
// Created by jedi on 11/5/18.
//
#ifndef MGL_DMXMENU_LAYOUT_H
#define MGL_DMXMENU_LAYOUT_H
#include "gfx/canvas.h"
#include "gfx/screen.h"
class layout {
class Slot {
private:
2018-11-06 17:30:21 +00:00
int pos_ = 0;
int size_ = 0;
canvas *canvas_ = nullptr;
2018-11-05 20:09:01 +00:00
public:
2018-11-06 17:30:21 +00:00
node *content = nullptr;
2018-11-05 20:09:01 +00:00
friend layout;
};
private:
const int maxwidth_;
2018-11-06 15:06:05 +00:00
const int maxheight_;
2018-11-05 20:09:01 +00:00
int allocated_;
2018-11-06 15:06:05 +00:00
screen& screen_;
2018-11-05 20:09:01 +00:00
int allocate_(node *, int);
int expand_(int);
int pack_(int);
public:
static const int maxslots = 10;
Slot slots[maxslots];
2018-11-06 17:30:21 +00:00
node *cursor;
2018-11-05 20:09:01 +00:00
2018-11-06 15:06:05 +00:00
layout(screen& s) : maxwidth_(s.getWidth()), maxheight_(s.getHeight()), screen_(s) {
2018-11-05 20:09:01 +00:00
}
int apply(node *);
void render();
};
#endif //MGL_DMXMENU_LAYOUT_H