Added text edit right click menu
This commit is contained in:
parent
f227e074f8
commit
d57d2f4752
10 changed files with 84 additions and 115 deletions
|
|
@ -1,7 +1,14 @@
|
|||
#include "DrawingProgramEditToolBase.hpp"
|
||||
#include "../MainProgram.hpp"
|
||||
|
||||
DrawingProgramEditToolBase::DrawingProgramEditToolBase(DrawingProgram& initDrawP):
|
||||
drawP(initDrawP)
|
||||
{}
|
||||
|
||||
bool DrawingProgramEditToolBase::right_click_popup_gui(const std::shared_ptr<DrawComponent>& comp, Vector2f popupPos) {
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.paint_popup(popupPos);
|
||||
return true;
|
||||
}
|
||||
|
||||
DrawingProgramEditToolBase::~DrawingProgramEditToolBase() {}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class DrawingProgramEditToolBase {
|
|||
virtual void commit_edit_updates(const std::shared_ptr<DrawComponent>& a, std::any& prevData) = 0;
|
||||
virtual bool edit_update(const std::shared_ptr<DrawComponent>& a) = 0;
|
||||
virtual bool edit_gui(const std::shared_ptr<DrawComponent>& a) = 0;
|
||||
virtual bool right_click_popup_gui(const std::shared_ptr<DrawComponent>& comp, Vector2f popupPos);
|
||||
virtual ~DrawingProgramEditToolBase();
|
||||
protected:
|
||||
DrawingProgram& drawP;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,10 @@ void EditTool::gui_toolbox() {
|
|||
}
|
||||
|
||||
bool EditTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
return drawP.selection_action_menu(popupPos);
|
||||
if(controls.isEditing)
|
||||
return controls.compEditTool->right_click_popup_gui(controls.compToEdit.lock(), popupPos);
|
||||
else
|
||||
return drawP.selection_action_menu(popupPos);
|
||||
}
|
||||
|
||||
void EditTool::add_point_handle(const HandleData& handle) {
|
||||
|
|
|
|||
|
|
@ -152,6 +152,37 @@ bool TextBoxEditTool::edit_gui(const std::shared_ptr<DrawComponent>& comp) {
|
|||
return oldInputChangedTextBox;
|
||||
}
|
||||
|
||||
bool TextBoxEditTool::right_click_popup_gui(const std::shared_ptr<DrawComponent>& comp, Vector2f popupPos) {
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
bool shouldClose = false;
|
||||
std::shared_ptr<DrawTextBox> a = std::static_pointer_cast<DrawTextBox>(comp);
|
||||
t.gui.list_popup_menu("Text popup menu", popupPos, [&]() {
|
||||
t.gui.text_label_light("Text menu");
|
||||
InputManager& input = drawP.world.main.input;
|
||||
if(t.gui.text_button_left_transparent("Paste", "Paste")) {
|
||||
input.call_text_paste(true);
|
||||
shouldClose = true;
|
||||
}
|
||||
if(t.gui.text_button_left_transparent("Paste without formatting", "Paste without formatting")) {
|
||||
input.call_text_paste(false);
|
||||
shouldClose = true;
|
||||
}
|
||||
if(a->cursor->selectionBeginPos != a->cursor->selectionEndPos) {
|
||||
if(t.gui.text_button_left_transparent("Copy", "Copy")) {
|
||||
input.set_clipboard_plain_and_richtext_pair(a->textBox->process_copy(*a->cursor));
|
||||
shouldClose = true;
|
||||
}
|
||||
if(t.gui.text_button_left_transparent("Cut", "Cut")) {
|
||||
input.text.do_textbox_operation_with_undo([&]() {
|
||||
input.set_clipboard_plain_and_richtext_pair(a->textBox->process_cut(*a->cursor));
|
||||
});
|
||||
shouldClose = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return !shouldClose;
|
||||
}
|
||||
|
||||
void TextBoxEditTool::hold_undo_data(const std::string& undoName, const std::shared_ptr<DrawTextBox>& a) {
|
||||
auto it = undoHeldData.find(undoName);
|
||||
if(it != undoHeldData.end()) {
|
||||
|
|
@ -286,7 +317,7 @@ bool TextBoxEditTool::edit_update(const std::shared_ptr<DrawComponent>& comp) {
|
|||
|
||||
bool collidesWithBox = a->collides_with_cam_coords(drawP.world.drawData.cam.c, mousePointCollection);
|
||||
|
||||
input.text.set_rich_text_box_input(a->textBox, a->cursor, currentMods);
|
||||
input.text.set_rich_text_box_input(a->textBox, a->cursor, true, currentMods);
|
||||
a->textBox->process_mouse_left_button(*a->cursor, a->get_mouse_pos(drawP), (drawP.controls.leftClick && collidesWithBox) ? drawP.world.main.input.mouse.leftClicks : 0, drawP.controls.leftClickHeld, input.key(InputManager::KEY_GENERIC_LSHIFT).held);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class TextBoxEditTool : public DrawingProgramEditToolBase {
|
|||
virtual void commit_edit_updates(const std::shared_ptr<DrawComponent>& a, std::any& prevData) override;
|
||||
virtual bool edit_update(const std::shared_ptr<DrawComponent>& a) override;
|
||||
virtual bool edit_gui(const std::shared_ptr<DrawComponent>& a) override;
|
||||
virtual bool right_click_popup_gui(const std::shared_ptr<DrawComponent>& comp, Vector2f popupPos) override;
|
||||
private:
|
||||
struct TextBoxEditToolAllData {
|
||||
DrawTextBox::Data textboxData;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue