Sdk/BaseWidget: Add a way to change background color
This commit is contained in:
parent
14e327c603
commit
5865679891
|
|
@ -43,6 +43,7 @@ namespace Ndk
|
|||
|
||||
//virtual BaseWidget* Clone() const = 0;
|
||||
|
||||
inline const Nz::Color& GetBackgroundColor() const;
|
||||
inline Canvas* GetCanvas();
|
||||
inline const Padding& GetPadding() const;
|
||||
inline const Nz::Vector2f& GetContentSize() const;
|
||||
|
|
@ -52,6 +53,7 @@ namespace Ndk
|
|||
|
||||
virtual void ResizeToContent() = 0;
|
||||
|
||||
void SetBackgroundColor(const Nz::Color& color);
|
||||
inline void SetContentSize(const Nz::Vector2f& size);
|
||||
inline void SetPadding(float left, float top, float right, float bottom);
|
||||
void SetSize(const Nz::Vector2f& size);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,11 @@ namespace Ndk
|
|||
SetPosition((parentSize.x - mySize.x) / 2.f, (parentSize.y - mySize.y) / 2.f);
|
||||
}
|
||||
|
||||
inline const Nz::Color& BaseWidget::GetBackgroundColor() const
|
||||
{
|
||||
return m_backgroundColor;
|
||||
}
|
||||
|
||||
inline Canvas* BaseWidget::GetCanvas()
|
||||
{
|
||||
return m_canvas;
|
||||
|
|
|
|||
|
|
@ -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)});
|
||||
|
|
|
|||
Loading…
Reference in New Issue