123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- #ifndef __UILOADINGBAR_H__
- #define __UILOADINGBAR_H__
- #include "ui/UIWidget.h"
- #include "ui/GUIExport.h"
- NS_CC_BEGIN
- struct CC_DLL ResourceData;
- namespace ui {
- class Scale9Sprite;
- class CC_GUI_DLL LoadingBar : public Widget
- {
-
- DECLARE_CLASS_GUI_INFO
-
- public:
-
- enum class Direction
- {
- LEFT,
- RIGHT
- };
-
- LoadingBar();
-
-
- virtual ~LoadingBar();
-
-
- static LoadingBar* create();
-
-
-
- static LoadingBar* create(const std::string& textureName, float percentage = 0);
-
-
-
- static LoadingBar* create(const std::string& textureName,
- TextureResType texType,
- float percentage = 0);
-
-
- void setDirection(Direction direction);
-
-
- Direction getDirection()const;
-
-
- void loadTexture(const std::string& texture,TextureResType texType = TextureResType::LOCAL);
-
-
- void setPercent(float percent);
-
-
- float getPercent() const;
-
-
- void setScale9Enabled(bool enabled);
-
-
-
- bool isScale9Enabled()const;
-
-
- void setCapInsets(const Rect &capInsets);
-
-
-
- const Rect& getCapInsets()const;
-
-
- virtual void ignoreContentAdaptWithSize(bool ignore) override;
- virtual Size getVirtualRendererSize() const override;
- virtual Node* getVirtualRenderer() override;
- virtual std::string getDescription() const override;
- ResourceData getRenderFile();
- protected:
- virtual void initRenderer() override;
- virtual void onSizeChanged() override;
-
- void setScale9Scale();
- void updateProgressBar();
- void barRendererScaleChangedWithSize();
- void setupTexture();
- void handleSpriteFlipX();
- void loadTexture(SpriteFrame* spriteframe);
-
- virtual void adaptRenderers() override;
-
- virtual Widget* createCloneInstance() override;
- virtual void copySpecialProperties(Widget* model) override;
- protected:
- Direction _direction;
- float _percent;
- float _totalLength;
- Scale9Sprite* _barRenderer;
- TextureResType _renderBarTexType;
- Size _barRendererTextureSize;
- Rect _originalRect;
- bool _scale9Enabled;
- bool _prevIgnoreSize;
- Rect _capInsets;
- bool _barRendererAdaptDirty;
- std::string _textureFile;
- };
- }
- NS_CC_END
- #endif
|