Created RichText namespace, and tweaked scrollbar behaviour

This commit is contained in:
Yousef Khadadeh 2025-11-10 14:45:51 +03:00
parent e0143f49f0
commit 435d9346a9
17 changed files with 163 additions and 139 deletions

View file

@ -9,9 +9,11 @@
#include "../DrawCollision.hpp"
#endif
using namespace RichText;
DrawTextBox::DrawTextBox():
textBox(std::make_shared<RichTextBox>()),
cursor(std::make_shared<RichTextBox::Cursor>())
textBox(std::make_shared<TextBox>()),
cursor(std::make_shared<TextBox::Cursor>())
{
skia::textlayout::TextStyle tStyle;
textBox->set_initial_text_style(tStyle);
@ -30,7 +32,7 @@ void DrawTextBox::save(cereal::PortableBinaryOutputArchive& a) const {
}
void DrawTextBox::load(cereal::PortableBinaryInputArchive& a) {
RichTextBox::RichTextData richText;
TextData richText;
a(d.editing, d.p1, d.p2, richText, *cursor);
textBox->set_rich_text_data(richText);
}
@ -78,7 +80,7 @@ void DrawTextBox::draw(SkCanvas* canvas, const DrawData& drawData) {
canvas->clipRect(clipR);
canvas->translate(d.p1.x(), d.p1.y());
RichTextBox::PaintOpts paintOpts;
TextBox::PaintOpts paintOpts;
paintOpts.cursorColor = {0.7f, 0.7f, 1.0f};
if(d.editing && cursor)
paintOpts.cursor = *cursor;

View file

@ -2,7 +2,7 @@
#include "../SharedTypes.hpp"
#include "DrawComponent.hpp"
#include "../CoordSpaceHelper.hpp"
#include "../RichTextBox/RichTextBox.hpp"
#include "../RichText/TextBox.hpp"
#ifndef IS_SERVER
#include <include/core/SkPath.h>
@ -39,8 +39,8 @@ class DrawTextBox : public DrawComponent {
virtual SCollision::AABB<float> get_obj_coord_bounds() const override;
std::shared_ptr<RichTextBox> textBox;
std::shared_ptr<RichTextBox::Cursor> cursor;
std::shared_ptr<RichText::TextBox> textBox;
std::shared_ptr<RichText::TextBox::Cursor> cursor;
SCollision::BVHContainer<float> collisionTree;
#endif
};