geode/loader/include/Geode/ui/Border.hpp
SMJS e9304c60ac
Added dynamic borders (#855)
* Added dynamic borders

* Removed an ambiguous size
2024-06-06 14:17:14 +02:00

54 lines
No EOL
1.9 KiB
C++

#pragma once
#include <Geode/DefaultInclude.hpp>
#include <cocos2d.h>
namespace geode {
class GEODE_DLL Border : public cocos2d::CCLayerColor {
public:
struct Padding {
float top;
float right;
float bottom;
float left;
};
static Border* create(cocos2d::CCNode* node, const cocos2d::ccColor4B& backgroundColor);
static Border* create(cocos2d::CCNode* node, const cocos2d::ccColor4B& backgroundColor, const cocos2d::CCSize& size);
static Border* create(cocos2d::CCNode* node, const cocos2d::ccColor4B& backgroundColor, const cocos2d::CCSize& size, const cocos2d::CCPoint& padding);
void setPadding(const cocos2d::CCPoint& padding);
void setPadding(float x, float y);
void setPadding(float padding);
Padding getPadding();
void setPaddingX(float x);
float getPaddingX();
void setPaddingY(float y);
float getPaddingY();
void setPaddingTop(float top);
float getPaddingTop();
void setPaddingRight(float right);
float getPaddingRight();
void setPaddingBottom(float bottom);
float getPaddingBottom();
void setPaddingLeft(float left);
float getPaddingLeft();
void setBackgroundColor(const cocos2d::ccColor4B& color);
cocos2d::ccColor4B getBackgroundColor();
void setNode(CCNode* node);
CCNode* getNode();
void setSize(const cocos2d::CCSize& size);
void setZOrder(int zOrder) override;
void resetZOrder();
protected:
cocos2d::CCSize m_size;
Padding m_padding;
bool m_customZOrder;
Border(const cocos2d::CCPoint& padding = { 0, 0 });
bool init(const cocos2d::ccColor4B& backgroundColor, const cocos2d::CCSize& size);
bool init(CCNode* node, const cocos2d::ccColor4B& backgroundColor, const cocos2d::CCSize& size);
private:
void updatePadding();
};
}