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_XL2DSCENE_H_ 24 : #define XENOLITH_RENDERER_BASIC2D_XL2DSCENE_H_ 25 : 26 : #include "XLScene.h" 27 : #include "XLInput.h" 28 : 29 : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d { 30 : 31 : class VectorSprite; 32 : 33 : class Scene2d : public Scene { 34 : public: 35 : class FpsDisplay; 36 : 37 2 : virtual ~Scene2d() { } 38 : 39 : // create with default render queue 40 : virtual bool init(Application *, const core::FrameContraints &); 41 : 42 : // create with default render queue, resources can be added via callback 43 : virtual bool init(Application *, const Callback<void(Queue::Builder &)> &, const core::FrameContraints &); 44 : 45 : virtual bool init(Queue::Builder &&, const core::FrameContraints &) override; 46 : 47 : virtual void update(const UpdateTime &time) override; 48 : 49 : virtual void onContentSizeDirty() override; 50 : 51 : virtual void setFpsVisible(bool); 52 : virtual bool isFpsVisible() const; 53 : 54 : virtual void setContent(SceneContent *) override; 55 : 56 : protected: 57 : virtual void initialize(); 58 : virtual void addContentNodes(SceneContent *); 59 : 60 : void updateInputEventData(InputEventData &data, const InputEventData &source, Vec2 pos, uint32_t id); 61 : 62 : InputEventData _data1 = InputEventData{maxOf<uint32_t>() - 1}; 63 : InputEventData _data2 = InputEventData{maxOf<uint32_t>() - 2}; 64 : InputListener *_listener = nullptr; 65 : FpsDisplay *_fps = nullptr; 66 : VectorSprite *_pointerReal = nullptr; 67 : VectorSprite *_pointerVirtual = nullptr; 68 : VectorSprite *_pointerCenter = nullptr; 69 : }; 70 : 71 : } 72 : 73 : #endif /* XENOLITH_RENDERER_BASIC2D_XL2DSCENE_H_ */