2025-08-02 20:10:33 +03:00
|
|
|
#include "EllipseDrawEditTool.hpp"
|
2025-12-26 10:40:58 +03:00
|
|
|
#include "../../DrawingProgram.hpp"
|
|
|
|
|
#include "../../../World.hpp"
|
|
|
|
|
#include "../../../MainProgram.hpp"
|
|
|
|
|
#include "../../../DrawData.hpp"
|
2025-08-02 20:10:33 +03:00
|
|
|
#include <cereal/types/vector.hpp>
|
|
|
|
|
#include <memory>
|
2025-12-26 10:40:58 +03:00
|
|
|
#include "../EditTool.hpp"
|
2025-08-02 20:10:33 +03:00
|
|
|
|
2026-03-30 17:05:24 +03:00
|
|
|
#include "../../../GUIStuff/ElementHelpers/TextLabelHelpers.hpp"
|
|
|
|
|
#include "../../../GUIStuff/ElementHelpers/RadioButtonHelpers.hpp"
|
|
|
|
|
#include "../../../GUIStuff/ElementHelpers/LayoutHelpers.hpp"
|
|
|
|
|
#include "../../../GUIStuff/ElementHelpers/NumberSliderHelpers.hpp"
|
|
|
|
|
|
2025-08-02 20:10:33 +03:00
|
|
|
EllipseDrawEditTool::EllipseDrawEditTool(DrawingProgram& initDrawP):
|
|
|
|
|
DrawingProgramEditToolBase(initDrawP)
|
|
|
|
|
{}
|
|
|
|
|
|
2026-03-30 17:05:24 +03:00
|
|
|
void EllipseDrawEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|
|
|
|
using namespace GUIStuff;
|
|
|
|
|
using namespace ElementHelpers;
|
|
|
|
|
|
2025-12-15 15:36:42 +03:00
|
|
|
auto& a = static_cast<EllipseCanvasComponent&>(comp->obj->get_comp());
|
2026-03-31 13:17:58 +03:00
|
|
|
auto& gui = drawP.world.main.g.gui;
|
2026-04-02 18:23:36 +03:00
|
|
|
Toolbar& t = drawP.world.main.toolbar;
|
2026-04-02 10:15:22 +03:00
|
|
|
auto commit_update_func = [&, comp] { comp->obj->commit_update(drawP); };
|
|
|
|
|
auto commit_update_and_layout_func = [&, comp] {
|
|
|
|
|
comp->obj->commit_update(drawP);
|
|
|
|
|
drawP.world.main.g.gui.set_to_layout();
|
|
|
|
|
};
|
2025-08-02 20:10:33 +03:00
|
|
|
|
2026-03-31 13:17:58 +03:00
|
|
|
gui.new_id("edit tool ellipse", [&] {
|
|
|
|
|
text_label_centered(gui, "Edit Ellipse");
|
|
|
|
|
radio_button_selector(gui, "Fill selector", &a.d.fillStrokeMode, {
|
2026-03-30 18:51:14 +03:00
|
|
|
{"Fill only", 0},
|
|
|
|
|
{"Outline only", 1},
|
|
|
|
|
{"Fill and outline", 2}
|
2026-04-02 10:15:22 +03:00
|
|
|
}, commit_update_and_layout_func);
|
2026-03-30 18:51:14 +03:00
|
|
|
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
|
2026-03-31 13:17:58 +03:00
|
|
|
left_to_right_line_layout(gui, [&] {
|
2026-04-02 18:23:36 +03:00
|
|
|
t.color_button_right("Fill color button", &a.d.fillColor, commit_update_func);
|
2026-03-31 13:17:58 +03:00
|
|
|
text_label(gui, "Fill Color");
|
2026-03-30 18:51:14 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
|
2026-04-02 10:15:22 +03:00
|
|
|
slider_scalar_field(gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f, {.onEdit = commit_update_func});
|
2026-03-31 13:17:58 +03:00
|
|
|
left_to_right_line_layout(gui, [&] {
|
2026-04-02 18:23:36 +03:00
|
|
|
t.color_button_right("Outline color button", &a.d.strokeColor, commit_update_func);
|
2026-03-31 13:17:58 +03:00
|
|
|
text_label(gui, "Outline Color");
|
2026-03-30 18:51:14 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-08-02 20:10:33 +03:00
|
|
|
}
|
|
|
|
|
|
2025-12-30 19:46:08 +03:00
|
|
|
void EllipseDrawEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
2025-12-15 15:36:42 +03:00
|
|
|
auto& a = static_cast<EllipseCanvasComponent&>(comp->obj->get_comp());
|
2025-08-02 20:10:33 +03:00
|
|
|
|
2025-12-15 15:36:42 +03:00
|
|
|
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});
|
2025-08-02 20:10:33 +03:00
|
|
|
}
|
|
|
|
|
|
2025-12-30 19:46:08 +03:00
|
|
|
void EllipseDrawEditTool::commit_edit_updates(CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
2025-08-02 20:10:33 +03:00
|
|
|
}
|
|
|
|
|
|
2025-12-30 19:46:08 +03:00
|
|
|
bool EllipseDrawEditTool::edit_update(CanvasComponentContainer::ObjInfo* comp) {
|
2025-08-02 20:10:33 +03:00
|
|
|
return true;
|
|
|
|
|
}
|