2013-09-20 22:23:13 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2022-07-09 01:23:11 +08:00
|
|
|
https://axis-project.github.io/
|
2013-09-20 22:23:13 +08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#ifndef __AX_EVENT_DISPATCHER_H__
|
|
|
|
#define __AX_EVENT_DISPATCHER_H__
|
2013-09-20 22:23:13 +08:00
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
2013-10-24 20:50:21 +08:00
|
|
|
#include <unordered_map>
|
2013-09-20 22:23:13 +08:00
|
|
|
#include <vector>
|
2014-08-29 15:39:52 +08:00
|
|
|
#include <set>
|
|
|
|
|
2014-09-10 08:17:07 +08:00
|
|
|
#include "platform/CCPlatformMacros.h"
|
2014-08-29 15:39:52 +08:00
|
|
|
#include "base/CCEventListener.h"
|
|
|
|
#include "base/CCEvent.h"
|
2014-09-10 07:50:02 +08:00
|
|
|
#include "platform/CCStdC.h"
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2015-03-24 18:22:52 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup base
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2013-09-20 22:23:13 +08:00
|
|
|
|
|
|
|
class Event;
|
|
|
|
class EventTouch;
|
|
|
|
class Node;
|
2013-12-21 16:56:28 +08:00
|
|
|
class EventCustom;
|
|
|
|
class EventListenerCustom;
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** @class EventDispatcher
|
|
|
|
* @brief This class manages event listener subscriptions
|
2013-09-20 22:23:13 +08:00
|
|
|
and event dispatching.
|
|
|
|
|
|
|
|
The EventListener list is managed in such a way that
|
|
|
|
event listeners can be added and removed even
|
|
|
|
from within an EventListener, while events are being
|
|
|
|
dispatched.
|
2015-03-24 16:37:09 +08:00
|
|
|
@js NA
|
2013-09-20 22:23:13 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
class AX_DLL EventDispatcher : public Ref
|
2013-09-20 22:23:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-23 18:39:27 +08:00
|
|
|
// Adds event listener.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-09-20 22:23:13 +08:00
|
|
|
/** Adds a event listener for a specified event with the priority of scene graph.
|
|
|
|
* @param listener The listener of a specified event.
|
|
|
|
* @param node The priority of the listener is based on the draw order of this node.
|
|
|
|
* @note The priority of scene graph will be fixed value 0. So the order of listener item
|
|
|
|
* in the vector will be ' <0, scene graph (0 priority), >0'.
|
|
|
|
*/
|
|
|
|
void addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node);
|
|
|
|
|
|
|
|
/** Adds a event listener for a specified event with the fixed priority.
|
|
|
|
* @param listener The listener of a specified event.
|
|
|
|
* @param fixedPriority The fixed priority of the listener.
|
|
|
|
* @note A lower priority will be called before the ones that have a higher value.
|
|
|
|
* 0 priority is forbidden for fixed priority since it's used for scene graph based priority.
|
|
|
|
*/
|
|
|
|
void addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority);
|
|
|
|
|
2013-12-21 16:56:28 +08:00
|
|
|
/** Adds a Custom event listener.
|
|
|
|
It will use a fixed priority of 1.
|
2015-03-23 18:39:27 +08:00
|
|
|
* @param eventName A given name of the event.
|
|
|
|
* @param callback A given callback method that associated the event name.
|
2015-09-22 16:08:23 +08:00
|
|
|
* @return the generated event. Needed in order to remove the event from the dispatcher
|
2013-12-21 16:56:28 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
EventListenerCustom* addCustomEventListener(std::string_view eventName,
|
2021-12-25 10:04:45 +08:00
|
|
|
const std::function<void(EventCustom*)>& callback);
|
2013-12-21 16:56:28 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
/////////////////////////////////////////////
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
// Removes event listener
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Remove a listener.
|
|
|
|
*
|
2013-09-20 22:23:13 +08:00
|
|
|
* @param listener The specified event listener which needs to be removed.
|
|
|
|
*/
|
|
|
|
void removeEventListener(EventListener* listener);
|
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Removes all listeners with the same event listener type.
|
|
|
|
*
|
|
|
|
* @param listenerType A given event listener type which needs to be removed.
|
|
|
|
*/
|
2014-03-02 15:54:36 +08:00
|
|
|
void removeEventListenersForType(EventListener::Type listenerType);
|
2013-12-22 02:55:16 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Removes all listeners which are associated with the specified target.
|
|
|
|
*
|
|
|
|
* @param target A given target node.
|
|
|
|
* @param recursive True if remove recursively, the default value is false.
|
|
|
|
*/
|
2014-03-02 15:54:36 +08:00
|
|
|
void removeEventListenersForTarget(Node* target, bool recursive = false);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Removes all custom listeners with the same event name.
|
|
|
|
*
|
|
|
|
* @param customEventName A given event listener name which needs to be removed.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void removeCustomEventListeners(std::string_view customEventName);
|
2013-12-22 02:55:16 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Removes all listeners.
|
|
|
|
*/
|
2013-10-25 16:34:26 +08:00
|
|
|
void removeAllEventListeners();
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
/////////////////////////////////////////////
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
// Pauses / Resumes event listener
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Pauses all listeners which are associated the specified target.
|
|
|
|
*
|
|
|
|
* @param target A given target node.
|
|
|
|
* @param recursive True if pause recursively, the default value is false.
|
|
|
|
*/
|
2014-03-02 15:54:36 +08:00
|
|
|
void pauseEventListenersForTarget(Node* target, bool recursive = false);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Resumes all listeners which are associated the specified target.
|
|
|
|
*
|
|
|
|
* @param target A given target node.
|
|
|
|
* @param recursive True if resume recursively, the default value is false.
|
|
|
|
*/
|
2014-03-02 15:54:36 +08:00
|
|
|
void resumeEventListenersForTarget(Node* target, bool recursive = false);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
/////////////////////////////////////////////
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Sets listener's priority with fixed value.
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2015-03-23 18:39:27 +08:00
|
|
|
* @param listener A given listener.
|
|
|
|
* @param fixedPriority The fixed priority value.
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void setPriority(EventListener* listener, int fixedPriority);
|
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Whether to enable dispatching events.
|
|
|
|
*
|
|
|
|
* @param isEnabled True if enable dispatching events.
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void setEnabled(bool isEnabled);
|
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Checks whether dispatching events is enabled.
|
|
|
|
*
|
|
|
|
* @return True if dispatching events is enabled.
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
bool isEnabled() const;
|
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
/////////////////////////////////////////////
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Dispatches the event.
|
2013-09-20 22:23:13 +08:00
|
|
|
* Also removes all EventListeners marked for deletion from the
|
|
|
|
* event dispatcher list.
|
2015-03-23 18:39:27 +08:00
|
|
|
*
|
|
|
|
* @param event The event needs to be dispatched.
|
2013-09-20 22:23:13 +08:00
|
|
|
*/
|
2013-10-23 11:27:24 +08:00
|
|
|
void dispatchEvent(Event* event);
|
2013-12-22 02:55:16 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Dispatches a Custom Event with a event name an optional user data.
|
|
|
|
*
|
|
|
|
* @param eventName The name of the event which needs to be dispatched.
|
|
|
|
* @param optionalUserData The optional user data, it's a void*, the default value is nullptr.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void dispatchCustomEvent(std::string_view eventName, void* optionalUserData = nullptr);
|
2013-12-22 02:55:16 +08:00
|
|
|
|
2016-12-14 09:27:47 +08:00
|
|
|
/** Query whether the specified event listener id has been added.
|
|
|
|
*
|
|
|
|
* @param listenerID The listenerID of the event listener id.
|
|
|
|
*
|
|
|
|
* @return True if dispatching events is exist
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool hasEventListener(std::string_view listenerID) const;
|
2016-12-14 09:27:47 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
/////////////////////////////////////////////
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Constructor of EventDispatcher.
|
|
|
|
*/
|
2013-10-29 14:57:16 +08:00
|
|
|
EventDispatcher();
|
2015-03-23 18:39:27 +08:00
|
|
|
/** Destructor of EventDispatcher.
|
|
|
|
*/
|
2013-10-29 14:57:16 +08:00
|
|
|
~EventDispatcher();
|
|
|
|
|
2022-07-16 10:43:05 +08:00
|
|
|
#if AX_NODE_DEBUG_VERIFY_EVENT_LISTENERS && AXIS_DEBUG > 0
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-27 04:12:44 +08:00
|
|
|
/**
|
|
|
|
* To help track down event listener issues in debug builds.
|
|
|
|
* Verifies that the node has no event listeners associated with it when destroyed.
|
|
|
|
*/
|
|
|
|
void debugCheckNodeHasNoEventListenersOnDestruction(Node* node);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-27 04:12:44 +08:00
|
|
|
#endif
|
|
|
|
|
2013-12-21 16:56:28 +08:00
|
|
|
protected:
|
2013-10-29 14:57:16 +08:00
|
|
|
friend class Node;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Sets the dirty flag for a node. */
|
2013-10-23 11:27:24 +08:00
|
|
|
void setDirtyForNode(Node* node);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/**
|
|
|
|
* The vector to store event listeners with scene graph based priority and fixed priority.
|
|
|
|
*/
|
2013-10-23 11:27:24 +08:00
|
|
|
class EventListenerVector
|
2013-10-21 17:22:42 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-10-23 11:27:24 +08:00
|
|
|
EventListenerVector();
|
|
|
|
~EventListenerVector();
|
2013-10-21 17:22:42 +08:00
|
|
|
size_t size() const;
|
|
|
|
bool empty() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-23 11:27:24 +08:00
|
|
|
void push_back(EventListener* item);
|
2013-10-24 17:27:22 +08:00
|
|
|
void clearSceneGraphListeners();
|
|
|
|
void clearFixedListeners();
|
2013-10-23 11:27:24 +08:00
|
|
|
void clear();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2016-09-12 09:44:21 +08:00
|
|
|
std::vector<EventListener*>* getFixedPriorityListeners() const { return _fixedListeners; }
|
|
|
|
std::vector<EventListener*>* getSceneGraphPriorityListeners() const { return _sceneGraphListeners; }
|
|
|
|
ssize_t getGt0Index() const { return _gt0Index; }
|
|
|
|
void setGt0Index(ssize_t index) { _gt0Index = index; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-21 17:22:42 +08:00
|
|
|
private:
|
2013-10-23 11:27:24 +08:00
|
|
|
std::vector<EventListener*>* _fixedListeners;
|
|
|
|
std::vector<EventListener*>* _sceneGraphListeners;
|
2013-12-12 14:15:08 +08:00
|
|
|
ssize_t _gt0Index;
|
2013-10-21 17:22:42 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-01-04 10:28:09 +08:00
|
|
|
/** Adds an event listener with item
|
|
|
|
* @note if it is dispatching event, the added operation will be delayed to the end of current dispatch
|
|
|
|
* @see forceAddEventListener
|
|
|
|
*/
|
2013-10-23 11:27:24 +08:00
|
|
|
void addEventListener(EventListener* listener);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-01-04 10:28:09 +08:00
|
|
|
/** Force adding an event listener
|
|
|
|
* @note force add an event listener which will ignore whether it's in dispatching.
|
|
|
|
* @see addEventListener
|
|
|
|
*/
|
|
|
|
void forceAddEventListener(EventListener* listener);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 10:35:48 +08:00
|
|
|
/** Gets event the listener list for the event listener type. */
|
2021-12-26 23:26:34 +08:00
|
|
|
EventListenerVector* getListeners(std::string_view listenerID) const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Update dirty flag */
|
2013-10-23 11:27:24 +08:00
|
|
|
void updateDirtyFlagForSceneGraph();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-29 14:57:16 +08:00
|
|
|
/** Removes all listeners with the same event listener ID */
|
2021-12-26 23:26:34 +08:00
|
|
|
void removeEventListenersForListenerID(std::string_view listenerID);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 10:35:48 +08:00
|
|
|
/** Sort event listener */
|
2021-12-26 23:26:34 +08:00
|
|
|
void sortEventListeners(std::string_view listenerID);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-23 11:27:24 +08:00
|
|
|
/** Sorts the listeners of specified type by scene graph priority */
|
2021-12-26 23:26:34 +08:00
|
|
|
void sortEventListenersOfSceneGraphPriority(std::string_view listenerID, Node* rootNode);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-23 11:27:24 +08:00
|
|
|
/** Sorts the listeners of specified type by fixed priority */
|
2021-12-26 23:26:34 +08:00
|
|
|
void sortEventListenersOfFixedPriority(std::string_view listenerID);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-23 11:27:24 +08:00
|
|
|
/** Updates all listeners
|
2013-09-20 22:23:13 +08:00
|
|
|
* 1) Removes all listener items that have been marked as 'removed' when dispatching event.
|
|
|
|
* 2) Adds all listener items that have been marked as 'added' when dispatching event.
|
|
|
|
*/
|
2013-10-28 16:00:01 +08:00
|
|
|
void updateListeners(Event* event);
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Touch event needs to be processed different with other events since it needs support ALL_AT_ONCE and ONE_BY_NONE
|
|
|
|
* mode. */
|
2013-10-25 10:35:48 +08:00
|
|
|
void dispatchTouchEvent(EventTouch* event);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Associates node with event listener */
|
2013-10-23 11:27:24 +08:00
|
|
|
void associateNodeAndEventListener(Node* node, EventListener* listener);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Dissociates node with event listener */
|
2013-10-23 11:27:24 +08:00
|
|
|
void dissociateNodeAndEventListener(Node* node, EventListener* listener);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Dispatches event to listeners with a specified listener type */
|
2014-03-02 15:54:36 +08:00
|
|
|
void dispatchEventToListeners(EventListenerVector* listeners, const std::function<bool(EventListener*)>& onEvent);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-06-18 10:23:52 +08:00
|
|
|
/** Special version dispatchEventToListeners for touch/mouse event.
|
|
|
|
*
|
|
|
|
* Touch/mouse event process flow different with common event,
|
|
|
|
* for scene graph node listeners, touch event process flow should
|
|
|
|
* order by viewport/camera first, because the touch location convert
|
|
|
|
* to 3D world space is different by different camera.
|
|
|
|
* When listener process touch event, can get current camera by Camera::getVisitingCamera().
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void dispatchTouchEventToListeners(EventListenerVector* listeners,
|
|
|
|
const std::function<bool(EventListener*)>& onEvent);
|
|
|
|
|
2015-12-17 21:55:47 +08:00
|
|
|
void releaseListener(EventListener* listener);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/// Priority dirty flag
|
|
|
|
enum class DirtyFlag
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
NONE = 0,
|
|
|
|
FIXED_PRIORITY = 1 << 0,
|
2013-10-25 15:40:21 +08:00
|
|
|
SCENE_GRAPH_PRIORITY = 1 << 1,
|
2021-12-25 10:04:45 +08:00
|
|
|
ALL = FIXED_PRIORITY | SCENE_GRAPH_PRIORITY
|
2013-10-25 15:40:21 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-28 16:00:01 +08:00
|
|
|
/** Sets the dirty flag for a specified listener ID */
|
2021-12-26 23:26:34 +08:00
|
|
|
void setDirty(std::string_view listenerID, DirtyFlag flag);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** Walks though scene graph to get the draw order for each node, it's called before sorting event listener with
|
|
|
|
* scene graph priority */
|
2014-01-21 10:23:05 +08:00
|
|
|
void visitTarget(Node* node, bool isRootNode);
|
2015-10-19 14:07:50 +08:00
|
|
|
|
|
|
|
/** Remove all listeners in _toRemoveListeners list and cleanup */
|
2015-10-19 16:06:39 +08:00
|
|
|
void cleanToRemovedListeners();
|
2015-10-19 14:07:50 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Listeners map */
|
2021-12-26 23:26:34 +08:00
|
|
|
hlookup::string_map<EventListenerVector*> _listenerMap;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** The map of dirty flag */
|
2021-12-26 23:26:34 +08:00
|
|
|
hlookup::string_map<DirtyFlag> _priorityDirtyFlagMap;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** The map of node and event listeners */
|
2013-10-24 20:50:21 +08:00
|
|
|
std::unordered_map<Node*, std::vector<EventListener*>*> _nodeListenersMap;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** The map of node and its event priority */
|
2013-10-24 20:50:21 +08:00
|
|
|
std::unordered_map<Node*, int> _nodePriorityMap;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-01-21 10:23:05 +08:00
|
|
|
/** key: Global Z Order, value: Sorted Nodes */
|
2014-01-22 08:36:19 +08:00
|
|
|
std::unordered_map<float, std::vector<Node*>> _globalZOrderNodeMap;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** The listeners to be added after dispatching event */
|
2013-10-23 11:27:24 +08:00
|
|
|
std::vector<EventListener*> _toAddedListeners;
|
2015-10-19 14:07:50 +08:00
|
|
|
|
|
|
|
/** The listeners to be removed after dispatching event */
|
|
|
|
std::vector<EventListener*> _toRemovedListeners;
|
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** The nodes were associated with scene graph based priority listeners */
|
2013-10-23 11:27:24 +08:00
|
|
|
std::set<Node*> _dirtyNodes;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Whether the dispatcher is dispatching event */
|
|
|
|
int _inDispatch;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 15:40:21 +08:00
|
|
|
/** Whether to enable dispatching event */
|
|
|
|
bool _isEnabled;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-10-25 17:03:50 +08:00
|
|
|
int _nodePriorityIndex;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-02-28 15:09:53 +08:00
|
|
|
std::set<std::string> _internalCustomListenerIDs;
|
2013-09-20 22:23:13 +08:00
|
|
|
};
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2015-03-24 18:22:52 +08:00
|
|
|
// end of base group
|
|
|
|
/// @}
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // __AX_EVENT_DISPATCHER_H__
|