forked from julapy/ofxFlashLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathofxFlashInteractiveObject.cpp
More file actions
235 lines (185 loc) · 4.52 KB
/
ofxFlashInteractiveObject.cpp
File metadata and controls
235 lines (185 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
* ofxFlashInteractiveObject.cpp
* emptyExample
*
* Created by lukasz karluk on 1/11/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#include "ofxFlashInteractiveObject.h"
ofxFlashInteractiveObject :: ofxFlashInteractiveObject()
{
typeID = OFX_FLASH_INTERACTIVE_OBJECT_TYPE;
_doubleClickEnabled = false;
_mouseEnabled = false;
_mouseUpOutside = true;
_tabEnabled = false;
_tabIndex = 0;
_mouseOver = false;
_mouseDown = false;
mouseOverDirty = false;
mouseDownDirty = false;
}
ofxFlashInteractiveObject :: ~ofxFlashInteractiveObject ()
{
// if( _mouseEnabled )
// {
// disableMouseEvents();
// }
}
//============================================================= DOUBLE CLICK ENABLED.
const bool& ofxFlashInteractiveObject :: doubleClickEnabled ()
{
return _doubleClickEnabled;
}
void ofxFlashInteractiveObject :: doubleClickEnabled ( bool value )
{
_doubleClickEnabled = value;
}
//============================================================= MOUSE ENABLED.
const bool& ofxFlashInteractiveObject :: mouseEnabled ()
{
return _mouseEnabled;
}
void ofxFlashInteractiveObject :: mouseEnabled ( bool value )
{
if( _mouseEnabled == value )
return;
_mouseEnabled = value;
// if( _mouseEnabled )
// {
// enableMouseEvents();
// }
// else
// {
// disableMouseEvents();
// }
}
//============================================================= MOUSE UP OUTSIDE.
const bool& ofxFlashInteractiveObject :: mouseUpOutside ()
{
return _mouseUpOutside;
}
void ofxFlashInteractiveObject :: mouseUpOutside ( bool value )
{
_mouseUpOutside = value;
}
//============================================================= MOUSE OVER.
void ofxFlashInteractiveObject :: mouseOver ( bool value )
{
_mouseOver = value;
}
const bool& ofxFlashInteractiveObject :: mouseOver ()
{
return _mouseOver;
}
//============================================================= MOUSE DOWN.
void ofxFlashInteractiveObject :: mouseDown ( bool value )
{
_mouseDown = value;
}
const bool& ofxFlashInteractiveObject :: mouseDown ()
{
return _mouseDown;
}
//============================================================= ENABLE / DISABLE MOUSE.
void ofxFlashInteractiveObject :: enableMouseEvents()
{
#ifdef OF_USING_POCO
ofAddListener( ofEvents.mouseMoved, this, &ofxFlashInteractiveObject :: _mouseMoved );
ofAddListener( ofEvents.mouseDragged, this, &ofxFlashInteractiveObject :: _mouseDragged );
ofAddListener( ofEvents.mousePressed, this, &ofxFlashInteractiveObject :: _mousePressed );
ofAddListener( ofEvents.mouseReleased, this, &ofxFlashInteractiveObject :: _mouseReleased );
#endif
}
void ofxFlashInteractiveObject :: disableMouseEvents()
{
#ifdef OF_USING_POCO
ofRemoveListener( ofEvents.mouseMoved, this, &ofxFlashInteractiveObject :: _mouseMoved );
ofRemoveListener( ofEvents.mouseDragged, this, &ofxFlashInteractiveObject :: _mouseDragged );
ofRemoveListener( ofEvents.mousePressed, this, &ofxFlashInteractiveObject :: _mousePressed );
ofRemoveListener( ofEvents.mouseReleased, this, &ofxFlashInteractiveObject :: _mouseReleased );
#endif
}
//============================================================= MOUSE EVENT HANDLERS.
void ofxFlashInteractiveObject :: _mouseMoved( int x, int y, int id )
{
if( !_mouseEnabled )
return;
// dispatch mouse move - should dispatch first.
if( hitTestPoint( x, y ) )
{
if( !_mouseOver )
{
_mouseOver = true;
// dispatch mouse over
}
}
else if( _mouseOver )
{
_mouseOver = false;
// dispatch mouse out.
if( _mouseUpOutside && _mouseDown )
{
_mouseDown = false;
// dispatch mouse up.
}
}
}
void ofxFlashInteractiveObject :: _mouseDragged( int x, int y, int id )
{
if( !_mouseEnabled )
return;
// dispatch mouse drag - should dispatch first.
if( hitTestPoint( x, y ) )
{
if( !_mouseOver )
{
_mouseOver = true;
// dispatch mouse over
}
}
else
{
if( _mouseOver )
{
_mouseOver = false;
// dispatch mouse out.
if( _mouseUpOutside && _mouseDown )
{
_mouseDown = false;
// dispatch mouse up.
}
}
}
}
void ofxFlashInteractiveObject :: _mousePressed( int x, int y, int id )
{
if( !_mouseEnabled )
return;
if( hitTestPoint( x, y ) )
{
if( !_mouseDown )
{
_mouseDown = true;
// dispatch mouse down.
}
}
}
void ofxFlashInteractiveObject :: _mouseReleased( int x, int y, int id )
{
if( !_mouseEnabled )
return;
if( hitTestPoint( x, y ) )
{
// dispatch mouse up inside.
}
else
{
if( _mouseDown )
{
// dispatch mouse up outside.
}
}
_mouseDown = false;
}