geode/loader/include/Geode/ui/IconButtonSprite.hpp

47 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
2022-10-13 05:56:23 -04:00
#include <cocos2d.h>
namespace cocos2d::extension {
class CCScale9Sprite;
}
namespace geode {
2022-10-30 14:59:20 -04:00
class GEODE_DLL IconButtonSprite : public cocos2d::CCSprite, public cocos2d::CCLabelProtocol {
protected:
cocos2d::extension::CCScale9Sprite* m_bg = nullptr;
cocos2d::CCLabelBMFont* m_label = nullptr;
cocos2d::CCNode* m_icon = nullptr;
bool init(
2022-10-30 14:59:20 -04:00
char const* bg, bool bgIsFrame, cocos2d::CCNode* icon, char const* text,
char const* font
);
void updateLayout();
IconButtonSprite() = default;
IconButtonSprite(IconButtonSprite&&) = delete;
IconButtonSprite& operator=(IconButtonSprite&&) = delete;
2022-10-30 14:59:20 -04:00
public:
static IconButtonSprite* create(
2022-10-30 14:59:20 -04:00
char const* bg, cocos2d::CCNode* icon, char const* text, char const* font
);
static IconButtonSprite* createWithSpriteFrameName(
2022-10-30 14:59:20 -04:00
char const* bg, cocos2d::CCNode* icon, char const* text, char const* font
);
2022-10-30 14:59:20 -04:00
void setBG(char const* bg, bool isFrame);
void setIcon(cocos2d::CCNode* icon);
cocos2d::CCNode* getIcon() const;
2022-10-30 14:59:20 -04:00
void setString(char const* label) override;
char const* getString() override;
void setColor(cocos2d::ccColor3B const& color) override;
void setOpacity(GLubyte opacity) override;
};
}