SDK/BaseWidget: Add Rendering rect
This commit is contained in:
parent
b214f48225
commit
7c045a50db
|
|
@ -272,6 +272,7 @@ Nazara Development Kit:
|
|||
- Added Entity::OnEntity[Disabled|Enabled] signals
|
||||
- Added BaseWidget::SetParent
|
||||
- BaseWidget::Show will no longer show entities disabled by the widget
|
||||
- BaseWidget now has a rendering rect property (allowing to tell a widget what part of it will be rendered)
|
||||
|
||||
# 0.4:
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace Ndk
|
|||
inline void CenterVertical();
|
||||
|
||||
void ClearFocus();
|
||||
inline void ClearRenderingRect();
|
||||
|
||||
void Destroy();
|
||||
|
||||
|
|
@ -66,6 +67,8 @@ namespace Ndk
|
|||
inline Nz::Vector2f GetPreferredSize() const;
|
||||
inline float GetPreferredWidth() const;
|
||||
|
||||
inline const Nz::Rectf& GetRenderingRect() const;
|
||||
|
||||
inline Nz::Vector2f GetSize() const;
|
||||
inline float GetWidth() const;
|
||||
inline std::size_t GetWidgetChildCount() const;
|
||||
|
|
@ -93,6 +96,8 @@ namespace Ndk
|
|||
inline void SetMinimumSize(const Nz::Vector2f& minimumSize);
|
||||
inline void SetMinimumWidth(float minimumWidth);
|
||||
|
||||
virtual void SetRenderingRect(const Nz::Rectf& renderingRect);
|
||||
|
||||
void Show(bool show = true);
|
||||
|
||||
BaseWidget& operator=(const BaseWidget&) = delete;
|
||||
|
|
@ -151,6 +156,7 @@ namespace Ndk
|
|||
EntityOwner m_backgroundEntity;
|
||||
WorldHandle m_world;
|
||||
Nz::Color m_backgroundColor;
|
||||
Nz::Rectf m_renderingRect;
|
||||
Nz::SpriteRef m_backgroundSprite;
|
||||
Nz::SystemCursor m_cursor;
|
||||
Nz::Vector2f m_maximumSize;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <NDK/BaseWidget.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Math/Algorithm.hpp>
|
||||
#include <limits>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
|
@ -12,6 +13,7 @@ namespace Ndk
|
|||
m_canvasIndex(InvalidCanvasIndex),
|
||||
m_canvas(nullptr),
|
||||
m_backgroundColor(Nz::Color(230, 230, 230, 255)),
|
||||
m_renderingRect(-std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()),
|
||||
m_cursor(Nz::SystemCursor_Default),
|
||||
m_size(50.f, 50.f),
|
||||
m_maximumSize(std::numeric_limits<float>::infinity()),
|
||||
|
|
@ -66,6 +68,11 @@ namespace Ndk
|
|||
SetPosition(GetPosition(Nz::CoordSys_Local).x, (parentSize.y - mySize.y) / 2.f);
|
||||
}
|
||||
|
||||
inline void BaseWidget::ClearRenderingRect()
|
||||
{
|
||||
SetRenderingRect(Nz::Rectf(-std::numeric_limits<float>::infinity(), -std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()));
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
inline void BaseWidget::ForEachWidgetChild(F iterator)
|
||||
{
|
||||
|
|
@ -145,6 +152,11 @@ namespace Ndk
|
|||
return m_preferredSize.x;
|
||||
}
|
||||
|
||||
inline const Nz::Rectf& BaseWidget::GetRenderingRect() const
|
||||
{
|
||||
return m_renderingRect;
|
||||
}
|
||||
|
||||
inline Nz::Vector2f BaseWidget::GetSize() const
|
||||
{
|
||||
return Nz::Vector2f(GetWidth(), GetHeight());
|
||||
|
|
|
|||
|
|
@ -336,7 +336,13 @@ namespace Ndk
|
|||
Nz::Vector2f widgetPos = Nz::Vector2f(GetPosition());
|
||||
Nz::Vector2f widgetSize = GetSize();
|
||||
|
||||
Nz::Recti fullBounds(Nz::Rectf(widgetPos.x, widgetPos.y, widgetSize.x, widgetSize.y));
|
||||
Nz::Rectf widgetRect(widgetPos.x, widgetPos.y, widgetSize.x, widgetSize.y);
|
||||
Nz::Rectf widgetRenderingRect(widgetPos.x + m_renderingRect.x, widgetPos.y + m_renderingRect.y, m_renderingRect.width, m_renderingRect.height);
|
||||
|
||||
Nz::Rectf widgetBounds;
|
||||
widgetRect.Intersect(widgetRenderingRect, &widgetBounds);
|
||||
|
||||
Nz::Recti fullBounds(widgetBounds);
|
||||
for (WidgetEntity& widgetEntity : m_entities)
|
||||
{
|
||||
const Ndk::EntityHandle& entity = widgetEntity.handle;
|
||||
|
|
|
|||
Loading…
Reference in New Issue