mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
fix max size of editor button sprites
This commit is contained in:
parent
eb0e4b6b1e
commit
0a37b01845
3 changed files with 12 additions and 5 deletions
|
@ -158,6 +158,7 @@ namespace geode {
|
|||
);
|
||||
|
||||
cocos2d::CCPoint getTopOffset() const;
|
||||
virtual cocos2d::CCSize getMaxTopSize() const;
|
||||
|
||||
virtual ~BasedButtonSprite();
|
||||
|
||||
|
@ -316,6 +317,7 @@ namespace geode {
|
|||
EditorBaseColor color = EditorBaseColor::Green,
|
||||
EditorBaseSize size = EditorBaseSize::Normal
|
||||
);
|
||||
cocos2d::CCSize getMaxTopSize() const override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Geode/DefaultInclude.hpp>
|
||||
#include <Geode/binding/CCTextInputNode.hpp>
|
||||
#include <cocos2d.h>
|
||||
|
||||
namespace geode {
|
||||
|
|
|
@ -191,17 +191,17 @@ bool BasedButtonSprite::init(CCNode* ontop, BaseType type, int size, int color)
|
|||
if (ontop) {
|
||||
m_onTop = ontop;
|
||||
m_onTop->setPosition(this->getContentSize() / 2 + this->getTopOffset());
|
||||
limitNodeSize(
|
||||
m_onTop,
|
||||
m_obContentSize - CCSize(18.f, 18.f),
|
||||
m_onTop->getScale(), .1f
|
||||
);
|
||||
limitNodeSize(m_onTop, this->getMaxTopSize(), m_onTop->getScale(), .1f);
|
||||
this->addChild(m_onTop);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCSize BasedButtonSprite::getMaxTopSize() const {
|
||||
return m_obContentSize - CCSize(18.f, 18.f);
|
||||
}
|
||||
|
||||
CCPoint BasedButtonSprite::getTopOffset() const {
|
||||
return { 0, 0 };
|
||||
}
|
||||
|
@ -303,6 +303,10 @@ DECL_BASED_CREATE_FUNS(Leaderboard);
|
|||
DECL_BASED_CREATE_FUNS(Editor);
|
||||
DECL_BASED_CREATE_FUNS(Category);
|
||||
|
||||
CCSize EditorButtonSprite::getMaxTopSize() const {
|
||||
return m_obContentSize - CCSize { 8.f, 8.f };
|
||||
}
|
||||
|
||||
TabButtonSprite* TabButtonSprite::create(char const* text, TabBaseColor color, TabBaseSize size) {
|
||||
auto ret = new TabButtonSprite();
|
||||
auto label = CCLabelBMFont::create(text, "bigFont.fnt");
|
||||
|
|
Loading…
Reference in a new issue