/* * InfiniPaint * Copyright (C) 2025-2026 Yousef Khadadeh * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "EllipseDrawEditTool.hpp" #include "../../DrawingProgram.hpp" #include "../../../World.hpp" #include "../../../MainProgram.hpp" #include "../../../DrawData.hpp" #include #include "../EditTool.hpp" #include "../../../GUIStuff/ElementHelpers/TextLabelHelpers.hpp" #include "../../../GUIStuff/ElementHelpers/RadioButtonHelpers.hpp" #include "../../../GUIStuff/ElementHelpers/LayoutHelpers.hpp" #include "../../../GUIStuff/ElementHelpers/NumberSliderHelpers.hpp" EllipseDrawEditTool::EllipseDrawEditTool(DrawingProgram& initDrawP, CanvasComponentContainer::ObjInfo* initComp): DrawingProgramEditToolBase(initDrawP, initComp) {} void EllipseDrawEditTool::edit_gui(Toolbar& t) { using namespace GUIStuff; using namespace ElementHelpers; auto& a = static_cast(comp->obj->get_comp()); auto& gui = drawP.world.main.g.gui; auto commit_update_func = [&] { commitUpdate = true; }; auto commit_update_and_layout_func = [&] { commitUpdate = true; drawP.world.main.g.gui.set_to_layout(); }; gui.new_id("edit tool ellipse", [&] { text_label_centered(gui, "Edit Ellipse"); radio_button_selector(gui, "Fill selector", &a.d.fillStrokeMode, { {"Fill only", 0}, {"Outline only", 1}, {"Fill and outline", 2} }, commit_update_and_layout_func); if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) { left_to_right_line_layout(gui, [&] { t.color_button_right("Fill color button", &a.d.fillColor, { .onChange = commit_update_func }); text_label(gui, "Fill Color"); }); } if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) { slider_scalar_field(gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f, {.onEdit = commit_update_func}); left_to_right_line_layout(gui, [&] { t.color_button_right("Outline color button", &a.d.strokeColor, { .onChange = commit_update_func }); text_label(gui, "Outline Color"); }); } }); } Vector4f* EllipseDrawEditTool::color_picker_color(Vector4f* oldColor) { auto& a = static_cast(comp->obj->get_comp()); if(oldColor == &a.d.fillColor) return oldColor; if(oldColor == &a.d.strokeColor) return oldColor; return nullptr; } void EllipseDrawEditTool::gui_phone_toolbox(PhoneDrawingProgramScreen& t) { using namespace GUIStuff; using namespace ElementHelpers; auto& a = static_cast(comp->obj->get_comp()); auto& gui = drawP.world.main.g.gui; auto commit_update_func = [&] { commitUpdate = true; }; auto commit_update_and_layout_func = [&] { commitUpdate = true; drawP.world.main.g.gui.set_to_layout(); }; gui.new_id("edit tool ellipse", [&] { radio_button_selector(gui, "Fill selector", &a.d.fillStrokeMode, { {"Fill only", 0}, {"Outline only", 1}, {"Fill and outline", 2} }, commit_update_and_layout_func); if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) { left_to_right_line_layout(gui, [&] { t.color_selector_button("Fill color button", &a.d.fillColor, { .onChange = commit_update_func }); text_label(gui, "Fill Color"); }); } if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) { slider_scalar_field(gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f, {.onEdit = commit_update_func}); left_to_right_line_layout(gui, [&] { t.color_selector_button("Outline color button", &a.d.strokeColor, { .onChange = commit_update_func }); text_label(gui, "Outline Color"); }); } }); } void EllipseDrawEditTool::edit_start(EditTool& editTool, std::any& prevData) { auto& a = static_cast(comp->obj->get_comp()); prevData = a.d; editTool.add_point_handle({&a.d.p1, nullptr, &a.d.p2}); editTool.add_point_handle({&a.d.p2, &a.d.p1, nullptr}); } void EllipseDrawEditTool::commit_edit_updates(std::any& prevData) { } void EllipseDrawEditTool::edit_update() { }