Event data.
More...
#include <framework/event.h>
|
enum | Type : event_t {
NONE
, KEYPRESS
, KEYDOWN
, KEYUP
,
KEYCHAR
, CURSORPOS
, FRAME
, TICK
,
SELECTED
, LOOK_AT
, LAST_EVENT
} |
|
Event data.
Fill in the struct fields and then use Event::Post() to send it out to listeners.
◆ Type
Enumerator |
---|
NONE | |
KEYPRESS | |
KEYDOWN | |
KEYUP | |
KEYCHAR | |
CURSORPOS | |
FRAME | |
TICK | |
SELECTED | |
LOOK_AT | |
LAST_EVENT | |
◆ AddListener() [1/4]
◆ AddListener() [2/4]
◆ AddListener() [3/4]
◆ AddListener() [4/4]
◆ AllocateData() [1/3]
template<typename T >
static T * tram::Event::AllocateData |
( |
| ) |
|
|
inlinestatic |
◆ AllocateData() [2/3]
template<typename T >
static T * tram::Event::AllocateData |
( |
const T & |
data | ) |
|
|
inlinestatic |
◆ AllocateData() [3/3]
void * tram::Event::AllocateData |
( |
size_t |
ammount | ) |
|
|
static |
Allocates space for event data.
This allocation is useful for storing the additional data (Event::data pointer), for events, since all allocated space will be cleared once all events have been dispatched.
- Note
- Only store POD data types in the allocated memory. Either that, or prepare for memory leaks. Altough an IDE might complain that a value_t is not POD, you can ignore the warning. Overwriting a value_t shouldn't cause memory leaks.
◆ Dispatch()
void tram::Event::Dispatch |
( |
| ) |
|
|
static |
Dispatches events from the event queue.
◆ GetLast()
Returns the last event_t plus one.
Useful for iterating over all registered events, i.e. in a while (++event < Event::GetLast());
or a similar loop.
◆ GetName()
Returns the name that was associated with a given event_t.
◆ GetType()
Returns the event_t associated with a given name.
◆ Post()
void tram::Event::Post |
( |
const Event & |
event | ) |
|
|
static |
Adds an event to the event queue.
◆ Register()
event_t tram::Event::Register |
( |
const char * |
name | ) |
|
|
static |
Registers a new event type.
◆ RemoveListener()
void tram::Event::RemoveListener |
( |
listener_t |
listener_id | ) |
|
|
static |
union { ... } tram::Event::@38 |
◆ data
tram::Event::data = nullptr |
Pointer to arbitrary data.
Can be set to a nullptr. Some event types have specific data, e.g. structs or other types that they need their data pointers to be pointing to. For your own event types, you can use this pointer for whatever purpose you want. If uncertain, set this to a nullptr.
◆ data_int
◆ data_value
◆ poster
◆ subtype
Arbitrary event subtype.
Some event types have subtypes with specific semantics, but if you create your own event types, you can use the subtype field for anything.
◆ type
The documentation for this struct was generated from the following files:
- C:/Users/Poga/Desktop/painis/tram-sdk/src/framework/event.h
- C:/Users/Poga/Desktop/painis/tram-sdk/src/framework/event.cpp