azul3d / engine

Azul3D - A 3D game engine written in Go!
https://azul3d.org
Other
606 stars 54 forks source link

EventMask Groups & Better Event Names #130

Closed azul3d-bot closed 8 years ago

azul3d-bot commented 8 years ago

Issue by slimsag Friday Dec 26, 2014 at 17:07 GMT Originally opened as https://github.com/azul3d/gfx/issues/78


EventMask Groups

Today we have an event mask for each specific type of event that a window may generate. This is perfect because it lets users be notified only of the events that they will actually use (more efficient).

Many cases do not require such performance, however typing out the bitmasks is sometimes more tedious than it needs to be, for example:

    evMask := window.CursorMovedEvents
    evMask |= window.CursorEnterEvents
    evMask |= window.CursorExitEvents

versus just

    evMask := window.CursorEvents

This can apply to keyboard, mouse, and cursor events. It would require adding just three new EventMask constants CursorEvents MouseEvents and KeyboardEvents:

    CursorEvents = CursorMovedEvents|CursorEnterEvents|CursorExitEvents
    MouseEvents = MouseButtonEvents|MouseScrolledEvents
    KeyboardEvents = KeyboardButtonEvents|KeyboardTypedEvents

Note that there is already a MouseEvents constant, which would have to be renamed to a more correct form MouseButtonEvents, instead.

This is primarily renaming keyboard state event to keyboard button event, and mouse event to mouse button event.

Before After
window.MouseEvents window.MouseButtonEvents (proper)
mouse.Event mouse.ButtonEvent (proper)
window.KeyboardStateEvents window.KeyboardButtonEvents (matches MouseButtonEvents)
keyboard.StateEvent keyboard.ButtonEvent (matches mouse.ButtonEvent)
keyboard.TypedEvent keyboard.Typed (matches mouse.Scrolled)

Conclusion

I think this gives us better and more clear event names and easier selection of common event mask groups.

azul3d-bot commented 8 years ago

Comment by slimsag Friday Dec 26, 2014 at 17:09 GMT


Also see azul3d/mouse#5 and azul3d/keyboard#4

azul3d-bot commented 8 years ago

Fixed/merged as part of https://github.com/azul3d/engine/issues/1