LCOV - code coverage report
Current view: top level - xenolith/renderer/basic2d - XL2dImageLayer.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2024-05-12 00:16:13 Functions: 0 1 0.0 %

          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_XL2DIMAGELAYER_H_
      24             : #define XENOLITH_RENDERER_BASIC2D_XL2DIMAGELAYER_H_
      25             : 
      26             : #include "XL2d.h"
      27             : #include "XL2dSprite.h"
      28             : 
      29             : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d {
      30             : 
      31             : class ImageLayer : public Node {
      32             : public:
      33           0 :         static constexpr float GetMaxScaleFactor() { return 1.0f; }
      34             : 
      35             :         virtual ~ImageLayer();
      36             : 
      37             :         virtual bool init() override;
      38             :         virtual void onContentSizeDirty() override;
      39             :     virtual void onTransformDirty(const Mat4 &) override;
      40             : 
      41             :         virtual void setTexture(Rc<Texture> &&);
      42             :         virtual const Rc<Texture> &getTexture() const;
      43             : 
      44             :         virtual void setActionCallback(Function<void()> &&);
      45             : 
      46             :         virtual Vec2 getTexturePosition() const;
      47             : 
      48             :         virtual void setScaleDisabled(bool);
      49             :         virtual void setImageSize(Size2);
      50             : 
      51             :         virtual bool handleTap(Vec2 point, int count);
      52             : 
      53             :         virtual bool handleSwipeBegin(Vec2 point);
      54             :         virtual bool handleSwipe(Vec2 delta);
      55             :         virtual bool handleSwipeEnd(Vec2 velocity);
      56             : 
      57             :         virtual bool handlePinch(Vec2 point, float scale, float velocity, bool isEnded);
      58             : 
      59             :         Node *getRoot() const { return _root; }
      60             : 
      61             : protected:
      62             :         Rect getCorrectRect(Size2 containerSize);
      63             :         Vec2 getCorrectPosition(Size2 containerSize, Vec2 point);
      64             : 
      65             :         Size2 getContainerSize() const;
      66             :         Size2 getContainerSizeForScale(float value) const;
      67             : 
      68             :         InputListener *_gestureListener = nullptr;
      69             : 
      70             :         Node *_root = nullptr;
      71             :         Sprite *_image = nullptr;
      72             : 
      73             :         Size2 _imageSize;
      74             :         Size2 _prevContentSize;
      75             :     Vec2 _globalScale; // values to scale input gestures
      76             : 
      77             :         float _minScale = 0.0f;
      78             :         float _maxScale = 0.0f;
      79             : 
      80             :         float _scaleSource;
      81             :         bool _imageSizePredefined = false;
      82             :         bool _scaleDisabled = false;
      83             :         bool _hasPinch = false;
      84             :         bool _textureDirty = false;
      85             : 
      86             :         Function<void()> _actionCallback;
      87             : };
      88             : 
      89             : }
      90             : 
      91             : #endif /* XENOLITH_RENDERER_BASIC2D_XL2DIMAGELAYER_H_ */

Generated by: LCOV version 1.14