- [NEW] draw::setZoom() i getZoom()
- [NEW] Ara amb F1 i F2 se pot fer zoom del contingut de la finestra - [NEW] Ja es pot editar els camps de text (pero encara no es guarda a arxiu)
This commit is contained in:
@@ -11,11 +11,14 @@ namespace propertygrid
|
||||
int y = 0;
|
||||
int element = 0;
|
||||
int max_elements = 0;
|
||||
int editing_element = -1;
|
||||
std::string editing_text = "";
|
||||
int editing_finished = 0;
|
||||
|
||||
void start()
|
||||
{
|
||||
y = 48;
|
||||
const SDL_Point win_size = draw::getWindowSize();
|
||||
const SDL_FPoint win_size = draw::getWindowSize();
|
||||
draw::setClip(win_size.x-propertygrid::width,y,propertygrid::width, win_size.y-y);
|
||||
draw::setColor(0xff181818);
|
||||
draw::fillrect(win_size.x-propertygrid::width,y,propertygrid::width, win_size.y-y);
|
||||
@@ -31,26 +34,69 @@ namespace propertygrid
|
||||
}
|
||||
}
|
||||
|
||||
std::string stringProperty(std::string label, std::string value)
|
||||
void doEditText()
|
||||
{
|
||||
const SDL_Point win_size = draw::getWindowSize();
|
||||
uint8_t key = input::getKeyPressed();
|
||||
if (key == SDL_SCANCODE_UNKNOWN) return;
|
||||
printf("key: %i\n", key);
|
||||
if (key==SDL_SCANCODE_BACKSPACE && !editing_text.empty()) editing_text.pop_back();
|
||||
else if (key>=SDL_SCANCODE_1 && key<=SDL_SCANCODE_9) editing_text.push_back(char(key+19));
|
||||
else if (key==SDL_SCANCODE_0 || key==SDL_SCANCODE_KP_0) editing_text.push_back('0');
|
||||
else if (key>=SDL_SCANCODE_KP_1 && key<=SDL_SCANCODE_KP_9) editing_text.push_back(char(key-40));
|
||||
else if (key>=SDL_SCANCODE_A && key<=SDL_SCANCODE_Z) editing_text.push_back(char(key+61));
|
||||
else if (key==SDL_SCANCODE_RETURN || key==SDL_SCANCODE_KP_ENTER) editing_finished = 1;
|
||||
else if (key==SDL_SCANCODE_ESCAPE) editing_finished = 2;
|
||||
}
|
||||
|
||||
bool stringProperty(std::string label, std::string value)
|
||||
{
|
||||
bool result = false;
|
||||
const SDL_FPoint win_size = draw::getWindowSize();
|
||||
const int x = win_size.x-propertygrid::width;
|
||||
draw::setClip(x,y,propertygrid::width, 24);
|
||||
//draw::setColor(0xffffffff);
|
||||
//draw::fillrect(x,y,propertygrid::width, 24);
|
||||
font::print(label.c_str(), x+8, y+9);
|
||||
|
||||
if (editing_element==line) {
|
||||
draw::setColor(0xff2a2d2e);
|
||||
draw::fillrect(x+propertygrid::width/3,y,2*(propertygrid::width/3), 24);
|
||||
font::print(editing_text.c_str(), x+8+propertygrid::width/3, y+9);
|
||||
doEditText();
|
||||
if (editing_finished!=0) {
|
||||
if (editing_finished==1) {
|
||||
result = true;
|
||||
}
|
||||
editing_element = -1;
|
||||
}
|
||||
} else {
|
||||
font::print(value.c_str(), x+8+propertygrid::width/3, y+9);
|
||||
}
|
||||
draw::setColor(0xff000000);
|
||||
draw::line(x,y+23,win_size.x, y+23);
|
||||
draw::line(x+propertygrid::width/3,y,x+propertygrid::width/3, y+23);
|
||||
font::print(label.c_str(), x+8, y+9);
|
||||
font::print(value.c_str(), x+8+propertygrid::width/3, y+9);
|
||||
|
||||
int mx = input::mouseX();
|
||||
int my = input::mouseY();
|
||||
if (editing_element!=line && mx>=x && my>=y && mx<x+propertygrid::width && my<y+24) {
|
||||
if (input::mouseClk(input::mouse::button::left)) {
|
||||
editing_element = line;
|
||||
editing_text = value;
|
||||
editing_finished = 0;
|
||||
}
|
||||
}
|
||||
|
||||
line++;
|
||||
y+=24;
|
||||
return "";
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string getStringPropertyResult()
|
||||
{
|
||||
return editing_text;
|
||||
}
|
||||
|
||||
void sectionProperty(std::string label)
|
||||
{
|
||||
const SDL_Point win_size = draw::getWindowSize();
|
||||
const SDL_FPoint win_size = draw::getWindowSize();
|
||||
const int x = win_size.x-propertygrid::width;
|
||||
draw::setClip(x,y,propertygrid::width, 16);
|
||||
draw::setColor(0xff3c3c3c);
|
||||
|
||||
Reference in New Issue
Block a user