#pragma once #include #include #include #include namespace frostbite2D { /** * @brief Composes 9 consecutive NPK frames into a resizable nine-slice panel. */ class NineSliceActor : public Actor { public: NineSliceActor(); ~NineSliceActor() override = default; static Ptr createFromNpk(const std::string& imgPath, size_t startIndex = 0); bool SetSlices(const std::string& imgPath, size_t startIndex); void SetSize(const Vec2& size); void SetSize(float width, float height); const std::string& GetImgPath() const { return imgPath_; } size_t GetStartIndex() const { return startIndex_; } private: enum SliceIndex : size_t { TopLeft = 0, Top = 1, TopRight = 2, Left = 3, Center = 4, Right = 5, BottomLeft = 6, Bottom = 7, BottomRight = 8, SliceCount = 9 }; void updateLayout(); void applySliceLayout(Ptr sprite, const Vec2& position, const Vec2& size); Vec2 getNaturalSize() const; std::string imgPath_; size_t startIndex_ = 0; std::array, SliceCount> sliceSprites_; std::array sliceNaturalSizes_ = {}; }; } // namespace frostbite2D