add scrollbar (WIP)

This commit is contained in:
MihailRis 2024-12-04 23:03:36 +03:00
parent ed3865964b
commit dbd27d4423

View File

@ -95,6 +95,19 @@ void Container::draw(const DrawContext* pctx, Assets* assets) {
if (node->isVisible())
node->draw(pctx, assets);
}
int diff = (actualLength-size.y);
if (scrollable && diff > 0) {
int w = 10;
int h = glm::max(size.y / actualLength * size.y, w / 2.0f);
batch->untexture();
batch->setColor(glm::vec4(1, 1, 1, 0.5f));
batch->rect(
pos.x + size.x - w,
pos.y - scroll / static_cast<float>(diff) * (size.y - h),
w, h
);
}
batch->flush();
}
}