16#ifndef AEONGUI_WINDOW_H
17#define AEONGUI_WINDOW_H
21#include <unordered_map>
24#include "aeongui/Canvas.hpp"
25#include "aeongui/dom/EventTarget.hpp"
26#include "aeongui/dom/USVString.hpp"
27#include "aeongui/dom/DOMString.hpp"
28#include "aeongui/dom/Location.hpp"
29#include "aeongui/dom/Document.hpp"
52 DLL
Window ( uint32_t aWidth, uint32_t aHeight );
80 DLL
void Update (
double aDeltaTime );
101 DLL
void HandleMouseMove (
double aX,
double aY,
unsigned short aButtons = 0,
102 bool aCtrlKey = false,
bool aShiftKey = false,
103 bool aAltKey = false,
bool aMetaKey = false );
115 unsigned short aButtons = 0,
116 bool aCtrlKey = false,
bool aShiftKey = false,
117 bool aAltKey = false,
bool aMetaKey = false );
128 DLL
void HandleMouseUp (
double aX,
double aY,
short aButton = 0,
129 unsigned short aButtons = 0,
130 bool aCtrlKey = false,
bool aShiftKey = false,
131 bool aAltKey = false,
bool aMetaKey = false );
142 DLL
void HandleKeyDown ( const DOMString& aKey, const DOMString& aCode,
143 unsigned long aLocation = 0,
bool aRepeat = false,
144 bool aCtrlKey = false,
bool aShiftKey = false,
145 bool aAltKey = false,
bool aMetaKey = false );
155 DLL
void HandleKeyUp ( const DOMString& aKey, const DOMString& aCode,
156 unsigned long aLocation = 0,
157 bool aCtrlKey = false,
bool aShiftKey = false,
158 bool aAltKey = false,
bool aMetaKey = false );
172 double aDeltaX,
double aDeltaY,
173 unsigned long aDeltaMode = 0,
174 unsigned short aButtons = 0,
175 bool aCtrlKey = false,
bool aShiftKey = false,
176 bool aAltKey = false,
bool aMetaKey = false );
180 Element* elementFromPoint (
double aX,
double aY ) const;
183 void AssignPickIds();
185 Element* mFocusedElement{
nullptr};
186 Element* mHoverElement{
nullptr};
187 Element* mActiveElement{
nullptr};
188 Location mLocation{std::bind ( &Window::OnLocationChanged,
this, std::placeholders::_1 ) };
189 Document mDocument{};
190 std::unique_ptr<Canvas> mCanvas;
191 std::array<Element*, 256> mPickElements{};
192 uint8_t mPickIdCounter{0};
194 std::unordered_map<const Element*, Canvas::PickBounds> mCachedBounds{};
Represents a DOM Document.
Definition Document.hpp:40
Base class for DOM elements.
Definition Element.hpp:46
Base class for objects that can receive DOM events.
Definition EventTarget.hpp:58
Represents the URL of the active document.
Definition Location.hpp:33
void HandleMouseDown(double aX, double aY, short aButton=0, unsigned short aButtons=0, bool aCtrlKey=false, bool aShiftKey=false, bool aAltKey=false, bool aMetaKey=false)
Handle a mouse button press event from the platform.
Definition Window.cpp:333
void HandleKeyUp(const DOMString &aKey, const DOMString &aCode, unsigned long aLocation=0, bool aCtrlKey=false, bool aShiftKey=false, bool aAltKey=false, bool aMetaKey=false)
Handle a keyboard key up event from the platform.
Definition Window.cpp:414
void HandleKeyDown(const DOMString &aKey, const DOMString &aCode, unsigned long aLocation=0, bool aRepeat=false, bool aCtrlKey=false, bool aShiftKey=false, bool aAltKey=false, bool aMetaKey=false)
Handle a keyboard key down event from the platform.
Definition Window.cpp:404
~Window() override final
Destructor.
size_t GetWidth() const
Get the window width in pixels.
Definition Window.cpp:92
Location & location() const
Get the Location object.
Definition Window.cpp:71
size_t GetHeight() const
Get the window height in pixels.
Definition Window.cpp:96
void HandleMouseUp(double aX, double aY, short aButton=0, unsigned short aButtons=0, bool aCtrlKey=false, bool aShiftKey=false, bool aAltKey=false, bool aMetaKey=false)
Handle a mouse button release event from the platform.
Definition Window.cpp:381
void Update(double aDeltaTime)
Advance animation time and update all animations.
Definition Window.cpp:243
void HandleWheel(double aX, double aY, double aDeltaX, double aDeltaY, unsigned long aDeltaMode=0, unsigned short aButtons=0, bool aCtrlKey=false, bool aShiftKey=false, bool aAltKey=false, bool aMetaKey=false)
Handle a wheel/scroll event from the platform.
Definition Window.cpp:424
const Document * document() const
Get the associated Document.
Definition Window.cpp:66
Window()
Default constructor. Creates an empty window.
Definition Window.cpp:46
size_t GetStride() const
Get the stride (bytes per row) of the pixel buffer.
Definition Window.cpp:100
void HandleMouseMove(double aX, double aY, unsigned short aButtons=0, bool aCtrlKey=false, bool aShiftKey=false, bool aAltKey=false, bool aMetaKey=false)
Handle a mouse move event from the platform.
Definition Window.cpp:254
bool Draw()
Render the current document to the internal canvas.
Definition Window.cpp:105
void ResizeViewport(uint32_t aWidth, uint32_t aHeight)
Resize the rendering viewport.
Definition Window.cpp:81
const uint8_t * GetPixels() const
Get a pointer to the rendered pixel data.
Definition Window.cpp:87