Line data Source code
1 : /** 2 : Copyright (c) 2023 Stappler LLC <admin@stappler.dev> 3 : 4 : Permission is hereby granted, free of charge, to any person obtaining a copy 5 : of this software and associated documentation files (the "Software"), to deal 6 : in the Software without restriction, including without limitation the rights 7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 : copies of the Software, and to permit persons to whom the Software is 9 : furnished to do so, subject to the following conditions: 10 : 11 : The above copyright notice and this permission notice shall be included in 12 : all copies or substantial portions of the Software. 13 : 14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 : THE SOFTWARE. 21 : **/ 22 : 23 : #ifndef XENOLITH_RENDERER_MATERIAL2D_BASE_MATERIALLAYERSURFACE_H_ 24 : #define XENOLITH_RENDERER_MATERIAL2D_BASE_MATERIALLAYERSURFACE_H_ 25 : 26 : #include "MaterialSurfaceStyle.h" 27 : #include "XL2dLayer.h" 28 : 29 : namespace STAPPLER_VERSIONIZED stappler::xenolith::material2d { 30 : 31 : class SurfaceInterior; 32 : class StyleContainer; 33 : 34 : class LayerSurface : public Layer { 35 : public: 36 : static constexpr uint32_t TransitionActionTag = maxOf<uint32_t>() - 1; 37 : 38 520 : virtual ~LayerSurface() { } 39 : 40 : virtual bool init(const SurfaceStyle &); 41 : 42 0 : virtual const SurfaceStyle &getStyleOrigin() const { return _styleOrigin; } 43 0 : virtual const SurfaceStyle &getStyleTarget() const { return _styleTarget; } 44 : 45 52 : virtual const SurfaceStyleData &getStyleCurrent() const { return _styleDataCurrent; } 46 : 47 : virtual void setStyle(const SurfaceStyle &); 48 : virtual void setStyle(const SurfaceStyle &, float duration); 49 : 50 : virtual void setColorRole(ColorRole value); 51 : virtual void setElevation(Elevation value); 52 : virtual void setShapeFamily(ShapeFamily value); 53 : virtual void setShapeStyle(ShapeStyle value); 54 : virtual void setNodeStyle(NodeStyle value); 55 : virtual void setActivityState(ActivityState value); 56 : 57 : virtual void setStyleDirtyCallback(Function<void(const SurfaceStyleData &)> &&); 58 0 : virtual const Function<void(const SurfaceStyleData &)> &getStyleDirtyCallback() const { return _styleDirtyCallback; } 59 : 60 : virtual bool visitDraw(FrameInfo &, NodeFlags parentFlags) override; 61 : 62 : protected: 63 : virtual void applyStyle(const SurfaceStyleData &); 64 : 65 : virtual StyleContainer *getStyleContainerForFrame(FrameInfo &) const; 66 : virtual SurfaceInterior *getSurfaceInteriorForFrame(FrameInfo &) const; 67 : virtual RenderingLevel getRealRenderingLevel() const override; 68 : 69 : SurfaceInterior *_interior = nullptr; 70 : 71 : SurfaceStyle _styleOrigin; 72 : SurfaceStyle _styleTarget; 73 : 74 : SurfaceStyleData _styleDataOrigin; 75 : SurfaceStyleData _styleDataTarget; 76 : SurfaceStyleData _styleDataCurrent; 77 : 78 : Function<void(const SurfaceStyleData &)> _styleDirtyCallback; 79 : 80 : float _styleProgress = 0.0f; 81 : bool _styleDirty = true; 82 : bool _inTransition = false; 83 : }; 84 : 85 : } 86 : 87 : #endif /* XENOLITH_RENDERER_MATERIAL2D_BASE_MATERIALLAYERSURFACE_H_ */