mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-04 03:15:59 -04:00
Added comments and EventPolling header to master header
This commit is contained in:
parent
b470eae400
commit
40a5297f0e
@ -26,6 +26,32 @@
|
|||||||
|
|
||||||
namespace SDL2pp {
|
namespace SDL2pp {
|
||||||
namespace Event {
|
namespace Event {
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Polls and handles a single event
|
||||||
|
///
|
||||||
|
/// This function tries to poll a single event from the event
|
||||||
|
/// queue using SDL_PollEvent(). If an event was polled the
|
||||||
|
/// event handler is called using the retrieved SDL_Event as an
|
||||||
|
/// argument then this function returns true. If no event was
|
||||||
|
/// retrieved the event handler is not called and this function
|
||||||
|
/// returns false.
|
||||||
|
///
|
||||||
|
/// This function accepts the following as event handlers:
|
||||||
|
/// - Functors (lambdas, free functions, callable objects)
|
||||||
|
/// - Objects (Objects that have a HandleEvent(EventType) function)
|
||||||
|
///
|
||||||
|
/// \ingroup events
|
||||||
|
///
|
||||||
|
/// \headerfile SDL2pp/EventPolling.hh
|
||||||
|
///
|
||||||
|
/// \param[in] eventHandlers A list of event handlers that will handle the event
|
||||||
|
///
|
||||||
|
/// \returns True if an event was polled, false otherwise
|
||||||
|
///
|
||||||
|
/// \see https://wiki.libsdl.org/SDL_PollEvent
|
||||||
|
/// \see https://wiki.libsdl.org/CategoryEvents#Structures
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
template <typename... EventHandlers>
|
template <typename... EventHandlers>
|
||||||
bool PollEvent(EventHandlers&&... eventHandlers) {
|
bool PollEvent(EventHandlers&&... eventHandlers) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@ -33,12 +59,35 @@ namespace Event {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Private::DispatchEvent(event, eventHandlers...);
|
|
||||||
Private::DispatchEvent(event, eventHandlers...);
|
Private::DispatchEvent(event, eventHandlers...);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Polls and handles all the events from the event queue
|
||||||
|
///
|
||||||
|
/// This function calls SDL_PollEvent() until the event queue is empty.
|
||||||
|
/// Then for each event that was polled the event handler is called
|
||||||
|
/// using the polled event as an argument. This function returns the
|
||||||
|
/// amount of events that were polled.
|
||||||
|
///
|
||||||
|
/// This function accepts the following as event handlers:
|
||||||
|
/// - Functors (lambdas, free functions, callable objects)
|
||||||
|
/// - Objects (Objects that have a HandleEvent(EventType) function)
|
||||||
|
///
|
||||||
|
/// \ingroup events
|
||||||
|
///
|
||||||
|
/// \headerfile SDL2pp/EventPolling.hh
|
||||||
|
///
|
||||||
|
/// \param[in] eventHandlers A list of event handlers that will handle the polled event
|
||||||
|
///
|
||||||
|
/// \returns The amount of polled events (can be zero)
|
||||||
|
///
|
||||||
|
/// \see https://wiki.libsdl.org/SDL_PollEvent
|
||||||
|
/// \see https://wiki.libsdl.org/CategoryEvents#Structures
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
template <typename... EventHandlers>
|
template <typename... EventHandlers>
|
||||||
int PollAllEvents(EventHandlers&&... eventHandlers) {
|
int PollAllEvents(EventHandlers&&... eventHandlers) {
|
||||||
int result;
|
int result;
|
||||||
|
@ -97,6 +97,14 @@
|
|||||||
#include <SDL2pp/ContainerRWops.hh>
|
#include <SDL2pp/ContainerRWops.hh>
|
||||||
#include <SDL2pp/StreamRWops.hh>
|
#include <SDL2pp/StreamRWops.hh>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
/// \defgroup events Event handling
|
||||||
|
///
|
||||||
|
/// \brief Functions and classes to easily manage SDL events
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
#include <SDL2pp/EventPolling.hh>
|
||||||
|
|
||||||
#ifdef SDL2PP_WITH_TTF
|
#ifdef SDL2PP_WITH_TTF
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \defgroup ttf SDL_ttf
|
/// \defgroup ttf SDL_ttf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user