reflexion 0.1.19 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/contact_event.cpp +6 -6
- data/.doc/ext/reflex/event.cpp +9 -1
- data/.doc/ext/reflex/focus_event.cpp +6 -6
- data/.doc/ext/reflex/key_event.cpp +211 -13
- data/.doc/ext/reflex/native.cpp +2 -0
- data/.doc/ext/reflex/pointer.cpp +158 -0
- data/.doc/ext/reflex/pointer_event.cpp +31 -90
- data/.doc/ext/reflex/selector.cpp +8 -0
- data/.doc/ext/reflex/view.cpp +57 -0
- data/.doc/ext/reflex/window.cpp +41 -0
- data/VERSION +1 -1
- data/ext/reflex/contact_event.cpp +6 -6
- data/ext/reflex/event.cpp +11 -2
- data/ext/reflex/focus_event.cpp +6 -6
- data/ext/reflex/key_event.cpp +212 -13
- data/ext/reflex/native.cpp +2 -0
- data/ext/reflex/pointer.cpp +170 -0
- data/ext/reflex/pointer_event.cpp +30 -95
- data/ext/reflex/selector.cpp +9 -0
- data/ext/reflex/view.cpp +67 -3
- data/ext/reflex/window.cpp +49 -3
- data/include/reflex/defs.h +140 -106
- data/include/reflex/event.h +26 -27
- data/include/reflex/pointer.h +107 -0
- data/include/reflex/ruby/pointer.h +41 -0
- data/include/reflex/ruby/view.h +9 -0
- data/include/reflex/ruby/window.h +9 -0
- data/include/reflex/selector.h +1 -1
- data/include/reflex/view.h +6 -4
- data/include/reflex/window.h +14 -8
- data/lib/reflex/application.rb +3 -3
- data/lib/reflex/autoinit.rb +1 -1
- data/lib/reflex/button.rb +7 -7
- data/lib/reflex/capture_event.rb +7 -7
- data/lib/reflex/contact_event.rb +4 -4
- data/lib/reflex/draw_event.rb +2 -2
- data/lib/reflex/ellipse_shape.rb +2 -2
- data/lib/reflex/focus_event.rb +4 -4
- data/lib/reflex/frame_event.rb +5 -5
- data/lib/reflex/helper.rb +20 -20
- data/lib/reflex/image_view.rb +2 -2
- data/lib/reflex/key_event.rb +6 -6
- data/lib/reflex/model.rb +22 -22
- data/lib/reflex/model_owner.rb +7 -7
- data/lib/reflex/model_view.rb +1 -1
- data/lib/reflex/module.rb +5 -5
- data/lib/reflex/pointer.rb +107 -0
- data/lib/reflex/pointer_event.rb +16 -54
- data/lib/reflex/polygon_shape.rb +2 -2
- data/lib/reflex/reflex.rb +3 -3
- data/lib/reflex/scroll_event.rb +1 -1
- data/lib/reflex/selector.rb +4 -4
- data/lib/reflex/shape.rb +13 -13
- data/lib/reflex/style.rb +11 -11
- data/lib/reflex/style_length.rb +1 -1
- data/lib/reflex/text_view.rb +2 -2
- data/lib/reflex/timer.rb +2 -2
- data/lib/reflex/timer_event.rb +1 -1
- data/lib/reflex/update_event.rb +1 -1
- data/lib/reflex/view.rb +32 -32
- data/lib/reflex/wheel_event.rb +3 -3
- data/lib/reflex/window.rb +7 -6
- data/lib/reflex.rb +1 -0
- data/lib/reflexion.rb +17 -17
- data/reflex.gemspec +5 -5
- data/samples/reflexion/noise.rb +1 -1
- data/samples/tree.rb +1 -1
- data/src/event.cpp +189 -37
- data/src/event.h +32 -0
- data/src/ios/event.h +15 -3
- data/src/ios/event.mm +126 -11
- data/src/ios/view_controller.mm +50 -22
- data/src/ios/window.mm +18 -0
- data/src/osx/event.h +14 -3
- data/src/osx/event.mm +213 -23
- data/src/osx/native_window.mm +84 -17
- data/src/osx/window.mm +22 -0
- data/src/pointer.cpp +203 -0
- data/src/pointer.h +26 -0
- data/src/selector.cpp +1 -1
- data/src/view.cpp +103 -64
- data/src/view.h +0 -4
- data/src/window.cpp +334 -98
- data/src/window.h +28 -3
- data/test/helper.rb +3 -3
- data/test/test_application.rb +1 -1
- data/test/test_capture_event.rb +6 -6
- data/test/test_event.rb +18 -4
- data/test/test_has_frame.rb +11 -11
- data/test/test_pointer.rb +149 -0
- data/test/test_pointer_event.rb +70 -104
- data/test/test_reflex.rb +1 -1
- data/test/test_selector.rb +15 -8
- data/test/test_shape.rb +8 -8
- data/test/test_style.rb +13 -13
- data/test/test_style_length.rb +5 -5
- data/test/test_view.rb +57 -30
- data/test/test_window.rb +45 -26
- metadata +46 -35
data/src/view.cpp
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
#include "reflex/exception.h"
|
10
10
|
#include "reflex/debug.h"
|
11
11
|
#include "window.h"
|
12
|
+
#include "event.h"
|
12
13
|
#include "selector.h"
|
13
14
|
#include "timer.h"
|
14
15
|
#include "style.h"
|
@@ -877,7 +878,7 @@ namespace Reflex
|
|
877
878
|
result->clear();
|
878
879
|
|
879
880
|
Selector* sel = view->self->pselector.get();
|
880
|
-
if (!sel || sel->
|
881
|
+
if (!sel || sel->empty())
|
881
882
|
return false;
|
882
883
|
|
883
884
|
get_styles_for_selector(result, view, *sel);
|
@@ -1211,7 +1212,7 @@ namespace Reflex
|
|
1211
1212
|
|
1212
1213
|
View::Data* self = view->self.get();
|
1213
1214
|
|
1214
|
-
if (selector.
|
1215
|
+
if (selector.empty())
|
1215
1216
|
self->add_flag(View::Data::UPDATE_STYLE);
|
1216
1217
|
else
|
1217
1218
|
self->selectors_for_update().insert(selector);
|
@@ -1228,16 +1229,15 @@ namespace Reflex
|
|
1228
1229
|
|
1229
1230
|
template <typename FUN, typename EVENT>
|
1230
1231
|
static void
|
1231
|
-
call_children (View* parent,
|
1232
|
+
call_children (View* parent, const EVENT& event, FUN fun)
|
1232
1233
|
{
|
1233
1234
|
assert(parent);
|
1234
1235
|
|
1235
|
-
|
1236
|
-
if (pchildren)
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
}
|
1236
|
+
auto* pchildren = parent->self->pchildren.get();
|
1237
|
+
if (!pchildren) return;
|
1238
|
+
|
1239
|
+
for (auto& pchild : *pchildren)
|
1240
|
+
fun(pchild.get(), event);
|
1241
1241
|
}
|
1242
1242
|
|
1243
1243
|
void
|
@@ -1246,9 +1246,6 @@ namespace Reflex
|
|
1246
1246
|
if (!view)
|
1247
1247
|
argument_error(__FILE__, __LINE__);
|
1248
1248
|
|
1249
|
-
bool capturing = view->capture() & View::CAPTURE_KEY;
|
1250
|
-
if (capturing != event.capture) return;
|
1251
|
-
|
1252
1249
|
KeyEvent e = event;
|
1253
1250
|
view->on_key(&e);
|
1254
1251
|
|
@@ -1261,22 +1258,34 @@ namespace Reflex
|
|
1261
1258
|
}
|
1262
1259
|
|
1263
1260
|
static void
|
1264
|
-
|
1265
|
-
PointerEvent* to, const PointerEvent& from, const Bounds& frame)
|
1261
|
+
update_captures (View* view, PointerEvent* event)
|
1266
1262
|
{
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1263
|
+
Window* win = view->window();
|
1264
|
+
if (!win)
|
1265
|
+
invalid_state_error(__FILE__, __LINE__);
|
1270
1266
|
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
if (
|
1275
|
-
|
1267
|
+
PointerEvent_each_pointer(event, [&](const auto& pointer)
|
1268
|
+
{
|
1269
|
+
auto action = pointer.action();
|
1270
|
+
if (action == Pointer::DOWN)
|
1271
|
+
{
|
1272
|
+
Window_register_capture(win, view, pointer.id());
|
1273
|
+
}
|
1274
|
+
else if (action == Pointer::UP || action == Pointer::CANCEL)
|
1275
|
+
{
|
1276
|
+
Window_unregister_capture(win, view, pointer.id());
|
1277
|
+
}
|
1278
|
+
});
|
1279
|
+
}
|
1276
1280
|
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1281
|
+
static void
|
1282
|
+
call_pointer_event_for_each_child (View* parent, const PointerEvent& event)
|
1283
|
+
{
|
1284
|
+
call_children(parent, event, [](View* child, const PointerEvent& e) {
|
1285
|
+
PointerEvent e2 = e;
|
1286
|
+
PointerEvent_update_for_child_view(&e2, child);
|
1287
|
+
View_call_pointer_event(child, e2);
|
1288
|
+
});
|
1280
1289
|
}
|
1281
1290
|
|
1282
1291
|
void
|
@@ -1285,29 +1294,25 @@ namespace Reflex
|
|
1285
1294
|
if (!view)
|
1286
1295
|
argument_error(__FILE__, __LINE__);
|
1287
1296
|
|
1288
|
-
|
1289
|
-
if (capturing != event.capture) return;
|
1290
|
-
|
1291
|
-
const Bounds& frame = view->frame();
|
1292
|
-
|
1293
|
-
PointerEvent e = event;
|
1294
|
-
filter_pointer_event(&e, event, frame);
|
1295
|
-
|
1296
|
-
if (!capturing && e.size == 0)
|
1297
|
+
if (event.empty())
|
1297
1298
|
return;
|
1298
1299
|
|
1300
|
+
PointerEvent e = event;
|
1299
1301
|
view->on_pointer(&e);
|
1300
1302
|
|
1301
|
-
switch (e.
|
1303
|
+
switch (e[0].action())
|
1302
1304
|
{
|
1303
|
-
case
|
1304
|
-
case
|
1305
|
-
case
|
1306
|
-
case
|
1305
|
+
case Pointer::DOWN: view->on_pointer_down(&e); break;
|
1306
|
+
case Pointer::UP: view->on_pointer_up(&e); break;
|
1307
|
+
case Pointer::MOVE: view->on_pointer_move(&e); break;
|
1308
|
+
case Pointer::CANCEL: view->on_pointer_cancel(&e); break;
|
1309
|
+
default: break;
|
1307
1310
|
}
|
1308
1311
|
|
1309
|
-
|
1310
|
-
|
1312
|
+
update_captures(view, &e);
|
1313
|
+
|
1314
|
+
if (!e.is_captured())
|
1315
|
+
call_pointer_event_for_each_child(view, e);
|
1311
1316
|
}
|
1312
1317
|
|
1313
1318
|
void
|
@@ -1326,7 +1331,7 @@ namespace Reflex
|
|
1326
1331
|
|
1327
1332
|
view->on_wheel(&e);
|
1328
1333
|
|
1329
|
-
call_children(view,
|
1334
|
+
call_children(view, e, View_call_wheel_event);
|
1330
1335
|
}
|
1331
1336
|
|
1332
1337
|
void
|
@@ -1462,22 +1467,29 @@ namespace Reflex
|
|
1462
1467
|
Point
|
1463
1468
|
View::from_parent (const Point& point) const
|
1464
1469
|
{
|
1465
|
-
|
1466
|
-
|
1470
|
+
if (!parent())
|
1471
|
+
invalid_state_error(__FILE__, __LINE__);
|
1472
|
+
|
1473
|
+
return point - frame().position();
|
1467
1474
|
}
|
1468
1475
|
|
1469
1476
|
Point
|
1470
1477
|
View::to_parent (const Point& point) const
|
1471
1478
|
{
|
1472
|
-
|
1473
|
-
|
1479
|
+
if (!parent())
|
1480
|
+
invalid_state_error(__FILE__, __LINE__);
|
1481
|
+
|
1482
|
+
return point + frame().position();
|
1474
1483
|
}
|
1475
1484
|
|
1476
1485
|
Point
|
1477
1486
|
View::from_window (const Point& point) const
|
1478
1487
|
{
|
1488
|
+
if (!window())
|
1489
|
+
invalid_state_error(__FILE__, __LINE__);
|
1490
|
+
|
1479
1491
|
Point p = point;
|
1480
|
-
for (const View* v =
|
1492
|
+
for (const View* v = this; v; v = v->parent())
|
1481
1493
|
p -= v->frame().position();
|
1482
1494
|
return p;
|
1483
1495
|
}
|
@@ -1485,22 +1497,33 @@ namespace Reflex
|
|
1485
1497
|
Point
|
1486
1498
|
View::to_window (const Point& point) const
|
1487
1499
|
{
|
1488
|
-
|
1489
|
-
|
1500
|
+
if (!window())
|
1501
|
+
invalid_state_error(__FILE__, __LINE__);
|
1502
|
+
|
1503
|
+
Point p = point;
|
1504
|
+
for (const View* v = this; v; v = v->parent())
|
1505
|
+
p += v->frame().position();
|
1506
|
+
return p;
|
1490
1507
|
}
|
1491
1508
|
|
1492
1509
|
Point
|
1493
1510
|
View::from_screen (const Point& point) const
|
1494
1511
|
{
|
1495
|
-
|
1496
|
-
|
1512
|
+
const Window* w = window();
|
1513
|
+
if (!w)
|
1514
|
+
invalid_state_error(__FILE__, __LINE__);
|
1515
|
+
|
1516
|
+
return w->from_screen(from_window(point));
|
1497
1517
|
}
|
1498
1518
|
|
1499
1519
|
Point
|
1500
1520
|
View::to_screen (const Point& point) const
|
1501
1521
|
{
|
1502
|
-
|
1503
|
-
|
1522
|
+
const Window* w = window();
|
1523
|
+
if (!w)
|
1524
|
+
invalid_state_error(__FILE__, __LINE__);
|
1525
|
+
|
1526
|
+
return w->to_screen(to_window(point));
|
1504
1527
|
}
|
1505
1528
|
|
1506
1529
|
static void
|
@@ -1682,7 +1705,7 @@ namespace Reflex
|
|
1682
1705
|
Style*
|
1683
1706
|
View::get_style (const Selector& selector, bool create)
|
1684
1707
|
{
|
1685
|
-
if (selector.
|
1708
|
+
if (selector.empty())
|
1686
1709
|
return style(create);
|
1687
1710
|
|
1688
1711
|
StyleList* pstyles = self->pstyles.get();
|
@@ -1989,18 +2012,23 @@ namespace Reflex
|
|
1989
2012
|
void
|
1990
2013
|
View::scroll_to (coord x, coord y, coord z)
|
1991
2014
|
{
|
1992
|
-
Point
|
1993
|
-
self->scroll().reset(x, y, z);
|
1994
|
-
ScrollEvent e(x, y, z, x - old.x, y - old.y, z - old.z);
|
1995
|
-
on_scroll(&e);
|
1996
|
-
|
1997
|
-
redraw();
|
2015
|
+
scroll_to(Point(x, y, z));
|
1998
2016
|
}
|
1999
2017
|
|
2000
2018
|
void
|
2001
2019
|
View::scroll_to (const Point& scroll)
|
2002
2020
|
{
|
2003
|
-
|
2021
|
+
if (scroll == this->scroll()) return;
|
2022
|
+
|
2023
|
+
Point old = self->scroll();
|
2024
|
+
self->scroll() = scroll;
|
2025
|
+
|
2026
|
+
ScrollEvent e(
|
2027
|
+
scroll.x, scroll.y, scroll.z,
|
2028
|
+
scroll.x - old.x, scroll.y - old.y, scroll.z - old.z);
|
2029
|
+
on_scroll(&e);
|
2030
|
+
|
2031
|
+
redraw();
|
2004
2032
|
}
|
2005
2033
|
|
2006
2034
|
void
|
@@ -2028,6 +2056,11 @@ namespace Reflex
|
|
2028
2056
|
void
|
2029
2057
|
View::set_zoom (float zoom)
|
2030
2058
|
{
|
2059
|
+
if (zoom == self->zoom) return;
|
2060
|
+
|
2061
|
+
if (zoom == 0)
|
2062
|
+
argument_error(__FILE__, __LINE__);
|
2063
|
+
|
2031
2064
|
self->zoom = zoom;
|
2032
2065
|
redraw();
|
2033
2066
|
}
|
@@ -2041,7 +2074,8 @@ namespace Reflex
|
|
2041
2074
|
void
|
2042
2075
|
View::set_capture (uint types)
|
2043
2076
|
{
|
2044
|
-
|
2077
|
+
Window* w = window();
|
2078
|
+
if (!w || types == self->capture) return;
|
2045
2079
|
|
2046
2080
|
uint old = self->capture;
|
2047
2081
|
self->capture = types;
|
@@ -2050,9 +2084,9 @@ namespace Reflex
|
|
2050
2084
|
bool capture = types != CAPTURE_NONE;
|
2051
2085
|
|
2052
2086
|
if (capture && !registered)
|
2053
|
-
|
2087
|
+
Window_register_capture(w, this);
|
2054
2088
|
else if (!capture && registered)
|
2055
|
-
|
2089
|
+
Window_unregister_capture(w, this);
|
2056
2090
|
|
2057
2091
|
CaptureEvent e(~old & types, old & ~types);
|
2058
2092
|
on_capture(&e);
|
@@ -2508,6 +2542,11 @@ namespace Reflex
|
|
2508
2542
|
{
|
2509
2543
|
}
|
2510
2544
|
|
2545
|
+
void
|
2546
|
+
View::on_pointer_cancel (PointerEvent* e)
|
2547
|
+
{
|
2548
|
+
}
|
2549
|
+
|
2511
2550
|
void
|
2512
2551
|
View::on_wheel (WheelEvent* e)
|
2513
2552
|
{
|
data/src/view.h
CHANGED
@@ -37,10 +37,6 @@ namespace Reflex
|
|
37
37
|
|
38
38
|
void View_update_shapes (View* view);
|
39
39
|
|
40
|
-
void View_register_capture (View* view);
|
41
|
-
|
42
|
-
void View_unregister_capture (View* view);
|
43
|
-
|
44
40
|
void View_call_key_event (View* view, const KeyEvent& event);
|
45
41
|
|
46
42
|
void View_call_pointer_event (View* view, const PointerEvent& event);
|