Widgets/BaseWidget: Fix background position and render mask
This commit is contained in:
parent
2a8568f2ac
commit
1b271a29ef
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
inline void LabelWidget::UpdateText(const Nz::AbstractTextDrawer& drawer, float scale)
|
inline void LabelWidget::UpdateText(const AbstractTextDrawer& drawer, float scale)
|
||||||
{
|
{
|
||||||
m_textSprite->Update(drawer, scale);
|
m_textSprite->Update(drawer, scale);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,12 @@ namespace Nz
|
||||||
auto material = std::make_shared<Material>();
|
auto material = std::make_shared<Material>();
|
||||||
material->AddPass("ForwardPass", std::make_shared<MaterialPass>(BasicMaterial::GetSettings()));
|
material->AddPass("ForwardPass", std::make_shared<MaterialPass>(BasicMaterial::GetSettings()));
|
||||||
|
|
||||||
m_backgroundSprite = std::make_shared<Nz::Sprite>(std::move(material));
|
m_backgroundSprite = std::make_shared<Sprite>(std::move(material));
|
||||||
m_backgroundSprite->SetColor(m_backgroundColor);
|
m_backgroundSprite->SetColor(m_backgroundColor);
|
||||||
//m_backgroundSprite->SetMaterial(Nz::Material::New((m_backgroundColor.IsOpaque()) ? "Basic2D" : "Translucent2D")); //< TODO: Use a shared material instead of creating one everytime
|
//m_backgroundSprite->SetMaterial(Nz::Material::New((m_backgroundColor.IsOpaque()) ? "Basic2D" : "Translucent2D")); //< TODO: Use a shared material instead of creating one everytime
|
||||||
|
|
||||||
entt::entity backgroundEntity = CreateEntity();
|
entt::entity backgroundEntity = CreateEntity();
|
||||||
m_registry->emplace<GraphicsComponent>(backgroundEntity).AttachRenderable(m_backgroundSprite);
|
m_registry->emplace<GraphicsComponent>(backgroundEntity).AttachRenderable(m_backgroundSprite, GetCanvas()->GetRenderMask());
|
||||||
m_registry->emplace<NodeComponent>(backgroundEntity).SetParent(this);
|
m_registry->emplace<NodeComponent>(backgroundEntity).SetParent(this);
|
||||||
|
|
||||||
m_backgroundEntity = backgroundEntity;
|
m_backgroundEntity = backgroundEntity;
|
||||||
|
|
@ -242,7 +242,10 @@ namespace Nz
|
||||||
void BaseWidget::Layout()
|
void BaseWidget::Layout()
|
||||||
{
|
{
|
||||||
if (m_backgroundSprite)
|
if (m_backgroundSprite)
|
||||||
|
{
|
||||||
|
m_registry->get<NodeComponent>(*m_backgroundEntity).SetPosition(0.f, m_size.y);
|
||||||
m_backgroundSprite->SetSize({ m_size.x, m_size.y });
|
m_backgroundSprite->SetSize({ m_size.x, m_size.y });
|
||||||
|
}
|
||||||
|
|
||||||
UpdatePositionAndSize();
|
UpdatePositionAndSize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue