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 "MaterialSurfaceInterior.h" 24 : 25 : #include "MaterialStyleContainer.h" 26 : #include "MaterialSurface.h" 27 : #include "MaterialLayerSurface.h" 28 : #include "XLFrameInfo.h" 29 : 30 : namespace STAPPLER_VERSIONIZED stappler::xenolith::material2d { 31 : 32 : uint64_t SurfaceInterior::ComponentFrameTag = Component::GetNextComponentId(); 33 : 34 848 : bool SurfaceInterior::init() { 35 848 : if (!Component::init()) { 36 0 : return false; 37 : } 38 : 39 848 : setFrameTag(ComponentFrameTag); 40 848 : return true; 41 : } 42 : 43 20 : bool SurfaceInterior::init(SurfaceStyle &&style) { 44 20 : if (!Component::init()) { 45 0 : return false; 46 : } 47 : 48 20 : setFrameTag(ComponentFrameTag); 49 20 : _assignedStyle = move(style); 50 20 : return true; 51 : } 52 : 53 868 : void SurfaceInterior::onAdded(Node *owner) { 54 868 : Component::onAdded(owner); 55 : 56 868 : _ownerIsMaterialNode = ((dynamic_cast<Surface *>(_owner) != nullptr) || (dynamic_cast<LayerSurface *>(_owner) != nullptr)); 57 868 : } 58 : 59 22468 : void SurfaceInterior::visit(FrameInfo &info, NodeFlags parentFlags) { 60 22468 : Component::visit(info, parentFlags); 61 : 62 22468 : if (!_ownerIsMaterialNode) { 63 5020 : auto style = info.getComponent<StyleContainer>(StyleContainer::ComponentFrameTag); 64 5020 : if (!style) { 65 0 : return; 66 : } 67 : 68 5020 : _assignedStyle.apply(_interiorStyle, _owner->getContentSize(), style, 69 10040 : info.getComponent<SurfaceInterior>(SurfaceInterior::ComponentFrameTag)); 70 5020 : } 71 : } 72 : 73 : }