diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 76def4b1b..aa47446f3 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -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); diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index 1833a2224..d5a91a2ed 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -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; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index c627019ea..8bcf972d3 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -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)});