- [NEW] Spin control

This commit is contained in:
2023-10-06 15:39:50 +02:00
parent f731d6aeb3
commit 1c76e406ca
2 changed files with 28 additions and 0 deletions

View File

@@ -56,6 +56,33 @@ namespace ui
return 0; return 0;
} }
const int spin(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);
//const int txt_size = strlen(label)*4;
//const int txt_x = x+(w-txt_size)/2;
draw::color(LIGHT+WHITE);
draw::fillrect(x, y, w, h);
draw::color(PAPER);
draw::rect(x, y, w, h);
draw::print(label, x+3, y+3, PAPER, 0);
if (inside)
{
draw::color(PAPER);
draw::rect(x+1, y+1, w-2, h-2);
return input::mouseWheel();
//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 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 mx = input::mouseX();

View File

@@ -4,5 +4,6 @@ namespace ui
{ {
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 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 int combo(const char *label, const int x, const int y, const int w, const int h); 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);
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 textbox(const char *label, const int x, const int y, const int w, const int h, const int c1, const int c2);
} }