2014-03-11 17:13:54 +08:00
|
|
|
/****************************************************************************
|
2016-01-25 14:48:17 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __UIPAGEVIEW_H__
|
|
|
|
#define __UIPAGEVIEW_H__
|
|
|
|
|
2015-09-16 17:13:58 +08:00
|
|
|
#include "ui/UIListView.h"
|
2014-07-21 17:45:56 +08:00
|
|
|
#include "ui/GUIExport.h"
|
2014-03-11 17:13:54 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup ui
|
|
|
|
* @{
|
|
|
|
*/
|
2015-03-26 15:47:14 +08:00
|
|
|
NS_CC_BEGIN
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2015-09-21 15:50:18 +08:00
|
|
|
class PageViewIndicator;
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
*PageView page turn event type.
|
2015-03-26 15:47:14 +08:00
|
|
|
*@deprecated Use `PageView::EventType` instead.
|
2015-03-25 18:17:58 +08:00
|
|
|
*/
|
2014-07-10 00:45:27 +08:00
|
|
|
typedef enum
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
PAGEVIEW_EVENT_TURNING,
|
|
|
|
}PageViewEventType;
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
*A callback which would be called when a PageView turning event is happening.
|
2015-03-26 15:47:14 +08:00
|
|
|
*@deprecated Use `PageView::ccPageViewCallback` instead.
|
2015-03-25 18:17:58 +08:00
|
|
|
*/
|
2014-07-10 00:45:27 +08:00
|
|
|
typedef void (Ref::*SEL_PageViewEvent)(Ref*, PageViewEventType);
|
2014-03-11 17:13:54 +08:00
|
|
|
#define pagevieweventselector(_SELECTOR)(SEL_PageViewEvent)(&_SELECTOR)
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
2015-08-01 18:18:46 +08:00
|
|
|
*@brief Layout manager that allows the user to flip left & right and up & down through pages of data.
|
2015-03-25 18:17:58 +08:00
|
|
|
*
|
|
|
|
*/
|
2015-09-16 17:13:58 +08:00
|
|
|
class CC_GUI_DLL PageView : public ListView
|
2014-03-11 17:13:54 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
DECLARE_CLASS_GUI_INFO
|
|
|
|
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
2015-12-21 07:21:45 +08:00
|
|
|
* Page turn event type.
|
2015-03-25 18:17:58 +08:00
|
|
|
*/
|
2014-05-12 10:31:52 +08:00
|
|
|
enum class EventType
|
|
|
|
{
|
|
|
|
TURNING
|
|
|
|
};
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* Touch direction type.
|
|
|
|
*/
|
2014-05-12 10:31:52 +08:00
|
|
|
enum class TouchDirection
|
|
|
|
{
|
|
|
|
LEFT,
|
2015-08-01 18:18:46 +08:00
|
|
|
RIGHT,
|
|
|
|
UP,
|
|
|
|
DOWN
|
|
|
|
};
|
2015-09-16 17:13:58 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
2015-09-16 17:13:58 +08:00
|
|
|
* PageView page turn event callback.
|
2015-03-25 18:17:58 +08:00
|
|
|
*/
|
2015-09-16 17:59:56 +08:00
|
|
|
typedef std::function<void(Ref*, EventType)> ccPageViewCallback;
|
2015-03-25 18:17:58 +08:00
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
/**
|
|
|
|
* Default constructor
|
2015-03-28 16:02:47 +08:00
|
|
|
* @js ctor
|
2015-03-30 15:47:47 +08:00
|
|
|
* @lua new
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
|
|
|
PageView();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default destructor
|
2015-03-28 16:02:47 +08:00
|
|
|
* @js NA
|
2015-03-30 15:47:47 +08:00
|
|
|
* @lua NA
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
|
|
|
virtual ~PageView();
|
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Create an empty PageView.
|
|
|
|
*@return A PageView instance.
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
|
|
|
static PageView* create();
|
2015-09-21 21:12:25 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes direction
|
|
|
|
* Direction Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll.
|
|
|
|
* @param direction Set the page view's scroll direction.
|
|
|
|
*/
|
|
|
|
virtual void setDirection(Direction direction) override;
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Add a widget as a page of PageView in a given index.
|
2014-03-11 17:13:54 +08:00
|
|
|
*
|
2015-03-25 18:17:58 +08:00
|
|
|
* @param widget Widget to be added to pageview.
|
|
|
|
* @param pageIdx A given index.
|
|
|
|
* @param forceCreate If `forceCreate` is true and `widget` isn't exists, pageview would create a default page and add it.
|
2015-11-10 20:03:51 +08:00
|
|
|
*
|
2015-11-10 20:30:43 +08:00
|
|
|
* Since v3.9, this is deprecated. Use `insertPage(Widget* page, int idx)` instead.
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
2015-09-16 17:59:56 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void addWidgetToPage(Widget* widget, ssize_t pageIdx, bool forceCreate);
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Insert a page into the end of PageView.
|
2014-03-11 17:13:54 +08:00
|
|
|
*
|
2015-03-25 18:17:58 +08:00
|
|
|
* @param page Page to be inserted.
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
2015-11-10 20:30:43 +08:00
|
|
|
void addPage(Widget* page);
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Insert a page into PageView at a given index.
|
2014-03-11 17:13:54 +08:00
|
|
|
*
|
2015-03-25 18:17:58 +08:00
|
|
|
* @param page Page to be inserted.
|
|
|
|
* @param idx A given index.
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
2015-11-10 20:30:43 +08:00
|
|
|
void insertPage(Widget* page, int idx);
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Remove a page of PageView.
|
2014-03-11 17:13:54 +08:00
|
|
|
*
|
2015-03-25 18:17:58 +08:00
|
|
|
* @param page Page to be removed.
|
2015-11-10 20:03:51 +08:00
|
|
|
*/
|
2015-11-10 20:30:43 +08:00
|
|
|
void removePage(Widget* page);
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Remove a page at a given index of PageView.
|
2014-03-11 17:13:54 +08:00
|
|
|
*
|
2015-03-25 18:17:58 +08:00
|
|
|
* @param index A given index.
|
2015-11-10 20:03:51 +08:00
|
|
|
*/
|
2015-11-10 20:30:43 +08:00
|
|
|
void removePageAtIndex(ssize_t index);
|
2015-08-01 18:18:46 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* @brief Remove all pages of the PageView.
|
2015-11-10 20:03:51 +08:00
|
|
|
*/
|
2015-11-10 20:30:43 +08:00
|
|
|
void removeAllPages();
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Scroll to a page with a given index.
|
2014-03-11 17:13:54 +08:00
|
|
|
*
|
2015-07-15 17:02:02 +08:00
|
|
|
* @param idx A given index in the PageView. Index start from 0 to pageCount -1.
|
2015-11-10 20:03:51 +08:00
|
|
|
*/
|
2015-11-10 20:30:43 +08:00
|
|
|
void scrollToPage(ssize_t idx);
|
2015-07-15 17:02:02 +08:00
|
|
|
|
2015-10-28 15:54:39 +08:00
|
|
|
/**
|
|
|
|
* Scroll to a page with a given index.
|
|
|
|
*
|
2016-07-03 23:42:10 +08:00
|
|
|
* @param itemIndex A given index in the PageView. Index start from 0 to pageCount -1.
|
2015-10-28 15:54:39 +08:00
|
|
|
*/
|
|
|
|
void scrollToItem(ssize_t itemIndex);
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* Gets current displayed page index.
|
2014-03-11 17:13:54 +08:00
|
|
|
* @return current page index.
|
2015-09-21 20:46:10 +08:00
|
|
|
*
|
|
|
|
* Since v3.9, this is deprecated. Use `getCurrentPageIndex()` instead.
|
2014-03-11 17:13:54 +08:00
|
|
|
*/
|
2015-09-21 20:46:10 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE ssize_t getCurPageIndex() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets current displayed page index.
|
|
|
|
* @return current page index.
|
|
|
|
*/
|
|
|
|
ssize_t getCurrentPageIndex() const { return _currentPageIndex; }
|
2015-07-15 17:02:02 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Jump to a page with a given index without scrolling.
|
|
|
|
* This is the different between scrollToPage.
|
|
|
|
*
|
|
|
|
* @param index A given index in PageView. Index start from 0 to pageCount -1.
|
2015-11-10 20:03:51 +08:00
|
|
|
*
|
|
|
|
* Since v3.9, this is deprecated. Use `setCurrentPageIndex()` instead.
|
|
|
|
*/
|
2015-09-21 20:46:10 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void setCurPageIndex(ssize_t index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Jump to a page with a given index without scrolling.
|
|
|
|
* This is the different between scrollToPage.
|
|
|
|
*
|
|
|
|
* @param index A given index in PageView. Index start from 0 to pageCount -1.
|
|
|
|
*/
|
|
|
|
void setCurrentPageIndex(ssize_t index);
|
2015-09-16 17:59:56 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* @brief Get all the pages in the PageView.
|
2015-10-23 15:37:33 +08:00
|
|
|
* @return A vector of Layout pointers.
|
2015-11-10 20:03:51 +08:00
|
|
|
*
|
|
|
|
* Since v3.9, this is obsolete. Use `Vector<Widget*>& ListView::getItems()` instead.
|
|
|
|
*/
|
|
|
|
CC_DEPRECATED_ATTRIBUTE Vector<Layout*>& getPages();
|
2015-09-16 17:59:56 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* @brief Get a page at a given index
|
|
|
|
*
|
|
|
|
* @param index A given index.
|
|
|
|
* @return A layout pointer in PageView container.
|
2015-11-10 20:03:51 +08:00
|
|
|
*
|
|
|
|
* Since v3.9, this is obsolete. Use `Widget* ListView::getItem(index)` instead.
|
|
|
|
*/
|
|
|
|
CC_DEPRECATED_ATTRIBUTE Layout* getPage(ssize_t index);
|
2014-03-11 17:13:54 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* Add a page turn callback to PageView, then when one page is turning, the callback will be called.
|
2015-03-26 15:47:14 +08:00
|
|
|
*@deprecated Use `PageView::addEventListener` instead.
|
2015-03-25 18:17:58 +08:00
|
|
|
*@param target A pointer of `Ref*` type.
|
|
|
|
*@param selector A member function pointer with signature of `SEL_PageViewEvent`.
|
|
|
|
*/
|
2014-05-12 10:31:52 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void addEventListenerPageView(Ref *target, SEL_PageViewEvent selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Add a page turn callback to PageView, then when one page is turning, the callback will be called.
|
|
|
|
*
|
|
|
|
* @param callback A page turning callback.
|
|
|
|
*/
|
2016-01-25 14:48:17 +08:00
|
|
|
void addEventListener(const ccPageViewCallback& callback);
|
2016-01-25 11:53:40 +08:00
|
|
|
using ScrollView::addEventListener;
|
2015-03-25 18:17:58 +08:00
|
|
|
//override methods
|
2014-03-11 17:13:54 +08:00
|
|
|
virtual std::string getDescription() const override;
|
2015-03-25 18:17:58 +08:00
|
|
|
|
2015-10-28 15:06:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Toggle page indicator enabled.
|
|
|
|
*
|
|
|
|
* @param enabled True if enable page indicator, false otherwise.
|
|
|
|
*/
|
2015-09-21 21:12:25 +08:00
|
|
|
void setIndicatorEnabled(bool enabled);
|
|
|
|
|
2015-10-28 15:06:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Query page indicator state.
|
|
|
|
*
|
|
|
|
* @return True if page indicator is enabled, false otherwise.
|
|
|
|
*/
|
2015-10-28 15:34:30 +08:00
|
|
|
bool getIndicatorEnabled() const { return _indicator != nullptr; }
|
2015-09-21 21:03:05 +08:00
|
|
|
|
2015-10-28 15:06:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Set the page indicator's position using anchor point.
|
|
|
|
*
|
|
|
|
* @param positionAsAnchorPoint The position as anchor point.
|
|
|
|
*/
|
2015-09-21 21:03:05 +08:00
|
|
|
void setIndicatorPositionAsAnchorPoint(const Vec2& positionAsAnchorPoint);
|
2015-10-28 15:06:53 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the page indicator's position as anchor point.
|
|
|
|
*
|
|
|
|
* @return positionAsAnchorPoint
|
|
|
|
*/
|
2015-09-21 21:03:05 +08:00
|
|
|
const Vec2& getIndicatorPositionAsAnchorPoint() const;
|
|
|
|
|
2015-10-28 15:06:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Set the page indicator's position in page view.
|
|
|
|
*
|
|
|
|
* @param position The position in page view
|
|
|
|
*/
|
2015-09-21 21:03:05 +08:00
|
|
|
void setIndicatorPosition(const Vec2& position);
|
2015-10-28 15:06:53 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the page indicator's position.
|
|
|
|
*
|
|
|
|
* @return positionAsAnchorPoint
|
|
|
|
*/
|
2015-09-21 21:03:05 +08:00
|
|
|
const Vec2& getIndicatorPosition() const;
|
|
|
|
|
2015-10-28 15:06:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Set space between page indicator's index nodes.
|
|
|
|
*
|
|
|
|
* @param spaceBetweenIndexNodes Space between nodes in pixel.
|
|
|
|
*/
|
2015-09-22 10:06:18 +08:00
|
|
|
void setIndicatorSpaceBetweenIndexNodes(float spaceBetweenIndexNodes);
|
2015-10-28 15:06:53 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the space between page indicator's index nodes.
|
|
|
|
*
|
|
|
|
* @return spaceBetweenIndexNodes
|
|
|
|
*/
|
2015-09-22 10:06:18 +08:00
|
|
|
float getIndicatorSpaceBetweenIndexNodes() const;
|
2015-09-21 21:03:05 +08:00
|
|
|
|
2015-10-28 15:06:53 +08:00
|
|
|
/**
|
|
|
|
* @brief Set color of page indicator's selected index.
|
|
|
|
*
|
2016-04-11 17:28:47 +08:00
|
|
|
* @param color Space between nodes in pixel.
|
2015-10-28 15:06:53 +08:00
|
|
|
*/
|
2015-09-22 10:06:18 +08:00
|
|
|
void setIndicatorSelectedIndexColor(const Color3B& color);
|
2015-10-28 15:06:53 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the color of page indicator's selected index.
|
|
|
|
*
|
|
|
|
* @return color
|
|
|
|
*/
|
2015-09-22 10:06:18 +08:00
|
|
|
const Color3B& getIndicatorSelectedIndexColor() const;
|
|
|
|
|
2016-04-11 17:28:47 +08:00
|
|
|
/**
|
|
|
|
* @brief Set color of page indicator's index nodes.
|
|
|
|
*
|
|
|
|
* @param color Space between nodes in pixel.
|
|
|
|
*/
|
|
|
|
void setIndicatorIndexNodesColor(const Color3B& color);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the color of page indicator's index nodes.
|
|
|
|
*
|
|
|
|
* @return color
|
|
|
|
*/
|
|
|
|
const Color3B& getIndicatorIndexNodesColor() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set scale of page indicator's index nodes.
|
|
|
|
*
|
|
|
|
* @param indexNodesScale Scale of index nodes.
|
|
|
|
*/
|
|
|
|
void setIndicatorIndexNodesScale(float indexNodesScale);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets texture for index nodes.
|
|
|
|
*
|
|
|
|
* @param fileName File name of texture.
|
|
|
|
* @param resType @see TextureResType .
|
|
|
|
*/
|
|
|
|
void setIndicatorIndexNodesTexture(const std::string& texName,Widget::TextureResType texType = Widget::TextureResType::LOCAL);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get scale of page indicator's index nodes.
|
|
|
|
*
|
|
|
|
* @return indexNodesScale
|
|
|
|
*/
|
|
|
|
float getIndicatorIndexNodesScale() const;
|
|
|
|
|
2015-09-22 10:06:18 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief If you don't specify the value, the pageView will turn page when scrolling at the half width of a page.
|
|
|
|
*@param threshold A threshold in float.
|
2015-11-10 20:11:11 +08:00
|
|
|
*@deprecated Since v3.9, this method has no effect.
|
2014-08-14 11:14:24 +08:00
|
|
|
*/
|
2015-11-10 20:11:11 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void setCustomScrollThreshold(float threshold);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
2014-08-14 11:14:24 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief Query the custom scroll threshold of the PageView.
|
|
|
|
*@return Custom scroll threshold in float.
|
2015-11-10 20:11:11 +08:00
|
|
|
*@deprecated Since v3.9, this method always returns 0.
|
2014-08-14 11:14:24 +08:00
|
|
|
*/
|
2015-11-10 20:11:11 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE float getCustomScrollThreshold()const;
|
2015-03-25 18:17:58 +08:00
|
|
|
|
2014-08-14 11:14:24 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief Set using user defined scroll page threshold or not.
|
2014-08-14 11:14:24 +08:00
|
|
|
* If you set it to false, then the default scroll threshold is pageView.width / 2
|
2015-03-25 18:17:58 +08:00
|
|
|
*@param flag True if using custom scroll threshold, false otherwise.
|
2015-11-10 20:11:11 +08:00
|
|
|
*@deprecated Since v3.9, this method has no effect.
|
2014-08-14 11:14:24 +08:00
|
|
|
*/
|
2015-11-10 20:11:11 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void setUsingCustomScrollThreshold(bool flag);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
2014-08-14 11:14:24 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
*@brief Query whether use user defined scroll page threshold or not.
|
|
|
|
*@return True if using custom scroll threshold, false otherwise.
|
2015-11-10 20:11:11 +08:00
|
|
|
*@deprecated Since v3.9, this method always returns false.
|
2014-08-14 11:14:24 +08:00
|
|
|
*/
|
2015-11-10 20:11:11 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool isUsingCustomScrollThreshold()const;
|
2014-03-11 17:13:54 +08:00
|
|
|
|
2016-04-08 03:08:02 +08:00
|
|
|
void setAutoScrollStopEpsilon(float epsilon);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
|
|
virtual bool init() override;
|
|
|
|
|
2015-11-15 21:48:42 +08:00
|
|
|
//override methods
|
|
|
|
virtual void doLayout() override;
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
protected:
|
|
|
|
void pageTurningEvent();
|
2016-03-09 19:08:18 +08:00
|
|
|
virtual float getAutoScrollStopEpsilon() const override;
|
2014-05-21 15:44:08 +08:00
|
|
|
|
2015-12-14 15:29:02 +08:00
|
|
|
virtual void remedyLayoutParameter(Widget* item)override;
|
2015-09-21 20:46:10 +08:00
|
|
|
virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) override;
|
2015-09-21 18:40:30 +08:00
|
|
|
virtual void onItemListChanged() override;
|
2015-09-21 15:50:18 +08:00
|
|
|
virtual void onSizeChanged() override;
|
2015-09-16 17:59:56 +08:00
|
|
|
virtual void handleReleaseLogic(Touch *touch) override;
|
2016-08-04 09:51:54 +08:00
|
|
|
virtual void handlePressLogic(Touch *touch) override;
|
2015-09-16 17:59:56 +08:00
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
virtual Widget* createCloneInstance() override;
|
|
|
|
virtual void copySpecialProperties(Widget* model) override;
|
2014-05-21 15:44:08 +08:00
|
|
|
|
2015-09-21 21:03:05 +08:00
|
|
|
void refreshIndicatorPosition();
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
protected:
|
2015-09-21 15:50:18 +08:00
|
|
|
PageViewIndicator* _indicator;
|
2015-09-21 21:03:05 +08:00
|
|
|
Vec2 _indicatorPositionAsAnchorPoint;
|
2015-09-21 15:50:18 +08:00
|
|
|
|
2015-09-21 20:46:10 +08:00
|
|
|
ssize_t _currentPageIndex;
|
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
float _childFocusCancelOffset;
|
2014-05-12 10:31:52 +08:00
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
Ref* _pageViewEventListener;
|
2014-05-12 10:31:52 +08:00
|
|
|
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
|
|
|
#pragma warning (push)
|
|
|
|
#pragma warning (disable: 4996)
|
|
|
|
#endif
|
2014-03-11 17:13:54 +08:00
|
|
|
SEL_PageViewEvent _pageViewEventSelector;
|
2014-05-12 10:31:52 +08:00
|
|
|
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
|
|
|
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
|
|
|
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
|
|
|
#pragma warning (pop)
|
|
|
|
#endif
|
|
|
|
ccPageViewCallback _eventCallback;
|
2016-04-08 03:08:02 +08:00
|
|
|
float _autoScrollStopEpsilon;
|
2016-08-04 09:51:54 +08:00
|
|
|
ssize_t _previousPageIndex;
|
2016-08-05 09:43:15 +08:00
|
|
|
bool _isTouchBegin;
|
2014-03-11 17:13:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2015-03-26 15:47:14 +08:00
|
|
|
NS_CC_END
|
2015-03-25 18:17:58 +08:00
|
|
|
// end of ui group
|
|
|
|
/// @}
|
2014-03-11 17:13:54 +08:00
|
|
|
|
|
|
|
#endif /* defined(__PageView__) */
|