Widgets/Canvas: Improve mouse owner system

This commit is contained in:
Jérôme Leclercq
2021-11-30 12:40:19 +01:00
parent 86071eae88
commit b20897a2fb
3 changed files with 58 additions and 34 deletions

View File

@@ -42,6 +42,8 @@ namespace Nz
inline bool IsKeyboardOwner(std::size_t canvasIndex) const;
inline bool IsMouseOwner(std::size_t canvasIndex) const;
inline std::size_t GetMouseEventTarget() const;
inline void NotifyWidgetBoxUpdate(std::size_t index);
inline void NotifyWidgetCursorUpdate(std::size_t index);

View File

@@ -54,6 +54,14 @@ namespace Nz
return m_mouseOwner == canvasIndex;
}
inline std::size_t Canvas::GetMouseEventTarget() const
{
if (m_mouseOwner != InvalidCanvasIndex)
return m_mouseOwner;
else
return m_hoveredWidget;
}
inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index)
{
WidgetEntry& entry = m_widgetEntries[index];
@@ -89,10 +97,7 @@ namespace Nz
inline void Canvas::SetMouseOwner(std::size_t canvasIndex)
{
if (m_mouseOwner != canvasIndex)
{
m_mouseOwner = canvasIndex;
}
m_mouseOwner = canvasIndex;
}
}