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 : #include "XL2dSceneLayout.h" 24 : #include "XL2dSceneContent.h" 25 : 26 : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d { 27 : 28 136 : SceneLayout2d::~SceneLayout2d() { } 29 : 30 0 : void SceneLayout2d::setDecorationMask(DecorationMask mask) { 31 0 : if (_decorationMask != mask) { 32 0 : _decorationMask = mask; 33 0 : if (_sceneContent) { 34 0 : _sceneContent->updateLayoutNode(this); 35 : } 36 : } 37 0 : } 38 : 39 348 : void SceneLayout2d::setDecorationPadding(Padding padding) { 40 348 : if (_decorationPadding != padding) { 41 52 : _decorationPadding = padding; 42 52 : _contentSizeDirty = true; 43 : } 44 348 : } 45 : 46 0 : void SceneLayout2d::setTargetContentSize(const Size2 &size) { 47 0 : _targetContentSize = size; 48 0 : } 49 : 50 10 : bool SceneLayout2d::onBackButton() { 51 10 : if (_backButtonCallback) { 52 0 : return _backButtonCallback(); 53 10 : } else if (_sceneContent) { 54 10 : if (_sceneContent->getLayoutsCount() >= 2 && _sceneContent->getTopLayout() == this) { 55 10 : _sceneContent->popLayout(this); 56 10 : return true; 57 : } 58 : } 59 0 : return false; 60 : } 61 : 62 0 : void SceneLayout2d::setBackButtonCallback(const BackButtonCallback &cb) { 63 0 : _backButtonCallback = cb; 64 0 : } 65 0 : const SceneLayout2d::BackButtonCallback &SceneLayout2d::getBackButtonCallback() const { 66 0 : return _backButtonCallback; 67 : } 68 : 69 136 : void SceneLayout2d::onPush(SceneContent2d *l, bool replace) { 70 136 : _sceneContent = l; 71 136 : _inTransition = true; 72 136 : } 73 136 : void SceneLayout2d::onPushTransitionEnded(SceneContent2d *l, bool replace) { 74 136 : _sceneContent = l; 75 136 : _inTransition = false; 76 136 : _contentSizeDirty = true; 77 136 : } 78 : 79 10 : void SceneLayout2d::onPopTransitionBegan(SceneContent2d *l, bool replace) { 80 10 : _inTransition = true; 81 10 : } 82 10 : void SceneLayout2d::onPop(SceneContent2d *l, bool replace) { 83 10 : _inTransition = false; 84 10 : _contentSizeDirty = true; 85 10 : _sceneContent = nullptr; 86 10 : } 87 : 88 126 : void SceneLayout2d::onBackground(SceneContent2d *l, SceneLayout2d *overlay) { 89 126 : _inTransition = true; 90 126 : } 91 126 : void SceneLayout2d::onBackgroundTransitionEnded(SceneContent2d *l, SceneLayout2d *overlay) { 92 126 : _inTransition = false; 93 126 : _contentSizeDirty = true; 94 126 : } 95 : 96 10 : void SceneLayout2d::onForegroundTransitionBegan(SceneContent2d *l, SceneLayout2d *overlay) { 97 10 : _inTransition = true; 98 10 : } 99 10 : void SceneLayout2d::onForeground(SceneContent2d *l, SceneLayout2d *overlay) { 100 10 : _inTransition = false; 101 10 : _contentSizeDirty = true; 102 10 : } 103 : 104 136 : Rc<SceneLayout2d::Transition> SceneLayout2d::makeEnterTransition(SceneContent2d *) const { 105 136 : return nullptr; 106 : } 107 10 : Rc<SceneLayout2d::Transition> SceneLayout2d::makeExitTransition(SceneContent2d *) const { 108 10 : return nullptr; 109 : } 110 : 111 10 : bool SceneLayout2d::hasBackButtonAction() const { 112 10 : return _backButtonCallback != nullptr; 113 : } 114 : 115 0 : void SceneLayout2d::setLayoutName(StringView name) { 116 0 : _name = name.str<Interface>(); 117 0 : } 118 : 119 0 : StringView SceneLayout2d::getLayoutName() const { 120 0 : return _name; 121 : } 122 : 123 : }