LCOV - code coverage report
Current view: top level - xenolith/renderer/basic2d - XL2dScrollItemHandle.cc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 47 0.0 %
Date: 2024-05-12 00:16:13 Functions: 0 13 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             : #include "XL2dScrollItemHandle.h"
      24             : 
      25             : namespace STAPPLER_VERSIONIZED stappler::xenolith::basic2d {
      26             : 
      27           0 : ScrollItemHandle::~ScrollItemHandle() { }
      28             : 
      29           0 : void ScrollItemHandle::onNodeInserted(ScrollController *c, Item &item, size_t index) {
      30           0 :         if (_owner) {
      31           0 :                 _controller = c;
      32           0 :                 _itemIndex = index;
      33             : 
      34           0 :                 if (_insertCallback) {
      35           0 :                         _insertCallback(item);
      36             :                 }
      37             :         }
      38           0 : }
      39             : 
      40           0 : void ScrollItemHandle::onNodeUpdated(ScrollController *c, Item &item, size_t index) {
      41           0 :         if (_owner) {
      42           0 :                 _controller = c;
      43           0 :                 _itemIndex = index;
      44             : 
      45           0 :                 if (_updateCallback) {
      46           0 :                         _updateCallback(item);
      47             :                 }
      48             :         }
      49           0 : }
      50             : 
      51           0 : void ScrollItemHandle::onNodeRemoved(ScrollController *c, Item &item, size_t index) {
      52           0 :         if (_owner) {
      53           0 :                 _controller = c;
      54           0 :                 _itemIndex = index;
      55             : 
      56           0 :                 if (_removeCallback) {
      57           0 :                         _removeCallback(item);
      58             :                 }
      59             :         }
      60           0 : }
      61             : 
      62           0 : void ScrollItemHandle::setInsertCallback(Callback &&cb) {
      63           0 :         _insertCallback = move(cb);
      64           0 : }
      65             : 
      66           0 : void ScrollItemHandle::setUpdateCallback(Callback &&cb) {
      67           0 :         _updateCallback = move(cb);
      68           0 : }
      69             : 
      70           0 : void ScrollItemHandle::setRemoveCallback(Callback &&cb) {
      71           0 :         _removeCallback = move(cb);
      72           0 : }
      73             : 
      74           0 : void ScrollItemHandle::resize(float newSize, bool forward) {
      75           0 :         if (auto item = _controller->getItem(_itemIndex)) {
      76           0 :                 _controller->resizeItem(item, newSize, forward);
      77             :         }
      78           0 : }
      79             : 
      80           0 : void ScrollItemHandle::forceResize(float newSize, bool forward) {
      81           0 :         if (auto item = _controller->getItem(_itemIndex)) {
      82           0 :                 _controller->resizeItem(item, newSize, forward);
      83           0 :                 _controller->onScrollPosition();
      84             :         }
      85           0 : }
      86             : 
      87           0 : void ScrollItemHandle::setLocked(bool value) {
      88           0 :         _isLocked = value;
      89           0 : }
      90             : 
      91           0 : bool ScrollItemHandle::isLocked() const {
      92           0 :         return _isLocked;
      93             : }
      94             : 
      95           0 : bool ScrollItemHandle::isConnected() const {
      96           0 :         return _controller != nullptr;
      97             : }
      98             : 
      99             : }

Generated by: LCOV version 1.14