LCOV - code coverage report
Current view: top level - xenolith/renderer/material2d/components/input - MaterialInputTextContainer.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 3 33.3 %
Date: 2024-05-12 00:16:13 Functions: 1 3 33.3 %

          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_MATERIAL2D_COMPONENTS_INPUT_MATERIALINPUTTEXTCONTAINER_H_
      24             : #define XENOLITH_RENDERER_MATERIAL2D_COMPONENTS_INPUT_MATERIALINPUTTEXTCONTAINER_H_
      25             : 
      26             : #include "MaterialLabel.h"
      27             : #include "MaterialIconSprite.h"
      28             : #include "XLTextInputManager.h"
      29             : #include "XL2dLayer.h"
      30             : 
      31             : namespace STAPPLER_VERSIONIZED stappler::xenolith::material2d {
      32             : 
      33             : class InputTextContainer : public DynamicStateNode {
      34             : public:
      35             :         virtual ~InputTextContainer();
      36             : 
      37             :         virtual bool init() override;
      38             :         virtual void update(const UpdateTime &time) override;
      39             :         virtual void onContentSizeDirty() override;
      40             : 
      41             :         virtual bool visitDraw(FrameInfo &, NodeFlags parentFlags) override;
      42             : 
      43         330 :         TypescaleLabel *getLabel() const { return _label; }
      44             : 
      45             :         virtual void setEnabled(bool);
      46           0 :         virtual bool isEnabled() const { return _enabled; }
      47             : 
      48             :         virtual void setCursor(TextCursor);
      49           0 :         virtual TextCursor getCursor() const { return _cursor; }
      50             : 
      51             :         virtual void handleLabelChanged();
      52             : 
      53             :         virtual TextCursor getCursorForPosition(const Vec2 &);
      54             : 
      55             :         virtual bool hasHorizontalOverflow() const;
      56             :         virtual void moveHorizontalOverflow(float d);
      57             : 
      58             :         virtual IconSprite *getTouchedCursor(const Vec2 &, float = 4.0f);
      59             : 
      60             :         virtual bool handleLongPress(const Vec2 &, uint32_t tickCount);
      61             : 
      62             :         virtual bool handleSwipeBegin(const Vec2 &);
      63             :         virtual bool handleSwipe(const Vec2 &, const Vec2 &);
      64             :         virtual bool handleSwipeEnd(const Vec2 &);
      65             : 
      66             :         virtual void touchPointers();
      67             : 
      68             :         virtual void setCursorCallback(Function<void(TextCursor)> &&);
      69             :         virtual const Function<void(TextCursor)> &getCursorCallback() const;
      70             : 
      71             : protected:
      72             :         virtual void updateCursorPosition();
      73             :         virtual void updateCursorPointers();
      74             :         virtual void runAdjustLabel(float pos);
      75             : 
      76             :         void scheduleCursorPointer();
      77             :         void unscheduleCursorPointer();
      78             :         void setPointerEnabled(bool value);
      79             : 
      80             :         TypescaleLabel *_label = nullptr;
      81             :         Vec2 _adjustment = Vec2::ZERO;
      82             :         Layer *_caret = nullptr;
      83             : 
      84             :         IconSprite *_selectedPointer = nullptr;
      85             : 
      86             :         IconSprite *_cursorPointer = nullptr;
      87             :         IconSprite *_selectionPointerStart = nullptr;
      88             :         IconSprite *_selectionPointerEnd = nullptr;
      89             : 
      90             :         float _cursorAnchor = 1.2f;
      91             :         TextCursor _cursor = TextCursor::InvalidCursor;
      92             :         bool _enabled = false;
      93             :         bool _cursorDirty = false;
      94             :         bool _pointerEnabled = false;
      95             :         Function<void(TextCursor)> _cursorCallback;
      96             : };
      97             : 
      98             : }
      99             : 
     100             : #endif /* XENOLITH_RENDERER_MATERIAL2D_COMPONENTS_INPUT_MATERIALINPUTTEXTCONTAINER_H_ */

Generated by: LCOV version 1.14