性能优化

This commit is contained in:
Nomango 2018-05-10 14:16:36 +08:00
parent 50825ba00d
commit 01882e73d4
8 changed files with 25 additions and 17 deletions

View File

@ -74,7 +74,7 @@ e2d::Node * e2d::Scene::getOne(const String& name) const
return _root->getChild(name); return _root->getChild(name);
} }
std::vector<e2d::Node*> e2d::Scene::getAll() const const std::vector<e2d::Node*>& e2d::Scene::getAll() const
{ {
return _root->getAllChildren(); return _root->getAllChildren();
} }

View File

@ -224,7 +224,7 @@ std::vector<e2d::Action*> e2d::ActionManager::get(const String& strActionName)
return std::move(actions); return std::move(actions);
} }
std::vector<e2d::Action*> e2d::ActionManager::getAll() const std::vector<e2d::Action*>& e2d::ActionManager::getAll()
{ {
return s_vActions; return s_vActions;
} }

View File

@ -89,3 +89,8 @@ bool e2d::Menu::removeButton(Button * button)
} }
return false; return false;
} }
const std::vector<e2d::Button*>& e2d::Menu::getAllButtons() const
{
return _buttons;
}

View File

@ -713,7 +713,7 @@ e2d::Node * e2d::Node::getChild(const String& name) const
return nullptr; return nullptr;
} }
std::vector<e2d::Node*> e2d::Node::getAllChildren() const const std::vector<e2d::Node*>& e2d::Node::getAllChildren() const
{ {
return _children; return _children;
} }

View File

@ -165,7 +165,7 @@ void e2d::Text::setText(const String& text)
_reset(); _reset();
} }
void e2d::Text::setTextStyle(TextStyle textStyle) void e2d::Text::setStyle(const TextStyle& textStyle)
{ {
_style = textStyle; _style = textStyle;
_reset(); _reset();
@ -209,11 +209,11 @@ void e2d::Text::setWrapping(bool wrapping)
} }
} }
void e2d::Text::setWrappingWidth(double fWrappingWidth) void e2d::Text::setWrappingWidth(double wrappingWidth)
{ {
if (_style.wrappingWidth != fWrappingWidth) if (_style.wrappingWidth != wrappingWidth)
{ {
_style.wrappingWidth = max(fWrappingWidth, 0); _style.wrappingWidth = max(wrappingWidth, 0);
if (_style.wrapping) if (_style.wrapping)
{ {
@ -222,11 +222,11 @@ void e2d::Text::setWrappingWidth(double fWrappingWidth)
} }
} }
void e2d::Text::setLineSpacing(double fLineSpacing) void e2d::Text::setLineSpacing(double lineSpacing)
{ {
if (_style.lineSpacing != fLineSpacing) if (_style.lineSpacing != lineSpacing)
{ {
_style.lineSpacing = fLineSpacing; _style.lineSpacing = lineSpacing;
_reset(); _reset();
} }
} }

View File

@ -872,7 +872,7 @@ public:
) const; ) const;
// 获取所有子节点 // 获取所有子节点
std::vector<Node*> getAll() const; const std::vector<Node*>& getAll() const;
// 获取根节点 // 获取根节点
Node * getRoot() const; Node * getRoot() const;

View File

@ -130,7 +130,7 @@ public:
); );
// 获取所有动作 // 获取所有动作
static std::vector<Action*> getAll(); static const std::vector<Action*>& getAll();
private: private:
// 更新动作状态 // 更新动作状态

View File

@ -133,7 +133,7 @@ public:
) const; ) const;
// 获取所有子节点 // 获取所有子节点
virtual std::vector<Node*> getAllChildren() const; virtual const std::vector<Node*>& getAllChildren() const;
// 获取子节点数量 // 获取子节点数量
virtual int getChildrenCount() const; virtual int getChildrenCount() const;
@ -649,8 +649,8 @@ public:
); );
// 设置文本样式 // 设置文本样式
void setTextStyle( void setStyle(
TextStyle pTextStyle const TextStyle& textStyle
); );
// 设置字体 // 设置字体
@ -685,12 +685,12 @@ public:
// 设置文本自动换行的宽度(默认为 0 // 设置文本自动换行的宽度(默认为 0
void setWrappingWidth( void setWrappingWidth(
double fWrappingWidth double wrappingWidth
); );
// 设置行间距(默认为 0 // 设置行间距(默认为 0
void setLineSpacing( void setLineSpacing(
double fLineSpacing double lineSpacing
); );
// 设置对齐方式(默认为 TextAlign::LEFT // 设置对齐方式(默认为 TextAlign::LEFT
@ -1000,6 +1000,9 @@ public:
Button * button Button * button
); );
// 获取所有按钮
const std::vector<Button*>& getAllButtons() const;
protected: protected:
bool _enable; bool _enable;
std::vector<Button*> _buttons; std::vector<Button*> _buttons;