- [NEW] ComboBox
- El text en el Textbox ja no està centrat
This commit is contained in:
@@ -26,17 +26,47 @@ namespace ui
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int combo(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) || input::mouseBtn(3);
|
||||
const bool inside = (mx>=x) && (mx<x+w) && (my>=y) && (my<y+h);
|
||||
|
||||
draw::color(WHITE);
|
||||
draw::fillrect(x, y, w, h);
|
||||
|
||||
draw::color(inside&&btnDown?BLACK:LIGHT+WHITE);
|
||||
draw::hline(x,y,w);
|
||||
draw::vline(x,y,h);
|
||||
draw::vline(x+w-9,y,h);
|
||||
|
||||
draw::color(inside&&btnDown?LIGHT+WHITE:BLACK);
|
||||
draw::hline(x,y+h-1,w);
|
||||
draw::vline(x+w-1,y,h);
|
||||
|
||||
draw::print(label, x+3, y+3, inside?RED:PAPER, 0);
|
||||
draw::print("v", x+w-6, y+3, PAPER, 0);
|
||||
|
||||
if (inside)
|
||||
{
|
||||
if (input::mouseClk(1)) return 1;
|
||||
if (input::mouseClk(3)) return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int textbox(const char *label, const int x, const int y, const int w, const int h, const int c1, const int c2)
|
||||
{
|
||||
const int mx = input::mouseX();
|
||||
const int my = input::mouseY();
|
||||
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?c2:c1);
|
||||
draw::fillrect(x, y, w, h);
|
||||
draw::print(label, 1+txt_x, y+3, LIGHT+WHITE, PAPER);
|
||||
draw::color(PAPER);
|
||||
draw::rect(x, y, w, h);
|
||||
draw::print(label, x+3, y+3, BLACK, 0);
|
||||
|
||||
if (inside)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user