UIScrollView.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  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. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __UISCROLLVIEW_H__
  22. #define __UISCROLLVIEW_H__
  23. #include "ui/UILayout.h"
  24. #include "ui/GUIExport.h"
  25. #include <list>
  26. NS_CC_BEGIN
  27. /**
  28. * @addtogroup ui
  29. * @{
  30. */
  31. class EventFocusListener;
  32. namespace ui {
  33. class ScrollViewBar;
  34. /**
  35. *Scrollview scroll event type.
  36. *@deprecated use @see `ScrollView::EventType` instead.
  37. */
  38. typedef enum
  39. {
  40. SCROLLVIEW_EVENT_SCROLL_TO_TOP,
  41. SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM,
  42. SCROLLVIEW_EVENT_SCROLL_TO_LEFT,
  43. SCROLLVIEW_EVENT_SCROLL_TO_RIGHT,
  44. SCROLLVIEW_EVENT_SCROLLING,
  45. SCROLLVIEW_EVENT_BOUNCE_TOP,
  46. SCROLLVIEW_EVENT_BOUNCE_BOTTOM,
  47. SCROLLVIEW_EVENT_BOUNCE_LEFT,
  48. SCROLLVIEW_EVENT_BOUNCE_RIGHT,
  49. SCROLLVIEW_EVENT_SCROLLING_BEGAN,
  50. SCROLLVIEW_EVENT_SCROLLING_ENDED,
  51. SCROLLVIEW_EVENT_AUTOSCROLL_ENDED
  52. }ScrollviewEventType;
  53. /**
  54. * A callback which would be called when a ScrollView is scrolling.
  55. *@deprecated Use @see `ccScrollViewCallback` instead.
  56. */
  57. typedef void (Ref::*SEL_ScrollViewEvent)(Ref*, ScrollviewEventType);
  58. #define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR)
  59. /**
  60. * Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display.
  61. * It holds a inner `Layout` container for storing child items horizontally or vertically.
  62. */
  63. class CC_GUI_DLL ScrollView : public Layout
  64. {
  65. DECLARE_CLASS_GUI_INFO
  66. public:
  67. /**
  68. * ScrollView scroll direction type.
  69. */
  70. enum class Direction
  71. {
  72. NONE,
  73. VERTICAL,
  74. HORIZONTAL,
  75. BOTH
  76. };
  77. /**
  78. * Scrollview scroll event type.
  79. */
  80. enum class EventType
  81. {
  82. SCROLL_TO_TOP,
  83. SCROLL_TO_BOTTOM,
  84. SCROLL_TO_LEFT,
  85. SCROLL_TO_RIGHT,
  86. SCROLLING,
  87. BOUNCE_TOP,
  88. BOUNCE_BOTTOM,
  89. BOUNCE_LEFT,
  90. BOUNCE_RIGHT,
  91. CONTAINER_MOVED,
  92. SCROLLING_BEGAN,
  93. SCROLLING_ENDED,
  94. AUTOSCROLL_ENDED
  95. };
  96. /**
  97. * A callback which would be called when a ScrollView is scrolling.
  98. */
  99. typedef std::function<void(Ref*, EventType)> ccScrollViewCallback;
  100. /**
  101. * Default constructor
  102. * @js ctor
  103. * @lua new
  104. */
  105. ScrollView();
  106. /**
  107. * Default destructor
  108. * @js NA
  109. * @lua NA
  110. */
  111. virtual ~ScrollView();
  112. /**
  113. * Create an empty ScrollView.
  114. * @return A ScrollView instance.
  115. */
  116. static ScrollView* create();
  117. /**
  118. * Changes scroll direction of scrollview.
  119. *
  120. * @see `Direction`
  121. * @param dir Scroll direction enum.
  122. */
  123. virtual void setDirection(Direction dir);
  124. /**
  125. * Query scroll direction of scrollview.
  126. *
  127. * @see `Direction` Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll
  128. *
  129. * @return Scrollview scroll direction.
  130. */
  131. Direction getDirection()const;
  132. /**
  133. * Get inner container of scrollview.
  134. *
  135. * Inner container is a child of scrollview.
  136. *
  137. * @return Inner container pointer.
  138. */
  139. Layout* getInnerContainer()const;
  140. /**
  141. * Immediately stops inner container scroll (auto scrolling is not affected).
  142. */
  143. virtual void stopScroll();
  144. /**
  145. * Immediately stops inner container scroll initiated by any of the "scrollTo*" member functions
  146. */
  147. virtual void stopAutoScroll();
  148. /**
  149. * Immediately stops inner container scroll if any.
  150. */
  151. virtual void stopOverallScroll();
  152. /**
  153. * Scroll inner container to bottom boundary of scrollview.
  154. * @param timeInSec Time in seconds.
  155. * @param attenuated Whether scroll speed attenuate or not.
  156. */
  157. virtual void scrollToBottom(float timeInSec, bool attenuated);
  158. /**
  159. * Scroll inner container to top boundary of scrollview.
  160. * @param timeInSec Time in seconds.
  161. * @param attenuated Whether scroll speed attenuate or not.
  162. */
  163. virtual void scrollToTop(float timeInSec, bool attenuated);
  164. /**
  165. * Scroll inner container to left boundary of scrollview.
  166. * @param timeInSec Time in seconds.
  167. * @param attenuated Whether scroll speed attenuate or not.
  168. */
  169. virtual void scrollToLeft(float timeInSec, bool attenuated);
  170. /**
  171. * Scroll inner container to right boundary of scrollview.
  172. * @param timeInSec Time in seconds.
  173. * @param attenuated Whether scroll speed attenuate or not.
  174. */
  175. virtual void scrollToRight(float timeInSec, bool attenuated);
  176. /**
  177. * Scroll inner container to top and left boundary of scrollview.
  178. * @param timeInSec Time in seconds.
  179. * @param attenuated Whether scroll speed attenuate or not.
  180. */
  181. virtual void scrollToTopLeft(float timeInSec, bool attenuated);
  182. /**
  183. * Scroll inner container to top and right boundary of scrollview.
  184. * @param timeInSec Time in seconds.
  185. * @param attenuated Whether scroll speed attenuate or not.
  186. */
  187. virtual void scrollToTopRight(float timeInSec, bool attenuated);
  188. /**
  189. * Scroll inner container to bottom and left boundary of scrollview.
  190. * @param timeInSec Time in seconds.
  191. * @param attenuated Whether scroll speed attenuate or not.
  192. */
  193. virtual void scrollToBottomLeft(float timeInSec, bool attenuated);
  194. /**
  195. * Scroll inner container to bottom and right boundary of scrollview.
  196. * @param timeInSec Time in seconds
  197. * @param attenuated Whether scroll speed attenuate or not.
  198. */
  199. virtual void scrollToBottomRight(float timeInSec, bool attenuated);
  200. /**
  201. * Scroll inner container to vertical percent position of scrollview.
  202. * @param percent A value between 0 and 100.
  203. * @param timeInSec Time in seconds.
  204. * @param attenuated Whether scroll speed attenuate or not.
  205. */
  206. virtual void scrollToPercentVertical(float percent, float timeInSec, bool attenuated);
  207. /**
  208. * Scroll inner container to horizontal percent position of scrollview.
  209. * @param percent A value between 0 and 100.
  210. * @param timeInSec Time in seconds.
  211. * @param attenuated Whether scroll speed attenuate or not.
  212. */
  213. virtual void scrollToPercentHorizontal(float percent, float timeInSec, bool attenuated);
  214. /**
  215. * Scroll inner container to both direction percent position of scrollview.
  216. * @param percent A value between 0 and 100.
  217. * @param timeInSec Time in seconds.
  218. * @param attenuated Whether scroll speed attenuate or not.
  219. */
  220. virtual void scrollToPercentBothDirection(const Vec2& percent, float timeInSec, bool attenuated);
  221. /**
  222. * @return How far the scroll view is scrolled in the vertical axis
  223. */
  224. float getScrolledPercentVertical() const;
  225. /**
  226. * @return How far the scroll view is scrolled in the horizontal axis
  227. */
  228. float getScrolledPercentHorizontal() const;
  229. /**
  230. * @return How far the scroll view is scrolled in both axes, combined as a Vec2
  231. */
  232. Vec2 getScrolledPercentBothDirection() const;
  233. /**
  234. * Move inner container to bottom boundary of scrollview.
  235. */
  236. virtual void jumpToBottom();
  237. /**
  238. * Move inner container to top boundary of scrollview.
  239. */
  240. virtual void jumpToTop();
  241. /**
  242. * Move inner container to left boundary of scrollview.
  243. */
  244. virtual void jumpToLeft();
  245. /**
  246. * Move inner container to right boundary of scrollview.
  247. */
  248. virtual void jumpToRight();
  249. /**
  250. * Move inner container to top and left boundary of scrollview.
  251. */
  252. virtual void jumpToTopLeft();
  253. /**
  254. * Move inner container to top and right boundary of scrollview.
  255. */
  256. virtual void jumpToTopRight();
  257. /**
  258. * Move inner container to bottom and left boundary of scrollview.
  259. */
  260. virtual void jumpToBottomLeft();
  261. /**
  262. * Move inner container to bottom and right boundary of scrollview.
  263. */
  264. virtual void jumpToBottomRight();
  265. /**
  266. * Move inner container to vertical percent position of scrollview.
  267. * @param percent A value between 0 and 100.
  268. */
  269. virtual void jumpToPercentVertical(float percent);
  270. /**
  271. * Move inner container to horizontal percent position of scrollview.
  272. * @param percent A value between 0 and 100.
  273. */
  274. virtual void jumpToPercentHorizontal(float percent);
  275. /**
  276. * Move inner container to both direction percent position of scrollview.
  277. * @param percent A value between 0 and 100.
  278. */
  279. virtual void jumpToPercentBothDirection(const Vec2& percent);
  280. /**
  281. * Change inner container size of scrollview.
  282. *
  283. * Inner container size must be larger than or equal scrollview's size.
  284. *
  285. * @param size Inner container size.
  286. */
  287. void setInnerContainerSize(const Size &size);
  288. /**
  289. * Get inner container size of scrollview.
  290. *
  291. * Inner container size must be larger than or equal scrollview's size.
  292. *
  293. * @return The inner container size.
  294. */
  295. const Size& getInnerContainerSize() const;
  296. /**
  297. * Set inner container position
  298. *
  299. * @param pos Inner container position.
  300. */
  301. void setInnerContainerPosition(const Vec2 &pos);
  302. /**
  303. * Get inner container position
  304. *
  305. * @return The inner container position.
  306. */
  307. const Vec2& getInnerContainerPosition() const;
  308. /**
  309. * Add callback function which will be called when scrollview event triggered.
  310. * @deprecated Use @see `addEventListener` instead.
  311. * @param target A pointer of `Ref*` type.
  312. * @param selector A member function pointer with type of `SEL_ScrollViewEvent`.
  313. */
  314. CC_DEPRECATED_ATTRIBUTE void addEventListenerScrollView(Ref* target, SEL_ScrollViewEvent selector);
  315. /**
  316. * Add callback function which will be called when scrollview event triggered.
  317. * @param callback A callback function with type of `ccScrollViewCallback`.
  318. */
  319. virtual void addEventListener(const ccScrollViewCallback& callback);
  320. //override functions
  321. virtual void addChild(Node* child)override;
  322. virtual void addChild(Node * child, int localZOrder)override;
  323. virtual void addChild(Node* child, int localZOrder, int tag) override;
  324. virtual void addChild(Node* child, int localZOrder, const std::string &name) override;
  325. virtual void removeAllChildren() override;
  326. virtual void removeAllChildrenWithCleanup(bool cleanup) override;
  327. virtual void removeChild(Node* child, bool cleanup = true) override;
  328. virtual Vector<Node*>& getChildren() override;
  329. virtual const Vector<Node*>& getChildren() const override;
  330. virtual ssize_t getChildrenCount() const override;
  331. virtual Node * getChildByTag(int tag) const override;
  332. virtual Node* getChildByName(const std::string& name)const override;
  333. //touch event callback
  334. virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
  335. virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override;
  336. virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;
  337. virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override;
  338. virtual void update(float dt) override;
  339. /**
  340. * @brief Toggle bounce enabled when scroll to the edge.
  341. *
  342. * @param enabled True if enable bounce, false otherwise.
  343. */
  344. void setBounceEnabled(bool enabled);
  345. /**
  346. * @brief Query bounce state.
  347. *
  348. * @return True if bounce is enabled, false otherwise.
  349. */
  350. bool isBounceEnabled() const;
  351. /**
  352. * @brief Toggle whether enable scroll inertia while scrolling.
  353. *
  354. * @param enabled True if enable inertia, false otherwise.
  355. */
  356. void setInertiaScrollEnabled(bool enabled);
  357. /**
  358. * @brief Query inertia scroll state.
  359. *
  360. * @return True if inertia is enabled, false otherwise.
  361. */
  362. bool isInertiaScrollEnabled() const;
  363. /**
  364. * @brief Toggle scroll bar enabled.
  365. *
  366. * @param enabled True if enable scroll bar, false otherwise.
  367. */
  368. void setScrollBarEnabled(bool enabled);
  369. /**
  370. * @brief Query scroll bar state.
  371. *
  372. * @return True if scroll bar is enabled, false otherwise.
  373. */
  374. bool isScrollBarEnabled() const;
  375. /**
  376. * @brief Set the scroll bar positions from the left-bottom corner (horizontal) and right-top corner (vertical).
  377. *
  378. * @param positionFromCorner The position from the left-bottom corner (horizontal) and right-top corner (vertical).
  379. */
  380. void setScrollBarPositionFromCorner(const Vec2& positionFromCorner);
  381. /**
  382. * @brief Set the vertical scroll bar position from right-top corner.
  383. *
  384. * @param positionFromCorner The position from right-top corner
  385. */
  386. void setScrollBarPositionFromCornerForVertical(const Vec2& positionFromCorner);
  387. /**
  388. * @brief Get the vertical scroll bar's position from right-top corner.
  389. *
  390. * @return positionFromCorner
  391. */
  392. Vec2 getScrollBarPositionFromCornerForVertical() const;
  393. /**
  394. * @brief Set the horizontal scroll bar position from left-bottom corner.
  395. *
  396. * @param positionFromCorner The position from left-bottom corner
  397. */
  398. void setScrollBarPositionFromCornerForHorizontal(const Vec2& positionFromCorner);
  399. /**
  400. * @brief Get the horizontal scroll bar's position from right-top corner.
  401. *
  402. * @return positionFromCorner
  403. */
  404. Vec2 getScrollBarPositionFromCornerForHorizontal() const;
  405. /**
  406. * @brief Set the scroll bar's width
  407. *
  408. * @param width The scroll bar's width
  409. */
  410. void setScrollBarWidth(float width);
  411. /**
  412. * @brief Get the scroll bar's width
  413. *
  414. * @return the scroll bar's width
  415. */
  416. float getScrollBarWidth() const;
  417. /**
  418. * @brief Set the scroll bar's color
  419. *
  420. * @param the scroll bar's color
  421. */
  422. void setScrollBarColor(const Color3B& color);
  423. /**
  424. * @brief Get the scroll bar's color
  425. *
  426. * @return the scroll bar's color
  427. */
  428. const Color3B& getScrollBarColor() const;
  429. /**
  430. * @brief Set the scroll bar's opacity
  431. *
  432. * @param the scroll bar's opacity
  433. */
  434. void setScrollBarOpacity(GLubyte opacity);
  435. /**
  436. * @brief Get the scroll bar's opacity
  437. *
  438. * @return the scroll bar's opacity
  439. */
  440. GLubyte getScrollBarOpacity() const;
  441. /**
  442. * @brief Set scroll bar auto hide state
  443. *
  444. * @param scroll bar auto hide state
  445. */
  446. void setScrollBarAutoHideEnabled(bool autoHideEnabled);
  447. /**
  448. * @brief Query scroll bar auto hide state
  449. *
  450. * @return True if scroll bar auto hide is enabled, false otherwise.
  451. */
  452. bool isScrollBarAutoHideEnabled() const;
  453. /**
  454. * @brief Set scroll bar auto hide time
  455. *
  456. * @param scroll bar auto hide time
  457. */
  458. void setScrollBarAutoHideTime(float autoHideTime);
  459. /**
  460. * @brief Get the scroll bar's auto hide time
  461. *
  462. * @return the scroll bar's auto hide time
  463. */
  464. float getScrollBarAutoHideTime() const;
  465. /**
  466. * @brief Set the touch total time threshold
  467. *
  468. * @param the touch total time threshold
  469. */
  470. void setTouchTotalTimeThreshold(float touchTotalTimeThreshold);
  471. /**
  472. * @brief Get the touch total time threshold
  473. *
  474. * @return the touch total time threshold
  475. */
  476. float getTouchTotalTimeThreshold() const;
  477. /**
  478. * Set layout type for scrollview.
  479. *
  480. * @see `Layout::Type`
  481. * @param type Layout type enum.
  482. */
  483. virtual void setLayoutType(Type type) override;
  484. /**
  485. * Get the layout type for scrollview.
  486. *
  487. * @see `Layout::Type`
  488. * @return LayoutType
  489. */
  490. virtual Type getLayoutType() const override;
  491. /**
  492. * Return the "class name" of widget.
  493. */
  494. virtual std::string getDescription() const override;
  495. /**
  496. * @lua NA
  497. */
  498. virtual void onEnter() override;
  499. /**
  500. * @lua NA
  501. */
  502. virtual void onExit() override;
  503. /**
  504. * When a widget is in a layout, you could call this method to get the next focused widget within a specified direction.
  505. * If the widget is not in a layout, it will return itself
  506. *@param direction the direction to look for the next focused widget in a layout
  507. *@param current the current focused widget
  508. *@return the next focused widget in a layout
  509. */
  510. virtual Widget* findNextFocusedWidget(FocusDirection direction, Widget* current) override;
  511. /**
  512. * @return Whether the user is currently dragging the ScrollView to scroll it
  513. */
  514. bool isScrolling() const { return _scrolling; }
  515. /**
  516. * @return Whether the ScrollView is currently scrolling because of a bounceback or inertia slowdown.
  517. */
  518. bool isAutoScrolling() const { return _autoScrolling; }
  519. CC_CONSTRUCTOR_ACCESS:
  520. virtual bool init() override;
  521. protected:
  522. enum class MoveDirection
  523. {
  524. TOP,
  525. BOTTOM,
  526. LEFT,
  527. RIGHT,
  528. };
  529. virtual void initRenderer() override;
  530. virtual void onSizeChanged() override;
  531. virtual void doLayout() override;
  532. virtual Widget* createCloneInstance() override;
  533. virtual void copySpecialProperties(Widget* model) override;
  534. virtual void copyClonedWidgetChildren(Widget* model) override;
  535. virtual void initScrollBar();
  536. virtual void removeScrollBar();
  537. Vec2 flattenVectorByDirection(const Vec2& vector);
  538. virtual Vec2 getHowMuchOutOfBoundary(const Vec2& addition = Vec2::ZERO);
  539. bool isOutOfBoundary(MoveDirection dir);
  540. bool isOutOfBoundary();
  541. virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack);
  542. bool calculateCurrAndPrevTouchPoints(Touch* touch, Vec3* currPt, Vec3* prevPt);
  543. void gatherTouchMove(const Vec2& delta);
  544. Vec2 calculateTouchMoveVelocity() const;
  545. virtual void startAttenuatingAutoScroll(const Vec2& deltaMove, const Vec2& initialVelocity);
  546. void startAutoScroll(const Vec2& deltaMove, float timeInSec, bool attenuated);
  547. void startAutoScrollToDestination(const Vec2& des, float timeInSec, bool attenuated);
  548. bool isNecessaryAutoScrollBrake();
  549. void processAutoScrolling(float deltaTime);
  550. void startInertiaScroll(const Vec2& touchMoveVelocity);
  551. bool startBounceBackIfNeeded();
  552. void jumpToDestination(const Vec2& des);
  553. virtual void scrollChildren(const Vec2& deltaMove);
  554. virtual void handlePressLogic(Touch *touch);
  555. virtual void handleMoveLogic(Touch *touch);
  556. virtual void handleReleaseLogic(Touch *touch);
  557. virtual void interceptTouchEvent(Widget::TouchEventType event,Widget* sender,Touch *touch) override;
  558. void processScrollEvent(MoveDirection dir, bool bounce);
  559. void processScrollingEvent();
  560. void processScrollingEndedEvent();
  561. void dispatchEvent(ScrollviewEventType scrollEventType, EventType eventType);
  562. void updateScrollBar(const Vec2& outOfBoundary);
  563. protected:
  564. virtual float getAutoScrollStopEpsilon() const;
  565. bool fltEqualZero(const Vec2& point) const;
  566. Layout* _innerContainer;
  567. Direction _direction;
  568. float _topBoundary;
  569. float _bottomBoundary;
  570. float _leftBoundary;
  571. float _rightBoundary;
  572. bool _bePressed;
  573. float _childFocusCancelOffsetInInch;
  574. // Touch move speed
  575. std::list<Vec2> _touchMoveDisplacements;
  576. std::list<float> _touchMoveTimeDeltas;
  577. long long _touchMovePreviousTimestamp;
  578. float _touchTotalTimeThreshold;
  579. bool _scrolling;
  580. bool _autoScrolling;
  581. bool _autoScrollAttenuate;
  582. Vec2 _autoScrollStartPosition;
  583. Vec2 _autoScrollTargetDelta;
  584. float _autoScrollTotalTime;
  585. float _autoScrollAccumulatedTime;
  586. bool _autoScrollCurrentlyOutOfBoundary;
  587. bool _autoScrollBraking;
  588. Vec2 _autoScrollBrakingStartPosition;
  589. bool _inertiaScrollEnabled;
  590. bool _bounceEnabled;
  591. Vec2 _outOfBoundaryAmount;
  592. bool _outOfBoundaryAmountDirty;
  593. bool _scrollBarEnabled;
  594. ScrollViewBar* _verticalScrollBar;
  595. ScrollViewBar* _horizontalScrollBar;
  596. Ref* _scrollViewEventListener;
  597. #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
  598. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  599. #elif _MSC_VER >= 1400 //vs 2005 or higher
  600. #pragma warning (push)
  601. #pragma warning (disable: 4996)
  602. #endif
  603. SEL_ScrollViewEvent _scrollViewEventSelector;
  604. #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
  605. #pragma GCC diagnostic warning "-Wdeprecated-declarations"
  606. #elif _MSC_VER >= 1400 //vs 2005 or higher
  607. #pragma warning (pop)
  608. #endif
  609. ccScrollViewCallback _eventCallback;
  610. };
  611. }
  612. // end of ui group
  613. /// @}
  614. NS_CC_END
  615. #endif /* defined(__CocoGUI__ScrollView__) */