reflexion 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/application.cpp +1 -1
- data/.doc/ext/reflex/capture_event.cpp +1 -1
- data/.doc/ext/reflex/contact_event.cpp +1 -1
- data/.doc/ext/reflex/draw_event.cpp +1 -1
- data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
- data/.doc/ext/reflex/event.cpp +1 -1
- data/.doc/ext/reflex/filter.cpp +1 -1
- data/.doc/ext/reflex/focus_event.cpp +1 -1
- data/.doc/ext/reflex/frame_event.cpp +1 -1
- data/.doc/ext/reflex/image_view.cpp +1 -1
- data/.doc/ext/reflex/key_event.cpp +74 -69
- data/.doc/ext/reflex/line_shape.cpp +1 -1
- data/.doc/ext/reflex/motion_event.cpp +1 -1
- data/.doc/ext/reflex/pointer.cpp +7 -16
- data/.doc/ext/reflex/pointer_event.cpp +1 -1
- data/.doc/ext/reflex/polygon_shape.cpp +1 -1
- data/.doc/ext/reflex/rect_shape.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +58 -50
- data/.doc/ext/reflex/screen.cpp +1 -1
- data/.doc/ext/reflex/scroll_event.cpp +1 -1
- data/.doc/ext/reflex/selector.cpp +2 -2
- data/.doc/ext/reflex/shape.cpp +1 -1
- data/.doc/ext/reflex/style.cpp +1 -1
- data/.doc/ext/reflex/style_length.cpp +5 -3
- data/.doc/ext/reflex/timer.cpp +1 -1
- data/.doc/ext/reflex/timer_event.cpp +1 -1
- data/.doc/ext/reflex/update_event.cpp +1 -1
- data/.doc/ext/reflex/view.cpp +17 -9
- data/.doc/ext/reflex/wheel_event.cpp +1 -1
- data/.doc/ext/reflex/window.cpp +1 -1
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +3 -0
- data/ChangeLog.md +17 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/Rakefile +1 -2
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +1 -1
- data/ext/reflex/capture_event.cpp +1 -1
- data/ext/reflex/contact_event.cpp +1 -1
- data/ext/reflex/defs.h +2 -0
- data/ext/reflex/draw_event.cpp +1 -1
- data/ext/reflex/ellipse_shape.cpp +1 -1
- data/ext/reflex/event.cpp +1 -1
- data/ext/reflex/extconf.rb +4 -4
- data/ext/reflex/filter.cpp +1 -1
- data/ext/reflex/focus_event.cpp +1 -1
- data/ext/reflex/frame_event.cpp +1 -1
- data/ext/reflex/image_view.cpp +1 -1
- data/ext/reflex/key_event.cpp +74 -69
- data/ext/reflex/line_shape.cpp +1 -1
- data/ext/reflex/motion_event.cpp +1 -1
- data/ext/reflex/pointer.cpp +7 -17
- data/ext/reflex/pointer_event.cpp +1 -1
- data/ext/reflex/polygon_shape.cpp +1 -1
- data/ext/reflex/rect_shape.cpp +1 -1
- data/ext/reflex/reflex.cpp +58 -50
- data/ext/reflex/screen.cpp +1 -1
- data/ext/reflex/scroll_event.cpp +1 -1
- data/ext/reflex/selector.cpp +2 -2
- data/ext/reflex/shape.cpp +1 -1
- data/ext/reflex/style.cpp +1 -1
- data/ext/reflex/style_length.cpp +5 -3
- data/ext/reflex/timer.cpp +1 -1
- data/ext/reflex/timer_event.cpp +1 -1
- data/ext/reflex/update_event.cpp +1 -1
- data/ext/reflex/view.cpp +18 -9
- data/ext/reflex/wheel_event.cpp +1 -1
- data/ext/reflex/window.cpp +1 -1
- data/include/reflex/defs.h +204 -187
- data/include/reflex/pointer.h +3 -5
- data/include/reflex/reflex.h +1 -0
- data/include/reflex/ruby/application.h +2 -2
- data/include/reflex/ruby/event.h +26 -26
- data/include/reflex/ruby/exception.h +3 -3
- data/include/reflex/ruby/filter.h +2 -2
- data/include/reflex/ruby/image_view.h +2 -2
- data/include/reflex/ruby/pointer.h +2 -2
- data/include/reflex/ruby/reflex.h +1 -1
- data/include/reflex/ruby/screen.h +2 -2
- data/include/reflex/ruby/selector.h +2 -2
- data/include/reflex/ruby/shape.h +10 -10
- data/include/reflex/ruby/style.h +4 -4
- data/include/reflex/ruby/timer.h +3 -3
- data/include/reflex/ruby/view.h +2 -2
- data/include/reflex/ruby/window.h +2 -2
- data/include/reflex/view.h +3 -1
- data/lib/reflex/extension.rb +4 -0
- data/lib/reflex/pointer.rb +1 -1
- data/lib/reflex/pointer_event.rb +2 -2
- data/reflex.gemspec +4 -4
- data/src/body.cpp +12 -6
- data/src/event.cpp +17 -31
- data/src/event.h +3 -3
- data/src/filter.cpp +3 -1
- data/src/ios/event.mm +20 -27
- data/src/osx/application.mm +6 -5
- data/src/osx/event.mm +1 -2
- data/src/pointer.cpp +12 -32
- data/src/pointer.h +0 -2
- data/src/selector.cpp +3 -1
- data/src/shape.cpp +5 -3
- data/src/style.cpp +14 -8
- data/src/view.cpp +47 -24
- data/src/win32/application.cpp +48 -35
- data/src/win32/device.cpp +18 -0
- data/src/win32/event.cpp +219 -0
- data/src/win32/event.h +50 -0
- data/src/win32/opengl.cpp +54 -27
- data/src/win32/opengl.h +15 -13
- data/src/win32/reflex.cpp +10 -16
- data/src/win32/screen.cpp +61 -0
- data/src/win32/screen.h +21 -0
- data/src/win32/window.cpp +445 -240
- data/src/window.cpp +28 -30
- data/src/window.h +3 -12
- data/test/test_pointer.rb +8 -10
- data/test/test_pointer_event.rb +8 -9
- data/test/test_window.rb +24 -21
- metadata +15 -12
- data/src/win32/defs.cpp +0 -303
- data/src/win32/defs.h +0 -34
data/src/view.cpp
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
#include <limits.h>
|
|
5
|
+
#include <string.h>
|
|
5
6
|
#include <assert.h>
|
|
6
7
|
#include <memory>
|
|
7
8
|
#include <algorithm>
|
|
@@ -288,15 +289,22 @@ namespace Reflex
|
|
|
288
289
|
|
|
289
290
|
World* child_world (View* view, bool create = true)
|
|
290
291
|
{
|
|
291
|
-
if (!pchild_world && create)
|
|
292
|
-
{
|
|
293
|
-
pchild_world.reset(new World());
|
|
294
|
-
create_walls(view);
|
|
295
|
-
}
|
|
296
|
-
|
|
292
|
+
if (!pchild_world && create) create_world(view);
|
|
297
293
|
return pchild_world.get();
|
|
298
294
|
}
|
|
299
295
|
|
|
296
|
+
void create_world (View* view, float pixels_per_meter = 0)
|
|
297
|
+
{
|
|
298
|
+
if (pchild_world)
|
|
299
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
300
|
+
|
|
301
|
+
if (pixels_per_meter == 0)
|
|
302
|
+
pixels_per_meter = World::DEFAULT_PIXELS_PER_METER;
|
|
303
|
+
|
|
304
|
+
pchild_world.reset(new World(pixels_per_meter));
|
|
305
|
+
create_walls(view);
|
|
306
|
+
}
|
|
307
|
+
|
|
300
308
|
void create_walls (View* view)
|
|
301
309
|
{
|
|
302
310
|
clear_walls(view);
|
|
@@ -1326,7 +1334,9 @@ namespace Reflex
|
|
|
1326
1334
|
void
|
|
1327
1335
|
View_call_key_event (View* view, KeyEvent* event)
|
|
1328
1336
|
{
|
|
1329
|
-
if (!view
|
|
1337
|
+
if (!view)
|
|
1338
|
+
argument_error(__FILE__, __LINE__);
|
|
1339
|
+
if (!event)
|
|
1330
1340
|
argument_error(__FILE__, __LINE__);
|
|
1331
1341
|
|
|
1332
1342
|
if (view->hidden()) return;
|
|
@@ -1382,9 +1392,6 @@ namespace Reflex
|
|
|
1382
1392
|
case Pointer::CANCEL: view->on_pointer_cancel(event); break;
|
|
1383
1393
|
default: break;
|
|
1384
1394
|
}
|
|
1385
|
-
|
|
1386
|
-
if (!event->is_captured())
|
|
1387
|
-
PointerEvent_increment_view_indices(event);
|
|
1388
1395
|
}
|
|
1389
1396
|
|
|
1390
1397
|
static void
|
|
@@ -1397,34 +1404,36 @@ namespace Reflex
|
|
|
1397
1404
|
PointerEvent_each_pointer(&event, [&](const auto& pointer)
|
|
1398
1405
|
{
|
|
1399
1406
|
if (pointer.action() == Pointer::DOWN)
|
|
1400
|
-
Window_register_capture(win, view, pointer.id()
|
|
1407
|
+
Window_register_capture(win, view, pointer.id());
|
|
1401
1408
|
});
|
|
1402
1409
|
}
|
|
1403
1410
|
|
|
1404
1411
|
static void
|
|
1405
|
-
unregister_captures (View* view, const PointerEvent& event)
|
|
1412
|
+
unregister_captures (Window* window, View* view, const PointerEvent& event)
|
|
1406
1413
|
{
|
|
1407
|
-
Window* win = view->window();
|
|
1408
|
-
if (!win)
|
|
1409
|
-
invalid_state_error(__FILE__, __LINE__);
|
|
1410
|
-
|
|
1411
1414
|
PointerEvent_each_pointer(&event, [&](const auto& pointer)
|
|
1412
1415
|
{
|
|
1413
1416
|
auto action = pointer.action();
|
|
1414
1417
|
if (action == Pointer::UP || action == Pointer::CANCEL)
|
|
1415
|
-
Window_unregister_capture(
|
|
1418
|
+
Window_unregister_capture(window, view, pointer.id());
|
|
1416
1419
|
});
|
|
1417
1420
|
}
|
|
1418
1421
|
|
|
1419
1422
|
void
|
|
1420
1423
|
View_call_pointer_event (View* view, PointerEvent* event)
|
|
1421
1424
|
{
|
|
1422
|
-
if (!view
|
|
1425
|
+
if (!view)
|
|
1426
|
+
argument_error(__FILE__, __LINE__);
|
|
1427
|
+
if (!event)
|
|
1423
1428
|
argument_error(__FILE__, __LINE__);
|
|
1424
1429
|
|
|
1425
1430
|
if (view->hidden() || event->empty())
|
|
1426
1431
|
return;
|
|
1427
1432
|
|
|
1433
|
+
Window* win = view->window();
|
|
1434
|
+
if (!win)
|
|
1435
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
1436
|
+
|
|
1428
1437
|
PointerEvent e = event->dup();
|
|
1429
1438
|
|
|
1430
1439
|
if (!e.is_captured())
|
|
@@ -1436,13 +1445,15 @@ namespace Reflex
|
|
|
1436
1445
|
call_pointer_events(view, &e);
|
|
1437
1446
|
}
|
|
1438
1447
|
|
|
1439
|
-
unregister_captures(view, e);
|
|
1448
|
+
unregister_captures(win, view, e);
|
|
1440
1449
|
}
|
|
1441
1450
|
|
|
1442
1451
|
void
|
|
1443
1452
|
View_call_wheel_event (View* view, WheelEvent* event)
|
|
1444
1453
|
{
|
|
1445
|
-
if (!view
|
|
1454
|
+
if (!view)
|
|
1455
|
+
argument_error(__FILE__, __LINE__);
|
|
1456
|
+
if (!event)
|
|
1446
1457
|
argument_error(__FILE__, __LINE__);
|
|
1447
1458
|
|
|
1448
1459
|
if (view->hidden()) return;
|
|
@@ -1468,7 +1479,9 @@ namespace Reflex
|
|
|
1468
1479
|
void
|
|
1469
1480
|
View_call_contact_event (View* view, ContactEvent* event)
|
|
1470
1481
|
{
|
|
1471
|
-
if (!view
|
|
1482
|
+
if (!view)
|
|
1483
|
+
argument_error(__FILE__, __LINE__);
|
|
1484
|
+
if (!event)
|
|
1472
1485
|
argument_error(__FILE__, __LINE__);
|
|
1473
1486
|
|
|
1474
1487
|
ContactEvent e = event->dup();
|
|
@@ -1737,7 +1750,9 @@ namespace Reflex
|
|
|
1737
1750
|
void
|
|
1738
1751
|
View::add_child (View* child)
|
|
1739
1752
|
{
|
|
1740
|
-
if (!child
|
|
1753
|
+
if (!child)
|
|
1754
|
+
argument_error(__FILE__, __LINE__);
|
|
1755
|
+
if (child == this)
|
|
1741
1756
|
argument_error(__FILE__, __LINE__);
|
|
1742
1757
|
|
|
1743
1758
|
bool found = std::find(child_begin(), child_end(), child) != child_end();
|
|
@@ -1763,7 +1778,9 @@ namespace Reflex
|
|
|
1763
1778
|
void
|
|
1764
1779
|
View::remove_child (View* child)
|
|
1765
1780
|
{
|
|
1766
|
-
if (!child
|
|
1781
|
+
if (!child)
|
|
1782
|
+
argument_error(__FILE__, __LINE__);
|
|
1783
|
+
if (child == this)
|
|
1767
1784
|
argument_error(__FILE__, __LINE__);
|
|
1768
1785
|
|
|
1769
1786
|
bool found = std::find(child_begin(), child_end(), child) != child_end();
|
|
@@ -2516,7 +2533,13 @@ namespace Reflex
|
|
|
2516
2533
|
}
|
|
2517
2534
|
|
|
2518
2535
|
void
|
|
2519
|
-
View::
|
|
2536
|
+
View::create_world (float pixels_per_meter)
|
|
2537
|
+
{
|
|
2538
|
+
self->create_world(this, pixels_per_meter);
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
void
|
|
2542
|
+
View::update_world (float duration)
|
|
2520
2543
|
{
|
|
2521
2544
|
World* w = self->pchild_world.get();
|
|
2522
2545
|
if (w) w->update(duration);
|
data/src/win32/application.cpp
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#include "reflex/application.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <windows.h>
|
|
4
|
+
#include <xot/windows.h>
|
|
5
5
|
#include "reflex/exception.h"
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,13 +9,18 @@ namespace Reflex
|
|
|
9
9
|
{
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
namespace global
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
static Application* instance = NULL;
|
|
16
|
+
|
|
17
|
+
}// global
|
|
13
18
|
|
|
14
19
|
|
|
15
20
|
Application*
|
|
16
21
|
app ()
|
|
17
22
|
{
|
|
18
|
-
return instance;
|
|
23
|
+
return global::instance;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
|
|
@@ -24,30 +29,27 @@ namespace Reflex
|
|
|
24
29
|
|
|
25
30
|
String name;
|
|
26
31
|
|
|
27
|
-
operator bool () const
|
|
28
|
-
{
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
32
|
};// Application::Data
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
Application::Application ()
|
|
36
36
|
{
|
|
37
|
-
if (instance)
|
|
37
|
+
if (global::instance)
|
|
38
|
+
reflex_error(__FILE__, __LINE__, "multiple application instances.");
|
|
38
39
|
|
|
39
|
-
instance = this;
|
|
40
|
+
global::instance = this;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
Application::~Application ()
|
|
43
44
|
{
|
|
44
|
-
instance = NULL;
|
|
45
|
+
global::instance = NULL;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
Application::
|
|
48
|
+
void
|
|
49
|
+
Application::start ()
|
|
49
50
|
{
|
|
50
|
-
|
|
51
|
+
Event e;
|
|
52
|
+
on_start(&e);
|
|
51
53
|
|
|
52
54
|
MSG msg;
|
|
53
55
|
while (GetMessage(&msg, NULL, 0, 0))
|
|
@@ -56,48 +58,59 @@ namespace Reflex
|
|
|
56
58
|
DispatchMessage(&msg);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
if (msg.wParam != 0)
|
|
62
|
+
reflex_error(__FILE__, __LINE__, "WM_QUIT with wParam %d.", msg.wParam);
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
void
|
|
63
66
|
Application::quit ()
|
|
64
67
|
{
|
|
65
|
-
if (!*this) return false;
|
|
66
|
-
|
|
67
68
|
PostQuitMessage(0);
|
|
68
|
-
return true;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
Application::
|
|
71
|
+
void
|
|
72
|
+
Application::set_name (const char* name)
|
|
73
73
|
{
|
|
74
|
-
|
|
74
|
+
if (!name)
|
|
75
|
+
argument_error(__FILE__, __LINE__);
|
|
76
|
+
|
|
77
|
+
self->name = name;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
Application::
|
|
80
|
+
const char*
|
|
81
|
+
Application::name () const
|
|
79
82
|
{
|
|
80
|
-
return
|
|
83
|
+
return self->name.c_str();
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
Application::
|
|
86
|
+
void
|
|
87
|
+
Application::on_start (Event* e)
|
|
85
88
|
{
|
|
86
|
-
if (!*this || !name) return false;
|
|
87
|
-
self->name = name;
|
|
88
|
-
return true;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
Application::
|
|
91
|
+
void
|
|
92
|
+
Application::on_quit (Event* e)
|
|
93
|
+
{
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void
|
|
97
|
+
Application::on_motion (MotionEvent* e)
|
|
98
|
+
{
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void
|
|
102
|
+
Application::on_preference (Event* e)
|
|
103
|
+
{
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void
|
|
107
|
+
Application::on_about (Event* e)
|
|
93
108
|
{
|
|
94
|
-
if (!*this) return "";
|
|
95
|
-
return self->name.c_str();
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
Application::operator bool () const
|
|
99
112
|
{
|
|
100
|
-
return
|
|
113
|
+
return true;
|
|
101
114
|
}
|
|
102
115
|
|
|
103
116
|
bool
|
data/src/win32/event.cpp
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#include "event.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <xot/time.h>
|
|
5
|
+
#include "reflex/exception.h"
|
|
6
|
+
#include "../pointer.h"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
namespace Reflex
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
static uint
|
|
14
|
+
get_modifiers ()
|
|
15
|
+
{
|
|
16
|
+
return
|
|
17
|
+
(GetKeyState(VK_SHIFT) & 0x8000 ? MOD_SHIFT : 0) |
|
|
18
|
+
(GetKeyState(VK_CONTROL) & 0x8000 ? MOD_CONTROL : 0) |
|
|
19
|
+
(GetKeyState(VK_MENU) & 0x8000 ? MOD_ALT : 0) |
|
|
20
|
+
(GetKeyState(VK_LWIN) & 0x8000 ? MOD_WIN : 0) |
|
|
21
|
+
(GetKeyState(VK_RWIN) & 0x8000 ? MOD_WIN : 0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
static KeyEvent::Action
|
|
26
|
+
get_key_action (UINT msg)
|
|
27
|
+
{
|
|
28
|
+
switch (msg)
|
|
29
|
+
{
|
|
30
|
+
case WM_KEYDOWN:
|
|
31
|
+
case WM_SYSKEYDOWN: return KeyEvent::DOWN;
|
|
32
|
+
case WM_KEYUP:
|
|
33
|
+
case WM_SYSKEYUP: return KeyEvent::UP;
|
|
34
|
+
default: argument_error(__FILE__, __LINE__);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
NativeKeyEvent::NativeKeyEvent (UINT msg, WPARAM wp, LPARAM lp, const char* chars)
|
|
39
|
+
: KeyEvent(get_key_action(msg), chars, (int) wp, get_modifiers(), lp & 0xFF)
|
|
40
|
+
{
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
static uint
|
|
46
|
+
get_mouse_type (UINT msg, WPARAM wp)
|
|
47
|
+
{
|
|
48
|
+
uint type = Reflex::Pointer::TYPE_NONE;
|
|
49
|
+
|
|
50
|
+
switch (msg)
|
|
51
|
+
{
|
|
52
|
+
case WM_LBUTTONDOWN:
|
|
53
|
+
case WM_LBUTTONDBLCLK:
|
|
54
|
+
case WM_LBUTTONUP:
|
|
55
|
+
type |= Reflex::Pointer::MOUSE | Reflex::Pointer::MOUSE_LEFT;
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case WM_RBUTTONDOWN:
|
|
59
|
+
case WM_RBUTTONDBLCLK:
|
|
60
|
+
case WM_RBUTTONUP:
|
|
61
|
+
type |= Reflex::Pointer::MOUSE | Reflex::Pointer::MOUSE_RIGHT;
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case WM_MBUTTONDOWN:
|
|
65
|
+
case WM_MBUTTONDBLCLK:
|
|
66
|
+
case WM_MBUTTONUP:
|
|
67
|
+
type |= Reflex::Pointer::MOUSE | Reflex::Pointer::MOUSE_MIDDLE;
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
case WM_MOUSEMOVE:
|
|
71
|
+
type |= Reflex::Pointer::MOUSE;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return type;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static Reflex::Pointer::Action
|
|
79
|
+
get_mouse_action (UINT msg)
|
|
80
|
+
{
|
|
81
|
+
switch (msg)
|
|
82
|
+
{
|
|
83
|
+
case WM_LBUTTONDOWN:
|
|
84
|
+
case WM_RBUTTONDOWN:
|
|
85
|
+
case WM_MBUTTONDOWN:
|
|
86
|
+
case WM_LBUTTONDBLCLK:
|
|
87
|
+
case WM_RBUTTONDBLCLK:
|
|
88
|
+
case WM_MBUTTONDBLCLK:
|
|
89
|
+
return Reflex::Pointer::DOWN;
|
|
90
|
+
|
|
91
|
+
case WM_LBUTTONUP:
|
|
92
|
+
case WM_RBUTTONUP:
|
|
93
|
+
case WM_MBUTTONUP:
|
|
94
|
+
return Reflex::Pointer::UP;
|
|
95
|
+
|
|
96
|
+
case WM_MOUSEMOVE:
|
|
97
|
+
return Reflex::Pointer::MOVE;
|
|
98
|
+
|
|
99
|
+
default:
|
|
100
|
+
return Reflex::Pointer::ACTION_NONE;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static bool
|
|
105
|
+
is_mouse_dragging (UINT msg, WPARAM wp)
|
|
106
|
+
{
|
|
107
|
+
return msg == WM_MOUSEMOVE && wp & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static int
|
|
111
|
+
get_mouse_click_count (UINT msg)
|
|
112
|
+
{
|
|
113
|
+
switch (msg)
|
|
114
|
+
{
|
|
115
|
+
case WM_LBUTTONDOWN:
|
|
116
|
+
case WM_RBUTTONDOWN:
|
|
117
|
+
case WM_MBUTTONDOWN:
|
|
118
|
+
return 1;
|
|
119
|
+
|
|
120
|
+
case WM_LBUTTONDBLCLK:
|
|
121
|
+
case WM_RBUTTONDBLCLK:
|
|
122
|
+
case WM_MBUTTONDBLCLK:
|
|
123
|
+
return 2;
|
|
124
|
+
|
|
125
|
+
default:
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
NativePointerEvent::NativePointerEvent (UINT msg, WPARAM wp, LPARAM lp)
|
|
131
|
+
{
|
|
132
|
+
PointerEvent_add_pointer(this, Pointer(
|
|
133
|
+
0,
|
|
134
|
+
get_mouse_type(msg, wp),
|
|
135
|
+
get_mouse_action(msg),
|
|
136
|
+
Point(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)),
|
|
137
|
+
get_modifiers(),
|
|
138
|
+
get_mouse_click_count(msg),
|
|
139
|
+
is_mouse_dragging(msg, wp),
|
|
140
|
+
Xot::time()));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static uint
|
|
144
|
+
get_touch_type (const TOUCHINPUT& touch)
|
|
145
|
+
{
|
|
146
|
+
if (touch.dwFlags & TOUCHEVENTF_PEN) return Pointer::PEN;
|
|
147
|
+
if (touch.dwFlags & TOUCHEVENTF_PALM) return Pointer::TYPE_NONE;
|
|
148
|
+
else return Pointer::TOUCH;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static Pointer::Action
|
|
152
|
+
get_touch_action (const TOUCHINPUT& touch)
|
|
153
|
+
{
|
|
154
|
+
if (touch.dwFlags & TOUCHEVENTF_DOWN) return Pointer::DOWN;
|
|
155
|
+
if (touch.dwFlags & TOUCHEVENTF_UP) return Pointer::UP;
|
|
156
|
+
if (touch.dwFlags & TOUCHEVENTF_MOVE) return Pointer::MOVE;
|
|
157
|
+
else return Pointer::ACTION_NONE;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static Point
|
|
161
|
+
get_touch_position (HWND hwnd, const TOUCHINPUT& touch)
|
|
162
|
+
{
|
|
163
|
+
coord x = (coord) touch.x / 100;
|
|
164
|
+
coord y = (coord) touch.y / 100;
|
|
165
|
+
|
|
166
|
+
POINT point = {0, 0};
|
|
167
|
+
if (ClientToScreen(hwnd, &point))
|
|
168
|
+
{
|
|
169
|
+
x -= point.x;
|
|
170
|
+
y -= point.y;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return Point(x, y);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static double
|
|
177
|
+
get_touch_time (const TOUCHINPUT& touch)
|
|
178
|
+
{
|
|
179
|
+
//if (touch.dwFlags & TOUCHINPUTMASKF_TIMEFROMSYSTEM)
|
|
180
|
+
// return (double) touch.dwTime / 1000.0;
|
|
181
|
+
|
|
182
|
+
return Xot::time();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
NativePointerEvent::NativePointerEvent (
|
|
186
|
+
HWND hwnd, const TOUCHINPUT* touches, size_t size)
|
|
187
|
+
{
|
|
188
|
+
for (size_t i = 0; i < size; ++i)
|
|
189
|
+
{
|
|
190
|
+
const TOUCHINPUT& touch = touches[i];
|
|
191
|
+
Pointer::Action action = get_touch_action(touch);
|
|
192
|
+
|
|
193
|
+
Pointer pointer(
|
|
194
|
+
0,
|
|
195
|
+
get_touch_type(touch),
|
|
196
|
+
action,
|
|
197
|
+
get_touch_position(hwnd, touch),
|
|
198
|
+
get_modifiers(),
|
|
199
|
+
action == Pointer::DOWN ? 1 : 0,
|
|
200
|
+
action == Pointer::MOVE,
|
|
201
|
+
get_touch_time(touch));
|
|
202
|
+
Pointer_set_system_id(&pointer, touch.dwID);
|
|
203
|
+
|
|
204
|
+
if (pointer)
|
|
205
|
+
PointerEvent_add_pointer(this, pointer);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
NativeWheelEvent::NativeWheelEvent (WPARAM wp_x, WPARAM wp_y, LPARAM lp)
|
|
211
|
+
: WheelEvent(
|
|
212
|
+
GET_X_LPARAM(lp), GET_Y_LPARAM(lp), 0,
|
|
213
|
+
GET_WHEEL_DELTA_WPARAM(wp_x), -GET_WHEEL_DELTA_WPARAM(wp_y), 0,
|
|
214
|
+
get_modifiers())
|
|
215
|
+
{
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
}// Reflex
|
data/src/win32/event.h
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// -*- c++ -*-
|
|
2
|
+
#pragma once
|
|
3
|
+
#ifndef __REFLEX_SRC_WIN32_EVENT_H__
|
|
4
|
+
#define __REFLEX_SRC_WIN32_EVENT_H__
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#include <xot/windows.h>
|
|
8
|
+
#include "../event.h"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
namespace Reflex
|
|
12
|
+
{
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class NativeKeyEvent : public KeyEvent
|
|
16
|
+
{
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
|
|
20
|
+
NativeKeyEvent (UINT msg, WPARAM wp, LPARAM lp, const char* chars = NULL);
|
|
21
|
+
|
|
22
|
+
};// NativeKeyEvent
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class NativePointerEvent : public PointerEvent
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
|
|
30
|
+
NativePointerEvent (UINT msg, WPARAM wp, LPARAM lp);
|
|
31
|
+
|
|
32
|
+
NativePointerEvent (HWND hwnd, const TOUCHINPUT* touches, size_t size);
|
|
33
|
+
|
|
34
|
+
};// NativePointerEvent
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class NativeWheelEvent : public WheelEvent
|
|
38
|
+
{
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
|
|
42
|
+
NativeWheelEvent (WPARAM wp_x, WPARAM wp_y, LPARAM lp);
|
|
43
|
+
|
|
44
|
+
};// NativeWheelEvent
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
}// Reflex
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
#endif//EOH
|