File indexing completed on 2025-02-02 04:11:07
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #pragma once 0010 0011 #include "shape.hpp" 0012 #include "model/animation/animatable_path.hpp" 0013 0014 namespace glaxnimate::model { 0015 0016 0017 class Path : public Shape 0018 { 0019 GLAXNIMATE_OBJECT(Path) 0020 using PointType = math::bezier::PointType; 0021 Q_ENUM(PointType) 0022 0023 public: 0024 GLAXNIMATE_ANIMATABLE(math::bezier::Bezier, shape, &Path::shape_changed) 0025 0026 GLAXNIMATE_PROPERTY(bool, closed, false, &Path::closed_changed) 0027 0028 public: 0029 using Shape::Shape; 0030 0031 QIcon tree_icon() const override 0032 { 0033 return QIcon::fromTheme("draw-bezier-curves"); 0034 } 0035 0036 QString type_name_human() const override 0037 { 0038 return i18n("Path"); 0039 } 0040 0041 math::bezier::Bezier to_bezier(FrameTime t) const override 0042 { 0043 auto bezier = shape.get_at(t); 0044 0045 if ( reversed.get() ) 0046 bezier.reverse(); 0047 0048 return bezier; 0049 } 0050 0051 QRectF local_bounding_rect(FrameTime t) const override 0052 { 0053 return shape.get_at(t).bounding_box(); 0054 } 0055 0056 private: 0057 void closed_changed(bool closed) 0058 { 0059 shape.set_closed(closed); 0060 } 0061 0062 Q_SIGNALS: 0063 void shape_changed(const math::bezier::Bezier& bez); 0064 }; 0065 0066 } // namespace glaxnimate::model 0067