GUI Textbox contents move with cursor again
This commit is contained in:
parent
8435816940
commit
9120062889
2 changed files with 7 additions and 3 deletions
|
|
@ -73,11 +73,15 @@ template <typename T> class TextBox : public Element {
|
|||
|
||||
float yOffset = bb.height() * 0.5f;
|
||||
yOffset -= textbox->get_height() * 0.5f;
|
||||
canvas->translate(bb.min.x() + 2.0f, bb.min.y() + yOffset);
|
||||
|
||||
RichText::TextBox::PaintOpts paintOpts;
|
||||
if(selection.selected)
|
||||
if(selection.selected) {
|
||||
paintOpts.cursor = *cur;
|
||||
SkRect cursorRect = textbox->get_cursor_rect(cur->pos);
|
||||
canvas->translate(bb.min.x() - std::max(cursorRect.fRight - bb.width(), -2.0f), bb.min.y() + yOffset);
|
||||
}
|
||||
else
|
||||
canvas->translate(bb.min.x() + 2.0f, bb.min.y() + yOffset);
|
||||
paintOpts.cursorColor = {io.theme->fillColor1.fR, io.theme->fillColor1.fG, io.theme->fillColor1.fB};
|
||||
|
||||
skia::textlayout::TextStyle tStyle;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class TextBox {
|
|||
void process_text_input(Cursor& cur, const std::string& in, const std::optional<TextStyleModifier::ModifierMap>& inputModMap = std::nullopt);
|
||||
void process_rich_text_input(Cursor& cur, const TextData& richText);
|
||||
|
||||
SkRect get_cursor_rect(TextPosition pos);
|
||||
private:
|
||||
std::pair<TextPosition, TextPosition> get_start_end_text_pos(TextPosition p1, TextPosition p2);
|
||||
std::pair<size_t, size_t> get_start_end_paragraph_pos(size_t p1, size_t p2);
|
||||
|
|
@ -157,7 +158,6 @@ class TextBox {
|
|||
|
||||
void rects_between_text_positions_func(TextPosition p1, TextPosition p2, std::function<void(const SkRect& r)> f);
|
||||
|
||||
SkRect get_cursor_rect(TextPosition pos);
|
||||
|
||||
TextPosition get_text_pos_closest_to_point(Vector2f point);
|
||||
std::shared_ptr<TextStyleModifier> get_last_text_style_mod_before_pos(TextPosition pos, TextStyleModifier::ModifierType modType);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue