1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /* shape.h - base for shape creating tools
- * Copyright (C) 2017-2018 caryoscelus
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
- #ifndef STUDIO_CANVAS_TOOLS_SHAPE_H_5A163439_B575_5309_B679_7539C7DF5AB7
- #define STUDIO_CANVAS_TOOLS_SHAPE_H_5A163439_B575_5309_B679_7539C7DF5AB7
- #include <2geom/point.h>
- #include <core/node_tree/path.h>
- #include "base.h"
- namespace rainynite::studio::tools {
- /**
- * Base class for shape-creating tools.
- */
- class Shape : public Base {
- public:
- bool canvas_event(QEvent* event) override;
- protected:
- using MakeShape = std::function<shared_ptr<core::AbstractValue>(Geom::Point)>;
- void new_shape_at(QPointF const& pos, MakeShape f);
- virtual bool draw_shape_event(QEvent* event);
- virtual bool mouse_press(QPoint const& pos) = 0;
- virtual bool mouse_move(QPoint const& /*pos*/) {
- return false;
- }
- virtual bool mouse_release(QPoint const& /*pos*/) {
- return false;
- }
- /**
- * Called on double click which should indicate editing is finished.
- *
- * Default implementation is empty because some shapes are finished
- * implicitly by end of dragging (circle, rectangle, etc)
- */
- virtual bool editing_done() {
- return false;
- }
- /// Returns whether this node can accept the shape
- virtual bool accept(shared_ptr<core::AbstractValue> node);
- /// Write shape to active node
- virtual void write_shape(shared_ptr<core::AbstractValue> node);
- /// Get target node index
- core::NodeTreeIndex get_index() const;
- private:
- core::NodeTreePath target_node_index;
- };
- } // namespace rainynite::studio::tools
- #endif
|