- [ONGOING] Treballant en que els camps d'edició funcionen millor

This commit is contained in:
2024-07-10 14:02:17 +02:00
parent 77cb597c80
commit 2a629529fd
5 changed files with 33 additions and 8 deletions

View File

@@ -6,6 +6,8 @@
namespace ui
{
static bool select = false;
void label(const char *label, const int x, const int y, const int w, const int h, const int color)
{
draw::color(color);
@@ -117,7 +119,7 @@ namespace ui
char temp[10];
const char *spin(const char *label, const int x, const int y, const int w, const int h)
const char *spin(const char *lbl, const int x, const int y, const int w, const int h)
{
const int mx = draw::getLocalX(input::mouseX());
const int my = draw::getLocalY(input::mouseY());
@@ -125,6 +127,12 @@ namespace ui
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;
char label[100];
if (!select) {
label[0]='0'; label[1]='\0';
} else {
strcpy(label, lbl);
}
draw::color(LIGHT+WHITE);
draw::fillrect(x, y, w, h);
@@ -152,7 +160,7 @@ namespace ui
}
const int wheel = input::mouseWheel();
if (wheel != 0) {
const int value = SDL_atoi(label)+wheel*(input::keyDown(SDL_SCANCODE_LCTRL)?32:1);
const int value = SDL_atoi(lbl)+wheel*(input::keyDown(SDL_SCANCODE_LCTRL)?32:1);
SDL_itoa(value, temp, 10);
return temp;
}
@@ -183,4 +191,10 @@ namespace ui
}
return 0;
}
void selected(const bool value)
{
select = value;
}
}