File indexing completed on 2025-02-02 04:11:06
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 #include "model/assets/bitmap.hpp" 0010 #include "model/shapes/shape.hpp" 0011 #include "model/transform.hpp" 0012 #include "model/property/reference_property.hpp" 0013 #include "model/property/sub_object_property.hpp" 0014 0015 namespace glaxnimate::model { 0016 0017 class Image : public ShapeElement 0018 { 0019 GLAXNIMATE_OBJECT(Image) 0020 0021 GLAXNIMATE_SUBOBJECT(Transform, transform) 0022 GLAXNIMATE_PROPERTY_REFERENCE(Bitmap, image, &Image::valid_images, &Image::is_valid_image, &Image::on_image_changed) 0023 0024 public: 0025 Image(model::Document* doc); 0026 0027 void add_shapes(FrameTime, math::bezier::MultiBezier&, const QTransform&) const override; 0028 0029 QIcon tree_icon() const override; 0030 QString type_name_human() const override; 0031 QRectF local_bounding_rect(FrameTime t) const override; 0032 QTransform local_transform_matrix(model::FrameTime t) const override; 0033 0034 protected: 0035 QPainterPath to_painter_path_impl(FrameTime t) const override; 0036 void on_paint(QPainter* p, FrameTime t, PaintMode, model::Modifier*) const override; 0037 0038 private Q_SLOTS: 0039 void on_transform_matrix_changed(); 0040 0041 private: 0042 std::vector<DocumentNode*> valid_images() const; 0043 bool is_valid_image(DocumentNode* node) const; 0044 void on_image_changed(Bitmap* new_use, Bitmap* old_use); 0045 void on_update_image(); 0046 }; 0047 0048 } // namespace glaxnimate::model