- [NEW] Ja se mostren els items en el treeview

This commit is contained in:
2025-11-18 13:42:10 +01:00
parent f05dec21b1
commit d686673b8e
2 changed files with 23 additions and 14 deletions

View File

@@ -7,8 +7,8 @@ namespace treeview
{
int width = 200;
int scroll = 0;
int current[2] = {-1, -1};
int selected[2] = {-1, -1};
int current[3] = {-1, -1};
int selected[3] = {-1, -1};
int line = 0;
int element = 0;
int max_elements = 0;
@@ -18,7 +18,7 @@ namespace treeview
draw::setClip(0,48,treeview::width, draw::getWindowSize().y-48);
draw::setColor(0xff181818);
draw::fillrect(0,48,treeview::width, draw::getWindowSize().y-48);
current[0] = current[1] = line = element = 0;
current[0] = current[1] = current[2] = line = element = 0;
max_elements = (draw::getWindowSize().y-48) / 24;
int mx = input::mouseX();
@@ -36,17 +36,19 @@ namespace treeview
int mx = input::mouseX();
int my = input::mouseY();
const int opt_y = (48+line*24);
if (mx>=0 && my>=opt_y && mx<treeview::width && my<opt_y+24) {
if (input::mouseClk(input::mouse::button::left)) {
input::mouseDiscard();
selected[level] = current[level];
if (level<1) selected[level+1] = -1;
if (level!=1) {
if (mx>=0 && my>=opt_y && mx<treeview::width && my<opt_y+24) {
if (input::mouseClk(input::mouse::button::left)) {
input::mouseDiscard();
selected[level] = current[level];
if (level==0) selected[2] = -1;
}
draw::setColor(selected[level]==current[level] ? 0xff37373d : 0xff2a2d2e);
draw::fillrect(0, opt_y, treeview::width, 24);
} else if (selected[level] == current[level]) {
draw::setColor(0xff37373d);
draw::fillrect(0, opt_y, treeview::width, 24);
}
draw::setColor(selected[level]==current[level] ? 0xff37373d : 0xff2a2d2e);
draw::fillrect(0, opt_y, treeview::width, 24);
} else if (selected[level] == current[level]) {
draw::setColor(0xff37373d);
draw::fillrect(0, opt_y, treeview::width, 24);
}
font::print(label, 8+16*level, opt_y+8);
line++;