2015-09-20 20:29:11 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2015 Neo Kim (neo.kim@neofect.com)
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2015-09-20 20:29:11 +08:00
|
|
|
|
2022-07-09 01:23:11 +08:00
|
|
|
https://axis-project.github.io/
|
2015-09-20 20:29:11 +08:00
|
|
|
|
|
|
|
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__
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "ui/UIPageView.h"
|
2016-04-11 17:28:47 +08:00
|
|
|
#include "2d/CCSprite.h"
|
2015-09-21 15:50:18 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2015-09-20 20:29:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup ui
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
namespace ui
|
|
|
|
{
|
2015-09-20 20:29:11 +08:00
|
|
|
|
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(); }
|
2016-04-11 17:28:47 +08:00
|
|
|
void setIndexNodesColor(const Color3B& indexNodesColor);
|
|
|
|
const Color3B& getIndexNodesColor() const { return _indexNodesColor; }
|
|
|
|
void setIndexNodesScale(float indexNodesScale);
|
|
|
|
float getIndexNodesScale() const { return _indexNodesScale; }
|
2019-06-05 17:58:33 +08:00
|
|
|
void setSelectedIndexOpacity(uint8_t opacity) { _currentIndexNode->setOpacity(opacity); }
|
|
|
|
uint8_t getSelectedIndexOpacity() const { return _currentIndexNode->getOpacity(); }
|
|
|
|
void setIndexNodesOpacity(uint8_t opacity);
|
|
|
|
uint8_t getIndexNodesOpacity() const { return _indexNodesOpacity; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2016-04-11 17:28:47 +08:00
|
|
|
/**
|
|
|
|
* Sets texture for index nodes.
|
|
|
|
*
|
|
|
|
* @param fileName File name of texture.
|
|
|
|
* @param resType @see TextureResType .
|
|
|
|
*/
|
2021-12-28 11:00:34 +08:00
|
|
|
void setIndexNodesTexture(std::string_view texName, Widget::TextureResType texType = Widget::TextureResType::LOCAL);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
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;
|
2016-04-11 17:28:47 +08:00
|
|
|
Vector<Sprite*> _indexNodes;
|
|
|
|
Sprite* _currentIndexNode;
|
2017-07-17 15:55:43 +08:00
|
|
|
Sprite* _currentOverlappingIndexNode;
|
2015-09-21 15:50:18 +08:00
|
|
|
float _spaceBetweenIndexNodes;
|
2016-04-11 17:28:47 +08:00
|
|
|
float _indexNodesScale;
|
|
|
|
Color3B _indexNodesColor;
|
2019-06-05 17:58:33 +08:00
|
|
|
uint8_t _indexNodesOpacity;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2016-04-11 17:28:47 +08:00
|
|
|
bool _useDefaultTexture;
|
|
|
|
std::string _indexNodesTextureFile;
|
|
|
|
Widget::TextureResType _indexNodesTexType;
|
2015-09-20 20:29:11 +08:00
|
|
|
};
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
} // namespace ui
|
2015-09-20 20:29:11 +08:00
|
|
|
// end of ui group
|
|
|
|
/// @}
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2015-09-20 20:29:11 +08:00
|
|
|
|
|
|
|
#endif /* defined(__UIPAGEVIEWINDICATOR_H__) */
|