Line data Source code
1 : /** 2 : Copyright (c) 2021 Roman Katuntsev <sbkarr@stappler.org> 3 : Copyright (c) 2023 Stappler LLC <admin@stappler.dev> 4 : 5 : Permission is hereby granted, free of charge, to any person obtaining a copy 6 : of this software and associated documentation files (the "Software"), to deal 7 : in the Software without restriction, including without limitation the rights 8 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 : copies of the Software, and to permit persons to whom the Software is 10 : furnished to do so, subject to the following conditions: 11 : 12 : The above copyright notice and this permission notice shall be included in 13 : all copies or substantial portions of the Software. 14 : 15 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 : THE SOFTWARE. 22 : **/ 23 : 24 : #ifndef XENOLITH_SCENE_NODES_XLSCENE_H_ 25 : #define XENOLITH_SCENE_NODES_XLSCENE_H_ 26 : 27 : #include "XLNode.h" 28 : #include "XLCoreResource.h" 29 : #include "XLCoreQueue.h" 30 : #include "XLCoreAttachment.h" 31 : #include "XLCoreMaterial.h" 32 : #include "XLDynamicStateNode.h" 33 : 34 : namespace STAPPLER_VERSIONIZED stappler::xenolith { 35 : 36 : class Application; 37 : class SceneContent; 38 : 39 : class Scene : public Node { 40 : public: 41 : using Queue = core::Queue; 42 : using FrameRequest = core::FrameRequest; 43 : using FrameQueue = core::FrameQueue; 44 : using FrameHandle = core::FrameHandle; 45 : 46 : virtual ~Scene(); 47 : 48 : virtual bool init(Queue::Builder &&, const core::FrameContraints &); 49 : 50 : virtual void renderRequest(const Rc<FrameRequest> &); 51 : virtual void render(FrameInfo &info); 52 : 53 : virtual void onEnter(Scene *) override; 54 : virtual void onExit() override; 55 : 56 : virtual void onContentSizeDirty() override; 57 : 58 9601 : const Rc<Queue> &getQueue() const { return _queue; } 59 88660 : Director *getDirector() const { return _director; } 60 : 61 : virtual void setContent(SceneContent *); 62 0 : virtual SceneContent *getContent() const { return _content; } 63 : 64 : virtual void onPresented(Director *); 65 : virtual void onFinished(Director *); 66 : 67 : virtual void onFrameStarted(FrameRequest &); 68 : virtual void onFrameEnded(FrameRequest &); 69 : 70 : virtual void onFrameAttached(const FrameHandle *); 71 : virtual void onFrameDetached(const FrameHandle *); 72 : 73 : virtual void setFrameConstraints(const core::FrameContraints &); 74 4650 : const core::FrameContraints & getFrameConstraints() const { return _constraints; } 75 : 76 : virtual const Size2& getContentSize() const override; 77 : 78 : virtual void setClipContent(bool); 79 : virtual bool isClipContent() const; 80 : 81 : protected: 82 : using Node::init; 83 : using Node::addChild; // запрет добавлять ноды напрямую на сцену 84 : 85 : virtual Rc<Queue> makeQueue(Queue::Builder &&); 86 : 87 : virtual void updateContentNode(SceneContent *); 88 : 89 : #if SP_REF_DEBUG 90 : virtual bool isRetainTrackerEnabled() const override { 91 : return true; 92 : } 93 : #endif 94 : 95 : Director *_director = nullptr; 96 : SceneContent *_content = nullptr; 97 : 98 : Rc<Queue> _queue; 99 : 100 : core::FrameContraints _constraints; 101 : }; 102 : 103 : } 104 : 105 : #endif /* XENOLITH_SCENE_NODES_XLSCENE_H_ */