IWindowListener

Receiving commands from a window.

IMPORTANT The IWindow implementation should not call these callback without care. In particular, there are two sets of calls that are assumed will NOT be called concurrently.

Set 1: - onAnimate - key events - mouse events - onMouseCaptureCancelled MUST NOT be called concurrently.

Set 2: - onDraw - onResized - recomputeDirtyAreas <---- this particular set has birthed many data races - getDirtyRectangle MUST NOT be called concurrently.

Some IWindow implentation ensure that unicity through passing in an event queue, others like the X11 implementation have to use locks.

TODO: clarify this, additionally onDraw and onAnimate are NOT called concurrently, on purpose: https://github.com/AuburnSounds/Dplug/issues/453

Members

Functions

getDirtyRectangle
box2i getDirtyRectangle()
getMouseCursor
MouseCursor getMouseCursor()

Must be called to get the current mouse cursor state for the plugin

onAnimate
void onAnimate(double dt, double time)

Must be called periodically (ideally 60 times per second but this is not mandatory). time must refer to the window creation time. dt and time are expressed in seconds (not milliseconds).

onDraw
void onDraw(WindowPixelFormat pf)

Render the window in software in the buffer previously returned by onResized. At the end of this function, the whole buffer should be a valid, coherent UI.

onKeyDown
bool onKeyDown(Key key)

Called on keyboard press.

onKeyUp
bool onKeyUp(Key up)

Called on keyboard release.

onMouseCaptureCancelled
void onMouseCaptureCancelled()

Called whenever mouse capture was canceled (ALT + TAB, SetForegroundWindow...)

onMouseClick
bool onMouseClick(int x, int y, MouseButton mb, bool isDoubleClick, MouseState mstate)

Called on mouse click.

onMouseExitedWindow
void onMouseExitedWindow()

Called whenever mouse exited the window (but a capture could still be in action).

onMouseMove
void onMouseMove(int x, int y, int dx, int dy, MouseState mstate)

Called on mouse movement (might not be within the window)

onMouseRelease
bool onMouseRelease(int x, int y, MouseButton mb, MouseState mstate)

Called on mouse button release

onMouseWheel
bool onMouseWheel(int x, int y, int wheelDeltaX, int wheelDeltaY, MouseState mstate)

Called on mouse wheel movement

onResized
ImageRef!RGBA onResized(int width, int height)

The drawing area size has changed. Always called at least once before onDraw.

recomputeDirtyAreas
void recomputeDirtyAreas()

Recompute internally what needs be done for the next onDraw. This function MUST have been called before calling onDraw and getDirtyRectangle. This method exists to allow the Window to recompute these draw lists less. And because cache invalidation was easier on user code than internally in the UI. Important: once you've called recomputeDirtyAreas() you COMMIT to redraw the corresponding area given by getDirtyRectangle(). IMPORTANT: Two calls to recomputeDirtyAreas() will not yield the same area. VERY IMPORTANT: See the above note about concurrent calls.

Meta