51 lines
792 B
C++
51 lines
792 B
C++
//
|
|
// 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:
|
|
int pos_ = 0;
|
|
int size_ = 0;
|
|
canvas *canvas_ = nullptr;
|
|
public:
|
|
node *content = nullptr;
|
|
friend layout;
|
|
};
|
|
|
|
private:
|
|
const int maxwidth_;
|
|
const int maxheight_;
|
|
int allocated_;
|
|
screen& screen_;
|
|
|
|
int allocate_(node *, int);
|
|
|
|
int expand_(int);
|
|
|
|
int pack_(int);
|
|
|
|
|
|
public:
|
|
static const int maxslots = 10;
|
|
Slot slots[maxslots];
|
|
node *cursor;
|
|
|
|
layout(screen& s) : maxwidth_(s.getWidth()), maxheight_(s.getHeight()), screen_(s) {
|
|
|
|
}
|
|
|
|
int apply(node *);
|
|
|
|
void render();
|
|
};
|
|
|
|
|
|
|
|
#endif //MGL_DMXMENU_LAYOUT_H
|