bWidgets
Core widget toolkit designed for Blender
EventHandler.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <array>
4
#include <functional>
5
#include <list>
6
#include <unordered_map>
7
8
namespace
bWidgets
{
9
10
class
bwEvent;
11
class
bwMouseButtonEvent;
12
class
bwMouseButtonDragEvent;
13
class
bwMouseWheelEvent;
14
15
namespace
bwScreenGraph {
16
17
class
Node;
18
19
// TODO bwHandlingContext
20
using
EventListener
= std::function<void(
Node
&)>;
21
31
class
EventHandler
{
32
public
:
33
enum
EventType
{
34
MOUSE_ENTER
,
35
MOUSE_LEAVE
,
36
37
TOT_EVENT_TYPES
,
38
};
39
40
EventHandler
() =
default
;
41
virtual
~EventHandler
() =
default
;
42
43
void
addEventListener
(
EventType
event_type,
EventListener
listener);
44
45
virtual
void
onMouseMove
(
bwEvent
&);
46
virtual
void
onMouseEnter
(
bwEvent
&);
47
virtual
void
onMouseLeave
(
bwEvent
&);
48
virtual
void
onMousePress
(
bwMouseButtonEvent
&);
49
virtual
void
onMouseRelease
(
bwMouseButtonEvent
&);
50
virtual
void
onMouseClick
(
bwMouseButtonEvent
&);
51
virtual
void
onMouseDrag
(
bwMouseButtonDragEvent
&);
52
virtual
void
onMouseWheel
(
bwMouseWheelEvent
&);
53
54
private
:
55
std::array<std::list<EventListener>,
TOT_EVENT_TYPES
> listeners;
56
// std::unordered_map<EventType, std::list<EventListener>> listener_map;
57
};
58
59
}
// namespace bwScreenGraph
60
}
// namespace bWidgets
bWidgets::bwEvent
Definition:
bwEvent.h:8
bWidgets::bwMouseButtonDragEvent
Definition:
bwEvent.h:39
bWidgets::bwMouseButtonEvent
Definition:
bwEvent.h:24
bWidgets::bwMouseWheelEvent
Definition:
bwEvent.h:56
bWidgets::bwScreenGraph::EventHandler
API for registering and calling event-listeners.
Definition:
EventHandler.h:31
bWidgets::bwScreenGraph::EventHandler::onMouseMove
virtual void onMouseMove(bwEvent &)
Definition:
EventHandler.cc:16
bWidgets::bwScreenGraph::EventHandler::EventHandler
EventHandler()=default
bWidgets::bwScreenGraph::EventHandler::onMouseDrag
virtual void onMouseDrag(bwMouseButtonDragEvent &)
Definition:
EventHandler.cc:40
bWidgets::bwScreenGraph::EventHandler::onMouseWheel
virtual void onMouseWheel(bwMouseWheelEvent &)
Definition:
EventHandler.cc:44
bWidgets::bwScreenGraph::EventHandler::onMousePress
virtual void onMousePress(bwMouseButtonEvent &)
Definition:
EventHandler.cc:28
bWidgets::bwScreenGraph::EventHandler::addEventListener
void addEventListener(EventType event_type, EventListener listener)
Definition:
EventHandler.cc:10
bWidgets::bwScreenGraph::EventHandler::EventType
EventType
Definition:
EventHandler.h:33
bWidgets::bwScreenGraph::EventHandler::MOUSE_ENTER
@ MOUSE_ENTER
Definition:
EventHandler.h:34
bWidgets::bwScreenGraph::EventHandler::TOT_EVENT_TYPES
@ TOT_EVENT_TYPES
Definition:
EventHandler.h:37
bWidgets::bwScreenGraph::EventHandler::MOUSE_LEAVE
@ MOUSE_LEAVE
Definition:
EventHandler.h:35
bWidgets::bwScreenGraph::EventHandler::onMouseEnter
virtual void onMouseEnter(bwEvent &)
Definition:
EventHandler.cc:20
bWidgets::bwScreenGraph::EventHandler::onMouseLeave
virtual void onMouseLeave(bwEvent &)
Definition:
EventHandler.cc:24
bWidgets::bwScreenGraph::EventHandler::~EventHandler
virtual ~EventHandler()=default
bWidgets::bwScreenGraph::EventHandler::onMouseClick
virtual void onMouseClick(bwMouseButtonEvent &)
Definition:
EventHandler.cc:36
bWidgets::bwScreenGraph::EventHandler::onMouseRelease
virtual void onMouseRelease(bwMouseButtonEvent &)
Definition:
EventHandler.cc:32
bWidgets::bwScreenGraph::Node
The base data-structure for a screen-graph node.
Definition:
Node.h:36
bWidgets::bwScreenGraph::EventListener
std::function< void(Node &)> EventListener
Definition:
EventHandler.h:20
bWidgets
Definition:
bwContext.h:3
bwidgets
screen_graph
EventHandler.h
Generated by
1.9.3