Sdk/BaseWidget: Add a way to change background color

This commit is contained in:
Lynix
2017-01-15 12:11:59 +01:00
parent 14e327c603
commit 5865679891
3 changed files with 18 additions and 0 deletions

View File

@@ -61,6 +61,17 @@ namespace Ndk
}
}
void BaseWidget::SetBackgroundColor(const Nz::Color& color)
{
m_backgroundColor = color;
if (m_backgroundSprite)
{
m_backgroundSprite->SetColor(color);
m_backgroundSprite->GetMaterial()->Configure((color.IsOpaque()) ? "Basic2D" : "Translucent2D"); //< Our sprite has its own material (see EnableBackground)
}
}
void BaseWidget::SetSize(const Nz::Vector2f& size)
{
SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)});