- Treballant en algo de UI
This commit is contained in:
23
source/jui.cpp
Normal file
23
source/jui.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "jui.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
const bool button(const char *label, const int x, const int y, const int w, const int h)
|
||||
{
|
||||
const int mx = input::mouseX();
|
||||
const int my = input::mouseY();
|
||||
const bool btnDown = input::mouseBtn(1);
|
||||
const bool inside = (mx>=x) && (mx<x+w) && (my>=y) && (my<y+h);
|
||||
const int txt_size = strlen(label)*4;
|
||||
const int txt_x = x+(w-txt_size)/2;
|
||||
|
||||
draw::color(inside?(btnDown?15:13):5);
|
||||
draw::fillrect(x, y, w, h);
|
||||
draw::print(label, 1+txt_x, y+3, 15, 8);
|
||||
|
||||
return inside && input::mouseClk(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user