implement input iteraction
This commit is contained in:
parent
c822a75df0
commit
6af3988056
12 changed files with 229 additions and 110 deletions
28
inc/buttons.h
Normal file
28
inc/buttons.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// Created by jedi on 11/6/18.
|
||||
//
|
||||
|
||||
#ifndef MGL_DMXMENU_INPUT_H
|
||||
#define MGL_DMXMENU_INPUT_H
|
||||
|
||||
|
||||
|
||||
#define I_LEFT 0
|
||||
#define I_RIGHT 1
|
||||
#define I_UP 2
|
||||
#define I_DOWN 3
|
||||
|
||||
|
||||
class buttons {
|
||||
private:
|
||||
void onPush(int id, bool state);
|
||||
public:
|
||||
bool raw[4]={false,false, false, false};
|
||||
bool last[4]={false,false, false, false};
|
||||
void poll();
|
||||
};
|
||||
|
||||
|
||||
extern buttons input;
|
||||
|
||||
#endif //MGL_DMXMENU_INPUT_H
|
||||
|
|
@ -11,11 +11,11 @@
|
|||
class layout {
|
||||
class Slot {
|
||||
private:
|
||||
int pos_;
|
||||
int size_;
|
||||
canvas *canvas_ = 0;
|
||||
int pos_ = 0;
|
||||
int size_ = 0;
|
||||
canvas *canvas_ = nullptr;
|
||||
public:
|
||||
node *content;
|
||||
node *content = nullptr;
|
||||
friend layout;
|
||||
};
|
||||
|
||||
|
|
@ -35,6 +35,7 @@ private:
|
|||
public:
|
||||
static const int maxslots = 10;
|
||||
Slot slots[maxslots];
|
||||
node *cursor;
|
||||
|
||||
layout(screen& s) : maxwidth_(s.getWidth()), maxheight_(s.getHeight()), screen_(s) {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,21 +2,15 @@
|
|||
#ifndef _HAL_H_
|
||||
#define _HAL_H_
|
||||
|
||||
#define I_LEFT 0
|
||||
#define I_RIGHT 1
|
||||
#define I_UP 2
|
||||
#define I_DOWN 3
|
||||
|
||||
|
||||
void debug(const char* str);
|
||||
void hal_init();
|
||||
void hal_init_screen(int w, int h);
|
||||
|
||||
void hal_poll_input(bool *ptr);
|
||||
void hal_draw(int x, int y);
|
||||
void hal_render();
|
||||
void render();
|
||||
|
||||
extern bool input[4];
|
||||
|
||||
#ifndef LINUX
|
||||
|
||||
void * operator new(unsigned int size);
|
||||
|
|
|
|||
17
inc/node.h
17
inc/node.h
|
|
@ -31,12 +31,13 @@ public:
|
|||
|
||||
virtual void render(canvas &c) = 0;
|
||||
|
||||
node(int min = 24, int max = 48) : next_(nullptr), child_(nullptr), parent_(nullptr), minsize(min), maxsize(max) {
|
||||
explicit node(int min = 24, int max = 48) : next_(nullptr), child_(nullptr), parent_(nullptr), minsize(min),
|
||||
maxsize(max) {
|
||||
}
|
||||
|
||||
node(const char *t, int min = 24, int max = 48) : title_(t), minsize(min), maxsize(max), next_(nullptr),
|
||||
child_(nullptr),
|
||||
parent_(nullptr) {
|
||||
explicit node(const char *t, int min = 24, int max = 48) : title_(t), minsize(min), maxsize(max), next_(nullptr),
|
||||
child_(nullptr),
|
||||
parent_(nullptr) {
|
||||
}
|
||||
|
||||
template<typename ... Args>
|
||||
|
|
@ -58,6 +59,14 @@ public:
|
|||
node *getCursor() {
|
||||
return cursor_;
|
||||
}
|
||||
|
||||
node *getParent() {
|
||||
return parent_;
|
||||
}
|
||||
|
||||
void setCursor(node *c) {
|
||||
cursor_ = c;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue