Former-commit-id: 685295853d1f0edf28c36b2f698eca881da25ea2 [formerly f65f951ed3d2edfd9c12d390837cd13e5691eaa3] [formerly 5e239f37c28bf5e93a71cba29a94f0de680a79a2 [formerly 38346fa5d68c7bf79ddebc1990959e7c56617640]] Former-commit-id: 92da4ed40fb63fe0b02c7543ea64cebda0575623 [formerly 2db1fe5fca87a1461ceb8314709d764af079a7be] Former-commit-id: 77d61a99fd5a2bb21701fbe4a4b4451c3655663a
67 lines
1.4 KiB
C++
67 lines
1.4 KiB
C++
// Copyright (C) 2015 Jérôme Leclercq
|
|
// This file is part of the "Nazara Development Kit"
|
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
|
|
|
#include <NDK/BaseWidget.hpp>
|
|
#include <Nazara/Core/Error.hpp>
|
|
#include <Nazara/Math/Algorithm.hpp>
|
|
|
|
namespace Ndk
|
|
{
|
|
inline BaseWidget::BaseWidget() :
|
|
m_backgroundColor(Nz::Color(230, 230, 230, 255)),
|
|
m_canvas(nullptr),
|
|
m_contentSize(50.f, 50.f),
|
|
m_widgetParent(nullptr)
|
|
{
|
|
SetPadding(5.f, 5.f, 5.f, 5.f);
|
|
}
|
|
|
|
inline void BaseWidget::AddChild(std::unique_ptr<BaseWidget>&& widget)
|
|
{
|
|
m_children.emplace_back(std::move(widget));
|
|
}
|
|
|
|
inline Canvas* BaseWidget::GetCanvas()
|
|
{
|
|
return m_canvas;
|
|
}
|
|
|
|
inline const BaseWidget::Padding& BaseWidget::GetPadding() const
|
|
{
|
|
return m_padding;
|
|
}
|
|
|
|
inline const Nz::Vector2f& BaseWidget::GetContentSize() const
|
|
{
|
|
return m_contentSize;
|
|
}
|
|
|
|
inline Nz::Vector2f BaseWidget::GetSize() const
|
|
{
|
|
return Nz::Vector2f(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom);
|
|
}
|
|
|
|
inline void BaseWidget::SetContentSize(const Nz::Vector2f& size)
|
|
{
|
|
m_contentSize = size;
|
|
|
|
Layout();
|
|
}
|
|
|
|
inline void BaseWidget::SetPadding(float left, float top, float right, float bottom)
|
|
{
|
|
m_padding.left = left;
|
|
m_padding.top = top;
|
|
m_padding.bottom = bottom;
|
|
m_padding.right = right;
|
|
|
|
Layout();
|
|
}
|
|
|
|
inline void BaseWidget::UpdateCanvasIndex(std::size_t index)
|
|
{
|
|
m_canvasIndex = index;
|
|
}
|
|
}
|