SDK/Widgets: Inherit parent rendering rect
This commit is contained in:
parent
369e21cafb
commit
9d88fcd649
|
|
@ -110,6 +110,8 @@ namespace Ndk
|
||||||
|
|
||||||
void InvalidateNode() override;
|
void InvalidateNode() override;
|
||||||
|
|
||||||
|
Nz::Rectf GetScissorRect() const;
|
||||||
|
|
||||||
virtual bool IsFocusable() const;
|
virtual bool IsFocusable() const;
|
||||||
virtual void OnFocusLost();
|
virtual void OnFocusLost();
|
||||||
virtual void OnFocusReceived();
|
virtual void OnFocusReceived();
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,8 @@ namespace Ndk
|
||||||
m_renderingRect = renderingRect;
|
m_renderingRect = renderingRect;
|
||||||
|
|
||||||
UpdatePositionAndSize();
|
UpdatePositionAndSize();
|
||||||
|
for (const auto& widgetPtr : m_children)
|
||||||
|
widgetPtr->UpdatePositionAndSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWidget::Show(bool show)
|
void BaseWidget::Show(bool show)
|
||||||
|
|
@ -244,6 +246,19 @@ namespace Ndk
|
||||||
UpdatePositionAndSize();
|
UpdatePositionAndSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Nz::Rectf BaseWidget::GetScissorRect() const
|
||||||
|
{
|
||||||
|
Nz::Vector2f widgetPos = Nz::Vector2f(GetPosition(Nz::CoordSys_Global));
|
||||||
|
Nz::Vector2f widgetSize = GetSize();
|
||||||
|
|
||||||
|
Nz::Rectf widgetRect(widgetPos.x, widgetPos.y, widgetSize.x, widgetSize.y);
|
||||||
|
Nz::Rectf widgetRenderingRect(widgetPos.x + m_renderingRect.x, widgetPos.y + m_renderingRect.y, m_renderingRect.width, m_renderingRect.height);
|
||||||
|
|
||||||
|
widgetRect.Intersect(widgetRenderingRect, &widgetRect);
|
||||||
|
|
||||||
|
return widgetRect;
|
||||||
|
}
|
||||||
|
|
||||||
bool BaseWidget::IsFocusable() const
|
bool BaseWidget::IsFocusable() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -336,16 +351,17 @@ namespace Ndk
|
||||||
if (IsRegisteredToCanvas())
|
if (IsRegisteredToCanvas())
|
||||||
m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex);
|
m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex);
|
||||||
|
|
||||||
Nz::Vector2f widgetPos = Nz::Vector2f(GetPosition(Nz::CoordSys_Global));
|
Nz::Rectf scissorRect = GetScissorRect();
|
||||||
Nz::Vector2f widgetSize = GetSize();
|
|
||||||
|
|
||||||
Nz::Rectf widgetRect(widgetPos.x, widgetPos.y, widgetSize.x, widgetSize.y);
|
if (m_widgetParent)
|
||||||
Nz::Rectf widgetRenderingRect(widgetPos.x + m_renderingRect.x, widgetPos.y + m_renderingRect.y, m_renderingRect.width, m_renderingRect.height);
|
{
|
||||||
|
Nz::Rectf parentScissorRect = m_widgetParent->GetScissorRect();
|
||||||
|
|
||||||
Nz::Rectf widgetBounds;
|
if (!scissorRect.Intersect(parentScissorRect, &scissorRect))
|
||||||
widgetRect.Intersect(widgetRenderingRect, &widgetBounds);
|
scissorRect = parentScissorRect;
|
||||||
|
}
|
||||||
|
|
||||||
Nz::Recti fullBounds(widgetBounds);
|
Nz::Recti fullBounds(scissorRect);
|
||||||
for (WidgetEntity& widgetEntity : m_entities)
|
for (WidgetEntity& widgetEntity : m_entities)
|
||||||
{
|
{
|
||||||
const Ndk::EntityHandle& entity = widgetEntity.handle;
|
const Ndk::EntityHandle& entity = widgetEntity.handle;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue