Sdk/BaseWidget: Add CenterHorizontal and CenterVertical() methods
This commit is contained in:
@@ -38,6 +38,8 @@ namespace Ndk
|
|||||||
inline void AddChild(std::unique_ptr<BaseWidget>&& widget);
|
inline void AddChild(std::unique_ptr<BaseWidget>&& widget);
|
||||||
|
|
||||||
inline void Center();
|
inline void Center();
|
||||||
|
inline void CenterHorizontal();
|
||||||
|
inline void CenterVertical();
|
||||||
|
|
||||||
inline void Destroy();
|
inline void Destroy();
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,24 @@ namespace Ndk
|
|||||||
SetPosition((parentSize.x - mySize.x) / 2.f, (parentSize.y - mySize.y) / 2.f);
|
SetPosition((parentSize.x - mySize.x) / 2.f, (parentSize.y - mySize.y) / 2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void BaseWidget::CenterHorizontal()
|
||||||
|
{
|
||||||
|
NazaraAssert(m_widgetParent, "Widget has no parent");
|
||||||
|
|
||||||
|
Nz::Vector2f parentSize = m_widgetParent->GetSize();
|
||||||
|
Nz::Vector2f mySize = GetSize();
|
||||||
|
SetPosition((parentSize.x - mySize.x) / 2.f, GetPosition(Nz::CoordSys_Local).y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void BaseWidget::CenterVertical()
|
||||||
|
{
|
||||||
|
NazaraAssert(m_widgetParent, "Widget has no parent");
|
||||||
|
|
||||||
|
Nz::Vector2f parentSize = m_widgetParent->GetSize();
|
||||||
|
Nz::Vector2f mySize = GetSize();
|
||||||
|
SetPosition(GetPosition(Nz::CoordSys_Local).x, (parentSize.y - mySize.y) / 2.f);
|
||||||
|
}
|
||||||
|
|
||||||
inline const Nz::Color& BaseWidget::GetBackgroundColor() const
|
inline const Nz::Color& BaseWidget::GetBackgroundColor() const
|
||||||
{
|
{
|
||||||
return m_backgroundColor;
|
return m_backgroundColor;
|
||||||
|
|||||||
Reference in New Issue
Block a user