Graphics/Widgets: Add support for scissoring

This commit is contained in:
Jérôme Leclercq
2021-12-01 20:26:33 +01:00
parent a483e16e15
commit 61779d1cad
21 changed files with 137 additions and 35 deletions

View File

@@ -382,12 +382,18 @@ namespace Nz
scissorRect = parentScissorRect;
}
/*Recti fullBounds(scissorRect);
scissorRect.y = GetCanvas()->GetSize().y - scissorRect.height - scissorRect.y; //< scissor rect is in screen coordinates
Recti fullBounds(scissorRect);
auto& registry = GetRegistry();
for (WidgetEntity& widgetEntity : m_entities)
{
const Ndk::EntityHandle& entity = widgetEntity.handle;
if (entity->HasComponent<GraphicsComponent>())
entity->GetComponent<GraphicsComponent>().SetScissorRect(fullBounds);
}*/
if (GraphicsComponent* gfx = registry.try_get<GraphicsComponent>(widgetEntity.handle))
{
for (const auto& renderable : gfx->GetRenderables())
renderable.renderable->UpdateScissorBox(fullBounds);
}
}
}
}

View File

@@ -19,6 +19,7 @@ namespace Nz
m_cursorController(cursorController)
{
m_canvas = this;
BaseWidget::m_registry = &m_registry;
m_widgetParent = nullptr;
SetBaseRenderLayer(initialRenderLayer);