add textbox:lineAt and textbox:linePos

This commit is contained in:
MihailRis
2024-11-19 05:57:46 +03:00
parent 6a466cf1ec
commit c5c9ef379e
5 changed files with 59 additions and 7 deletions
+9 -1
View File
@@ -623,6 +623,14 @@ void TextBox::select(int start, int end) {
setCaret(selectionEnd);
}
uint TextBox::getLineAt(size_t position) const {
return label->getLineByTextIndex(position);
}
size_t TextBox::getLinePos(uint line) const {
return label->getTextLineOffset(line);
}
std::shared_ptr<UINode> TextBox::getAt(glm::vec2 pos, std::shared_ptr<UINode> self) {
return UINode::getAt(pos, self);
}
@@ -740,7 +748,7 @@ void TextBox::setCaret(size_t position) {
uint lineHeight = font->getLineHeight()*label->getLineInterval();
scrollStep = lineHeight;
if (offset < 0) {
scrolled(1);
scrolled(-glm::floor(offset/static_cast<double>(scrollStep)+0.5f));
} else if (offset >= getSize().y) {
offset -= getSize().y;
scrolled(-glm::ceil(offset/static_cast<double>(scrollStep)+0.5f));