cleanup prototype code

This commit is contained in:
j3d1 2018-11-05 21:09:01 +01:00
parent d958452e48
commit bfef6fdc1e
17 changed files with 272 additions and 243 deletions

View file

@ -5,7 +5,7 @@
#ifndef MGL_DMXMENU_CANVAS_H
#define MGL_DMXMENU_CANVAS_H
#include "hal.h"
#include "hal/hal.h"
#include "gfx/font.h"
#include "fonts/basic_5x4.h"
#include "gfx/buffer_1.h"
@ -32,6 +32,10 @@ public:
void print(int x, int y, char *str, font & = basic_5x4);
int getWidth();
int getHeight();
friend screen;
};

49
inc/gfx/layout.h Normal file
View file

@ -0,0 +1,49 @@
//
// 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_;
int size_;
canvas *canvas_ = 0;
public:
node *content;
friend layout;
};
private:
const int maxwidth_;
int allocated_;
screen screen_;
int allocate_(node *, int);
int expand_(int);
int pack_(int);
public:
static const int maxslots = 10;
Slot slots[maxslots];
layout(int width) : maxwidth_(width), screen_(width, 32) {
}
int apply(node *);
void render();
};
#endif //MGL_DMXMENU_LAYOUT_H

View file

@ -5,7 +5,8 @@
#ifndef MGL_DMXMENU_SCREEN_H
#define MGL_DMXMENU_SCREEN_H
#include "hal.h"
#include "hal/hal.h"
#include "gfx/canvas.h"
class screen {
private:
@ -13,22 +14,26 @@ private:
const int height_;
public:
screen(int w, int h): width_(w), height_(h){
screen(int w, int h) : width_(w), height_(h) {
}
void draw(int x, int y){
hal_draw(x,y);
void draw(int x, int y) {
hal_draw(x, y);
}
void draw(int x, int y, canvas& c){
void draw(int x, int y, canvas &c) {
for (int x_ = 0; x_ < 128; x_++)
for (int y_ = 0; y_ < 32; y_++)
if(c.buffer_.get(x_*32+y_))
hal_draw(x+x_,y+y_);
if (c.buffer_.get(x_ * 32 + y_))
hal_draw(x + x_, y + y_);
}
void print(int x, int y, char* str){
void print(int x, int y, const char *str, font & = basic_5x4){
}
void print(int x, int y, char *str, font & = basic_5x4){
}