class Button will never modify the pivot of its child automatically.
This commit is contained in:
parent
741ebefb25
commit
bdfb03dc1d
|
|
@ -38,7 +38,7 @@ void e2d::ActionScaleBy::_update()
|
|||
// 缩放节点
|
||||
m_pTarget->setScale(
|
||||
m_nBeginScaleX + m_nVariationX * m_fRateOfProgress,
|
||||
m_nBeginScaleX + m_nVariationX * m_fRateOfProgress);
|
||||
m_nBeginScaleY + m_nVariationY * m_fRateOfProgress);
|
||||
}
|
||||
|
||||
e2d::ActionScaleBy * e2d::ActionScaleBy::clone() const
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
|
||||
#define SAFE_SETTER(pointer, func, ...) if (pointer) { pointer->##func(__VA_ARGS__); }
|
||||
|
||||
|
||||
e2d::Button::Button()
|
||||
: m_Callback((const ButtonCallback &)nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
|
|
@ -93,7 +96,6 @@ void e2d::Button::setNormal(Node * normal)
|
|||
if (normal)
|
||||
{
|
||||
this->addChild(normal);
|
||||
normal->setPivot(m_fPivotX, m_fPivotY);
|
||||
this->_setSize(normal->getWidth(), normal->getHeight());
|
||||
}
|
||||
m_pNormal = normal;
|
||||
|
|
@ -115,7 +117,6 @@ void e2d::Button::setMouseOver(Node * mouseover)
|
|||
if (mouseover)
|
||||
{
|
||||
this->addChild(mouseover);
|
||||
mouseover->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pMouseover = mouseover;
|
||||
_updateVisiable();
|
||||
|
|
@ -135,7 +136,6 @@ void e2d::Button::setSelected(Node * selected)
|
|||
if (selected)
|
||||
{
|
||||
this->addChild(selected);
|
||||
selected->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pSelected = selected;
|
||||
_updateVisiable();
|
||||
|
|
@ -155,7 +155,6 @@ void e2d::Button::setDisabled(Node * disabled)
|
|||
if (disabled)
|
||||
{
|
||||
this->addChild(disabled);
|
||||
disabled->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pDisabled = disabled;
|
||||
_updateVisiable();
|
||||
|
|
@ -178,33 +177,6 @@ void e2d::Button::setCallback(const ButtonCallback & callback)
|
|||
m_Callback = callback;
|
||||
}
|
||||
|
||||
void e2d::Button::setPivotX(float pivotX)
|
||||
{
|
||||
Node::setPivotX(pivotX);
|
||||
if (m_pNormal) m_pNormal->setPivotX(pivotX);
|
||||
if (m_pMouseover) m_pMouseover->setPivotX(pivotX);
|
||||
if (m_pSelected) m_pSelected->setPivotX(pivotX);
|
||||
if (m_pDisabled) m_pDisabled->setPivotX(pivotX);
|
||||
}
|
||||
|
||||
void e2d::Button::setPivotY(float pivotY)
|
||||
{
|
||||
Node::setPivotY(pivotY);
|
||||
if (m_pNormal) m_pNormal->setPivotY(pivotY);
|
||||
if (m_pMouseover) m_pMouseover->setPivotY(pivotY);
|
||||
if (m_pSelected) m_pSelected->setPivotY(pivotY);
|
||||
if (m_pDisabled) m_pDisabled->setPivotY(pivotY);
|
||||
}
|
||||
|
||||
void e2d::Button::setPivot(float pivotX, float pivotY)
|
||||
{
|
||||
Node::setPivot(pivotX, pivotY);
|
||||
if (m_pNormal) m_pNormal->setPivot(pivotX, pivotY);
|
||||
if (m_pMouseover) m_pMouseover->setPivot(pivotX, pivotY);
|
||||
if (m_pSelected) m_pSelected->setPivot(pivotX, pivotY);
|
||||
if (m_pDisabled) m_pDisabled->setPivot(pivotX, pivotY);
|
||||
}
|
||||
|
||||
void e2d::Button::onFixedUpdate()
|
||||
{
|
||||
if (SceneManager::isTransitioning())
|
||||
|
|
@ -263,10 +235,10 @@ void e2d::Button::_setState(BTN_STATE state)
|
|||
|
||||
void e2d::Button::_updateVisiable()
|
||||
{
|
||||
if (m_pNormal) m_pNormal->setVisiable(false);
|
||||
if (m_pMouseover) m_pMouseover->setVisiable(false);
|
||||
if (m_pSelected) m_pSelected->setVisiable(false);
|
||||
if (m_pDisabled) m_pDisabled->setVisiable(false);
|
||||
SAFE_SETTER(m_pNormal, setVisiable, false);
|
||||
SAFE_SETTER(m_pMouseover, setVisiable, false);
|
||||
SAFE_SETTER(m_pSelected, setVisiable, false);
|
||||
SAFE_SETTER(m_pDisabled, setVisiable, false);
|
||||
|
||||
if (m_bEnable)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ void e2d::ButtonToggle::setNormal(Node * normal)
|
|||
if (normal)
|
||||
{
|
||||
this->addChild(normal);
|
||||
normal->setPivot(m_fPivotX, m_fPivotY);
|
||||
this->_setSize(normal->getWidth(), normal->getHeight());
|
||||
}
|
||||
m_pNormalOn = normal;
|
||||
|
|
@ -145,7 +144,6 @@ void e2d::ButtonToggle::setMouseOver(Node * mouseover)
|
|||
if (mouseover)
|
||||
{
|
||||
this->addChild(mouseover);
|
||||
mouseover->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pMouseoverOn = mouseover;
|
||||
|
||||
|
|
@ -167,7 +165,6 @@ void e2d::ButtonToggle::setSelected(Node * selected)
|
|||
if (selected)
|
||||
{
|
||||
this->addChild(selected);
|
||||
selected->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pSelectedOn = selected;
|
||||
|
||||
|
|
@ -189,7 +186,6 @@ void e2d::ButtonToggle::setDisabled(Node * disabled)
|
|||
if (disabled)
|
||||
{
|
||||
this->addChild(disabled);
|
||||
disabled->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pDisabledOn = disabled;
|
||||
|
||||
|
|
@ -211,7 +207,6 @@ void e2d::ButtonToggle::setNormalOff(Node * normal)
|
|||
if (normal)
|
||||
{
|
||||
this->addChild(normal);
|
||||
normal->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pNormalOff = normal;
|
||||
|
||||
|
|
@ -233,7 +228,6 @@ void e2d::ButtonToggle::setMouseOverOff(Node * mouseover)
|
|||
if (mouseover)
|
||||
{
|
||||
this->addChild(mouseover);
|
||||
mouseover->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pMouseoverOff = mouseover;
|
||||
|
||||
|
|
@ -255,7 +249,6 @@ void e2d::ButtonToggle::setSelectedOff(Node * selected)
|
|||
if (selected)
|
||||
{
|
||||
this->addChild(selected);
|
||||
selected->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pSelectedOff = selected;
|
||||
|
||||
|
|
@ -277,7 +270,6 @@ void e2d::ButtonToggle::setDisabledOff(Node * disabled)
|
|||
if (disabled)
|
||||
{
|
||||
this->addChild(disabled);
|
||||
disabled->setPivot(m_fPivotX, m_fPivotY);
|
||||
}
|
||||
m_pDisabledOff = disabled;
|
||||
|
||||
|
|
@ -286,45 +278,6 @@ void e2d::ButtonToggle::setDisabledOff(Node * disabled)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ButtonToggle::setPivotX(float pivotX)
|
||||
{
|
||||
Node::setPivotX(pivotX);
|
||||
if (m_pNormalOn) m_pNormalOn->setPivotX(pivotX);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setPivotX(pivotX);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setPivotX(pivotX);
|
||||
if (m_pDisabledOn) m_pDisabledOn->setPivotX(pivotX);
|
||||
if (m_pNormalOff) m_pNormalOff->setPivotX(pivotX);
|
||||
if (m_pMouseoverOff) m_pMouseoverOff->setPivotX(pivotX);
|
||||
if (m_pSelectedOff) m_pSelectedOff->setPivotX(pivotX);
|
||||
if (m_pDisabledOff) m_pDisabledOff->setPivotX(pivotX);
|
||||
}
|
||||
|
||||
void e2d::ButtonToggle::setPivotY(float pivotY)
|
||||
{
|
||||
Node::setPivotY(pivotY);
|
||||
if (m_pNormalOn) m_pNormalOn->setPivotY(pivotY);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setPivotY(pivotY);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setPivotY(pivotY);
|
||||
if (m_pDisabledOn) m_pDisabledOn->setPivotY(pivotY);
|
||||
if (m_pNormalOff) m_pNormalOff->setPivotY(pivotY);
|
||||
if (m_pMouseoverOff) m_pMouseoverOff->setPivotY(pivotY);
|
||||
if (m_pSelectedOff) m_pSelectedOff->setPivotY(pivotY);
|
||||
if (m_pDisabledOff) m_pDisabledOff->setPivotY(pivotY);
|
||||
}
|
||||
|
||||
void e2d::ButtonToggle::setPivot(float pivotX, float pivotY)
|
||||
{
|
||||
Node::setPivot(pivotX, pivotY);
|
||||
if (m_pNormalOn) m_pNormalOn->setPivot(pivotX, pivotY);
|
||||
if (m_pMouseoverOn) m_pMouseoverOn->setPivot(pivotX, pivotY);
|
||||
if (m_pSelectedOn) m_pSelectedOn->setPivot(pivotX, pivotY);
|
||||
if (m_pDisabledOn) m_pDisabledOn->setPivot(pivotX, pivotY);
|
||||
if (m_pNormalOff) m_pNormalOff->setPivot(pivotX, pivotY);
|
||||
if (m_pMouseoverOff) m_pMouseoverOff->setPivot(pivotX, pivotY);
|
||||
if (m_pSelectedOff) m_pSelectedOff->setPivot(pivotX, pivotY);
|
||||
if (m_pDisabledOff) m_pDisabledOff->setPivot(pivotX, pivotY);
|
||||
}
|
||||
|
||||
void e2d::ButtonToggle::_updateState()
|
||||
{
|
||||
if (m_bState)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ void e2d::Text::setFont(Font * font)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setWordWrapping(bool value)
|
||||
void e2d::Text::setWordWrappingEnable(bool value)
|
||||
{
|
||||
m_bWordWrapping = value;
|
||||
_initTextLayout();
|
||||
|
|
|
|||
|
|
@ -512,17 +512,17 @@ public:
|
|||
|
||||
// 设置字体
|
||||
void setFont(
|
||||
Font * font
|
||||
Font * pFont
|
||||
);
|
||||
|
||||
// 设置文字自动换行
|
||||
void setWordWrapping(
|
||||
bool value
|
||||
void setWordWrappingEnable(
|
||||
bool bEnable
|
||||
);
|
||||
|
||||
// 设置文字换行宽度(WordWrapping 打开时生效)
|
||||
void setWordWrappingWidth(
|
||||
float wordWrapWidth
|
||||
float fWordWrapWidth
|
||||
);
|
||||
|
||||
// 渲染文字
|
||||
|
|
@ -610,25 +610,6 @@ public:
|
|||
const ButtonCallback & callback
|
||||
);
|
||||
|
||||
// 设置中心点的横向位置
|
||||
// 默认为 0, 范围 [0, 1]
|
||||
virtual void setPivotX(
|
||||
float pivotX
|
||||
) override;
|
||||
|
||||
// 设置中心点的纵向位置
|
||||
// 默认为 0, 范围 [0, 1]
|
||||
virtual void setPivotY(
|
||||
float pivotY
|
||||
) override;
|
||||
|
||||
// 设置中心点位置
|
||||
// 默认为 (0, 0), 范围 [0, 1]
|
||||
virtual void setPivot(
|
||||
float pivotX,
|
||||
float pivotY
|
||||
) override;
|
||||
|
||||
// 更新按钮状态
|
||||
virtual void onFixedUpdate() override;
|
||||
|
||||
|
|
@ -751,25 +732,6 @@ public:
|
|||
Node * disabled
|
||||
);
|
||||
|
||||
// 设置中心点的横向位置
|
||||
// 默认为 0, 范围 [0, 1]
|
||||
virtual void setPivotX(
|
||||
float pivotX
|
||||
) override;
|
||||
|
||||
// 设置中心点的纵向位置
|
||||
// 默认为 0, 范围 [0, 1]
|
||||
virtual void setPivotY(
|
||||
float pivotY
|
||||
) override;
|
||||
|
||||
// 设置中心点位置
|
||||
// 默认为 (0, 0), 范围 [0, 1]
|
||||
virtual void setPivot(
|
||||
float pivotX,
|
||||
float pivotY
|
||||
) override;
|
||||
|
||||
protected:
|
||||
// 刷新按钮开关
|
||||
virtual void _updateState();
|
||||
|
|
|
|||
Loading…
Reference in New Issue