Unigine::EngineWindow Class
Header: | #include <UnigineWindowManager.h> |
This base class operates with engine windows: their components, relations with other windows, size, position, visual representation and other features.
When you create a window viewport or a window group, the engine window is created.
The image below demonstrates the window components that can be controlled by the EngineWindow class methods.
To create the engine window, use one of the EngineWindowViewportor EngineWindowGroupclass constructors. For example:
// create an engine window of the specified size with the specified name
EngineWindowViewportPtr window = EngineWindowViewport::create("New window", 580, 300);
Then, by using methods of the EngineWindow class, you can specify the window appearance (for example, set a title, an icon, change opacity, add borders, and so on), and properties (whether the window can be nested, or whether it can become a group), define its style (system or engine), change the window state (whether it is shown/hidden, minimized/maximized, focused, etc.), manage window intersections and events.
Setting Up Position and Size#
In UNIGINE, the window size and position coordinates are measured in both units and pixels:
- The size and position in units don't depend on the DPI scale and always remain the same. You can change the window and client area size via setSize and setClientSize , adjust the minimum and maximum size and set the window and client position via the corresponding methods. All of them work with units.
-
The size and position in pixels are calculated by multiplying the size in units by the current DPI scale. You can get it using one of the RenderSize-related methods/properties (e.g., getRenderSize , and so on). When the DPI scale is 100%, 1 unit corresponds to 1 pixel.
DPI scaling is applied only when the auto_dpi_scalingflag is enabled. You can check the current flag value via the console or by using WindowManager::isAutoDpiScaling .
To determine how the OS handles the DPI scale, specify the DPI awareness mode.
You should consider this information when resizing textures, calculating mouse intersections, etc. The window size and position should be set individually, depending on the situation.
- Use one of the toRenderSize or toUnitSize to convert the size.
- Use globalToLocalUnitPosition to transform the coordinates in pixels into units or localUnitToGlobalPosition to do the opposite.
In the following example, the positions of the window and client area (in units) change to the mouse cursor when you press the P or C respectively:
#include <UnigineEngine.h>
#include <UnigineLogic.h>
#include <UnigineWindowManager.h>
using namespace Unigine;
using namespace Math;
EngineWindowViewportPtr system_viewport;
int AppSystemLogic::init()
{
// create a separate window viewport
system_viewport = EngineWindowViewport::create("Separate System Viewport", 400, 350);
// specify an intial position
system_viewport->setPosition(ivec2(30, 30));
// render the window viewport
system_viewport->show();
return 1;
}
int AppSystemLogic::update()
{
// change the window position to the mouse cursor when pressing 'P'
if (Input::isKeyDown(Input::KEY_P))
{
if (system_viewport.isDeleted() == false)
system_viewport->setPosition(mouse_pos);
}
// change the client area position to the mouse cursor when pressing 'C'
if (Input::isKeyDown(Input::KEY_C))
{
if (system_viewport.isDeleted() == false)
system_viewport->setClientPosition(mouse_pos);
}
return 1;
}
Check also the WindowSandbox and WindowSize samples — they print the full information on the window size and DPI.
Adjusting Visual Representation#
The window visual representation includes all available window parameters such as title and title bar, icon, borders, opacity, and window style (the engine or system one).
Here are some window examples:
#include <UnigineEngine.h>
#include <UnigineLogic.h>
#include <UnigineWindowManager.h>
using namespace Unigine;
using namespace Math;
EngineWindowViewportPtr system_viewport;
EngineWindowViewportPtr system_viewport_borderless;
EngineWindowViewportPtr engine_viewport_borderless;
EngineWindowViewportPtr engine_viewport;
int AppSystemLogic::init()
{
// create a separate system viewport
system_viewport = EngineWindowViewport::create("Window", 200, 200);
// specify an intial position
system_viewport->setPosition(ivec2(30, 30));
// change the size
system_viewport->setSize(ivec2(400, 350));
// render the window viewport
system_viewport->show();
// create a separate system viewport with borders and title bar disabled
system_viewport_borderless = EngineWindowViewport::create(400, 350);
system_viewport_borderless->setPosition(ivec2(460, 30));
system_viewport_borderless->setSize(ivec2(400, 350));
// disable borders
system_viewport_borderless->setBordersEnabled(false);
// disable a title bar
system_viewport_borderless->setTitleBarEnabled(false);
system_viewport_borderless->show();
// create a separate engine viewport with no borders
engine_viewport_borderless = EngineWindowViewport::create("Window", 400, 350);
engine_viewport_borderless->setPosition(ivec2(460, 30));
engine_viewport_borderless->setEngineStyle(true);
engine_viewport_borderless->setSize(ivec2(400, 350));
// disable borders
engine_viewport_borderless->setBordersEnabled(false);
engine_viewport_borderless->show();
// create a separate engine viewport with borders
engine_viewport = EngineWindowViewport::create("Window", 400, 350);
engine_viewport->setPosition(ivec2(460, 30));
engine_viewport->setEngineStyle(true);
engine_viewport->setSize(ivec2(400, 350));
engine_viewport->show();
return 1;
}
A system-style window
|
A window (either system or engine style),
borders and title bar disabled |
An engine-style window, borders disabled
|
An engine-style window, borders enabled
|
The system and engine style windows have the same component layout except the sizing border: in the engine style, it is in the visual part of the window.
The ability to customize the window style makes it possible to create a standard set of window settings for different systems and frameworks.
Check the WindowVisual sample in UNIGINE SDK for more details.
Setting Up Order#
In the following example, the order of the window under the cursor changes when you press the specific button: T to make the window appear on top of all other windows, A to always render the window above the other windows.
#include "AppSystemLogic.h"
#include <UnigineEngine.h>
#include <UnigineLogic.h>
#include <UnigineWindowManager.h>
using namespace Unigine;
using namespace Math;
EngineWindowPtr current_window;
EngineWindowViewportPtr system_viewport;
EngineWindowViewportPtr system_viewport_borderless;
EngineWindowViewportPtr engine_viewport_borderless;
EngineWindowViewportPtr engine_viewport;
int AppSystemLogic::init()
{
// create a separate system viewport
system_viewport = EngineWindowViewport::create("Window", 200, 200);
// specify an intial position
system_viewport->setPosition(ivec2(30, 30));
// change the size
system_viewport->setSize(ivec2(400, 350));
// render the window viewport
system_viewport->show();
// create a separate system viewport with borders and title bar disabled
system_viewport_borderless = EngineWindowViewport::create(400, 350);
system_viewport_borderless->setPosition(ivec2(460, 30));
system_viewport_borderless->setSize(ivec2(400, 350));
// disable borders
system_viewport_borderless->setBordersEnabled(false);
// disable a title bar
system_viewport_borderless->setTitleBarEnabled(false);
system_viewport_borderless->show();
// create a separate engine viewport with no borders
engine_viewport_borderless = EngineWindowViewport::create("Window", 400, 350);
engine_viewport_borderless->setPosition(ivec2(460, 30));
engine_viewport_borderless->setEngineStyle(true);
engine_viewport_borderless->setSize(ivec2(400, 350));
// disable borders
engine_viewport_borderless->setBordersEnabled(false);
engine_viewport_borderless->show();
// create a separate engine viewport with borders
engine_viewport = EngineWindowViewport::create("Window", 400, 350);
engine_viewport->setPosition(ivec2(460, 30));
engine_viewport->setEngineStyle(true);
engine_viewport->setSize(ivec2(400, 350));
engine_viewport->show();
return 1;
}
int AppSystemLogic::update()
{
// get the current mouse position
ivec2 mouse_pos = Input::getMousePosition();
// make the window under the cursor appear on top when pressing 'T'
if (Input::isKeyDown(Input::KEY_T))
{
current_window = WindowManager::getUnderCursorWindow();
if (current_window.isDeleted() == false)
current_window->toTop();
}
// set the window under the cursor to be always on top when pressing 'A'
if (Input::isKeyDown(Input::KEY_A))
{
current_window = WindowManager::getUnderCursorWindow();
if (current_window.isDeleted() == false)
current_window->setAlwaysOnTop(true);
}
return 1;
}
Check the WindowOrder sample in UNIGINE SDK for more details.
Changing Behavior#
With the set of behavior-related functions, you can do the following:
- Force the engine to stop operating while the engine window is opened.
- Ignore or allow using the OS methods for windows closing.
- Specify whether the window is resizable.
- Specify the sizing border size.
- Control rendering of the engine window - show, hide, focus, minimize, maximize, restore, or close.
Check the WindowBehavior and WindowSandbox samples in UNIGINE SDK for more details.
Working with Modal Windows#
The following example demonstrates how to create modal windows and add modal children to the main window. Additionally, the main window includes a message that informs the user whether they can close the window or not.
#include "AppSystemLogic.h"
#include <UnigineEngine.h>
#include <UnigineLogic.h>
#include <UnigineWindowManager.h>
using namespace Unigine;
using namespace Math;
WidgetLabelPtr label;
EngineWindowViewportPtr main_window;
int AppSystemLogic::init()
{
// main window
main_window = WindowManager::getMainWindow();
main_window->setSize(ivec2(1600, 900));
main_window->setPosition(ivec2(30, 30));
main_window->setCanBeNested(false);
main_window->setCanCreateGroup(false);
// add an info label to the main window
label = WidgetLabel::create("");
label->setFontOutline(1);
label->setLifetime(Widget::LIFETIME_WINDOW);
label->setFontColor(vec4_red);
main_window->addChild(label, Gui::ALIGN_LEFT);
// first modal window of the main window
EngineWindowViewportPtr main_modal_0 = EngineWindowViewport::create("Modal for Main 0", 600, 650);
main_modal_0->setPosition(ivec2(50, 250));
main_modal_0->setCanBeNested(false);
main_modal_0->setCanCreateGroup(false);
main_modal_0->show();
main_modal_0->setModal(main_window);
// second modal window of the main window
EngineWindowViewportPtr main_modal_1 = EngineWindowViewport::create("Modal for Main 1", 900, 650);
main_modal_1->setPosition(ivec2(700, 250));
main_modal_1->setCanBeNested(false);
main_modal_1->setCanCreateGroup(false);
main_modal_1->show();
main_modal_1->setModal(main_window);
return 1;
}
int AppSystemLogic::update()
{
String text;
// check if the modal children of the main window are still opened
if (main_window->isModalParent())
text += "You CANNOT close this window. Please close modal children first.\n";
else
text += "You CAN close this window.\n";
// render the info label
label->setText(text);
return 1;
}
Check the WindowModal sample in UNIGINE SDK for more details.
See Also#
- A set of SDK samples (samples/Api/WindowManager) demonstrating various usage aspects.
EngineWindow Class
Перечисления (Enums)
HITTEST#
FLAGS#
AREA#
TYPE#
Имя | Описание |
---|---|
ENGINE_WINDOW = 0 | Engine window. |
ENGINE_WINDOW_VIEWPORT = 1 | Engine viewport window. |
ENGINE_WINDOW_GROUP = 2 | Engine window group. |
NUM_ENGINE_WINDOWS = 3 | Total number of engine windows. |
Members
Ptr<Gui> getGui() const#
Return value
Current Gui instance.int getDisplayIndex() const#
Return value
Current number of the display, on which the window is currently displayed.bool isNested() const#
Return value
true if this is a nested window or group of windows; otherwise false.bool isSeparate() const#
Return value
true if this is a separate window or group of windows is enabled; otherwise false.Ptr<Gui> getSelfGui() const#
Return value
Current Gui instance.void setPosition ( const Math::ivec2& position ) #
Arguments
- const Math::ivec2& position - The window screen position (coordinates of the top left corner).
Math::ivec2 getPosition() const#
Return value
Current window screen position (coordinates of the top left corner).void setClientPosition ( const Math::ivec2& position ) #
Arguments
- const Math::ivec2& position - The screen position of the client (coordinates of the top left corner).
Math::ivec2 getClientPosition() const#
Return value
Current screen position of the client (coordinates of the top left corner).Math::ivec2 getClientLocalPosition() const#
Return value
Current screen position of the client (coordinates of the top left corner) relative to the window position.void setSize ( const Math::ivec2& size ) #
Arguments
- const Math::ivec2& size - The engine window size in units (including the sizing border).
Math::ivec2 getSize() const#
Return value
Current engine window size in units (including the sizing border).void setClientSize ( const Math::ivec2& size ) #
Arguments
- const Math::ivec2& size - The
Math::ivec2 getClientSize() const#
Return value
Currentvoid setMinSize ( const Math::ivec2& size ) #
Arguments
- const Math::ivec2& size - The minimum possible size of the window.
Math::ivec2 getMinSize() const#
Return value
Current minimum possible size of the window.void setMaxSize ( const Math::ivec2& size ) #
Arguments
- const Math::ivec2& size - The maximum possible size of the window.
Math::ivec2 getMaxSize() const#
Return value
Current maximum possible size of the window.void setTitle ( const char * title ) #
Arguments
- const char * title - The title of the window.
const char * getTitle() const#
Return value
Current title of the window.void setOpacity ( float opacity ) #
Arguments
- float opacity - The opacity for the window.
float getOpacity() const#
Return value
Current opacity for the window.void setBordersEnabled ( bool enabled ) #
Arguments
- bool enabled - Set true to enable borders for the window; false - to disable it.
bool isBordersEnabled() const#
Return value
true if borders for the window is enabled; otherwise false.void setBorderSize ( int size ) #
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Arguments
- int size - The engine window border size.
int getBorderSize() const#
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Return value
Current engine window border size.void setResizable ( bool resizable ) #
Arguments
- bool resizable - Set true to enable the option of making the engine window resizable by the mouse; false - to disable it.
bool isResizable() const#
Return value
true if the option of making the engine window resizable by the mouse is enabled; otherwise false.bool isShown() const#
Return value
true if the engine window is rendered; otherwise false.bool isHidden() const#
Return value
true if the engine window isn't rendered; otherwise false.bool isFocused() const#
Return value
true if the engine window is in focus; otherwise false.bool isMinimized() const#
Return value
true if the engine window is minimized; otherwise false.bool isMaximized() const#
Return value
true if the engine window is maximized; otherwise false.int getOrder() const#
Return value
Current order of the window.Ptr<EngineWindowGroup> getParentGroup() const#
Return value
Current group into which the current window is nested, or nullptr if it is a separate window.Ptr<EngineWindowGroup> getGlobalParentGroup() const#
Return value
Current top group of the hierarchy into which the current window is nested, or nullptr if it is a separate window.int getNumDroppedItems() const#
Return value
Current number of dropped files and/or folders.int getNumModalWindows() const#
Return value
Current total number of modal windows.Ptr<EngineWindow> getModalParent() const#
Return value
Current modal parent of the window.bool isModalParent() const#
Return value
true if the window is parent for any modal window; otherwise false.bool isModal() const#
Return value
true if the window is modal; otherwise false.void setIgnoreSystemClose ( bool close ) #
Arguments
- bool close - Set true to enable ignoring OS methods for closing the window; false - to disable it.
bool isIgnoreSystemClose() const#
Return value
true if ignoring OS methods for closing the window is enabled; otherwise false.void setHoldEngine ( bool engine ) #
Arguments
- bool engine - Set true to enable the engine can't stop operating while this window is open; false - to disable it.
bool isHoldEngine() const#
Return value
true if the engine can't stop operating while this window is open; otherwise false.unsigned long long getID() const#
Return value
Current ID of the engine window, if the window is external.void setAlwaysOnTop ( bool top ) #
Arguments
- bool top - Set true to enable the window is always on top; false - to disable it.
bool isAlwaysOnTop() const#
Return value
true if the window is always on top; otherwise false.bool isHiddenByTab() const#
Return value
true if the window is overlapped by any other tab; otherwise false.void setCanCreateGroup ( bool group ) #
Arguments
- bool group - Set true to enable usage of the engine window as a group; false - to disable it.
bool isCanCreateGroup() const#
Return value
true if usage of the engine window as a group is enabled; otherwise false.void setCanBeNested ( bool nested ) #
Arguments
- bool nested - Set true to enable usage of the engine window as a nested window; false - to disable it.
bool isCanBeNested() const#
Return value
true if usage of the engine window as a nested window is enabled; otherwise false.bool isSystemFocused() const#
Return value
true if the engine window is in focus; otherwise false.void setSizingBorderSize ( int size ) #
- This method should not be applied to a system-style window with enabled borders, as the system settings cannot be changed (for an unmodified system-style window (i.e. with the enabled border size), the system value is applied).
- This method should not be applied to nested windows (it will return 0).
Arguments
- int size - The size of the border in the widget that is manipulated to resize the window, in pixels.
int getSizingBorderSize() const#
- This method should not be applied to a system-style window with enabled borders, as the system settings cannot be changed (for an unmodified system-style window (i.e. with the enabled border size), the system value is applied).
- This method should not be applied to nested windows (it will return 0).
Return value
Current size of the border in the widget that is manipulated to resize the window, in pixels.void setEngineStyle ( bool style ) #
Arguments
- bool style - Set true to enable the engine style for the engine window; false - to disable it.
bool isEngineStyle() const#
Return value
true if the engine style for the engine window is enabled; otherwise false.void setSystemStyle ( bool style ) #
Arguments
- bool style - Set true to enable the default system style for the engine window; false - to disable it.
bool isSystemStyle() const#
Return value
true if the default system style for the engine window is enabled; otherwise false.void setTitleBarHeight ( int height ) #
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method can be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Arguments
- int height - The engine window title bar height.
int getTitleBarHeight() const#
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method can be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Return value
Current engine window title bar height.void setTitleBarEnabled ( bool enabled ) #
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Arguments
- bool enabled - Set true to enable the title bar for the engine window; false - to disable it.
bool isTitleBarEnabled() const#
- This value is applied to the windows in the engine style only. For system-style windows system settings are applied.
- This method should be applied to a separate or parent window, using this method for a nested window is not allowed (it will return 0).
Return value
true if the title bar for the engine window is enabled; otherwise false.const char * getTypeName() const#
Return value
Current string representation of the engine window type.EngineWindow::TYPE getType() const#
Return value
Current type of the engine window.float getDpiScale() const#
Return value
Current DPI scale applied to the elements inside the window.int getDpi() const#
Return value
Current DPI level for the window.Math::ivec2 getMaxRenderSize() const#
Return value
Current maximum window size in pixels.Math::ivec2 getMinRenderSize() const#
Return value
Current minimum window size in pixels.Math::ivec2 getClientRenderSize() const#
Return value
Current client area size in pixels.Math::ivec2 getRenderSize() const#
Return value
Current engine window frame size in pixels.Event<> getEventUnstack() const#
Usage Example
// implement the Unstack event handler
void unstack_event_handler()
{
Log::message("\Handling Unstack event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections unstack_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventUnstack().connect(unstack_event_connections, unstack_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventUnstack().connect(unstack_event_connections, []() {
Log::message("\Handling Unstack event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
unstack_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection unstack_event_connection;
// subscribe to the Unstack event with a handler function keeping the connection
publisher->getEventUnstack().connect(unstack_event_connection, unstack_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
unstack_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
unstack_event_connection.setEnabled(true);
// ...
// remove subscription to the Unstack event via the connection
unstack_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Unstack event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Unstack event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventUnstack().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId unstack_handler_id;
// subscribe to the Unstack event with a lambda handler function and keeping connection ID
unstack_handler_id = publisher->getEventUnstack().connect(e_connections, []() {
Log::message("\Handling Unstack event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventUnstack().disconnect(unstack_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Unstack events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventUnstack().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventUnstack().setEnabled(true);
Return value
Event reference.Event<> getEventStack() const#
Usage Example
// implement the Stack event handler
void stack_event_handler()
{
Log::message("\Handling Stack event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections stack_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventStack().connect(stack_event_connections, stack_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventStack().connect(stack_event_connections, []() {
Log::message("\Handling Stack event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
stack_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection stack_event_connection;
// subscribe to the Stack event with a handler function keeping the connection
publisher->getEventStack().connect(stack_event_connection, stack_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
stack_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
stack_event_connection.setEnabled(true);
// ...
// remove subscription to the Stack event via the connection
stack_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Stack event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Stack event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventStack().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId stack_handler_id;
// subscribe to the Stack event with a lambda handler function and keeping connection ID
stack_handler_id = publisher->getEventStack().connect(e_connections, []() {
Log::message("\Handling Stack event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventStack().disconnect(stack_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Stack events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventStack().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventStack().setEnabled(true);
Return value
Event reference.Event<const Ptr<EngineWindow> &> getEventUnstackMove() const#
Usage Example
// implement the UnstackMove event handler
void unstackmove_event_handler(const Ptr<EngineWindow> & window)
{
Log::message("\Handling UnstackMove event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections unstackmove_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventUnstackMove().connect(unstackmove_event_connections, unstackmove_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventUnstackMove().connect(unstackmove_event_connections, [](const Ptr<EngineWindow> & window) {
Log::message("\Handling UnstackMove event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
unstackmove_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection unstackmove_event_connection;
// subscribe to the UnstackMove event with a handler function keeping the connection
publisher->getEventUnstackMove().connect(unstackmove_event_connection, unstackmove_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
unstackmove_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
unstackmove_event_connection.setEnabled(true);
// ...
// remove subscription to the UnstackMove event via the connection
unstackmove_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A UnstackMove event handler implemented as a class member
void event_handler(const Ptr<EngineWindow> & window)
{
Log::message("\Handling UnstackMove event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventUnstackMove().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId unstackmove_handler_id;
// subscribe to the UnstackMove event with a lambda handler function and keeping connection ID
unstackmove_handler_id = publisher->getEventUnstackMove().connect(e_connections, [](const Ptr<EngineWindow> & window) {
Log::message("\Handling UnstackMove event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventUnstackMove().disconnect(unstackmove_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all UnstackMove events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventUnstackMove().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventUnstackMove().setEnabled(true);
Return value
Event reference.Event<const char *> getEventItemDrop() const#
Usage Example
// implement the ItemDrop event handler
void itemdrop_event_handler(const char * item)
{
Log::message("\Handling ItemDrop event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections itemdrop_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventItemDrop().connect(itemdrop_event_connections, itemdrop_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventItemDrop().connect(itemdrop_event_connections, [](const char * item) {
Log::message("\Handling ItemDrop event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
itemdrop_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection itemdrop_event_connection;
// subscribe to the ItemDrop event with a handler function keeping the connection
publisher->getEventItemDrop().connect(itemdrop_event_connection, itemdrop_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
itemdrop_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
itemdrop_event_connection.setEnabled(true);
// ...
// remove subscription to the ItemDrop event via the connection
itemdrop_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A ItemDrop event handler implemented as a class member
void event_handler(const char * item)
{
Log::message("\Handling ItemDrop event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventItemDrop().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId itemdrop_handler_id;
// subscribe to the ItemDrop event with a lambda handler function and keeping connection ID
itemdrop_handler_id = publisher->getEventItemDrop().connect(e_connections, [](const char * item) {
Log::message("\Handling ItemDrop event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventItemDrop().disconnect(itemdrop_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all ItemDrop events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventItemDrop().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventItemDrop().setEnabled(true);
Return value
Event reference.Event<> getEventClose() const#
Usage Example
// implement the Close event handler
void close_event_handler()
{
Log::message("\Handling Close event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections close_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventClose().connect(close_event_connections, close_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventClose().connect(close_event_connections, []() {
Log::message("\Handling Close event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
close_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection close_event_connection;
// subscribe to the Close event with a handler function keeping the connection
publisher->getEventClose().connect(close_event_connection, close_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
close_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
close_event_connection.setEnabled(true);
// ...
// remove subscription to the Close event via the connection
close_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Close event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Close event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventClose().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId close_handler_id;
// subscribe to the Close event with a lambda handler function and keeping connection ID
close_handler_id = publisher->getEventClose().connect(e_connections, []() {
Log::message("\Handling Close event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventClose().disconnect(close_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Close events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventClose().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventClose().setEnabled(true);
Return value
Event reference.Event<> getEventRestored() const#
Usage Example
// implement the Restored event handler
void restored_event_handler()
{
Log::message("\Handling Restored event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections restored_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventRestored().connect(restored_event_connections, restored_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventRestored().connect(restored_event_connections, []() {
Log::message("\Handling Restored event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
restored_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection restored_event_connection;
// subscribe to the Restored event with a handler function keeping the connection
publisher->getEventRestored().connect(restored_event_connection, restored_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
restored_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
restored_event_connection.setEnabled(true);
// ...
// remove subscription to the Restored event via the connection
restored_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Restored event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Restored event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventRestored().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId restored_handler_id;
// subscribe to the Restored event with a lambda handler function and keeping connection ID
restored_handler_id = publisher->getEventRestored().connect(e_connections, []() {
Log::message("\Handling Restored event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventRestored().disconnect(restored_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Restored events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventRestored().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventRestored().setEnabled(true);
Return value
Event reference.Event<> getEventMaximized() const#
Usage Example
// implement the Maximized event handler
void maximized_event_handler()
{
Log::message("\Handling Maximized event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections maximized_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventMaximized().connect(maximized_event_connections, maximized_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventMaximized().connect(maximized_event_connections, []() {
Log::message("\Handling Maximized event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
maximized_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection maximized_event_connection;
// subscribe to the Maximized event with a handler function keeping the connection
publisher->getEventMaximized().connect(maximized_event_connection, maximized_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
maximized_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
maximized_event_connection.setEnabled(true);
// ...
// remove subscription to the Maximized event via the connection
maximized_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Maximized event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Maximized event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventMaximized().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId maximized_handler_id;
// subscribe to the Maximized event with a lambda handler function and keeping connection ID
maximized_handler_id = publisher->getEventMaximized().connect(e_connections, []() {
Log::message("\Handling Maximized event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventMaximized().disconnect(maximized_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Maximized events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventMaximized().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventMaximized().setEnabled(true);
Return value
Event reference.Event<> getEventMinimized() const#
Usage Example
// implement the Minimized event handler
void minimized_event_handler()
{
Log::message("\Handling Minimized event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections minimized_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventMinimized().connect(minimized_event_connections, minimized_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventMinimized().connect(minimized_event_connections, []() {
Log::message("\Handling Minimized event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
minimized_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection minimized_event_connection;
// subscribe to the Minimized event with a handler function keeping the connection
publisher->getEventMinimized().connect(minimized_event_connection, minimized_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
minimized_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
minimized_event_connection.setEnabled(true);
// ...
// remove subscription to the Minimized event via the connection
minimized_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Minimized event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Minimized event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventMinimized().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId minimized_handler_id;
// subscribe to the Minimized event with a lambda handler function and keeping connection ID
minimized_handler_id = publisher->getEventMinimized().connect(e_connections, []() {
Log::message("\Handling Minimized event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventMinimized().disconnect(minimized_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Minimized events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventMinimized().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventMinimized().setEnabled(true);
Return value
Event reference.Event<> getEventHidden() const#
Usage Example
// implement the Hidden event handler
void hidden_event_handler()
{
Log::message("\Handling Hidden event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections hidden_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventHidden().connect(hidden_event_connections, hidden_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventHidden().connect(hidden_event_connections, []() {
Log::message("\Handling Hidden event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
hidden_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection hidden_event_connection;
// subscribe to the Hidden event with a handler function keeping the connection
publisher->getEventHidden().connect(hidden_event_connection, hidden_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
hidden_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
hidden_event_connection.setEnabled(true);
// ...
// remove subscription to the Hidden event via the connection
hidden_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Hidden event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Hidden event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventHidden().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId hidden_handler_id;
// subscribe to the Hidden event with a lambda handler function and keeping connection ID
hidden_handler_id = publisher->getEventHidden().connect(e_connections, []() {
Log::message("\Handling Hidden event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventHidden().disconnect(hidden_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Hidden events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventHidden().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventHidden().setEnabled(true);
Return value
Event reference.Event<> getEventShown() const#
Usage Example
// implement the Shown event handler
void shown_event_handler()
{
Log::message("\Handling Shown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections shown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventShown().connect(shown_event_connections, shown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventShown().connect(shown_event_connections, []() {
Log::message("\Handling Shown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
shown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection shown_event_connection;
// subscribe to the Shown event with a handler function keeping the connection
publisher->getEventShown().connect(shown_event_connection, shown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
shown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
shown_event_connection.setEnabled(true);
// ...
// remove subscription to the Shown event via the connection
shown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Shown event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Shown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventShown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId shown_handler_id;
// subscribe to the Shown event with a lambda handler function and keeping connection ID
shown_handler_id = publisher->getEventShown().connect(e_connections, []() {
Log::message("\Handling Shown event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventShown().disconnect(shown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Shown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventShown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventShown().setEnabled(true);
Return value
Event reference.Event<> getEventMouseLeave() const#
Usage Example
// implement the MouseLeave event handler
void mouseleave_event_handler()
{
Log::message("\Handling MouseLeave event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mouseleave_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventMouseLeave().connect(mouseleave_event_connections, mouseleave_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventMouseLeave().connect(mouseleave_event_connections, []() {
Log::message("\Handling MouseLeave event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mouseleave_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mouseleave_event_connection;
// subscribe to the MouseLeave event with a handler function keeping the connection
publisher->getEventMouseLeave().connect(mouseleave_event_connection, mouseleave_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mouseleave_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mouseleave_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseLeave event via the connection
mouseleave_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseLeave event handler implemented as a class member
void event_handler()
{
Log::message("\Handling MouseLeave event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventMouseLeave().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId mouseleave_handler_id;
// subscribe to the MouseLeave event with a lambda handler function and keeping connection ID
mouseleave_handler_id = publisher->getEventMouseLeave().connect(e_connections, []() {
Log::message("\Handling MouseLeave event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventMouseLeave().disconnect(mouseleave_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all MouseLeave events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventMouseLeave().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventMouseLeave().setEnabled(true);
Return value
Event reference.Event<> getEventMouseEnter() const#
Usage Example
// implement the MouseEnter event handler
void mouseenter_event_handler()
{
Log::message("\Handling MouseEnter event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections mouseenter_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventMouseEnter().connect(mouseenter_event_connections, mouseenter_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventMouseEnter().connect(mouseenter_event_connections, []() {
Log::message("\Handling MouseEnter event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
mouseenter_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection mouseenter_event_connection;
// subscribe to the MouseEnter event with a handler function keeping the connection
publisher->getEventMouseEnter().connect(mouseenter_event_connection, mouseenter_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
mouseenter_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
mouseenter_event_connection.setEnabled(true);
// ...
// remove subscription to the MouseEnter event via the connection
mouseenter_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A MouseEnter event handler implemented as a class member
void event_handler()
{
Log::message("\Handling MouseEnter event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventMouseEnter().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId mouseenter_handler_id;
// subscribe to the MouseEnter event with a lambda handler function and keeping connection ID
mouseenter_handler_id = publisher->getEventMouseEnter().connect(e_connections, []() {
Log::message("\Handling MouseEnter event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventMouseEnter().disconnect(mouseenter_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all MouseEnter events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventMouseEnter().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventMouseEnter().setEnabled(true);
Return value
Event reference.Event<> getEventUnfocused() const#
Usage Example
// implement the Unfocused event handler
void unfocused_event_handler()
{
Log::message("\Handling Unfocused event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections unfocused_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventUnfocused().connect(unfocused_event_connections, unfocused_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventUnfocused().connect(unfocused_event_connections, []() {
Log::message("\Handling Unfocused event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
unfocused_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection unfocused_event_connection;
// subscribe to the Unfocused event with a handler function keeping the connection
publisher->getEventUnfocused().connect(unfocused_event_connection, unfocused_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
unfocused_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
unfocused_event_connection.setEnabled(true);
// ...
// remove subscription to the Unfocused event via the connection
unfocused_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Unfocused event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Unfocused event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventUnfocused().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId unfocused_handler_id;
// subscribe to the Unfocused event with a lambda handler function and keeping connection ID
unfocused_handler_id = publisher->getEventUnfocused().connect(e_connections, []() {
Log::message("\Handling Unfocused event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventUnfocused().disconnect(unfocused_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Unfocused events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventUnfocused().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventUnfocused().setEnabled(true);
Return value
Event reference.Event<> getEventFocused() const#
Usage Example
// implement the Focused event handler
void focused_event_handler()
{
Log::message("\Handling Focused event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections focused_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFocused().connect(focused_event_connections, focused_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFocused().connect(focused_event_connections, []() {
Log::message("\Handling Focused event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
focused_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection focused_event_connection;
// subscribe to the Focused event with a handler function keeping the connection
publisher->getEventFocused().connect(focused_event_connection, focused_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
focused_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
focused_event_connection.setEnabled(true);
// ...
// remove subscription to the Focused event via the connection
focused_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Focused event handler implemented as a class member
void event_handler()
{
Log::message("\Handling Focused event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFocused().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId focused_handler_id;
// subscribe to the Focused event with a lambda handler function and keeping connection ID
focused_handler_id = publisher->getEventFocused().connect(e_connections, []() {
Log::message("\Handling Focused event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFocused().disconnect(focused_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Focused events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFocused().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFocused().setEnabled(true);
Return value
Event reference.Event<const Math::ivec2 &> getEventResized() const#
Usage Example
// implement the Resized event handler
void resized_event_handler(const Math::ivec2 & new_size)
{
Log::message("\Handling Resized event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections resized_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventResized().connect(resized_event_connections, resized_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventResized().connect(resized_event_connections, [](const Math::ivec2 & new_size) {
Log::message("\Handling Resized event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
resized_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection resized_event_connection;
// subscribe to the Resized event with a handler function keeping the connection
publisher->getEventResized().connect(resized_event_connection, resized_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
resized_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
resized_event_connection.setEnabled(true);
// ...
// remove subscription to the Resized event via the connection
resized_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Resized event handler implemented as a class member
void event_handler(const Math::ivec2 & new_size)
{
Log::message("\Handling Resized event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventResized().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId resized_handler_id;
// subscribe to the Resized event with a lambda handler function and keeping connection ID
resized_handler_id = publisher->getEventResized().connect(e_connections, [](const Math::ivec2 & new_size) {
Log::message("\Handling Resized event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventResized().disconnect(resized_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Resized events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventResized().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventResized().setEnabled(true);
Return value
Event reference.Event<const Math::ivec2 &> getEventMoved() const#
Usage Example
// implement the Moved event handler
void moved_event_handler(const Math::ivec2 & new_coords)
{
Log::message("\Handling Moved event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections moved_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventMoved().connect(moved_event_connections, moved_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventMoved().connect(moved_event_connections, [](const Math::ivec2 & new_coords) {
Log::message("\Handling Moved event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
moved_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection moved_event_connection;
// subscribe to the Moved event with a handler function keeping the connection
publisher->getEventMoved().connect(moved_event_connection, moved_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
moved_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
moved_event_connection.setEnabled(true);
// ...
// remove subscription to the Moved event via the connection
moved_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A Moved event handler implemented as a class member
void event_handler(const Math::ivec2 & new_coords)
{
Log::message("\Handling Moved event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventMoved().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId moved_handler_id;
// subscribe to the Moved event with a lambda handler function and keeping connection ID
moved_handler_id = publisher->getEventMoved().connect(e_connections, [](const Math::ivec2 & new_coords) {
Log::message("\Handling Moved event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventMoved().disconnect(moved_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all Moved events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventMoved().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventMoved().setEnabled(true);
Return value
Event reference.Event<> getEventFuncSwap() const#
Usage Example
// implement the FuncSwap event handler
void funcswap_event_handler()
{
Log::message("\Handling FuncSwap event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcswap_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncSwap().connect(funcswap_event_connections, funcswap_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncSwap().connect(funcswap_event_connections, []() {
Log::message("\Handling FuncSwap event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcswap_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcswap_event_connection;
// subscribe to the FuncSwap event with a handler function keeping the connection
publisher->getEventFuncSwap().connect(funcswap_event_connection, funcswap_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcswap_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcswap_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncSwap event via the connection
funcswap_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncSwap event handler implemented as a class member
void event_handler()
{
Log::message("\Handling FuncSwap event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncSwap().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcswap_handler_id;
// subscribe to the FuncSwap event with a lambda handler function and keeping connection ID
funcswap_handler_id = publisher->getEventFuncSwap().connect(e_connections, []() {
Log::message("\Handling FuncSwap event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncSwap().disconnect(funcswap_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncSwap events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncSwap().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncSwap().setEnabled(true);
Return value
Event reference.Event<> getEventFuncEndRender() const#
Usage Example
// implement the FuncEndRender event handler
void funcendrender_event_handler()
{
Log::message("\Handling FuncEndRender event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcendrender_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncEndRender().connect(funcendrender_event_connections, funcendrender_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncEndRender().connect(funcendrender_event_connections, []() {
Log::message("\Handling FuncEndRender event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcendrender_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcendrender_event_connection;
// subscribe to the FuncEndRender event with a handler function keeping the connection
publisher->getEventFuncEndRender().connect(funcendrender_event_connection, funcendrender_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcendrender_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcendrender_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncEndRender event via the connection
funcendrender_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncEndRender event handler implemented as a class member
void event_handler()
{
Log::message("\Handling FuncEndRender event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncEndRender().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcendrender_handler_id;
// subscribe to the FuncEndRender event with a lambda handler function and keeping connection ID
funcendrender_handler_id = publisher->getEventFuncEndRender().connect(e_connections, []() {
Log::message("\Handling FuncEndRender event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncEndRender().disconnect(funcendrender_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncEndRender events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncEndRender().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncEndRender().setEnabled(true);
Return value
Event reference.Event<const Ptr<Gui> &> getEventFuncEndRenderGui() const#
Usage Example
// implement the FuncEndRenderGui event handler
void funcendrendergui_event_handler(const Ptr<Gui> & gui)
{
Log::message("\Handling FuncEndRenderGui event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcendrendergui_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncEndRenderGui().connect(funcendrendergui_event_connections, funcendrendergui_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncEndRenderGui().connect(funcendrendergui_event_connections, [](const Ptr<Gui> & gui) {
Log::message("\Handling FuncEndRenderGui event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcendrendergui_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcendrendergui_event_connection;
// subscribe to the FuncEndRenderGui event with a handler function keeping the connection
publisher->getEventFuncEndRenderGui().connect(funcendrendergui_event_connection, funcendrendergui_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcendrendergui_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcendrendergui_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncEndRenderGui event via the connection
funcendrendergui_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncEndRenderGui event handler implemented as a class member
void event_handler(const Ptr<Gui> & gui)
{
Log::message("\Handling FuncEndRenderGui event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncEndRenderGui().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcendrendergui_handler_id;
// subscribe to the FuncEndRenderGui event with a lambda handler function and keeping connection ID
funcendrendergui_handler_id = publisher->getEventFuncEndRenderGui().connect(e_connections, [](const Ptr<Gui> & gui) {
Log::message("\Handling FuncEndRenderGui event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncEndRenderGui().disconnect(funcendrendergui_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncEndRenderGui events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncEndRenderGui().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncEndRenderGui().setEnabled(true);
Return value
Event reference.Event<const Ptr<Gui> &> getEventFuncBeginRenderGui() const#
Usage Example
// implement the FuncBeginRenderGui event handler
void funcbeginrendergui_event_handler(const Ptr<Gui> & gui)
{
Log::message("\Handling FuncBeginRenderGui event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcbeginrendergui_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncBeginRenderGui().connect(funcbeginrendergui_event_connections, funcbeginrendergui_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncBeginRenderGui().connect(funcbeginrendergui_event_connections, [](const Ptr<Gui> & gui) {
Log::message("\Handling FuncBeginRenderGui event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcbeginrendergui_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcbeginrendergui_event_connection;
// subscribe to the FuncBeginRenderGui event with a handler function keeping the connection
publisher->getEventFuncBeginRenderGui().connect(funcbeginrendergui_event_connection, funcbeginrendergui_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcbeginrendergui_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcbeginrendergui_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncBeginRenderGui event via the connection
funcbeginrendergui_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncBeginRenderGui event handler implemented as a class member
void event_handler(const Ptr<Gui> & gui)
{
Log::message("\Handling FuncBeginRenderGui event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncBeginRenderGui().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcbeginrendergui_handler_id;
// subscribe to the FuncBeginRenderGui event with a lambda handler function and keeping connection ID
funcbeginrendergui_handler_id = publisher->getEventFuncBeginRenderGui().connect(e_connections, [](const Ptr<Gui> & gui) {
Log::message("\Handling FuncBeginRenderGui event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncBeginRenderGui().disconnect(funcbeginrendergui_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncBeginRenderGui events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncBeginRenderGui().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncBeginRenderGui().setEnabled(true);
Return value
Event reference.Event<> getEventFuncRender() const#
Usage Example
// implement the FuncRender event handler
void funcrender_event_handler()
{
Log::message("\Handling FuncRender event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcrender_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncRender().connect(funcrender_event_connections, funcrender_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncRender().connect(funcrender_event_connections, []() {
Log::message("\Handling FuncRender event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcrender_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcrender_event_connection;
// subscribe to the FuncRender event with a handler function keeping the connection
publisher->getEventFuncRender().connect(funcrender_event_connection, funcrender_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcrender_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcrender_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncRender event via the connection
funcrender_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncRender event handler implemented as a class member
void event_handler()
{
Log::message("\Handling FuncRender event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncRender().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcrender_handler_id;
// subscribe to the FuncRender event with a lambda handler function and keeping connection ID
funcrender_handler_id = publisher->getEventFuncRender().connect(e_connections, []() {
Log::message("\Handling FuncRender event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncRender().disconnect(funcrender_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncRender events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncRender().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncRender().setEnabled(true);
Return value
Event reference.Event<> getEventFuncBeginRender() const#
Usage Example
// implement the FuncBeginRender event handler
void funcbeginrender_event_handler()
{
Log::message("\Handling FuncBeginRender event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcbeginrender_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncBeginRender().connect(funcbeginrender_event_connections, funcbeginrender_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncBeginRender().connect(funcbeginrender_event_connections, []() {
Log::message("\Handling FuncBeginRender event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcbeginrender_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcbeginrender_event_connection;
// subscribe to the FuncBeginRender event with a handler function keeping the connection
publisher->getEventFuncBeginRender().connect(funcbeginrender_event_connection, funcbeginrender_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcbeginrender_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcbeginrender_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncBeginRender event via the connection
funcbeginrender_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncBeginRender event handler implemented as a class member
void event_handler()
{
Log::message("\Handling FuncBeginRender event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncBeginRender().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcbeginrender_handler_id;
// subscribe to the FuncBeginRender event with a lambda handler function and keeping connection ID
funcbeginrender_handler_id = publisher->getEventFuncBeginRender().connect(e_connections, []() {
Log::message("\Handling FuncBeginRender event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncBeginRender().disconnect(funcbeginrender_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncBeginRender events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncBeginRender().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncBeginRender().setEnabled(true);
Return value
Event reference.Event<> getEventFuncUpdate() const#
Usage Example
// implement the FuncUpdate event handler
void funcupdate_event_handler()
{
Log::message("\Handling FuncUpdate event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections funcupdate_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventFuncUpdate().connect(funcupdate_event_connections, funcupdate_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventFuncUpdate().connect(funcupdate_event_connections, []() {
Log::message("\Handling FuncUpdate event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
funcupdate_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection funcupdate_event_connection;
// subscribe to the FuncUpdate event with a handler function keeping the connection
publisher->getEventFuncUpdate().connect(funcupdate_event_connection, funcupdate_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
funcupdate_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
funcupdate_event_connection.setEnabled(true);
// ...
// remove subscription to the FuncUpdate event via the connection
funcupdate_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A FuncUpdate event handler implemented as a class member
void event_handler()
{
Log::message("\Handling FuncUpdate event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventFuncUpdate().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId funcupdate_handler_id;
// subscribe to the FuncUpdate event with a lambda handler function and keeping connection ID
funcupdate_handler_id = publisher->getEventFuncUpdate().connect(e_connections, []() {
Log::message("\Handling FuncUpdate event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventFuncUpdate().disconnect(funcupdate_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all FuncUpdate events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventFuncUpdate().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventFuncUpdate().setEnabled(true);
Return value
Event reference.Event<const Ptr<WindowEvent> &> getEventWindowEvent() const#
Usage Example
// implement the WindowEvent event handler
void windowevent_event_handler(const Ptr<WindowEvent> & event)
{
Log::message("\Handling WindowEvent event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections windowevent_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventWindowEvent().connect(windowevent_event_connections, windowevent_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
publisher->getEventWindowEvent().connect(windowevent_event_connections, [](const Ptr<WindowEvent> & event) {
Log::message("\Handling WindowEvent event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
windowevent_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection windowevent_event_connection;
// subscribe to the WindowEvent event with a handler function keeping the connection
publisher->getEventWindowEvent().connect(windowevent_event_connection, windowevent_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
windowevent_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
windowevent_event_connection.setEnabled(true);
// ...
// remove subscription to the WindowEvent event via the connection
windowevent_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A WindowEvent event handler implemented as a class member
void event_handler(const Ptr<WindowEvent> & event)
{
Log::message("\Handling WindowEvent event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
publisher->getEventWindowEvent().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId windowevent_handler_id;
// subscribe to the WindowEvent event with a lambda handler function and keeping connection ID
windowevent_handler_id = publisher->getEventWindowEvent().connect(e_connections, [](const Ptr<WindowEvent> & event) {
Log::message("\Handling WindowEvent event (lambda).\n");
}
);
// remove the subscription later using the ID
publisher->getEventWindowEvent().disconnect(windowevent_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all WindowEvent events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
publisher->getEventWindowEvent().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
publisher->getEventWindowEvent().setEnabled(true);
Return value
Event reference.void moveToCenter ( ) #
Positions the window so that the client center coincides with the center of the current display.void setMinAndMaxSize ( const Math::ivec2 & min_size, const Math::ivec2 & max_size ) #
Sets the minimum and maximum possible window size when resizing the window.Arguments
- const Math::ivec2 & min_size - The minimum possible size of the window.
- const Math::ivec2 & max_size - The maximum possible size of the window.
int setIcon ( const Ptr<Image> & image ) #
Sets the icon for the window.Arguments
Return value
1 if the specified icon is successfully set for the window, otherwise 0.int getIcon ( ) const#
Returns the icon for the engine window.Return value
The icon for the window.1 if the icon for the window is returned successfully, otherwise 0.void show ( ) #
Enables rendering of the engine window.void hide ( ) #
Disables rendering of the engine window.void setFocus ( ) #
Sets the focus to the window.void setSystemFocus ( ) #
Sets the focus to the engine window.void minimize ( ) #
Minimizes the engine window to an iconic representation.void maximize ( ) #
Makes the engine window as large as possible.void restore ( ) #
Restores the size and position of the minimized or maximized engine window via the system proxy.EngineWindow::HITTEST getHitTestResult ( const Math::ivec2 & global_pos ) #
Returns a value indicating in which area of the engine window the mouse is located.Arguments
- const Math::ivec2 & global_pos - Global coordinates of the hit-test point.
Return value
Value indicating the window area, one of the HITTEST_* values.const char * getHitTestResultName ( EngineWindow::HITTEST hit_test ) const#
Returns the string representation of the hit test result value.Arguments
- EngineWindow::HITTEST hit_test - Value indicating the window area, one of the HITTEST_* values.
Return value
The string representation of the hit test result value (e.g., HITTEST_RESIZE_RIGHT is RESIZE RIGHT).void toTop ( ) #
Makes the window appear on top of all other windows.bool isGlobalChildOf ( const Ptr<EngineWindowGroup> & group ) #
Returns the value specifying if the current window is a part of a hierarchy of the specified window.Arguments
- const Ptr<EngineWindowGroup> & group - Window to be checked.
Return value
true if the current window is globally a child of the specified one, otherwise false.void updateGuiHierarchy ( ) #
Updates the hierarchy for all widgets — the widgets are arranged, expanded to the required sizes and then their positions are updated. Updating the hierarchy may be required, for example, for getting the screen position immediately after the widget has been added to the hierarchy. For a separate window, the hierarchy in self gui is updated; for a nested window, the hierarchy in self gui of the global parent group is updated.const char * getDroppedItem ( int index ) const#
Returns the absolute path to the file or folder dropped to the window.Arguments
- int index - Index of the dropped file or folder.
Return value
Absolute path to the dropped file or folder.void screenshot ( const char * path ) #
Creates a screenshot after the rendering stage is completed.Arguments
- const char * path - Path to save the screenshot.
void setModal ( const Ptr<EngineWindow> & parent_window ) #
Sets the current window modal to the specified parent window. Both the parent and the child windows must be separate. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- const Ptr<EngineWindow> & parent_window - Parent window.
void addModalWindow ( const Ptr<EngineWindow> & window ) #
Adds the argument window as modal to the current window. Both the parent and the child windows must be separate. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- const Ptr<EngineWindow> & window - Window to be added as modal.
void removeModalWindow ( const Ptr<EngineWindow> & window ) #
Removes the argument modal window from this window. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- const Ptr<EngineWindow> & window - Engine window.
Ptr<EngineWindow> getModalWindow ( int index ) const#
Returns the modal window for this window by its index. The concept of modal assumes that if a window has modal children, it cannot be closed. Any other interaction with a parent window is possible.Arguments
- int index - Index of the modal window.
Return value
Modal window.void unstack ( ) #
Removes the current window from a parent group.void close ( ) #
Deletes the window if this window is not a modal parent or a member of a fixed group. If a window is a member of a fixed group, it cannot be closed (i.e. deleted).bool getIntersection ( const Math::ivec2 & global_mouse_pos ) const#
Returns the value indicating if the mouse is hovering over the window.Arguments
- const Math::ivec2 & global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
true if the mouse hovers over the current window, otherwise false.bool getClientIntersection ( const Math::ivec2 & global_mouse_pos ) const#
Returns the value indicating if the mouse is hovering over the client area of the window.//checks if the mouse is hovering over the main window
WindowManager::getMainWindow()->getClientIntersection(Input::getMousePosition());
Arguments
- const Math::ivec2 & global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
true if the mouse hovers over the client area of the window, otherwise false.EngineWindow::AREA getClient9Area ( const Math::ivec2 & global_mouse_pos ) const#
Returns the area over which the mouse hovers, one of the nine areas into which the window is segmented.Arguments
- const Math::ivec2 & global_mouse_pos - Global screen coordinates of the mouse relative to the main display.
Return value
One of the nine segments the screen area is split into.const char * get9AreaName ( EngineWindow::AREA area ) const#
Returns the name of the screen segment as a string.Arguments
- EngineWindow::AREA area - One of the nine segments the screen area is split into.
Return value
The string representation of the segment value (e.g., AREA_TOP_LEFT is TOP LEFT).Math::ivec2 globalToLocalUnitPosition ( const Math::ivec2 & global_pos ) const#
Transforms the global screen coordinates in pixels into units relative to the window client area.Arguments
- const Math::ivec2 & global_pos - The position in global coordinates.
Return value
The coordinates in units relative to the window client area.Math::ivec2 localUnitToGlobalPosition ( const Math::ivec2 & unit_pos ) const#
Transforms the position in units relative to the window client area into the global screen coordinates in pixels.Arguments
- const Math::ivec2 & unit_pos - The coordinates in units relative to the window client area.
Return value
The position in global coordinates.int toRenderSize ( int unit_size ) #
Transforms the unit value to the pixel value.Arguments
- int unit_size - Size in units.
Return value
Size in pixels.int toUnitSize ( int render_size ) #
Transforms the pixel value to the unit value.Arguments
- int render_size - Size in pixels.
Return value
Size in units.Math::ivec2 toRenderSize ( const Math::ivec2 & unit_size ) #
Transforms the unit value to the pixel value.Arguments
- const Math::ivec2 & unit_size - Size in units.
Return value
Size in pixels.Math::ivec2 toUnitSize ( const Math::ivec2 & render_size ) #
Transforms the pixel value to the unit value.Arguments
- const Math::ivec2 & render_size - Size in pixels.