- [CHG] Botó amb aspecte de botó

This commit is contained in:
2024-06-13 13:28:09 +02:00
parent 115685046a
commit 50c768edb3
2 changed files with 16 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ namespace ui
draw::print(label, x+3, y+3, BLACK, 0);
}
const int button(const char *label, const int x, const int y, const int w, const int h, const int c1, const int c2, const int c3)
const bool button(const char *label, const int x, const int y, const int w, const int h, const bool pressed)
{
const int mx = draw::getLocalX(input::mouseX());
const int my = draw::getLocalY(input::mouseY());
@@ -23,16 +23,25 @@ namespace ui
const int txt_size = strlen(label)*4;
const int txt_x = x+(w-txt_size)/2;
draw::color(inside?(btnDown?c3:c2):c1);
draw::color(WHITE);
draw::fillrect(x, y, w, h);
draw::print(label, 1+txt_x, y+3, LIGHT+WHITE, PAPER);
draw::color((inside&&btnDown)||pressed?BLACK:LIGHT+WHITE);
draw::hline(x, y, w);
draw::vline(x, y, h);
draw::color((inside&&btnDown)||pressed?LIGHT+WHITE:BLACK);
draw::hline(x, y+h-1, w);
draw::vline(x+w-1, y, h);
draw::print(label, 1+txt_x, y+3, LIGHT+(pressed?YELLOW:WHITE), PAPER);
if (inside)
{
if (input::mouseClk(1)) return 1;
if (input::mouseClk(3)) return 3;
if (input::mouseClk(1)) return true;
//if (input::mouseClk(3)) return 3;
}
return 0;
return false;
}
const int check(const char *label, const int x, const int y, const int w, const int h, const bool checked)

View File

@@ -5,7 +5,7 @@
namespace ui
{
void label(const char *label, const int x, const int y, const int w, const int h, const int color=WHITE+LIGHT);
const int button(const char *label, const int x, const int y, const int w, const int h, const int c1, const int c2, const int c3);
const bool button(const char *label, const int x, const int y, const int w, const int h, const bool pressed=false);
const int check(const char *label, const int x, const int y, const int w, const int h, const bool checked);
const int combo(const char *label, const int x, const int y, const int w, const int h);
const int spin(const char *label, const int x, const int y, const int w, const int h);