更新ENode
This commit is contained in:
parent
d07f95424a
commit
7f402c7593
|
|
@ -23,7 +23,7 @@
|
||||||
<ProjectGuid>{70931955-FE2D-4A50-93C6-6955A730B0FE}</ProjectGuid>
|
<ProjectGuid>{70931955-FE2D-4A50-93C6-6955A730B0FE}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>ConsoleDemo</RootNamespace>
|
<RootNamespace>ConsoleDemo</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,14 @@
|
||||||
<ProjectGuid>{9D85A92F-BCCE-4EF0-BAD3-601C0086661C}</ProjectGuid>
|
<ProjectGuid>{9D85A92F-BCCE-4EF0-BAD3-601C0086661C}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>Demo</RootNamespace>
|
<RootNamespace>Demo</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,11 @@ int WINAPI WinMain(
|
||||||
node->setSize(30, 180);
|
node->setSize(30, 180);
|
||||||
scene->add(node);
|
scene->add(node);
|
||||||
|
|
||||||
auto listener = new EMouseClickListener([=](EPoint) {
|
auto mlistener = new EMouseClickListener([=](EPoint) {
|
||||||
if (EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::MOVE)
|
node->setPos(EMouseMsg::getPos());
|
||||||
{
|
|
||||||
node->setPos(EMouseMsg::getPos());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
auto listener = new EKeyPressListener([=] {
|
auto klistener = new EKeyPressListener([=] {
|
||||||
if (EKeyMsg::isCapitalLockOn())
|
if (EKeyMsg::isCapitalLockOn())
|
||||||
{
|
{
|
||||||
if (EKeyMsg::getVal() == EKeyMsg::KEY::LEFT)
|
if (EKeyMsg::getVal() == EKeyMsg::KEY::LEFT)
|
||||||
|
|
@ -40,9 +37,9 @@ int WINAPI WinMain(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listener->bindWithNode(node);
|
mlistener->bindWith(node);
|
||||||
|
|
||||||
scene->bindListener(listener);
|
scene->bindListener(klistener);
|
||||||
|
|
||||||
app.enterScene(scene);
|
app.enterScene(scene);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ void e2d::EScene::add(ENode * child, int zOrder /* = 0 */)
|
||||||
// 忽略空指针
|
// 忽略空指针
|
||||||
if (child == nullptr) return;
|
if (child == nullptr) return;
|
||||||
// 设置节点的父场景
|
// 设置节点的父场景
|
||||||
child->bindWithScene(this);
|
child->setParentScene(this);
|
||||||
// 设置 z 轴顺序
|
// 设置 z 轴顺序
|
||||||
child->setZOrder(zOrder);
|
child->setZOrder(zOrder);
|
||||||
// 对象的引用计数加一
|
// 对象的引用计数加一
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,14 @@
|
||||||
<ProjectGuid>{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}</ProjectGuid>
|
<ProjectGuid>{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>Easy2D</RootNamespace>
|
<RootNamespace>Easy2D</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
|
@ -196,7 +196,7 @@
|
||||||
<ClCompile Include="Base\EObject.cpp" />
|
<ClCompile Include="Base\EObject.cpp" />
|
||||||
<ClCompile Include="Base\EScene.cpp" />
|
<ClCompile Include="Base\EScene.cpp" />
|
||||||
<ClCompile Include="Msg\EMsgManager.cpp" />
|
<ClCompile Include="Msg\EMsgManager.cpp" />
|
||||||
<ClCompile Include="Msg\Listener\EKeyListener.cpp" />
|
<ClCompile Include="Msg\Listener\EKeyboardListener.cpp" />
|
||||||
<ClCompile Include="Msg\Listener\EKeyPressListener.cpp" />
|
<ClCompile Include="Msg\Listener\EKeyPressListener.cpp" />
|
||||||
<ClCompile Include="Msg\Listener\EListener.cpp" />
|
<ClCompile Include="Msg\Listener\EListener.cpp" />
|
||||||
<ClCompile Include="Msg\Listener\EMouseClickListener.cpp" />
|
<ClCompile Include="Msg\Listener\EMouseClickListener.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,6 @@
|
||||||
<ClCompile Include="Msg\EMsgManager.cpp">
|
<ClCompile Include="Msg\EMsgManager.cpp">
|
||||||
<Filter>Msg</Filter>
|
<Filter>Msg</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Msg\Listener\EKeyListener.cpp">
|
|
||||||
<Filter>Msg\Listener</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Msg\Listener\EListener.cpp">
|
<ClCompile Include="Msg\Listener\EListener.cpp">
|
||||||
<Filter>Msg\Listener</Filter>
|
<Filter>Msg\Listener</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -57,12 +54,15 @@
|
||||||
<ClCompile Include="Msg\Listener\EMouseListener.cpp">
|
<ClCompile Include="Msg\Listener\EMouseListener.cpp">
|
||||||
<Filter>Msg\Listener</Filter>
|
<Filter>Msg\Listener</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Msg\Listener\EKeyPressListener.cpp">
|
|
||||||
<Filter>Msg\Listener</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Tool\ETimerManager.cpp">
|
<ClCompile Include="Tool\ETimerManager.cpp">
|
||||||
<Filter>Tool</Filter>
|
<Filter>Tool</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Msg\Listener\EKeyboardListener.cpp">
|
||||||
|
<Filter>Msg\Listener</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Msg\Listener\EKeyPressListener.cpp">
|
||||||
|
<Filter>Msg\Listener</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Win\winbase.h">
|
<ClInclude Include="Win\winbase.h">
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,53 @@
|
||||||
#include "..\..\emsg.h"
|
#include "..\..\emsg.h"
|
||||||
|
|
||||||
e2d::EKeyboardListener::EKeyboardListener()
|
e2d::EKeyboardListener::EKeyboardListener()
|
||||||
: EListener()
|
: EListener()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::EKeyboardListener::EKeyboardListener(EString name)
|
e2d::EKeyboardListener::EKeyboardListener(EString name)
|
||||||
: EListener(name)
|
: EListener(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::EKeyboardListener::EKeyboardListener(const KEY_LISTENER_CALLBACK & callback)
|
e2d::EKeyboardListener::EKeyboardListener(const KEY_LISTENER_CALLBACK & callback)
|
||||||
: EListener()
|
: EListener()
|
||||||
{
|
{
|
||||||
m_callback = callback;
|
m_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::EKeyboardListener::EKeyboardListener(EString name, const KEY_LISTENER_CALLBACK & callback)
|
e2d::EKeyboardListener::EKeyboardListener(EString name, const KEY_LISTENER_CALLBACK & callback)
|
||||||
: EListener(name)
|
: EListener(name)
|
||||||
{
|
{
|
||||||
m_callback = callback;
|
m_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::EKeyboardListener::runCallback()
|
void e2d::EKeyboardListener::runCallback()
|
||||||
{
|
{
|
||||||
m_callback();
|
m_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::EKeyboardListener::setCallback(const KEY_LISTENER_CALLBACK & callback)
|
void e2d::EKeyboardListener::setCallback(const KEY_LISTENER_CALLBACK & callback)
|
||||||
{
|
{
|
||||||
m_callback = callback;
|
m_callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::EKeyboardListener::bindWithScene(EScene * pParentScene)
|
void e2d::EKeyboardListener::bindWith(EScene * pParentScene)
|
||||||
{
|
{
|
||||||
WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object.");
|
WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object.");
|
||||||
|
|
||||||
if (pParentScene)
|
if (pParentScene)
|
||||||
{
|
{
|
||||||
EMsgManager::bindListenerWith(this, pParentScene);
|
EMsgManager::bindListenerWith(this, pParentScene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::EKeyboardListener::bindWithNode(ENode * pParentNode)
|
void e2d::EKeyboardListener::bindWith(ENode * pParentNode)
|
||||||
{
|
{
|
||||||
WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object.");
|
WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object.");
|
||||||
|
|
||||||
if (pParentNode != nullptr && m_pParentScene == nullptr)
|
if (pParentNode != nullptr && m_pParentScene == nullptr)
|
||||||
{
|
{
|
||||||
EMsgManager::bindListenerWith(this, pParentNode);
|
EMsgManager::bindListenerWith(this, pParentNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,8 +24,7 @@ e2d::EMouseClickListener::EMouseClickListener(EString name, const MOUSE_CLICK_LI
|
||||||
|
|
||||||
void e2d::EMouseClickListener::runCallback()
|
void e2d::EMouseClickListener::runCallback()
|
||||||
{
|
{
|
||||||
if (EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::LBUTTON_DOWN ||
|
if (EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::LBUTTON_UP)
|
||||||
EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::LBUTTON_DBLCLK)
|
|
||||||
{
|
{
|
||||||
m_callback(EMouseMsg::getPos());
|
m_callback(EMouseMsg::getPos());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,30 +4,22 @@
|
||||||
e2d::ENode::ENode()
|
e2d::ENode::ENode()
|
||||||
: m_nZOrder(0)
|
: m_nZOrder(0)
|
||||||
, m_bVisiable(true)
|
, m_bVisiable(true)
|
||||||
|
, m_pParent(nullptr)
|
||||||
|
, m_pParentScene(nullptr)
|
||||||
|
, m_nHashName(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ENode::ENode(EPoint p)
|
e2d::ENode::ENode(EString name)
|
||||||
: ENode()
|
: ENode()
|
||||||
{
|
{
|
||||||
setPos(p);
|
setName(name);
|
||||||
}
|
|
||||||
|
|
||||||
e2d::ENode::ENode(int x, int y)
|
|
||||||
: ENode()
|
|
||||||
{
|
|
||||||
setPos(x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::ENode::~ENode()
|
e2d::ENode::~ENode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::ENode::_exec(bool active)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::ENode::_onRender()
|
void e2d::ENode::_onRender()
|
||||||
{
|
{
|
||||||
D2D1_RECT_F rectangle = D2D1::RectF(
|
D2D1_RECT_F rectangle = D2D1::RectF(
|
||||||
|
|
@ -173,6 +165,19 @@ void e2d::ENode::setParent(ENode * parent)
|
||||||
m_pParent = parent;
|
m_pParent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void e2d::ENode::addChild(ENode * child)
|
||||||
|
{
|
||||||
|
WARN_IF(child == nullptr, "NULL ENode pointer exception.");
|
||||||
|
|
||||||
|
if (child)
|
||||||
|
{
|
||||||
|
for (ENode * parent = this; parent != nullptr; parent = parent->getParent())
|
||||||
|
{
|
||||||
|
ASSERT(child != parent, "A ENode cannot be the child of his own children");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e2d::ENode *& e2d::ENode::getParent()
|
e2d::ENode *& e2d::ENode::getParent()
|
||||||
{
|
{
|
||||||
return m_pParent;
|
return m_pParent;
|
||||||
|
|
@ -183,16 +188,68 @@ e2d::EScene * &e2d::ENode::getParentScene()
|
||||||
return m_pParentScene;
|
return m_pParentScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ENode::bindWithScene(EScene * scene)
|
std::vector<e2d::ENode*>& e2d::ENode::getChildren()
|
||||||
|
{
|
||||||
|
return m_vChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
int e2d::ENode::getChildrenCount() const
|
||||||
|
{
|
||||||
|
return m_vChildren.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::ENode * e2d::ENode::getChild(EString name)
|
||||||
|
{
|
||||||
|
WARN_IF(name.empty(), "Invalid ENode name.");
|
||||||
|
|
||||||
|
std::hash<EString> h;
|
||||||
|
size_t hash = h(name);
|
||||||
|
|
||||||
|
for (const auto& child : m_vChildren)
|
||||||
|
{
|
||||||
|
// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
|
||||||
|
if (child->m_nHashName == hash && child->m_sName == name)
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::ENode::setParentScene(EScene * scene)
|
||||||
{
|
{
|
||||||
m_pParentScene = scene;
|
m_pParentScene = scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void e2d::ENode::removeFromParent(bool release)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::ENode::removeChild(ENode * child, bool release)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::ENode::removeChild(EString childName, bool release)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void e2d::ENode::setVisiable(bool value)
|
void e2d::ENode::setVisiable(bool value)
|
||||||
{
|
{
|
||||||
m_bVisiable = value;
|
m_bVisiable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void e2d::ENode::setName(EString name)
|
||||||
|
{
|
||||||
|
WARN_IF(name.empty(), "Invalid ENode name.");
|
||||||
|
|
||||||
|
if (!name.empty())
|
||||||
|
{
|
||||||
|
// 保存节点名
|
||||||
|
m_sName = name;
|
||||||
|
// 保存节点 Hash 名
|
||||||
|
std::hash<EString> h;
|
||||||
|
m_nHashName = h(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool e2d::ENode::isVisiable() const
|
bool e2d::ENode::isVisiable() const
|
||||||
{
|
{
|
||||||
return m_bVisiable;
|
return m_bVisiable;
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
// Windows Header Files:
|
// Windows Header Files:
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSERT_IF
|
#ifndef ASSERT_IF
|
||||||
#if defined( DEBUG ) || defined( _DEBUG )
|
#if defined( DEBUG ) || defined( _DEBUG )
|
||||||
#define ASSERT(b, m) do {if (!(b)) { fprintf(stderr, "Assert: " #m "\n"); abort(); }} while(0)
|
#define ASSERT(b, m) do {if (!(b)) { fprintf(stderr, "Assert: " #m "\n"); assert(b); }} while(0)
|
||||||
#else
|
#else
|
||||||
#define ASSERT(b, m) ((void)0)
|
#define ASSERT(b, m) ((void)0)
|
||||||
#endif //DEBUG || _DEBUG
|
#endif //DEBUG || _DEBUG
|
||||||
|
|
|
||||||
|
|
@ -183,12 +183,12 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
// 绑定监听器到场景
|
// 绑定监听器到场景
|
||||||
virtual void bindWithScene(
|
virtual void bindWith(
|
||||||
EScene * pParentScene
|
EScene * pParentScene
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
// 绑定监听器到节点
|
// 绑定监听器到节点
|
||||||
virtual void bindWithNode(
|
virtual void bindWith(
|
||||||
ENode * pParentNode
|
ENode * pParentNode
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
|
|
@ -232,12 +232,12 @@ public:
|
||||||
// 绑定监听器到场景
|
// 绑定监听器到场景
|
||||||
virtual void bindWith(
|
virtual void bindWith(
|
||||||
EScene * pParentScene
|
EScene * pParentScene
|
||||||
);
|
) override;
|
||||||
|
|
||||||
// 绑定监听器到节点
|
// 绑定监听器到节点
|
||||||
virtual void bindWith(
|
virtual void bindWith(
|
||||||
ENode * pParentNode
|
ENode * pParentNode
|
||||||
);
|
) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MOUSE_LISTENER_CALLBACK m_callback;
|
MOUSE_LISTENER_CALLBACK m_callback;
|
||||||
|
|
@ -341,14 +341,14 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
// 绑定监听器到场景
|
// 绑定监听器到场景
|
||||||
virtual void bindWithScene(
|
virtual void bindWith(
|
||||||
EScene * pParentScene
|
EScene * pParentScene
|
||||||
);
|
) override;
|
||||||
|
|
||||||
// 绑定监听器到节点
|
// 绑定监听器到节点
|
||||||
virtual void bindWithNode(
|
virtual void bindWith(
|
||||||
ENode * pParentNode
|
ENode * pParentNode
|
||||||
);
|
) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KEY_LISTENER_CALLBACK m_callback;
|
KEY_LISTENER_CALLBACK m_callback;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@
|
||||||
namespace e2d
|
namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
class EScene;
|
|
||||||
class EObject;
|
|
||||||
|
|
||||||
class ENode :
|
class ENode :
|
||||||
public EObject
|
public EObject
|
||||||
{
|
{
|
||||||
|
|
@ -16,12 +13,7 @@ public:
|
||||||
ENode();
|
ENode();
|
||||||
|
|
||||||
ENode(
|
ENode(
|
||||||
EPoint p
|
EString name
|
||||||
);
|
|
||||||
|
|
||||||
ENode(
|
|
||||||
int x,
|
|
||||||
int y
|
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~ENode();
|
virtual ~ENode();
|
||||||
|
|
@ -48,22 +40,34 @@ public:
|
||||||
virtual UINT32 getHeight() const;
|
virtual UINT32 getHeight() const;
|
||||||
|
|
||||||
// 获取节点大小
|
// 获取节点大小
|
||||||
virtual e2d::ESize getSize() const;
|
virtual ESize getSize() const;
|
||||||
|
|
||||||
// 获取节点所在的矩形
|
// 获取节点所在的矩形
|
||||||
virtual e2d::ERect getRect() const;
|
virtual ERect getRect() const;
|
||||||
|
|
||||||
// 获取父节点
|
// 获取父节点
|
||||||
virtual e2d::ENode* &getParent();
|
virtual ENode * &getParent();
|
||||||
|
|
||||||
// 获取节点所在场景
|
// 获取节点所在场景
|
||||||
EScene * &getParentScene();
|
virtual EScene * &getParentScene();
|
||||||
|
|
||||||
|
// 获取所有子节点
|
||||||
|
virtual std::vector<ENode*> &getChildren();
|
||||||
|
|
||||||
|
// 获取子节点数量
|
||||||
|
virtual int getChildrenCount() const;
|
||||||
|
|
||||||
|
// 根据名字获取子节点
|
||||||
|
virtual ENode * getChild(EString name);
|
||||||
|
|
||||||
// 设置节点是否显示
|
// 设置节点是否显示
|
||||||
virtual void setVisiable(
|
virtual void setVisiable(
|
||||||
bool value
|
bool value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 设置节点名称
|
||||||
|
virtual void setName(EString name);
|
||||||
|
|
||||||
// 设置节点横坐标
|
// 设置节点横坐标
|
||||||
virtual void setX(
|
virtual void setX(
|
||||||
int x
|
int x
|
||||||
|
|
@ -114,7 +118,7 @@ public:
|
||||||
|
|
||||||
// 设置节点大小
|
// 设置节点大小
|
||||||
virtual void setSize(
|
virtual void setSize(
|
||||||
e2d::ESize size
|
ESize size
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置节点所在的矩形
|
// 设置节点所在的矩形
|
||||||
|
|
@ -133,7 +137,7 @@ public:
|
||||||
|
|
||||||
// 设置节点所在的矩形
|
// 设置节点所在的矩形
|
||||||
virtual void setRect(
|
virtual void setRect(
|
||||||
e2d::ERect rect
|
ERect rect
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置节点绘图顺序(0为最先绘制,显示在最底层)
|
// 设置节点绘图顺序(0为最先绘制,显示在最底层)
|
||||||
|
|
@ -141,28 +145,41 @@ public:
|
||||||
int z
|
int z
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 设置节点所在场景
|
||||||
|
virtual void setParentScene(
|
||||||
|
EScene * scene
|
||||||
|
);
|
||||||
|
|
||||||
// 设置父节点
|
// 设置父节点
|
||||||
virtual void setParent(
|
virtual void setParent(
|
||||||
ENode* parent
|
ENode* parent
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置节点所在场景
|
// 添加子节点
|
||||||
void bindWithScene(
|
virtual void addChild(ENode * child);
|
||||||
EScene * scene
|
|
||||||
);
|
// 从父节点移除
|
||||||
|
virtual void removeFromParent(bool release = false);
|
||||||
|
|
||||||
|
// 移除子节点
|
||||||
|
virtual void removeChild(ENode * child, bool release = false);
|
||||||
|
|
||||||
|
// 移除子节点
|
||||||
|
virtual void removeChild(EString childName, bool release = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// 渲染节点
|
||||||
|
virtual void _onRender();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
EString m_sName;
|
||||||
|
size_t m_nHashName;
|
||||||
int m_nZOrder;
|
int m_nZOrder;
|
||||||
bool m_bVisiable;
|
bool m_bVisiable;
|
||||||
ERect m_Rect;
|
ERect m_Rect;
|
||||||
EScene * m_pParentScene;
|
EScene * m_pParentScene;
|
||||||
ENode * m_pParent;
|
ENode * m_pParent;
|
||||||
|
std::vector<ENode*> m_vChildren;
|
||||||
protected:
|
|
||||||
|
|
||||||
virtual bool _exec(bool active);
|
|
||||||
|
|
||||||
virtual void _onRender();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue