2020-08-04 12:31:33 +08:00
|
|
|
#ifndef __GLOADER_H__
|
|
|
|
#define __GLOADER_H__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "FairyGUIMacros.h"
|
|
|
|
#include "GObject.h"
|
|
|
|
|
|
|
|
NS_FGUI_BEGIN
|
|
|
|
|
|
|
|
class GComponent;
|
|
|
|
class ActionMovieClip;
|
|
|
|
class FUISprite;
|
|
|
|
|
|
|
|
class GLoader : public GObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLoader();
|
|
|
|
virtual ~GLoader();
|
|
|
|
|
|
|
|
CREATE_FUNC(GLoader);
|
|
|
|
|
|
|
|
const std::string& getURL() const { return _url; }
|
|
|
|
void setURL(const std::string& value);
|
|
|
|
|
|
|
|
virtual const std::string& getIcon() const override { return _url; }
|
|
|
|
virtual void setIcon(const std::string& value) override { setURL(value); }
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TextHAlignment getAlign() const { return _align; }
|
|
|
|
void setAlign(axis::TextHAlignment value);
|
2020-08-04 12:31:33 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TextVAlignment getVerticalAlign() const { return _verticalAlign; }
|
|
|
|
void setVerticalAlign(axis::TextVAlignment value);
|
2020-08-04 12:31:33 +08:00
|
|
|
|
|
|
|
bool getAutoSize() const { return _autoSize; }
|
|
|
|
void setAutoSize(bool value);
|
|
|
|
|
|
|
|
LoaderFillType getFill() const { return _fill; }
|
|
|
|
void setFill(LoaderFillType value);
|
|
|
|
|
|
|
|
bool isShrinkOnly() const { return _shrinkOnly; }
|
|
|
|
void setShrinkOnly(bool value);
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
const axis::Size& getContentSize();
|
2020-08-04 12:31:33 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color3B getColor() const;
|
|
|
|
void setColor(const axis::Color3B& value);
|
2020-08-04 12:31:33 +08:00
|
|
|
|
|
|
|
bool isPlaying() const { return _playing; }
|
|
|
|
void setPlaying(bool value);
|
|
|
|
|
|
|
|
int getFrame() const;
|
|
|
|
void setFrame(int value);
|
|
|
|
|
|
|
|
FillMethod getFillMethod() const;
|
|
|
|
void setFillMethod(FillMethod value);
|
|
|
|
|
|
|
|
FillOrigin getFillOrigin() const;
|
|
|
|
void setFillOrigin(FillOrigin value);
|
|
|
|
|
|
|
|
bool isFillClockwise() const;
|
|
|
|
void setFillClockwise(bool value);
|
|
|
|
|
|
|
|
float getFillAmount() const;
|
|
|
|
void setFillAmount(float value);
|
|
|
|
|
|
|
|
GComponent* getComponent() const { return _content2; }
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual axis::Value getProp(ObjectPropID propId) override;
|
|
|
|
virtual void setProp(ObjectPropID propId, const axis::Value& value) override;
|
2020-08-04 12:31:33 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void handleInit() override;
|
|
|
|
virtual void handleSizeChanged() override;
|
|
|
|
virtual void handleGrayedChanged() override;
|
|
|
|
virtual void setup_beforeAdd(ByteBuffer* buffer, int beginPos) override;
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual GObject* hitTest(const axis::Vec2 & worldPoint, const axis::Camera * camera) override;
|
2020-08-04 12:31:33 +08:00
|
|
|
|
|
|
|
virtual void loadExternal();
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void freeExternal(axis::SpriteFrame* spriteFrame);
|
|
|
|
void onExternalLoadSuccess(axis::SpriteFrame* spriteFrame);
|
2020-08-04 12:31:33 +08:00
|
|
|
void onExternalLoadFailed();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void loadContent();
|
|
|
|
void loadFromPackage();
|
|
|
|
void clearContent();
|
|
|
|
void updateLayout();
|
|
|
|
void setErrorState();
|
|
|
|
void clearErrorState();
|
|
|
|
|
|
|
|
std::string _url;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TextHAlignment _align;
|
|
|
|
axis::TextVAlignment _verticalAlign;
|
2020-08-04 12:31:33 +08:00
|
|
|
bool _autoSize;
|
|
|
|
LoaderFillType _fill;
|
|
|
|
bool _shrinkOnly;
|
|
|
|
bool _updatingLayout;
|
|
|
|
PackageItem* _contentItem;
|
|
|
|
int _contentStatus;
|
|
|
|
bool _playing;
|
|
|
|
int _frame;
|
|
|
|
|
|
|
|
FUISprite* _content;
|
|
|
|
GComponent* _content2;
|
|
|
|
ActionMovieClip* _playAction;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_FGUI_END
|
|
|
|
|
|
|
|
#endif
|