2015-09-20 20:29:11 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2015 Neo Kim (neo.kim@neofect.com)
|
|
|
|
|
|
|
|
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 __UIPAGEVIEWINDICATOR_H__
|
|
|
|
#define __UIPAGEVIEWINDICATOR_H__
|
|
|
|
|
2015-09-21 21:11:42 +08:00
|
|
|
#include "UIPageView.h"
|
2015-09-21 15:50:18 +08:00
|
|
|
|
2015-09-20 20:29:11 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
/**
|
|
|
|
* @addtogroup ui
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2015-09-21 15:50:18 +08:00
|
|
|
class PageViewIndicator : public ProtectedNode
|
2015-09-20 20:29:11 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2015-09-21 15:50:18 +08:00
|
|
|
/**
|
|
|
|
* Create a page view indicator with its parent page view.
|
|
|
|
* @return A page view indicator instance.
|
|
|
|
*/
|
|
|
|
static PageViewIndicator* create();
|
|
|
|
|
|
|
|
PageViewIndicator();
|
|
|
|
virtual ~PageViewIndicator();
|
|
|
|
|
2015-09-21 21:11:42 +08:00
|
|
|
void setDirection(PageView::Direction direction);
|
2015-11-15 21:48:42 +08:00
|
|
|
void reset(ssize_t numberOfTotalPages);
|
2015-09-21 18:42:48 +08:00
|
|
|
void indicate(ssize_t index);
|
2015-09-21 15:50:18 +08:00
|
|
|
void clear();
|
2015-09-22 10:06:18 +08:00
|
|
|
void setSpaceBetweenIndexNodes(float spaceBetweenIndexNodes);
|
|
|
|
float getSpaceBetweenIndexNodes() const { return _spaceBetweenIndexNodes; }
|
|
|
|
void setSelectedIndexColor(const Color3B& color) { _currentIndexNode->setColor(color); }
|
|
|
|
const Color3B& getSelectedIndexColor() const { return _currentIndexNode->getColor(); }
|
2015-09-21 15:50:18 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool init() override;
|
2015-09-21 18:42:48 +08:00
|
|
|
void increaseNumberOfPages();
|
|
|
|
void decreaseNumberOfPages();
|
2015-09-21 15:50:18 +08:00
|
|
|
void rearrange();
|
|
|
|
|
2015-09-21 21:11:42 +08:00
|
|
|
PageView::Direction _direction;
|
2015-09-21 15:50:18 +08:00
|
|
|
Vector<Node*> _indexNodes;
|
|
|
|
Node* _currentIndexNode;
|
|
|
|
float _spaceBetweenIndexNodes;
|
2015-09-20 20:29:11 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
// end of ui group
|
|
|
|
/// @}
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /* defined(__UIPAGEVIEWINDICATOR_H__) */
|