- [ONGOING] Treballant en que els camps d'edició funcionen millor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace ui
|
||||
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 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 textbox(const char *label, const int x, const int y, const int w, const int h);
|
||||
|
||||
void selected(const bool value);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace modules
|
||||
std::vector<std::string> gifs;
|
||||
int treeview_scroll = 0;
|
||||
|
||||
int *current_field = nullptr;
|
||||
|
||||
void init()
|
||||
{
|
||||
actor::clear(true);
|
||||
@@ -61,11 +63,18 @@ namespace modules
|
||||
const bool btn_small(const int x, const int y, int &var, int min, int max)
|
||||
{
|
||||
char buffer[100];
|
||||
if (current_field == &var) {
|
||||
ui::selected(false);
|
||||
} else {
|
||||
ui::selected(true);
|
||||
}
|
||||
const char *result=ui::spin(SDL_itoa(var, buffer, 10), x, y, 17, 11);
|
||||
ui::selected(false);
|
||||
if (result)
|
||||
{
|
||||
const int value = SDL_atoi(result);
|
||||
var=SDL_max(min, SDL_min(max, value));
|
||||
current_field = &var;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user