Some Change to Grid

This commit is contained in:
tobid7 2024-02-24 07:32:57 +01:00
parent 3a77cd0687
commit 0627fa71be
2 changed files with 28 additions and 9 deletions

View File

@ -49,6 +49,12 @@ void DrawWave(R7Vec2 position, R7Vec2 size, float time, bool dbg) {
}
R7Vec2 testv2 = R7Vec2(48, 48);
std::vector<int*> img;
R7Vec2 display_icon(void* v, R7Vec2 p) {
DV2::RFS(p, testv2, 0xff00ffff);
return testv2;
}
Sample::Sample() {
auto t = RD7::FileSystem::GetDirContent("sdmc:/music/");
@ -56,9 +62,15 @@ Sample::Sample() {
names.push_back(it.name);
files.push_back(it.path);
}
auto ti = new int;
ti[0] = 0;
for (int i = 0; i < 256; i++) {
img.push_back(ti);
}
}
Sample::~Sample() {
delete img[0];
// Here you can clear your data
}
@ -85,8 +97,9 @@ void Sample::Draw() const {
RD7TextFlags_AlignRight);
UI7::RestoreCursor();
if (state == State_Menu) {
UI7::Label("Test App");
UI7::BrowserList(names, sel);
UI7::Label("SZS: " + std::to_string(img.size()));
UI7::Grid("Images", R7Vec2(390, 180), display_icon, (void**)&img[0],
img.size());
}
UI7::EndMenu();
}
@ -101,6 +114,8 @@ void Sample::Draw() const {
UI7::Checkbox("Debug BG", debug_background);
UI7::SameLine();
UI7::Checkbox("RD7-Debug", rd7_debugging);
UI7::SameLine();
UI7::Checkbox("UI7-Debug", UI7::IsDebugging());
UI7::InputText("Search", search__, "Tap Here");
UI7::Label("Text Control:");
if (UI7::Button("text++")) txt_size += 0.01;
@ -108,6 +123,10 @@ void Sample::Draw() const {
if (UI7::Button("text--")) txt_size -= 0.01;
UI7::SameLine();
if (UI7::Button("def")) txt_size = 0.5;
UI7::Label("GridControl: ");
if(UI7::Button("icn++")) testv2 += R7Vec2(1, 1);
UI7::SameLine();
if(UI7::Button("icn--")) testv2 -= R7Vec2(1, 1);
}
UI7::EndMenu();
}

View File

@ -489,8 +489,7 @@ void Grid(const std::string &name, const R7Vec2 &size,
R7Vec2 pos = GetCursorPos();
R7Vec2 cpos(pos);
// Debug Grid
RenderD7::Draw2::Rect(pos, size, RenderD7::Color::Hex("#ff0000"), 1);
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, size), 1));
// Y-Offset
int yoff = 0;
@ -498,12 +497,13 @@ void Grid(const std::string &name, const R7Vec2 &size,
pos += ui7_ctx->grid_mapping[UI7ID(name).real_id];
for (size_t i = 0; i < num_entrys; i++) {
R7Vec2 szs = display_func(data_array[i], pos);
RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
UI7CtxRegObj(UI7OBJ(R7Vec4(pos, szs), 2));
if(ui7_ctx->debugging) RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
if (pos.x + (szs.x * 2) > (cpos.x + size.x) &&
pos.y + szs.y > cpos.y + size.y) {
if (ui7_ctx->grid_mapping[UI7ID(name).real_id].y == 0)
ui7_ctx->grid_mapping[UI7ID(name).real_id].y =
(cpos.y + size.y) / 2 - ((yoff + 1) * (szs.y + 4)) / 2;
pos.y + (szs.y*2) > cpos.y + size.y) {
if (ui7_ctx->grid_mapping[UI7ID(name).real_id].y == 0)
ui7_ctx->grid_mapping[UI7ID(name).real_id].y =
(cpos.y + size.y) / 2 - ((yoff+2) * (szs.y + 4)) / 2;
break;
} else if (pos.x + (szs.x * 2) > (cpos.x + size.x)) {
if (ui7_ctx->grid_mapping[UI7ID(name).real_id].x == 0)