Widgets: Fix manually hidden entities being incorrectly shown when widget itself is shown

This commit is contained in:
SirLynix
2023-08-24 07:54:33 +02:00
parent e145501568
commit 1b7a89213d
10 changed files with 63 additions and 45 deletions

View File

@@ -226,8 +226,8 @@ namespace Nz
m_cursorPositionBegin = NormalizeCursorPosition(fromPosition);
m_cursorPositionEnd = NormalizeCursorPosition(toPosition);
RefreshCursorColor();
RefreshCursorSize();
RefreshCursorColor();
}
}
@@ -251,8 +251,8 @@ namespace Nz
m_cursorPositionBegin = cursorPosition;
m_cursorPositionEnd = m_cursorPositionBegin;
RefreshCursorColor();
RefreshCursorSize();
RefreshCursorColor();
}
}

View File

@@ -8,6 +8,7 @@
#define NAZARA_WIDGETS_BASEWIDGET_HPP
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Graphics/Components/GraphicsComponent.hpp>
#include <Nazara/Platform/Mouse.hpp>
#include <Nazara/Platform/WindowEvent.hpp>
#include <Nazara/Utility/Node.hpp>
@@ -116,6 +117,7 @@ namespace Nz
virtual void Layout();
entt::entity CreateEntity();
entt::entity CreateGraphicsEntity(Node* parent = nullptr);
void DestroyEntity(entt::entity entity);
inline int GetBaseRenderLayer() const;
@@ -173,6 +175,9 @@ namespace Nz
struct WidgetEntity
{
entt::entity handle;
bool wasVisible;
NazaraSlot(GraphicsComponent, OnVisibilityUpdate, onVisibilityUpdate);
};
static constexpr std::size_t InvalidCanvasIndex = std::numeric_limits<std::size_t>::max();
@@ -193,6 +198,7 @@ namespace Nz
Vector2f m_preferredSize;
Vector2f m_size;
BaseWidget* m_parentWidget;
bool m_disableVisibilitySignal;
bool m_visible;
int m_baseRenderLayer;
int m_renderLayerCount;

View File

@@ -21,6 +21,7 @@ namespace Nz
m_preferredSize(-1),
m_size(50.f, 50.f),
m_parentWidget(nullptr),
m_disableVisibilitySignal(false),
m_visible(true),
m_baseRenderLayer(0),
m_renderLayerCount(1)

View File

@@ -85,7 +85,7 @@ namespace Nz
virtual ~BaseWidgetStyle();
inline entt::entity CreateEntity();
entt::entity CreateGraphicsEntity();
inline entt::entity CreateGraphicsEntity(Node* parent = nullptr);
inline void DestroyEntity(entt::entity entity);
template<typename T> T* GetOwnerWidget() const;

View File

@@ -26,6 +26,11 @@ namespace Nz
return m_widgetOwner->CreateEntity();
}
inline entt::entity BaseWidgetStyle::CreateGraphicsEntity(Node* parent)
{
return m_widgetOwner->CreateGraphicsEntity(parent);
}
inline void BaseWidgetStyle::DestroyEntity(entt::entity entity)
{
m_widgetOwner->DestroyEntity(entity);