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_BASIC2D_XL2DSCENELAYOUT_H_ 24 : #define XENOLITH_RENDERER_BASIC2D_XL2DSCENELAYOUT_H_ 25 : 26 : #include "XLDynamicStateNode.h" 27 : #include "XLAction.h" 28 : 29 : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d { 30 : 31 : class SceneContent2d; 32 : 33 : enum class DecorationMask { 34 : None, 35 : Top = 1 << 0, 36 : Bottom = 1 << 1, 37 : Left = 1 << 2, 38 : Right = 1 << 3, 39 : Vertical = Top | Bottom, 40 : Horizontal = Left | Right, 41 : All = Vertical | Horizontal 42 : }; 43 : 44 : SP_DEFINE_ENUM_AS_MASK(DecorationMask) 45 : 46 : enum class DecorationStatus { 47 : DontCare, 48 : Visible, 49 : Hidden 50 : }; 51 : 52 : class SceneLayout2d : public DynamicStateNode { 53 : public: 54 : using BackButtonCallback = Function<bool()>; 55 : using Transition = ActionInterval; 56 : 57 : virtual ~SceneLayout2d(); 58 : 59 : virtual void setDecorationMask(DecorationMask mask); 60 78 : virtual DecorationMask getDecodationMask() const { return _decorationMask; } 61 : 62 : virtual void setDecorationPadding(Padding); 63 0 : virtual Padding getDecorationPadding() const { return _decorationPadding; } 64 : 65 : virtual void setTargetContentSize(const Size2 &); 66 78 : virtual Size2 getTargetContentSize() const { return _targetContentSize; } 67 : 68 : virtual bool onBackButton(); 69 : 70 : virtual void setBackButtonCallback(const BackButtonCallback &); 71 : virtual const BackButtonCallback &getBackButtonCallback() const; 72 : 73 : virtual void onPush(SceneContent2d *l, bool replace); 74 : virtual void onPushTransitionEnded(SceneContent2d *l, bool replace); 75 : 76 : virtual void onPopTransitionBegan(SceneContent2d *l, bool replace); 77 : virtual void onPop(SceneContent2d *l, bool replace); 78 : 79 : virtual void onBackground(SceneContent2d *l, SceneLayout2d *overlay); 80 : virtual void onBackgroundTransitionEnded(SceneContent2d *l, SceneLayout2d *overlay); 81 : 82 : virtual void onForegroundTransitionBegan(SceneContent2d *l, SceneLayout2d *overlay); 83 : virtual void onForeground(SceneContent2d *l, SceneLayout2d *overlay); 84 : 85 : virtual Rc<Transition> makeEnterTransition(SceneContent2d *) const; 86 : virtual Rc<Transition> makeExitTransition(SceneContent2d *) const; 87 : 88 : virtual bool hasBackButtonAction() const; 89 : 90 : virtual void setLayoutName(StringView); 91 : virtual StringView getLayoutName() const; 92 : 93 20 : virtual DecorationStatus getDecorationStatus() const { return DecorationStatus::DontCare; } 94 0 : virtual SceneContent2d *getSceneContent() const { return _sceneContent; } 95 : 96 : protected: 97 : DecorationMask _decorationMask = DecorationMask::None; 98 : Padding _decorationPadding; 99 : bool _inTransition = false; 100 : BackButtonCallback _backButtonCallback; 101 : SceneContent2d *_sceneContent = nullptr; 102 : String _name; 103 : Size2 _targetContentSize; 104 : }; 105 : 106 : } 107 : 108 : #endif /* XENOLITH_RENDERER_BASIC2D_XL2DSCENELAYOUT_H_ */