Working on getting textbox edit tool functional
This commit is contained in:
parent
262bf23bce
commit
0087048a02
43 changed files with 605 additions and 295 deletions
|
|
@ -16,89 +16,137 @@
|
|||
|
||||
#include "../../../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
||||
#include "../../../GUIStuff/ElementHelpers/LayoutHelpers.hpp"
|
||||
#include "../../../GUIStuff/ElementHelpers/ButtonHelpers.hpp"
|
||||
#include "../../../GUIStuff/ElementHelpers/NumberSliderHelpers.hpp"
|
||||
#include "../../../GUIStuff/Elements/PositionAdjustingPopupMenu.hpp"
|
||||
|
||||
using namespace RichText;
|
||||
|
||||
TextBoxEditTool::TextBoxEditTool(DrawingProgram& initDrawP):
|
||||
DrawingProgramEditToolBase(initDrawP)
|
||||
TextBoxEditTool::TextBoxEditTool(DrawingProgram& initDrawP, CanvasComponentContainer::ObjInfo* initComp):
|
||||
DrawingProgramEditToolBase(initDrawP, initComp)
|
||||
{}
|
||||
|
||||
void TextBoxEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
||||
void TextBoxEditTool::commit_update_func() {
|
||||
comp->obj->commit_update(drawP);
|
||||
}
|
||||
|
||||
void TextBoxEditTool::commit_update_and_layout_func() {
|
||||
comp->obj->commit_update(drawP);
|
||||
drawP.world.main.g.gui.set_to_layout();
|
||||
}
|
||||
|
||||
void TextBoxEditTool::edit_gui() {
|
||||
using namespace GUIStuff;
|
||||
using namespace ElementHelpers;
|
||||
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
auto& gui = drawP.world.main.g.gui;
|
||||
|
||||
auto& currentMods = *currentModsPtr;
|
||||
|
||||
gui.new_id("edit tool text", [&] {
|
||||
text_label_centered(gui, "Edit Text");
|
||||
|
||||
left_to_right_line_layout(gui, [&] {
|
||||
text_label(gui, "Font");
|
||||
//if(gui.font_picker("font picker", &newFontName)) {
|
||||
// currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES] = std::make_shared<FontFamiliesTextStyleModifier>(std::vector<SkString>{SkString{newFontName.c_str(), newFontName.size()}});
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES]);});
|
||||
//}
|
||||
});
|
||||
//left_to_right_line_layout(gui, [&] {
|
||||
// text_label(gui, "Font");
|
||||
// if(gui.font_picker("font picker", &newFontName)) {
|
||||
// currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES] = std::make_shared<FontFamiliesTextStyleModifier>(std::vector<SkString>{SkString{newFontName.c_str(), newFontName.size()}});
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES]);});
|
||||
// }
|
||||
//});
|
||||
|
||||
//left_to_right_line_centered_layout(gui, [&] {
|
||||
// if(svg_icon_button("Bold button", "data/icons/RemixIcon/bold.svg", newIsBold)) {
|
||||
// newIsBold = !newIsBold;
|
||||
// currentMods[TextStyleModifier::ModifierType::WEIGHT] = std::make_shared<WeightTextStyleModifier>(newIsBold ? SkFontStyle::Weight::kBold_Weight : SkFontStyle::Weight::kNormal_Weight);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::WEIGHT]);});
|
||||
// }
|
||||
left_to_right_line_centered_layout(gui, [&] {
|
||||
svg_icon_button(gui, "Bold button", "data/icons/RemixIcon/bold.svg", {
|
||||
.isSelected = newIsBold,
|
||||
.onClick = [&] {
|
||||
newIsBold = !newIsBold;
|
||||
currentMods[TextStyleModifier::ModifierType::WEIGHT] = std::make_shared<WeightTextStyleModifier>(newIsBold ? SkFontStyle::Weight::kBold_Weight : SkFontStyle::Weight::kNormal_Weight);
|
||||
add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::WEIGHT]);});
|
||||
commit_update_func();
|
||||
}
|
||||
});
|
||||
|
||||
// if(gui.svg_icon_button("Italic button", "data/icons/RemixIcon/italic.svg", newIsItalic)) {
|
||||
// newIsItalic = !newIsItalic;
|
||||
// currentMods[TextStyleModifier::ModifierType::SLANT] = std::make_shared<SlantTextStyleModifier>(newIsItalic ? SkFontStyle::Slant::kItalic_Slant : SkFontStyle::Slant::kUpright_Slant);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SLANT]);});
|
||||
// }
|
||||
svg_icon_button(gui, "Italic button", "data/icons/RemixIcon/italic.svg", {
|
||||
.isSelected = newIsItalic,
|
||||
.onClick = [&] {
|
||||
newIsItalic = !newIsItalic;
|
||||
currentMods[TextStyleModifier::ModifierType::SLANT] = std::make_shared<SlantTextStyleModifier>(newIsItalic ? SkFontStyle::Slant::kItalic_Slant : SkFontStyle::Slant::kUpright_Slant);
|
||||
add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SLANT]);});
|
||||
commit_update_func();
|
||||
}
|
||||
});
|
||||
|
||||
// bool decorationEdited = false;
|
||||
// if(gui.svg_icon_button("Underline button", "data/icons/RemixIcon/underline.svg", newIsUnderlined)) {
|
||||
// newIsUnderlined = !newIsUnderlined;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(gui.svg_icon_button("Strikethrough button", "data/icons/RemixIcon/strikethrough.svg", newIsLinethrough)) {
|
||||
// newIsLinethrough = !newIsLinethrough;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(gui.svg_icon_button("Overline button", "data/icons/RemixIcon/overline.svg", newIsOverline)) {
|
||||
// newIsOverline = !newIsOverline;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(decorationEdited) {
|
||||
// currentMods[TextStyleModifier::ModifierType::DECORATION] = std::make_shared<DecorationTextStyleModifier>(get_new_decoration_value());
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::DECORATION]);});
|
||||
// }
|
||||
//});
|
||||
auto decorationChange = [&] {
|
||||
currentMods[TextStyleModifier::ModifierType::DECORATION] = std::make_shared<DecorationTextStyleModifier>(get_new_decoration_value());
|
||||
add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::DECORATION]);});
|
||||
commit_update_func();
|
||||
};
|
||||
|
||||
//gui.left_to_right_line_centered_layout([&]() {
|
||||
// if(gui.svg_icon_button("Align left button", "data/icons/RemixIcon/align-left.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kLeft))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kLeft);});
|
||||
// if(gui.svg_icon_button("Align center button", "data/icons/RemixIcon/align-center.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kCenter))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kCenter);});
|
||||
// if(gui.svg_icon_button("Align right button", "data/icons/RemixIcon/align-right.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kRight))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kRight);});
|
||||
// if(gui.svg_icon_button("Align justify button", "data/icons/RemixIcon/align-justify.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kJustify))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kJustify);});
|
||||
// if(gui.svg_icon_button("Text direction left", "data/icons/RemixIcon/text-direction-l.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kLtr))
|
||||
// add_undo([&](){a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kLtr);});
|
||||
// if(gui.svg_icon_button("Text direction right", "data/icons/RemixIcon/text-direction-r.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kRtl))
|
||||
// add_undo([&](){a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kRtl);});
|
||||
//});
|
||||
svg_icon_button(gui, "Underline button", "data/icons/RemixIcon/underline.svg", {
|
||||
.isSelected = newIsUnderlined,
|
||||
.onClick = [&, decorationChange] {
|
||||
newIsUnderlined = !newIsUnderlined;
|
||||
decorationChange();
|
||||
}
|
||||
});
|
||||
|
||||
//if(gui.slider_scalar_field<uint32_t>("Font Size Slider", "Font Size", &newFontSize, 3, 100)) {
|
||||
// hold_undo_data("Font Size", a);
|
||||
// currentMods[TextStyleModifier::ModifierType::SIZE] = std::make_shared<SizeTextStyleModifier>(newFontSize);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SIZE]);
|
||||
//}
|
||||
//else
|
||||
// release_undo_data("Font Size");
|
||||
svg_icon_button(gui, "Strikethrough button", "data/icons/RemixIcon/strikethrough.svg", {
|
||||
.isSelected = newIsLinethrough,
|
||||
.onClick = [&, decorationChange] {
|
||||
newIsLinethrough = !newIsLinethrough;
|
||||
decorationChange();
|
||||
}
|
||||
});
|
||||
|
||||
svg_icon_button(gui, "Overline button", "data/icons/RemixIcon/overline.svg", {
|
||||
.isSelected = newIsOverline,
|
||||
.onClick = [&, decorationChange] {
|
||||
newIsOverline = !newIsOverline;
|
||||
decorationChange();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
left_to_right_line_centered_layout(gui, [&]() {
|
||||
auto paragraph_operation_button = [&](const char* id, const char* svgPath, bool isSelected, const std::function<void()>& func) {
|
||||
svg_icon_button(gui, id, svgPath, {
|
||||
.isSelected = isSelected,
|
||||
.onClick = [&, func] {
|
||||
add_undo(func);
|
||||
commit_update_func();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
paragraph_operation_button("Align left button", "data/icons/RemixIcon/align-left.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kLeft, [&] {
|
||||
a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kLeft);
|
||||
});
|
||||
paragraph_operation_button("Align center button", "data/icons/RemixIcon/align-center.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kCenter, [&] {
|
||||
a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kCenter);
|
||||
});
|
||||
paragraph_operation_button("Align right button", "data/icons/RemixIcon/align-right.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kRight, [&] {
|
||||
a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kRight);
|
||||
});
|
||||
paragraph_operation_button("Align justify button", "data/icons/RemixIcon/align-justify.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kJustify, [&] {
|
||||
a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kJustify);
|
||||
});
|
||||
paragraph_operation_button("Text direction left button", "data/icons/RemixIcon/text-direction-l.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kLtr, [&] {
|
||||
a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kLtr);
|
||||
});
|
||||
paragraph_operation_button("Text direction right button", "data/icons/RemixIcon/text-direction-r.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kRtl, [&] {
|
||||
a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kRtl);
|
||||
});
|
||||
});
|
||||
|
||||
slider_scalar_field<uint32_t>(gui, "Font Size Slider", "Font Size", &newFontSize, 3, 100, TextBoxScalarOptions{
|
||||
.onEdit = [&] {
|
||||
currentMods[TextStyleModifier::ModifierType::SIZE] = std::make_shared<SizeTextStyleModifier>(newFontSize);
|
||||
a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SIZE]);
|
||||
commit_update_func();
|
||||
},
|
||||
.onSelect = [&] { hold_undo_data("Font Size", a); },
|
||||
.onDeselect = [&] { release_undo_data("Font Size"); }
|
||||
});
|
||||
|
||||
//// Text color
|
||||
//gui.left_to_right_line_layout([&]() {
|
||||
|
|
@ -117,8 +165,6 @@ void TextBoxEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::COLOR]);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//// Highlight color
|
||||
//gui.left_to_right_line_layout([&]() {
|
||||
// if(gui.color_button_big("Highlight Color", &newHighlightColor, &newHighlightColor == t.colorRight)) {
|
||||
|
|
@ -160,10 +206,37 @@ void TextBoxEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
//return oldInputChangedTextBox;
|
||||
}
|
||||
|
||||
void TextBoxEditTool::input_key_callback(CanvasComponentContainer::ObjInfo* comp, const InputManager::KeyCallbackArgs& key) {
|
||||
void TextBoxEditTool::input_paste_callback(const CustomEvents::PasteEventData& paste) {
|
||||
if(textboxID.has_value() && textboxID.value() == drawP.world.main.input.text.current_textbox_editing_id()) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
if(userInput->input_paste_callback(paste)) {
|
||||
commit_update_and_layout_func();
|
||||
set_styles_at_selection(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextBoxEditTool::input_mouse_button_on_canvas_callback(CanvasComponentContainer::ObjInfo* comp, const InputManager::MouseButtonCallbackArgs& button, bool isDraggingPoint) {
|
||||
void TextBoxEditTool::input_text_key_callback(const InputManager::KeyCallbackArgs& key) {
|
||||
if(textboxID.has_value() && textboxID.value() == drawP.world.main.input.text.current_textbox_editing_id()) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
auto changes = userInput->input_key_callback(drawP.world.main.input, key);
|
||||
if(changes.textEdited || changes.cursorChanged) {
|
||||
commit_update_and_layout_func();
|
||||
set_styles_at_selection(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextBoxEditTool::input_text_callback(const InputManager::TextCallbackArgs& text) {
|
||||
if(textboxID.has_value() && textboxID.value() == drawP.world.main.input.text.current_textbox_editing_id()) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
userInput->add_text_to_textbox(text.str);
|
||||
commit_update_and_layout_func();
|
||||
set_styles_at_selection(a);
|
||||
}
|
||||
}
|
||||
|
||||
void TextBoxEditTool::input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button, bool isDraggingPoint) {
|
||||
if(button.button == InputManager::MouseButton::LEFT && !isDraggingPoint) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
|
||||
|
|
@ -175,11 +248,16 @@ void TextBoxEditTool::input_mouse_button_on_canvas_callback(CanvasComponentConta
|
|||
|
||||
bool collidesWithBox = comp->obj->collides_with_cam_coords(drawP.world.drawData.cam.c, mousePointCollection);
|
||||
|
||||
auto oldCursor = *a.cursor;
|
||||
a.textBox->process_mouse_left_button(*a.cursor, a.get_mouse_pos(drawP), (button.down && button.clicks && collidesWithBox) ? button.clicks : 0, button.down, input.key(InputManager::KEY_GENERIC_LSHIFT).held);
|
||||
if(oldCursor != *a.cursor) {
|
||||
set_styles_at_selection(a);
|
||||
commit_update_and_layout_func();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextBoxEditTool::input_mouse_motion_callback(CanvasComponentContainer::ObjInfo* comp, const InputManager::MouseMotionCallbackArgs& motion, bool isDraggingPoint) {
|
||||
void TextBoxEditTool::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool isDraggingPoint) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
a.init_text_box(drawP);
|
||||
|
||||
|
|
@ -192,11 +270,16 @@ void TextBoxEditTool::input_mouse_motion_callback(CanvasComponentContainer::ObjI
|
|||
|
||||
InputManager& input = drawP.world.main.input;
|
||||
|
||||
auto oldCursor = *a.cursor;
|
||||
a.textBox->process_mouse_left_button(*a.cursor, a.get_mouse_pos(drawP), 0, drawP.controls.leftClickHeld, input.key(InputManager::KEY_GENERIC_LSHIFT).held);
|
||||
if(oldCursor != *a.cursor) {
|
||||
set_styles_at_selection(a);
|
||||
commit_update_and_layout_func();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextBoxEditTool::right_click_popup_gui(CanvasComponentContainer::ObjInfo* comp, Vector2f popupPos) {
|
||||
void TextBoxEditTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
using namespace GUIStuff;
|
||||
using namespace ElementHelpers;
|
||||
|
||||
|
|
@ -241,8 +324,7 @@ void TextBoxEditTool::release_undo_data(const std::string& undoName) {
|
|||
auto it = undoHeldData.find(undoName);
|
||||
if(it != undoHeldData.end()) {
|
||||
std::pair<RichText::TextBox::Cursor, RichText::TextData>& undoData = it->second;
|
||||
InputManager& input = drawP.world.main.input;
|
||||
//input.text.add_textbox_undo(undoData.first, undoData.second);
|
||||
userInput->add_textbox_undo(undoData.first, undoData.second);
|
||||
undoHeldData.erase(it);
|
||||
}
|
||||
}
|
||||
|
|
@ -250,15 +332,12 @@ void TextBoxEditTool::release_undo_data(const std::string& undoName) {
|
|||
void TextBoxEditTool::add_undo_if_selecting_area(TextBoxCanvasComponent& a, const std::function<void()>& func) {
|
||||
if(a.cursor->selectionBeginPos == a.cursor->selectionEndPos)
|
||||
func();
|
||||
else {
|
||||
InputManager& input = drawP.world.main.input;
|
||||
//input.text.do_textbox_operation_with_undo(func);
|
||||
}
|
||||
else
|
||||
userInput->do_textbox_operation_with_undo(func);
|
||||
}
|
||||
|
||||
void TextBoxEditTool::add_undo(const std::function<void()>& func) {
|
||||
InputManager& input = drawP.world.main.input;
|
||||
//input.text.do_textbox_operation_with_undo(func);
|
||||
userInput->do_textbox_operation_with_undo(func);
|
||||
}
|
||||
|
||||
uint8_t TextBoxEditTool::get_new_decoration_value() {
|
||||
|
|
@ -295,11 +374,12 @@ void TextBoxEditTool::set_styles_at_selection(TextBoxCanvasComponent& a) {
|
|||
currentPStyle = a.textBox->get_paragraph_style_data_at(start.fParagraphIndex);
|
||||
}
|
||||
|
||||
void TextBoxEditTool::commit_edit_updates(CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
||||
void TextBoxEditTool::commit_edit_updates(std::any& prevData) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
a.d.editing = false;
|
||||
comp->obj->commit_update(drawP);
|
||||
//drawP.world.main.input.remove_rich_text_box_input(a.textBox);
|
||||
if(textboxID.has_value())
|
||||
drawP.world.main.input.remove_text_box(textboxID.value());
|
||||
}
|
||||
|
||||
TextBoxEditTool::TextBoxEditToolAllData TextBoxEditTool::get_all_data(const TextBoxCanvasComponent& a) {
|
||||
|
|
@ -309,7 +389,7 @@ TextBoxEditTool::TextBoxEditToolAllData TextBoxEditTool::get_all_data(const Text
|
|||
};
|
||||
}
|
||||
|
||||
void TextBoxEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
||||
void TextBoxEditTool::edit_start(EditTool& editTool, std::any& prevData) {
|
||||
auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
auto& cur = a.cursor;
|
||||
auto& textbox = a.textBox;
|
||||
|
|
@ -321,7 +401,6 @@ void TextBoxEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::O
|
|||
textbox->process_mouse_left_button(*cur, textSelectPos, 1, false, false);
|
||||
prevData = get_all_data(a);
|
||||
a.d.editing = true;
|
||||
a.textBox->inputChangedTextBox = true;
|
||||
|
||||
set_styles_at_selection(a);
|
||||
|
||||
|
|
@ -330,15 +409,16 @@ void TextBoxEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::O
|
|||
|
||||
comp->obj->commit_update(drawP);
|
||||
|
||||
//drawP.world.main.input.set_rich_text_box_input_back(a.textBox, a.cursor, true, nullptr, {
|
||||
// .inputType = SDL_TextInputType::SDL_TEXTINPUT_TYPE_TEXT,
|
||||
// .capitalization = SDL_Capitalization::SDL_CAPITALIZE_NONE,
|
||||
// .autocorrect = true,
|
||||
// .multiline = true,
|
||||
// .androidInputType = InputManager::AndroidInputType::ANDROIDTEXT_TYPE_CLASS_TEXT
|
||||
//}, currentModsPtr);
|
||||
userInput = std::make_unique<RichTextUserInput>(textbox, cur, currentModsPtr);
|
||||
textboxID = drawP.world.main.input.set_text_box_back(std::nullopt, {
|
||||
.inputType = SDL_TextInputType::SDL_TEXTINPUT_TYPE_TEXT,
|
||||
.capitalization = SDL_Capitalization::SDL_CAPITALIZE_NONE,
|
||||
.autocorrect = true,
|
||||
.multiline = true,
|
||||
.androidInputType = InputManager::AndroidInputType::ANDROIDTEXT_TYPE_CLASS_TEXT
|
||||
});
|
||||
}
|
||||
|
||||
bool TextBoxEditTool::edit_update(CanvasComponentContainer::ObjInfo* comp) {
|
||||
bool TextBoxEditTool::edit_update() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue