add 'scroll-step' property to container

This commit is contained in:
MihailRis
2024-11-19 06:46:54 +03:00
parent 5c005b4f9a
commit 2412699b89
6 changed files with 21 additions and 3 deletions
+4 -1
View File
@@ -43,6 +43,7 @@ TextBox::TextBox(std::wstring placeholder, glm::vec4 padding)
textInitX = label->getPos().x;
scrollable = true;
scrollStep = 0;
}
void TextBox::draw(const DrawContext* pctx, Assets* assets) {
@@ -746,7 +747,9 @@ void TextBox::setCaret(size_t position) {
uint line = label->getLineByTextIndex(caret);
int offset = label->getLineYOffset(line) + getContentOffset().y;
uint lineHeight = font->getLineHeight()*label->getLineInterval();
scrollStep = lineHeight;
if (scrollStep == 0) {
scrollStep = lineHeight;
}
if (offset < 0) {
scrolled(-glm::floor(offset/static_cast<double>(scrollStep)+0.5f));
} else if (offset >= getSize().y) {