infinipaint/src/DrawComponents/DrawTextBox.hpp

47 lines
1.8 KiB
C++
Raw Normal View History

2025-07-06 20:43:53 +03:00
#pragma once
#include "../SharedTypes.hpp"
#include "DrawComponent.hpp"
#include "../CoordSpaceHelper.hpp"
#include "../RichText/TextBox.hpp"
2025-07-06 20:43:53 +03:00
#ifndef IS_SERVER
#include <include/core/SkPath.h>
#endif
class DrawTextBox : public DrawComponent {
public:
DrawTextBox();
2025-07-06 20:43:53 +03:00
virtual DrawComponentType get_type() const override;
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
virtual void load(cereal::PortableBinaryInputArchive& a) override;
// User input data
struct Data {
Vector2f p1;
Vector2f p2;
bool editing = false; // Should probably move this out of the Data struct
2025-07-06 20:43:53 +03:00
bool operator==(const Data& o) const = default;
bool operator!=(const Data& o) const = default;
2025-07-06 20:43:53 +03:00
} d;
#ifndef IS_SERVER
virtual std::shared_ptr<DrawComponent> copy() const override;
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
2025-07-06 20:43:53 +03:00
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
virtual void initialize_draw_data(DrawingProgram& drawP) override;
2025-07-28 14:25:28 +03:00
virtual bool collides_within_coords(const SCollision::ColliderCollection<float>& checkAgainst) override;
2025-07-06 20:43:53 +03:00
virtual void update(DrawingProgram& drawP) override;
2025-07-31 09:34:17 +03:00
void create_collider();
virtual void update_from_delayed_ptr(const std::shared_ptr<DrawComponent>& delayedUpdatePtr) override;
2025-07-06 20:43:53 +03:00
void init_text_box(DrawingProgram& drawP);
Vector2f get_mouse_pos(DrawingProgram& drawP);
virtual SCollision::AABB<float> get_obj_coord_bounds() const override;
std::shared_ptr<RichText::TextBox> textBox;
std::shared_ptr<RichText::TextBox::Cursor> cursor;
2025-07-06 20:43:53 +03:00
SCollision::BVHContainer<float> collisionTree;
#endif
};