Sdk/Widget: Add Canvas system, mouse movement event for widgets (buttons react to hovering)
Former-commit-id: 685295853d1f0edf28c36b2f698eca881da25ea2 [formerly f65f951ed3d2edfd9c12d390837cd13e5691eaa3] [formerly 5e239f37c28bf5e93a71cba29a94f0de680a79a2 [formerly 38346fa5d68c7bf79ddebc1990959e7c56617640]] Former-commit-id: 92da4ed40fb63fe0b02c7543ea64cebda0575623 [formerly 2db1fe5fca87a1461ceb8314709d764af079a7be] Former-commit-id: 77d61a99fd5a2bb21701fbe4a4b4451c3655663a
This commit is contained in:
61
SDK/include/NDK/Canvas.hpp
Normal file
61
SDK/include/NDK/Canvas.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_CANVAS_HPP
|
||||
#define NDK_CANVAS_HPP
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API Canvas : public BaseWidget
|
||||
{
|
||||
friend BaseWidget;
|
||||
|
||||
public:
|
||||
struct Padding;
|
||||
|
||||
inline Canvas(WorldHandle world, Nz::EventHandler& eventHandler);
|
||||
Canvas(const Canvas&) = delete;
|
||||
Canvas(Canvas&&) = delete;
|
||||
~Canvas() = default;
|
||||
|
||||
inline const WorldHandle& GetWorld() const;
|
||||
|
||||
void ResizeToContent() override;
|
||||
|
||||
Canvas& operator=(const Canvas&) = delete;
|
||||
Canvas& operator=(Canvas&&) = delete;
|
||||
|
||||
protected:
|
||||
void Layout() override;
|
||||
|
||||
void NotifyWidgetUpdate(std::size_t index);
|
||||
std::size_t RegisterWidget(BaseWidget* widget);
|
||||
void UnregisterWidget(std::size_t index);
|
||||
|
||||
private:
|
||||
void OnMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event);
|
||||
|
||||
struct WidgetBox
|
||||
{
|
||||
BaseWidget* widget;
|
||||
Nz::Boxf box;
|
||||
};
|
||||
|
||||
NazaraSlot(Nz::EventHandler, OnMouseMoved, m_mouseMovedSlot);
|
||||
|
||||
std::vector<WidgetBox> m_widgetBoxes;
|
||||
BaseWidget* m_hoveredWidget;
|
||||
WorldHandle m_world;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Canvas.inl>
|
||||
|
||||
#endif // NDK_CANVAS_HPP
|
||||
Reference in New Issue
Block a user