Warning, file /graphics/glaxnimate/src/gui/tools/ellipse_tool.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #include "rectangle_tool.hpp"
0008 #include "model/shapes/ellipse.hpp"
0009 
0010 namespace glaxnimate::gui::tools {
0011 
0012 class EllipseTool : public RectangleTool
0013 {
0014 public:
0015     QString id() const override { return "draw-ellipse"; }
0016     QIcon icon() const override { return QIcon::fromTheme("draw-ellipse"); }
0017     QString name() const override { return i18n("Ellipse"); }
0018     QKeySequence key_sequence() const override { return QKeySequence(i18n("F5"), QKeySequence::PortableText); }
0019     static int static_group() noexcept { return Registry::Shape; }
0020     int group() const noexcept override { return static_group(); }
0021 
0022     void on_drag_complete(const MouseEvent& event) override
0023     {
0024         auto shape = std::make_unique<model::Ellipse>(event.window->document());
0025         rect = rect.normalized();
0026         shape->position.set(rect.center());
0027         shape->size.set(rect.size());
0028         create_shape(i18n("Draw Ellipse"), event, std::move(shape));
0029     }
0030 
0031     void paint(const PaintEvent& event) override
0032     {
0033         if ( dragging )
0034         {
0035             QPainterPath path;
0036             path.addEllipse(rect);
0037             path = event.view->mapFromScene(path);
0038             draw_shape(event, path);
0039         }
0040     }
0041 
0042 private:
0043     static Autoreg<EllipseTool> autoreg;
0044 };
0045 
0046 tools::Autoreg<tools::EllipseTool> tools::EllipseTool::autoreg{max_priority + 1};
0047 
0048 } // namespace glaxnimate::gui::tools
0049