2025-08-02 20:10:33 +03:00
|
|
|
#pragma once
|
2025-12-15 15:36:42 +03:00
|
|
|
#include "../CanvasComponents/TextBoxCanvasComponent.hpp"
|
2025-08-02 20:10:33 +03:00
|
|
|
#include "DrawingProgramEditToolBase.hpp"
|
|
|
|
|
#include <Helpers/SCollision.hpp>
|
|
|
|
|
#include <any>
|
|
|
|
|
|
|
|
|
|
class DrawingProgram;
|
|
|
|
|
|
|
|
|
|
class TextBoxEditTool : public DrawingProgramEditToolBase {
|
|
|
|
|
public:
|
|
|
|
|
TextBoxEditTool(DrawingProgram& initDrawP);
|
|
|
|
|
|
2025-12-15 15:36:42 +03:00
|
|
|
virtual void edit_start(EditTool& editTool,const CanvasComponentContainer::ObjInfoSharedPtr& comp, std::any& prevData) override;
|
|
|
|
|
virtual void commit_edit_updates(const CanvasComponentContainer::ObjInfoSharedPtr& comp, std::any& prevData) override;
|
|
|
|
|
virtual bool edit_update(const CanvasComponentContainer::ObjInfoSharedPtr& comp) override;
|
|
|
|
|
virtual bool edit_gui(const CanvasComponentContainer::ObjInfoSharedPtr& comp) override;
|
|
|
|
|
virtual bool right_click_popup_gui(const CanvasComponentContainer::ObjInfoSharedPtr& comp, Vector2f popupPos) override;
|
2025-08-02 20:10:33 +03:00
|
|
|
private:
|
2025-10-25 17:31:55 +03:00
|
|
|
struct TextBoxEditToolAllData {
|
2025-12-15 15:36:42 +03:00
|
|
|
TextBoxCanvasComponent::Data textboxData;
|
2025-11-10 14:45:51 +03:00
|
|
|
RichText::TextData richText;
|
2025-10-25 17:31:55 +03:00
|
|
|
};
|
2025-11-05 18:21:49 +03:00
|
|
|
|
|
|
|
|
uint32_t newFontSize = 15;
|
|
|
|
|
Vector4f newTextColor{1.0f, 1.0f, 1.0f, 1.0f};
|
2025-11-24 17:45:21 +03:00
|
|
|
Vector4f newHighlightColor{1.0f, 1.0f, 1.0f, 0.0f};
|
2025-11-09 16:24:40 +03:00
|
|
|
bool newIsBold = false;
|
|
|
|
|
bool newIsItalic = false;
|
|
|
|
|
bool newIsUnderlined = false;
|
|
|
|
|
bool newIsLinethrough = false;
|
|
|
|
|
bool newIsOverline = false;
|
2025-11-08 20:50:23 +03:00
|
|
|
std::string newFontName;
|
2025-11-27 10:54:56 +03:00
|
|
|
RichText::ParagraphStyleData currentPStyle;
|
2025-11-05 12:29:31 +03:00
|
|
|
|
2025-11-09 16:24:40 +03:00
|
|
|
uint8_t get_new_decoration_value();
|
2025-12-15 15:36:42 +03:00
|
|
|
void set_styles_at_selection(TextBoxCanvasComponent& a);
|
|
|
|
|
void add_undo_if_selecting_area(TextBoxCanvasComponent& a, const std::function<void()>& func);
|
2025-11-12 14:54:46 +03:00
|
|
|
void add_undo(const std::function<void()>& func);
|
|
|
|
|
|
2025-12-15 15:36:42 +03:00
|
|
|
void hold_undo_data(const std::string& undoName, TextBoxCanvasComponent& a);
|
2025-11-12 14:54:46 +03:00
|
|
|
void release_undo_data(const std::string& undoName);
|
|
|
|
|
|
|
|
|
|
std::unordered_map<std::string, std::pair<RichText::TextBox::Cursor, RichText::TextData>> undoHeldData;
|
|
|
|
|
|
2025-11-10 14:45:51 +03:00
|
|
|
RichText::TextStyleModifier::ModifierMap currentMods;
|
2025-11-05 12:29:31 +03:00
|
|
|
|
2025-11-08 20:50:23 +03:00
|
|
|
std::vector<std::string> sortedFontList;
|
|
|
|
|
|
2025-12-15 15:36:42 +03:00
|
|
|
TextBoxEditToolAllData get_all_data(const TextBoxCanvasComponent& a);
|
2025-08-02 20:10:33 +03:00
|
|
|
};
|