50 lines
1,006 B
C
50 lines
1,006 B
C
|
//
|
||
|
// Created by jedi on 11/5/18.
|
||
|
//
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include "gfx/Canvas.h"
|
||
|
#include "gfx/Screen.h"
|
||
|
|
||
|
namespace micromenu {
|
||
|
|
||
|
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_ = 0;
|
||
|
Screen &screen_;
|
||
|
|
||
|
int allocate_(node *, int);
|
||
|
|
||
|
int expand_(int);
|
||
|
|
||
|
int pack_(int);
|
||
|
|
||
|
public:
|
||
|
static const int maxslots = 10;
|
||
|
Slot slots[maxslots];
|
||
|
node *cursor = nullptr;
|
||
|
|
||
|
explicit Layout(Screen &s) noexcept: maxwidth_(s.getWidth()), maxheight_(s.getHeight()), screen_(s) {
|
||
|
|
||
|
}
|
||
|
|
||
|
int apply(node *);
|
||
|
|
||
|
void render();
|
||
|
};
|
||
|
|
||
|
}
|