/* * InfiniPaint * Copyright (C) 2025-2026 Yousef Khadadeh * * 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 . */ #pragma once #include "../SharedTypes.hpp" #include "CanvasComponent.hpp" #include "../CoordSpaceHelper.hpp" #include class RectangleCanvasComponent : public CanvasComponent { public: virtual void save(cereal::PortableBinaryOutputArchive& a) const override; virtual void load(cereal::PortableBinaryInputArchive& a) override; virtual void save_file(cereal::PortableBinaryOutputArchive& a) const override; virtual void load_file(cereal::PortableBinaryInputArchive& a, VersionNumber version) override; virtual void change_stroke_color(const Vector4f& newStrokeColor) override; virtual std::optional get_stroke_color() const override; virtual CanvasComponentType get_type() const override; std::unique_ptr get_data_copy() const override; virtual void set_data_from(const CanvasComponent& other) override; // User input data struct Data { Vector4f strokeColor; Vector4f fillColor; float cornerRadius; float strokeWidth; Vector2f p1; Vector2f p2; uint8_t fillStrokeMode; bool operator==(const Data& o) const = default; } d; private: virtual void draw(SkCanvas* canvas, const DrawData& drawData, const std::shared_ptr& predrawData) const override; virtual void initialize_draw_data(DrawingProgram& drawP) override; virtual bool collides_within_coords_point(const Vector2f& checkAgainst) const override; virtual bool collides_within_coords_skpath(const SkPath& checkAgainst) const override; void create_draw_data(); void create_collider(); virtual SCollision::AABB get_obj_coord_bounds() const override; SkPath rectPath; SkPath colliderPath; };