SDK/BaseWidget: Add SetParent

This commit is contained in:
Lynix 2019-07-05 22:21:35 +02:00
parent c09b2d3747
commit 3bed2fb7fe
3 changed files with 23 additions and 0 deletions

View File

@ -270,6 +270,7 @@ Nazara Development Kit:
- Fixed possible crash when disabling BaseWidget background
- Added BaseWidget::OnMouseWheelMoved
- Added Entity::OnEntity[Disabled|Enabled] signals
- Added BaseWidget::SetParent
# 0.4:

View File

@ -81,6 +81,7 @@ namespace Ndk
void SetBackgroundColor(const Nz::Color& color);
void SetCursor(Nz::SystemCursor systemCursor);
void SetFocus();
void SetParent(BaseWidget* widget);
inline void SetFixedHeight(float fixedHeight);
inline void SetFixedSize(const Nz::Vector2f& fixedSize);

View File

@ -145,6 +145,27 @@ namespace Ndk
m_canvas->SetKeyboardOwner(m_canvasIndex);
}
void BaseWidget::SetParent(BaseWidget* widget)
{
Canvas* oldCanvas = m_canvas;
Canvas* newCanvas = widget->GetCanvas();
// Changing a widget canvas is a problem because of the canvas entities
NazaraAssert(oldCanvas == newCanvas, "Transferring a widget between canvas is not yet supported");
Node::SetParent(widget);
m_widgetParent = widget;
Layout();
}
void BaseWidget::SetRenderingRect(const Nz::Rectf& renderingRect)
{
m_renderingRect = renderingRect;
UpdatePositionAndSize();
}
void BaseWidget::Show(bool show)
{
if (m_visible != show)