From ee796af1df123076e7c84efb8503af50719efe61 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Thu, 9 Nov 2017 18:22:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=82=B9=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=94=B9=E4=B8=BA(0,0)=EF=BC=9B=E6=96=B0?= =?UTF-8?q?=E5=A2=9EENode::setDefaultPivot=E5=87=BD=E6=95=B0=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=BB=98=E8=AE=A4=E4=B8=AD=E5=BF=83=E7=82=B9=EF=BC=9B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=90=AF=E7=94=A8=E6=88=96=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E6=8C=89=E9=92=AE=E5=90=8E=E6=8C=89=E9=92=AE=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=E7=9A=84bug=EF=BC=9B=E6=9B=B4=E6=96=B0=E4=BA=86?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=82=B9=E6=98=AF=E5=90=A6=E5=9C=A8=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=86=85=E7=9A=84=E7=AE=97=E6=B3=95=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BA=86=E5=88=87=E6=8D=A2=E5=BC=80=E5=85=B3=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=8A=B6=E6=80=81=E4=B8=8D=E6=89=A7=E8=A1=8C=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E5=87=BD=E6=95=B0=E7=9A=84bug=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BA=86=E5=AD=90=E8=8A=82=E7=82=B9=E4=B8=8E=E7=88=B6?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9B=B8=E5=AF=B9=E4=BD=8D=E7=BD=AE=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84bug=EF=BC=9B=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E7=9A=84=E4=B8=80=E4=BA=9B=E5=B0=8Fbug?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConsoleDemo/main.cpp | 64 +++++++---- Easy2D/Base/EScene.cpp | 2 +- Easy2D/Common/EFont.cpp | 2 +- Easy2D/Easy2D.vcxproj | 2 +- Easy2D/Geometry/EGeometry.cpp | 5 +- Easy2D/Node/EButton.cpp | 8 ++ Easy2D/Node/EButtonToggle.cpp | 11 +- Easy2D/Node/ENode.cpp | 115 ++++++++++--------- Easy2D/Transition/ETransitionScaleEmerge.cpp | 26 ++--- Easy2D/ecommon.h | 2 +- Easy2D/egeometry.h | 1 - Easy2D/enodes.h | 41 ++++--- 12 files changed, 162 insertions(+), 117 deletions(-) diff --git a/ConsoleDemo/main.cpp b/ConsoleDemo/main.cpp index 3248efa4..519cafa3 100644 --- a/ConsoleDemo/main.cpp +++ b/ConsoleDemo/main.cpp @@ -1,35 +1,53 @@ #include +class Scene2 : + public EScene +{ +public: + Scene2() + { + auto text = new EText(L"测试按钮"); + auto text2 = new EText(L"测试按钮", L"", 22, EColor::BLUE); + auto button = new EButton(text, text2, text); + button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2); + button->setCallback([]() { + EApp::backScene(new ETransitionScaleEmerge(1, ETransitionScaleEmerge::ENTER)); + }); + this->add(button); + } +}; + +class Scene : + public EScene +{ +public: + Scene() + { + /*auto sprite = new ESprite(L"test2.png"); + auto button = new EButton(sprite); + button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2); + button->setCallback([]() { + EApp::enterScene(new Scene2(), new ETransitionScaleEmerge(1, ETransitionScaleEmerge::ENTER)); + }); + this->add(button);*/ + auto sprite = new ESprite(L"test2.png"); + sprite->setPivot(-1, 0); + sprite->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2); + this->add(sprite); + + sprite->runAction(new EActionLoop(new EActionRotateBy(1, 60))); + } +}; + int main() { EApp app; if (app.init(L"Easy2D Demo", 640, 480)) { - app.showConsole(); - auto scene = new EScene(); - - // 创建一个文本 - auto btnNormal = new EText(L"开"); - auto btnSelected = new EText(L"开"); - btnSelected->movePosY(2); - auto btnNormal2 = new EText(L"关"); - auto btnSelected2 = new EText(L"关"); - btnSelected2->movePosY(2); - // 创建一个按钮 - auto button = new EButtonToggle(btnNormal, btnNormal2, btnSelected, btnSelected2); - button->setCallback([=]() { - //button->setEnable(false); - }); - button->toggle(); - button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2); - scene->add(button); - - // 创建按钮 - auto button2 = new EButton(new EText(L"关闭"), [=]() { button->setEnable(!button->isEnable()); }); - button2->setPos(40, 40); - scene->add(button2); + ENode::setDefaultPiovt(0.5f, 0.5f); + auto scene = new Scene(); app.enterScene(scene); app.run(); diff --git a/Easy2D/Base/EScene.cpp b/Easy2D/Base/EScene.cpp index 42dd54ec..58664f9d 100644 --- a/Easy2D/Base/EScene.cpp +++ b/Easy2D/Base/EScene.cpp @@ -15,8 +15,8 @@ e2d::EScene::EScene() m_pRoot->retain(); m_pRoot->_onEnter(); m_pRoot->_setParentScene(this); + m_pRoot->setPivot(0, 0); m_pRoot->_setSize(EApp::getWidth(), EApp::getHeight()); - m_pRoot->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2); } e2d::EScene::~EScene() diff --git a/Easy2D/Common/EFont.cpp b/Easy2D/Common/EFont.cpp index 5e56c7a2..1e85bac7 100644 --- a/Easy2D/Common/EFont.cpp +++ b/Easy2D/Common/EFont.cpp @@ -46,7 +46,7 @@ bool e2d::EFont::isItalic() const return m_bItalic; } -void e2d::EFont::setFamily(EString fontFamily) +void e2d::EFont::setFamily(const EString & fontFamily) { m_sFontFamily = fontFamily; m_bRecreateNeeded = true; diff --git a/Easy2D/Easy2D.vcxproj b/Easy2D/Easy2D.vcxproj index e5eb2565..5820be2a 100644 --- a/Easy2D/Easy2D.vcxproj +++ b/Easy2D/Easy2D.vcxproj @@ -101,7 +101,7 @@ Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - EditAndContinue + None false diff --git a/Easy2D/Geometry/EGeometry.cpp b/Easy2D/Geometry/EGeometry.cpp index b00babf7..7b994cdc 100644 --- a/Easy2D/Geometry/EGeometry.cpp +++ b/Easy2D/Geometry/EGeometry.cpp @@ -4,8 +4,7 @@ #include "..\Win\winbase.h" e2d::EGeometry::EGeometry() - : m_bTransformed(false) - , m_nCategoryBitmask(0) + : m_nCategoryBitmask(0) , m_nCollisionBitmask(0) , m_bIsVisiable(true) , m_nColor(EColor::RED) @@ -105,7 +104,7 @@ void e2d::EGeometry::_transform() // 根据父节点转换几何图形 GetFactory()->CreateTransformedGeometry( _getD2dGeometry(), - m_pParentNode->m_Matri, + m_pParentNode->m_MatriFinal, &m_pTransformedGeometry ); diff --git a/Easy2D/Node/EButton.cpp b/Easy2D/Node/EButton.cpp index 572fe0c6..80605aff 100644 --- a/Easy2D/Node/EButton.cpp +++ b/Easy2D/Node/EButton.cpp @@ -73,6 +73,7 @@ void e2d::EButton::setNormal(ENode * normal) this->addChild(normal); } m_pNormal = normal; + _updateVisiable(); } } @@ -139,6 +140,7 @@ void e2d::EButton::setEnable(bool bEnable) if (m_bEnable != bEnable) { m_bEnable = bEnable; + _updateVisiable(); _updateStatus(); } } @@ -159,6 +161,12 @@ void e2d::EButton::_setStatus(STATUS status) } } +void e2d::EButton::_updateTransform() +{ + ENode::_updateTransform(); + _updateStatus(); +} + void e2d::EButton::_updateVisiable() { if (m_pNormal) m_pNormal->setVisiable(false); diff --git a/Easy2D/Node/EButtonToggle.cpp b/Easy2D/Node/EButtonToggle.cpp index ff5c029d..d8ecbfd4 100644 --- a/Easy2D/Node/EButtonToggle.cpp +++ b/Easy2D/Node/EButtonToggle.cpp @@ -63,9 +63,13 @@ e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNorma void e2d::EButtonToggle::toggle() { - m_bToggle = !m_bToggle; - _updateToggle(); - _updateVisiable(); + // 设置按钮状态 + setToggle(!m_bToggle); + // 执行回调函数 + if (m_Callback) + { + m_Callback(); + } } bool e2d::EButtonToggle::isToggleOn() const @@ -79,6 +83,7 @@ void e2d::EButtonToggle::setToggle(bool toggle) { m_bToggle = toggle; _updateToggle(); + _updateVisiable(); } } diff --git a/Easy2D/Node/ENode.cpp b/Easy2D/Node/ENode.cpp index 46857eac..3dd91ba3 100644 --- a/Easy2D/Node/ENode.cpp +++ b/Easy2D/Node/ENode.cpp @@ -6,6 +6,10 @@ #include "..\Win\winbase.h" #include +// 默认中心点位置 +static float s_fDefaultPiovtX = 0; +static float s_fDefaultPiovtY = 0; + e2d::ENode::ENode() : m_nOrder(0) , m_fScaleX(1.0f) @@ -15,9 +19,10 @@ e2d::ENode::ENode() , m_fSkewAngleY(0) , m_fDisplayOpacity(1.0f) , m_fRealOpacity(1.0f) - , m_fPivotX(0.5f) - , m_fPivotY(0.5f) - , m_Matri(D2D1::Matrix3x2F::Identity()) + , m_fPivotX(s_fDefaultPiovtX) + , m_fPivotY(s_fDefaultPiovtY) + , m_MatriInitial(D2D1::Matrix3x2F::Identity()) + , m_MatriFinal(D2D1::Matrix3x2F::Identity()) , m_bVisiable(true) , m_bDisplayedInScene(false) , m_pGeometry(nullptr) @@ -25,7 +30,7 @@ e2d::ENode::ENode() , m_pParentScene(nullptr) , m_nHashName(0) , m_bSortChildrenNeeded(false) - , m_bTransformChildrenNeeded(false) + , m_bTransformNeeded(false) { } @@ -64,7 +69,7 @@ void e2d::ENode::_callOn() return; } - if (m_bTransformChildrenNeeded) + if (m_bTransformNeeded) { _updateTransform(this); } @@ -89,7 +94,7 @@ void e2d::ENode::_callOn() } } - GetRenderTarget()->SetTransform(m_Matri); + GetRenderTarget()->SetTransform(m_MatriFinal); // 渲染自身 this->_onRender(); @@ -99,7 +104,7 @@ void e2d::ENode::_callOn() } else { - GetRenderTarget()->SetTransform(m_Matri); + GetRenderTarget()->SetTransform(m_MatriFinal); // 渲染自身 this->_onRender(); } @@ -169,20 +174,15 @@ void e2d::ENode::_sortChildren() } } -void e2d::ENode::_updateTransformToReal() +void e2d::ENode::_updateTransform() { - // 计算锚点坐标 + // 计算中心点坐标 D2D1_POINT_2F pivot = D2D1::Point2F( getRealWidth() * m_fPivotX, getRealHeight() * m_fPivotY ); - // 计算左上角坐标 - D2D1_POINT_2F upperLeftCorner = D2D1::Point2F( - m_Pos.x - getRealWidth() * m_fPivotX, - m_Pos.y - getRealHeight() * m_fPivotY - ); - // 二维矩形变换 - m_Matri = D2D1::Matrix3x2F::Scale( + // 初步的二维矩形变换,子节点将根据这个矩阵进行变换 + m_MatriInitial = D2D1::Matrix3x2F::Scale( m_fScaleX, m_fScaleY, pivot @@ -194,9 +194,16 @@ void e2d::ENode::_updateTransformToReal() m_fRotation, pivot ) * D2D1::Matrix3x2F::Translation( - upperLeftCorner.x, - upperLeftCorner.y + m_Pos.x, + m_Pos.y ); + // 和父节点矩阵相乘 + if (m_pParent) + { + m_MatriInitial = m_MatriInitial * m_pParent->m_MatriInitial; + } + // 根据自身中心点做最终变换 + m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y); } void e2d::ENode::_updateChildrenTransform() @@ -210,13 +217,8 @@ void e2d::ENode::_updateChildrenTransform() void e2d::ENode::_updateTransform(ENode * node) { // 计算自身的转换矩阵 - node->_updateTransformToReal(); - // 和父节点矩阵相乘 - if (node->m_pParent) - { - node->m_Matri = node->m_Matri * node->m_pParent->m_Matri; - } - // 转换几何形状 + node->_updateTransform(); + // 绑定于自身的形状也进行相应转换 if (node->m_pGeometry) { node->m_pGeometry->_transform(); @@ -224,12 +226,7 @@ void e2d::ENode::_updateTransform(ENode * node) // 遍历子节点下的所有节点 node->_updateChildrenTransform(); // 标志已执行过变换 - node->m_bTransformChildrenNeeded = false; - // 绑定于自身的形状也进行相应转换 - if (node->m_pGeometry) - { - node->m_pGeometry->m_bTransformed = true; - } + node->m_bTransformNeeded = false; } void e2d::ENode::_updateChildrenOpacity() @@ -376,7 +373,7 @@ void e2d::ENode::setPos(float x, float y) m_Pos.x = x; m_Pos.y = y; - m_bTransformChildrenNeeded = true; + m_bTransformNeeded = true; } void e2d::ENode::movePosX(float x) @@ -421,7 +418,7 @@ void e2d::ENode::_setSize(float width, float height) m_Size.width = width; m_Size.height = height; - m_bTransformChildrenNeeded = true; + m_bTransformNeeded = true; } void e2d::ENode::setScaleX(float scaleX) @@ -446,7 +443,7 @@ void e2d::ENode::setScale(float scaleX, float scaleY) m_fScaleX = scaleX; m_fScaleY = scaleY; - m_bTransformChildrenNeeded = true; + m_bTransformNeeded = true; } void e2d::ENode::setSkewX(float angleX) @@ -466,7 +463,7 @@ void e2d::ENode::setSkew(float angleX, float angleY) m_fSkewAngleX = angleX; m_fSkewAngleY = angleY; - m_bTransformChildrenNeeded = true; + m_bTransformNeeded = true; } void e2d::ENode::setRotation(float angle) @@ -475,7 +472,7 @@ void e2d::ENode::setRotation(float angle) return; m_fRotation = angle; - m_bTransformChildrenNeeded = true; + m_bTransformNeeded = true; } void e2d::ENode::setOpacity(float opacity) @@ -505,7 +502,7 @@ void e2d::ENode::setPivot(float pivotX, float pivotY) m_fPivotX = min(max(pivotX, 0), 1); m_fPivotY = min(max(pivotY, 0), 1); - m_bTransformChildrenNeeded = true; + m_bTransformNeeded = true; } void e2d::ENode::setGeometry(EGeometry * geometry) @@ -547,8 +544,6 @@ void e2d::ENode::addChild(ENode * child, int order /* = 0 */) child->m_pParent = this; - _updateOpacity(child); - if (this->m_pParentScene) { child->_setParentScene(this->m_pParentScene); @@ -559,6 +554,11 @@ void e2d::ENode::addChild(ENode * child, int order /* = 0 */) child->_onEnter(); } + // 更新子节点透明度 + _updateOpacity(child); + // 更新节点转换 + child->m_bTransformNeeded = true; + // 更新子节点排序 m_bSortChildrenNeeded = true; } } @@ -710,27 +710,26 @@ void e2d::ENode::pauseAction(EAction * action) bool e2d::ENode::isPointIn(EPoint point) { - if (m_bTransformChildrenNeeded) + if (m_bTransformNeeded) { _updateTransform(this); } - // 保存节点所在矩形 - D2D1_POINT_2F leftTop = m_Matri.TransformPoint( - D2D1::Point2F(0, 0) + // 为节点创建一个形状 + ID2D1RectangleGeometry * rect; + GetFactory()->CreateRectangleGeometry( + D2D1::RectF(0, 0, getRealWidth(), getRealHeight()), + &rect ); - D2D1_POINT_2F rightBottom = m_Matri.TransformPoint( - D2D1::Point2F(getRealWidth(), getRealHeight()) + // 判断点是否在形状内 + BOOL ret; + rect->FillContainsPoint( + D2D1::Point2F( + point.x, + point.y), + &m_MatriFinal, + &ret ); - D2D1_RECT_F rt = D2D1::RectF( - leftTop.x, - leftTop.y, - rightBottom.x, - rightBottom.y - ); - if (point.x >= rt.left && - point.x <= rt.right && - point.y >= rt.top && - point.y <= rt.bottom) + if (ret) { return true; } @@ -743,6 +742,12 @@ bool e2d::ENode::isPointIn(EPoint point) return false; } +void e2d::ENode::setDefaultPiovt(float defaultPiovtX, float defaultPiovtY) +{ + s_fDefaultPiovtX = min(max(defaultPiovtX, 0), 1); + s_fDefaultPiovtY = min(max(defaultPiovtY, 0), 1); +} + void e2d::ENode::stopAction(EAction * action) { if (action->getTarget() == this) diff --git a/Easy2D/Transition/ETransitionScaleEmerge.cpp b/Easy2D/Transition/ETransitionScaleEmerge.cpp index 90f1f278..f76aed3c 100644 --- a/Easy2D/Transition/ETransitionScaleEmerge.cpp +++ b/Easy2D/Transition/ETransitionScaleEmerge.cpp @@ -10,44 +10,44 @@ e2d::ETransitionScaleEmerge::ETransitionScaleEmerge(float duration, SCALE_EMERGE void e2d::ETransitionScaleEmerge::_setTarget(EScene * prev, EScene * next, bool & transitional) { - float prevScaleTo; - float nextScaleStart; + float prevScaleBy; + float nextScaleBy; if (m_Mode == SCALE_EMERGE_MODE::ENTER) { - prevScaleTo = 1.2f; - nextScaleStart = 0.8f; + prevScaleBy = 0.2f; + nextScaleBy = -0.2f; } else { - prevScaleTo = 0.8f; - nextScaleStart = 1.2f; + prevScaleBy = -0.2f; + nextScaleBy = 0.2f; } // 初始化场景属性 - next->getRoot()->setScale(nextScaleStart); + next->getRoot()->setScale(next->getRoot()->getScaleX() - nextScaleBy, next->getRoot()->getScaleY() - nextScaleBy); next->getRoot()->setOpacity(0); // 第一个场景淡出 auto prevActionFadeOut = new EActionFadeOut(m_fDuration); - auto prevActionScaleTo = new EActionScaleTo(m_fDuration, prevScaleTo); + auto prevActionScaleBy = new EActionScaleBy(m_fDuration, prevScaleBy); auto action1 = new EActionTwoAtSameTime( prevActionFadeOut, - prevActionScaleTo); + prevActionScaleBy); if (prev) { prevActionFadeOut->setTarget(prev->getRoot()); - prevActionScaleTo->setTarget(prev->getRoot()); + prevActionScaleBy->setTarget(prev->getRoot()); } // 第二个场景淡入 auto nextActionFadeOut = new EActionFadeIn(m_fDuration); - auto nextActionScaleTo = new EActionScaleTo(m_fDuration, 1); + auto nextActionScaleBy = new EActionScaleBy(m_fDuration, nextScaleBy); auto action2 = new EActionTwoAtSameTime( nextActionFadeOut, - nextActionScaleTo); + nextActionScaleBy); nextActionFadeOut->setTarget(next->getRoot()); - nextActionScaleTo->setTarget(next->getRoot()); + nextActionScaleBy->setTarget(next->getRoot()); // 标志动画结束 auto action3 = new EActionCallback([&, prev, next] { diff --git a/Easy2D/ecommon.h b/Easy2D/ecommon.h index cd803610..3c873f2e 100644 --- a/Easy2D/ecommon.h +++ b/Easy2D/ecommon.h @@ -395,7 +395,7 @@ public: // 设置字体 void setFamily( - EString fontFamily + const EString & fontFamily ); // 设置字号 diff --git a/Easy2D/egeometry.h b/Easy2D/egeometry.h index 582d248e..633407be 100644 --- a/Easy2D/egeometry.h +++ b/Easy2D/egeometry.h @@ -69,7 +69,6 @@ protected: virtual ID2D1Geometry * _getD2dGeometry() const = 0; protected: - bool m_bTransformed; bool m_bIsVisiable; UINT32 m_nCategoryBitmask; UINT32 m_nCollisionBitmask; diff --git a/Easy2D/enodes.h b/Easy2D/enodes.h index 49bdada1..be56405d 100644 --- a/Easy2D/enodes.h +++ b/Easy2D/enodes.h @@ -68,10 +68,10 @@ public: // 获取节点大小(不考虑缩放) virtual ESize getRealSize() const; - // 获取节点的锚点 + // 获取节点的中心点 virtual float getPivotX() const; - // 获取节点的锚点 + // 获取节点的中心点 virtual float getPivotY() const; // 获取节点大小 @@ -226,20 +226,20 @@ public: float opacity ); - // 设置支点的横向位置 - // 默认为 0.5f, 范围 [0, 1] + // 设置中心点的横向位置 + // 默认为 0, 范围 [0, 1] virtual void setPivotX( float pivotX ); - // 设置支点的纵向位置 - // 默认为 0.5f, 范围 [0, 1] + // 设置中心点的纵向位置 + // 默认为 0, 范围 [0, 1] virtual void setPivotY( float pivotY ); - // 设置支点位置 - // 默认为 (0.5f, 0.5f), 范围 [0, 1] + // 设置中心点位置 + // 默认为 (0, 0), 范围 [0, 1] virtual void setPivot( float pivotX, float pivotY @@ -306,6 +306,12 @@ public: EPoint point ); + // 修改节点的默认中心点位置 + static void setDefaultPiovt( + float defaultPiovtX, + float defaultPiovtY + ); + protected: // 访问节点 virtual void _callOn(); @@ -330,14 +336,14 @@ protected: EScene * scene ); - // 只考虑自身进行二维矩阵变换 - void _updateTransformToReal(); + // 对自身进行二维矩阵变换 + virtual void _updateTransform(); // 更新所有子节点矩阵 - void _updateChildrenTransform(); + virtual void _updateChildrenTransform(); // 更新所有子节点透明度 - void _updateChildrenOpacity(); + virtual void _updateChildrenOpacity(); // 更新节点矩阵 static void _updateTransform(ENode * node); @@ -384,11 +390,12 @@ protected: bool m_bVisiable; bool m_bDisplayedInScene; bool m_bSortChildrenNeeded; - bool m_bTransformChildrenNeeded; + bool m_bTransformNeeded; EGeometry * m_pGeometry; EScene * m_pParentScene; ENode * m_pParent; - D2D1::Matrix3x2F m_Matri; + D2D1::Matrix3x2F m_MatriInitial; + D2D1::Matrix3x2F m_MatriFinal; EVector m_vChildren; }; @@ -646,6 +653,9 @@ protected: // 设置按钮状态 virtual void _setStatus(STATUS status); + // 对自身进行二维矩阵变换 + virtual void _updateTransform() override; + // 刷新按钮显示 virtual void _updateVisiable(); @@ -715,13 +725,14 @@ public: const BUTTON_CLICK_CALLBACK & callback = nullptr ); - // 切换开关状态 + // 切换开关状态,并执行回调函数 void toggle(); // 获取开关状态 bool isToggleOn() const; // 打开或关闭开关 + // 仅设置按钮状态,不执行回调函数 void setToggle( bool toggle );