MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / edit_gui

Method edit_gui

src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp:76–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void TextBoxEditTool::edit_gui(Toolbar& t) {
77 using namespace GUIStuff;
78 using namespace ElementHelpers;
79
80 auto& a = static_cast<TextBoxCanvasComponent&>(comp->obj->get_comp());
81 auto& gui = drawP.world.main.g.gui;
82 auto& currentMods = *currentModsPtr;
83
84 gui.new_id("edit tool text", [&] {
85 text_label_centered(gui, "Edit Text");
86
87 left_to_right_line_layout(gui, [&] {
88 text_label(gui, "Font");
89 gui.element<FontPicker>("Font picker", &newFontName, FontPickerData{
90 .onFontChange = [&] {
91 currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES] = std::make_shared<FontFamiliesTextStyleModifier>(std::vector<SkString>{SkString{newFontName.c_str(), newFontName.size()}});
92 add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES]);});
93 commit_update_func_and_android_update();
94 }
95 });
96 });
97
98 left_to_right_line_centered_layout(gui, [&] {
99 svg_icon_button(gui, "Bold button", "data/icons/RemixIcon/bold.svg", {
100 .isSelected = newIsBold,
101 .onClick = [&] {
102 newIsBold = !newIsBold;
103 currentMods[TextStyleModifier::ModifierType::WEIGHT] = std::make_shared<WeightTextStyleModifier>(newIsBold ? SkFontStyle::Weight::kBold_Weight : SkFontStyle::Weight::kNormal_Weight);
104 add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::WEIGHT]);});
105 commit_update_func_and_android_update();
106 }
107 });
108
109 svg_icon_button(gui, "Italic button", "data/icons/RemixIcon/italic.svg", {
110 .isSelected = newIsItalic,
111 .onClick = [&] {
112 newIsItalic = !newIsItalic;
113 currentMods[TextStyleModifier::ModifierType::SLANT] = std::make_shared<SlantTextStyleModifier>(newIsItalic ? SkFontStyle::Slant::kItalic_Slant : SkFontStyle::Slant::kUpright_Slant);
114 add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SLANT]);});
115 commit_update_func_and_android_update();
116 }
117 });
118
119 auto decorationChange = [&] {
120 currentMods[TextStyleModifier::ModifierType::DECORATION] = std::make_shared<DecorationTextStyleModifier>(get_new_decoration_value());
121 add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::DECORATION]);});
122 commit_update_func_and_android_update();
123 };
124
125 svg_icon_button(gui, "Underline button", "data/icons/RemixIcon/underline.svg", {
126 .isSelected = newIsUnderlined,
127 .onClick = [&, decorationChange] {
128 newIsUnderlined = !newIsUnderlined;
129 decorationChange();
130 }
131 });
132
133 svg_icon_button(gui, "Strikethrough button", "data/icons/RemixIcon/strikethrough.svg", {

Callers

nothing calls this directly

Calls 14

text_label_centeredFunction · 0.85
text_labelFunction · 0.85
svg_icon_buttonFunction · 0.85
new_idMethod · 0.80
c_strMethod · 0.80
color_button_rightMethod · 0.80
set_to_layoutMethod · 0.80

Tested by

no test coverage detected