Sdk/BaseWidget: Add visibility control
This commit is contained in:
@@ -49,6 +49,8 @@ namespace Ndk
|
||||
inline const Nz::Vector2f& GetContentSize() const;
|
||||
inline Nz::Vector2f GetSize() const;
|
||||
|
||||
inline bool IsVisible() const;
|
||||
|
||||
void GrabKeyboard();
|
||||
|
||||
virtual void ResizeToContent() = 0;
|
||||
@@ -58,6 +60,8 @@ namespace Ndk
|
||||
inline void SetPadding(float left, float top, float right, float bottom);
|
||||
void SetSize(const Nz::Vector2f& size);
|
||||
|
||||
void Show(bool show = true);
|
||||
|
||||
BaseWidget& operator=(const BaseWidget&) = delete;
|
||||
BaseWidget& operator=(BaseWidget&&) = default;
|
||||
|
||||
@@ -104,6 +108,7 @@ namespace Ndk
|
||||
Nz::SpriteRef m_backgroundSprite;
|
||||
Nz::Vector2f m_contentSize;
|
||||
BaseWidget* m_widgetParent;
|
||||
bool m_visible;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Ndk
|
||||
m_backgroundColor(Nz::Color(230, 230, 230, 255)),
|
||||
m_canvas(nullptr),
|
||||
m_contentSize(50.f, 50.f),
|
||||
m_widgetParent(nullptr)
|
||||
m_widgetParent(nullptr),
|
||||
m_visible(true)
|
||||
{
|
||||
SetPadding(5.f, 5.f, 5.f, 5.f);
|
||||
}
|
||||
@@ -31,6 +32,7 @@ namespace Ndk
|
||||
|
||||
inline void BaseWidget::AddChild(std::unique_ptr<BaseWidget>&& widget)
|
||||
{
|
||||
widget->Show(m_visible);
|
||||
m_children.emplace_back(std::move(widget));
|
||||
}
|
||||
|
||||
@@ -68,6 +70,11 @@ namespace Ndk
|
||||
return Nz::Vector2f(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom);
|
||||
}
|
||||
|
||||
inline bool BaseWidget::IsVisible() const
|
||||
{
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
inline void BaseWidget::SetContentSize(const Nz::Vector2f& size)
|
||||
{
|
||||
NotifyParentResized(size);
|
||||
|
||||
Reference in New Issue
Block a user