Sdk/Widgets: Add possibility to set cursor when mouse hover a widget

This commit is contained in:
Lynix
2017-01-20 20:03:00 +01:00
parent bb3f395319
commit cf286e0413
6 changed files with 48 additions and 14 deletions

View File

@@ -3,10 +3,12 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Canvas.hpp>
#include <Nazara/Utility/Cursor.hpp>
namespace Ndk
{
inline Canvas::Canvas(WorldHandle world, Nz::EventHandler& eventHandler) :
inline Canvas::Canvas(WorldHandle world, Nz::EventHandler& eventHandler, Nz::CursorControllerHandle cursorController) :
m_cursorController(cursorController),
m_hoveredWidget(nullptr),
m_keyboardOwner(nullptr),
m_world(std::move(world))
@@ -44,6 +46,25 @@ namespace Ndk
return m_world;
}
inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index)
{
WidgetBox& entry = m_widgetBoxes[index];
Nz::Vector3f pos = entry.widget->GetPosition();
Nz::Vector2f size = entry.widget->GetContentSize();
entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f);
}
inline void Canvas::NotifyWidgetCursorUpdate(std::size_t index)
{
WidgetBox& entry = m_widgetBoxes[index];
entry.cursor = entry.widget->GetCursor();
if (m_cursorController && m_hoveredWidget == &entry)
m_cursorController->UpdateCursor(Nz::Cursor::Get(entry.cursor));
}
inline void Ndk::Canvas::SetKeyboardOwner(BaseWidget* widget)
{
m_keyboardOwner = widget;