reflexion 0.1.20 → 0.1.24
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/capture_event.cpp +6 -5
- data/.doc/ext/reflex/contact_event.cpp +18 -16
- data/.doc/ext/reflex/draw_event.cpp +10 -8
- data/.doc/ext/reflex/event.cpp +10 -10
- data/.doc/ext/reflex/focus_event.cpp +18 -17
- data/.doc/ext/reflex/frame_event.cpp +17 -17
- data/.doc/ext/reflex/key_event.cpp +227 -28
- data/.doc/ext/reflex/native.cpp +2 -0
- data/.doc/ext/reflex/pointer.cpp +158 -0
- data/.doc/ext/reflex/pointer_event.cpp +32 -91
- data/.doc/ext/reflex/scroll_event.cpp +14 -17
- data/.doc/ext/reflex/selector.cpp +8 -0
- data/.doc/ext/reflex/timer.cpp +9 -1
- data/.doc/ext/reflex/timer_event.cpp +4 -13
- data/.doc/ext/reflex/update_event.cpp +6 -5
- data/.doc/ext/reflex/view.cpp +57 -0
- data/.doc/ext/reflex/wheel_event.cpp +39 -22
- data/.doc/ext/reflex/window.cpp +41 -0
- data/VERSION +1 -1
- data/ext/reflex/capture_event.cpp +6 -5
- data/ext/reflex/contact_event.cpp +18 -16
- data/ext/reflex/draw_event.cpp +9 -7
- data/ext/reflex/event.cpp +11 -11
- data/ext/reflex/focus_event.cpp +18 -17
- data/ext/reflex/frame_event.cpp +16 -16
- data/ext/reflex/key_event.cpp +228 -28
- data/ext/reflex/native.cpp +2 -0
- data/ext/reflex/pointer.cpp +170 -0
- data/ext/reflex/pointer_event.cpp +31 -96
- data/ext/reflex/scroll_event.cpp +15 -18
- data/ext/reflex/selector.cpp +9 -0
- data/ext/reflex/timer.cpp +15 -6
- data/ext/reflex/timer_event.cpp +9 -19
- data/ext/reflex/update_event.cpp +6 -5
- data/ext/reflex/view.cpp +67 -3
- data/ext/reflex/wheel_event.cpp +40 -21
- data/ext/reflex/window.cpp +49 -3
- data/include/reflex/defs.h +140 -106
- data/include/reflex/event.h +232 -124
- 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/shape.h +2 -2
- 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 +10 -10
- data/lib/reflex/draw_event.rb +2 -2
- data/lib/reflex/ellipse_shape.rb +2 -2
- data/lib/reflex/focus_event.rb +11 -11
- 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 +12 -12
- 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 +3 -2
- data/lib/reflex/update_event.rb +1 -1
- data/lib/reflex/view.rb +32 -32
- data/lib/reflex/wheel_event.rb +2 -10
- data/lib/reflex/window.rb +8 -7
- 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 +792 -86
- data/src/event.h +47 -0
- data/src/image_view.cpp +2 -2
- data/src/ios/event.h +15 -3
- data/src/ios/event.mm +126 -11
- data/src/ios/view_controller.mm +51 -23
- data/src/ios/window.mm +18 -0
- data/src/osx/event.h +15 -4
- data/src/osx/event.mm +214 -24
- data/src/osx/native_window.mm +85 -18
- 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/shape.cpp +11 -13
- data/src/shape.h +1 -1
- data/src/view.cpp +205 -118
- data/src/view.h +5 -10
- data/src/window.cpp +346 -104
- data/src/window.h +28 -3
- data/src/world.cpp +6 -4
- data/test/helper.rb +3 -3
- data/test/test_application.rb +1 -1
- data/test/test_capture_event.rb +22 -6
- data/test/test_contact_event.rb +40 -0
- data/test/test_draw_event.rb +35 -0
- data/test/test_event.rb +33 -5
- data/test/test_focus_event.rb +34 -0
- data/test/test_frame_event.rb +38 -0
- data/test/test_has_frame.rb +11 -11
- data/test/test_key_event.rb +33 -0
- 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_scroll_event.rb +39 -0
- 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_timer_event.rb +38 -0
- data/test/test_update_event.rb +29 -0
- data/test/test_view.rb +57 -30
- data/test/test_wheel_event.rb +40 -0
- data/test/test_window.rb +45 -26
- metadata +64 -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);
|
@@ -947,7 +948,7 @@ namespace Reflex
|
|
947
948
|
|
948
949
|
View::Data* self = view->self.get();
|
949
950
|
|
950
|
-
fire_timers(view, event.now);
|
951
|
+
fire_timers(view, event.now());
|
951
952
|
|
952
953
|
View::ChildList* pchildren = self->pchildren.get();
|
953
954
|
if (pchildren)
|
@@ -957,9 +958,9 @@ namespace Reflex
|
|
957
958
|
}
|
958
959
|
|
959
960
|
update_view_shapes(view);
|
960
|
-
update_child_world(view, event.dt);
|
961
|
+
update_child_world(view, event.dt());
|
961
962
|
|
962
|
-
UpdateEvent e = event;
|
963
|
+
UpdateEvent e = event.dup();
|
963
964
|
view->on_update(&e);
|
964
965
|
|
965
966
|
update_views_for_selectors(view);
|
@@ -1023,7 +1024,10 @@ namespace Reflex
|
|
1023
1024
|
static void
|
1024
1025
|
draw_default_shape (View* view, DrawEvent* event)
|
1025
1026
|
{
|
1026
|
-
assert(view && event
|
1027
|
+
assert(view && event);
|
1028
|
+
|
1029
|
+
Painter* painter = event->painter();
|
1030
|
+
assert(painter);
|
1027
1031
|
|
1028
1032
|
const Style& style = View_get_style(view);
|
1029
1033
|
const Color& back_fill = style.background_fill();
|
@@ -1032,26 +1036,26 @@ namespace Reflex
|
|
1032
1036
|
Shape* shape = view->shape(false);
|
1033
1037
|
if (shape)
|
1034
1038
|
{
|
1035
|
-
setup_painter(
|
1039
|
+
setup_painter(painter, back_fill, back_stroke);
|
1036
1040
|
shape->on_draw(event);
|
1037
1041
|
}
|
1038
1042
|
else if (back_fill || back_stroke)
|
1039
1043
|
{
|
1040
|
-
setup_painter(
|
1041
|
-
|
1044
|
+
setup_painter(painter, back_fill, back_stroke);
|
1045
|
+
painter->rect(event->bounds());
|
1042
1046
|
}
|
1043
1047
|
}
|
1044
1048
|
|
1045
1049
|
static void
|
1046
1050
|
draw_content (View* view, DrawEvent* event)
|
1047
1051
|
{
|
1048
|
-
assert(view && event && event->painter);
|
1052
|
+
assert(view && event && event->painter());
|
1049
1053
|
|
1050
1054
|
draw_default_shape(view, event);
|
1051
1055
|
|
1052
1056
|
const Style& style = View_get_style(view);
|
1053
1057
|
setup_painter(
|
1054
|
-
event->painter, style.foreground_fill(), style.foreground_stroke());
|
1058
|
+
event->painter(), style.foreground_fill(), style.foreground_stroke());
|
1055
1059
|
|
1056
1060
|
View::ShapeList* pshapes = view->self->pshapes.get();
|
1057
1061
|
if (pshapes && !pshapes->empty())
|
@@ -1067,10 +1071,10 @@ namespace Reflex
|
|
1067
1071
|
draw_view (
|
1068
1072
|
View* view, DrawEvent* event, const Point& offset, const Bounds& clip)
|
1069
1073
|
{
|
1070
|
-
assert(view && event && event->painter);
|
1074
|
+
assert(view && event && event->painter());
|
1071
1075
|
View::Data* self = view->self.get();
|
1072
1076
|
|
1073
|
-
Painter* p = event->painter;
|
1077
|
+
Painter* p = event->painter();
|
1074
1078
|
p->push_state();
|
1075
1079
|
|
1076
1080
|
if (self->has_flag(View::FLAG_CLIP) && !self->pbody)
|
@@ -1087,8 +1091,8 @@ namespace Reflex
|
|
1087
1091
|
{
|
1088
1092
|
for (auto& pchild : *pchildren)
|
1089
1093
|
{
|
1090
|
-
if (event->bounds & pchild->self->frame)
|
1091
|
-
View_draw_tree(pchild.get(),
|
1094
|
+
if (event->bounds() & pchild->self->frame)
|
1095
|
+
View_draw_tree(pchild.get(), event, offset, clip);
|
1092
1096
|
}
|
1093
1097
|
}
|
1094
1098
|
|
@@ -1104,23 +1108,24 @@ namespace Reflex
|
|
1104
1108
|
static void
|
1105
1109
|
draw_view_to_cache (View* view, DrawEvent* event)
|
1106
1110
|
{
|
1107
|
-
assert(view && event && event->painter && view->self->pcache_image);
|
1111
|
+
assert(view && event && event->painter() && view->self->pcache_image);
|
1108
1112
|
|
1109
|
-
Painter* view_painter = event->painter;
|
1113
|
+
Painter* view_painter = event->painter();
|
1110
1114
|
Painter cache_painter = view->self->pcache_image->painter();
|
1111
|
-
|
1115
|
+
|
1116
|
+
DrawEvent_set_painter(event, &cache_painter);
|
1112
1117
|
|
1113
1118
|
cache_painter.begin();
|
1114
|
-
draw_view(view, event, 0, event->bounds);
|
1119
|
+
draw_view(view, event, 0, event->bounds());
|
1115
1120
|
cache_painter.end();
|
1116
1121
|
|
1117
|
-
event
|
1122
|
+
DrawEvent_set_painter(event, view_painter);
|
1118
1123
|
}
|
1119
1124
|
|
1120
1125
|
static bool
|
1121
1126
|
draw_view_with_cache (View* view, DrawEvent* event, bool redraw)
|
1122
1127
|
{
|
1123
|
-
assert(view && event && event->painter);
|
1128
|
+
assert(view && event && event->painter());
|
1124
1129
|
View::Data* self = view->self.get();
|
1125
1130
|
|
1126
1131
|
if (!use_cache(view))
|
@@ -1129,7 +1134,7 @@ namespace Reflex
|
|
1129
1134
|
return false;
|
1130
1135
|
}
|
1131
1136
|
|
1132
|
-
Painter* painter = event->painter;
|
1137
|
+
Painter* painter = event->painter();
|
1133
1138
|
|
1134
1139
|
if (reset_cache_image(view, *painter) || redraw)
|
1135
1140
|
{
|
@@ -1147,7 +1152,7 @@ namespace Reflex
|
|
1147
1152
|
if (self->pfilter && *self->pfilter)
|
1148
1153
|
self->pfilter->apply(painter, *self->pcache_image);
|
1149
1154
|
else
|
1150
|
-
painter->image(*self->pcache_image, event->bounds);
|
1155
|
+
painter->image(*self->pcache_image, event->bounds());
|
1151
1156
|
|
1152
1157
|
painter->pop_state();
|
1153
1158
|
|
@@ -1156,7 +1161,7 @@ namespace Reflex
|
|
1156
1161
|
|
1157
1162
|
void
|
1158
1163
|
View_draw_tree (
|
1159
|
-
View* view,
|
1164
|
+
View* view, DrawEvent* event, const Point& offset, const Bounds& clip)
|
1160
1165
|
{
|
1161
1166
|
if (!view)
|
1162
1167
|
argument_error(__FILE__, __LINE__);
|
@@ -1165,26 +1170,24 @@ namespace Reflex
|
|
1165
1170
|
|
1166
1171
|
bool redraw = self->check_and_remove_flag(View::Data::REDRAW);
|
1167
1172
|
|
1168
|
-
if (
|
1173
|
+
if (view->hidden() || event->is_blocked())
|
1169
1174
|
return;
|
1170
1175
|
|
1171
1176
|
if (self->frame.width <= 0 || self->frame.height <= 0)
|
1172
1177
|
return;
|
1173
1178
|
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
e.view = view;
|
1178
|
-
e.bounds = self->frame;
|
1179
|
-
e.bounds.move_to(0, 0, e.bounds.z);
|
1179
|
+
Bounds bounds = self->frame;
|
1180
|
+
Point pos = bounds.position();
|
1181
|
+
Bounds clip2 = bounds.dup().move_by(offset) & clip;
|
1180
1182
|
|
1183
|
+
bounds.move_to(0, 0, bounds.z);
|
1181
1184
|
if (self->pscroll)
|
1182
1185
|
{
|
1183
|
-
|
1184
|
-
|
1186
|
+
bounds.move_by(-*self->pscroll);
|
1187
|
+
pos .move_by( *self->pscroll);
|
1185
1188
|
}
|
1186
1189
|
|
1187
|
-
Painter* p = event
|
1190
|
+
Painter* p = event->painter();
|
1188
1191
|
p->push_matrix();
|
1189
1192
|
p->translate(pos);
|
1190
1193
|
|
@@ -1196,9 +1199,15 @@ namespace Reflex
|
|
1196
1199
|
if (zoom != 1 && zoom > 0)
|
1197
1200
|
p->scale(zoom, zoom);
|
1198
1201
|
|
1199
|
-
|
1202
|
+
DrawEvent e = event->dup();
|
1203
|
+
DrawEvent_set_view(&e, view);
|
1204
|
+
DrawEvent_set_bounds(&e, bounds);
|
1205
|
+
|
1200
1206
|
if (!draw_view_with_cache(view, &e, redraw))
|
1207
|
+
{
|
1208
|
+
pos += offset;
|
1201
1209
|
draw_view(view, &e, pos, clip2);
|
1210
|
+
}
|
1202
1211
|
|
1203
1212
|
p->pop_matrix();
|
1204
1213
|
}
|
@@ -1211,7 +1220,7 @@ namespace Reflex
|
|
1211
1220
|
|
1212
1221
|
View::Data* self = view->self.get();
|
1213
1222
|
|
1214
|
-
if (selector.
|
1223
|
+
if (selector.empty())
|
1215
1224
|
self->add_flag(View::Data::UPDATE_STYLE);
|
1216
1225
|
else
|
1217
1226
|
self->selectors_for_update().insert(selector);
|
@@ -1226,123 +1235,167 @@ namespace Reflex
|
|
1226
1235
|
view->self->add_flag(View::Data::UPDATE_SHAPES);
|
1227
1236
|
}
|
1228
1237
|
|
1229
|
-
|
1238
|
+
void
|
1239
|
+
View_call_key_event (View* view, KeyEvent* event)
|
1240
|
+
{
|
1241
|
+
if (!view || !event)
|
1242
|
+
argument_error(__FILE__, __LINE__);
|
1243
|
+
|
1244
|
+
if (view->hidden()) return;
|
1245
|
+
|
1246
|
+
KeyEvent e = event->dup();
|
1247
|
+
view->on_key(&e);
|
1248
|
+
|
1249
|
+
switch (e.action())
|
1250
|
+
{
|
1251
|
+
case KeyEvent::DOWN: view->on_key_down(&e); break;
|
1252
|
+
case KeyEvent::UP: view->on_key_up(&e); break;
|
1253
|
+
default: break;
|
1254
|
+
}
|
1255
|
+
}
|
1256
|
+
|
1230
1257
|
static void
|
1231
|
-
call_children (View* parent,
|
1258
|
+
call_children (View* parent, std::function<bool(View*)> fun)
|
1232
1259
|
{
|
1233
1260
|
assert(parent);
|
1234
1261
|
|
1235
|
-
|
1236
|
-
if (pchildren)
|
1262
|
+
auto* pchildren = parent->self->pchildren.get();
|
1263
|
+
if (!pchildren) return;
|
1264
|
+
|
1265
|
+
auto end = pchildren->rend();
|
1266
|
+
for (auto it = pchildren->rbegin(); it != end; ++it)
|
1237
1267
|
{
|
1238
|
-
|
1239
|
-
|
1268
|
+
if (!fun(it->get()))
|
1269
|
+
break;
|
1240
1270
|
}
|
1241
1271
|
}
|
1242
1272
|
|
1243
|
-
void
|
1244
|
-
|
1273
|
+
static void
|
1274
|
+
call_pointer_events_for_each_child (View* parent, PointerEvent* event)
|
1245
1275
|
{
|
1246
|
-
|
1247
|
-
|
1276
|
+
assert(parent && event);
|
1277
|
+
|
1278
|
+
call_children(parent, [&](View* child) {
|
1279
|
+
PointerEvent e = event->dup();
|
1280
|
+
PointerEvent_update_for_child_view(&e, child);
|
1281
|
+
View_call_pointer_event(child, &e);
|
1282
|
+
return !e.is_blocked();
|
1283
|
+
});
|
1284
|
+
}
|
1248
1285
|
|
1249
|
-
|
1250
|
-
|
1286
|
+
static void
|
1287
|
+
call_pointer_events (View* view, PointerEvent* event)
|
1288
|
+
{
|
1289
|
+
assert(view && event);
|
1251
1290
|
|
1252
|
-
|
1253
|
-
view->on_key(&e);
|
1291
|
+
view->on_pointer(event);
|
1254
1292
|
|
1255
|
-
switch (
|
1293
|
+
switch ((*event)[0].action())
|
1256
1294
|
{
|
1257
|
-
case
|
1258
|
-
case
|
1259
|
-
case
|
1295
|
+
case Pointer::DOWN: view->on_pointer_down(event); break;
|
1296
|
+
case Pointer::UP: view->on_pointer_up(event); break;
|
1297
|
+
case Pointer::MOVE: view->on_pointer_move(event); break;
|
1298
|
+
case Pointer::CANCEL: view->on_pointer_cancel(event); break;
|
1299
|
+
default: break;
|
1260
1300
|
}
|
1261
1301
|
}
|
1262
1302
|
|
1263
1303
|
static void
|
1264
|
-
|
1265
|
-
PointerEvent* to, const PointerEvent& from, const Bounds& frame)
|
1304
|
+
register_captures (View* view, const PointerEvent& event)
|
1266
1305
|
{
|
1267
|
-
assert(
|
1268
|
-
|
1269
|
-
const Point& offset = frame.position();
|
1306
|
+
assert(view);
|
1270
1307
|
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
if (!frame.is_include(pos))
|
1275
|
-
continue;
|
1308
|
+
Window* win = view->window();
|
1309
|
+
if (!win)
|
1310
|
+
invalid_state_error(__FILE__, __LINE__);
|
1276
1311
|
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1312
|
+
PointerEvent_each_pointer(&event, [&](const auto& pointer)
|
1313
|
+
{
|
1314
|
+
if (pointer.action() == Pointer::DOWN)
|
1315
|
+
Window_register_capture(win, view, pointer.id());
|
1316
|
+
});
|
1280
1317
|
}
|
1281
1318
|
|
1282
|
-
void
|
1283
|
-
|
1319
|
+
static void
|
1320
|
+
unregister_captures (View* view, const PointerEvent& event)
|
1284
1321
|
{
|
1285
|
-
|
1286
|
-
argument_error(__FILE__, __LINE__);
|
1322
|
+
assert(view);
|
1287
1323
|
|
1288
|
-
|
1289
|
-
if (
|
1324
|
+
Window* win = view->window();
|
1325
|
+
if (!win)
|
1326
|
+
invalid_state_error(__FILE__, __LINE__);
|
1290
1327
|
|
1291
|
-
const
|
1328
|
+
PointerEvent_each_pointer(&event, [&](const auto& pointer)
|
1329
|
+
{
|
1330
|
+
auto action = pointer.action();
|
1331
|
+
if (action == Pointer::UP || action == Pointer::CANCEL)
|
1332
|
+
Window_unregister_capture(win, view, pointer.id());
|
1333
|
+
});
|
1334
|
+
}
|
1292
1335
|
|
1293
|
-
|
1294
|
-
|
1336
|
+
void
|
1337
|
+
View_call_pointer_event (View* view, PointerEvent* event)
|
1338
|
+
{
|
1339
|
+
if (!view || !event)
|
1340
|
+
argument_error(__FILE__, __LINE__);
|
1295
1341
|
|
1296
|
-
if (
|
1342
|
+
if (view->hidden() || event->empty())
|
1297
1343
|
return;
|
1298
1344
|
|
1299
|
-
|
1345
|
+
PointerEvent e = event->dup();
|
1300
1346
|
|
1301
|
-
|
1347
|
+
if (!e.is_captured())
|
1348
|
+
call_pointer_events_for_each_child(view, &e);
|
1349
|
+
|
1350
|
+
if (!e.is_blocked())
|
1302
1351
|
{
|
1303
|
-
|
1304
|
-
|
1305
|
-
case PointerEvent::MOVE: view->on_pointer_move(&e); break;
|
1306
|
-
case PointerEvent::NONE: break;
|
1352
|
+
register_captures(view, e);
|
1353
|
+
call_pointer_events(view, &e);
|
1307
1354
|
}
|
1308
1355
|
|
1309
|
-
|
1310
|
-
call_children(view, View_call_pointer_event, e);
|
1356
|
+
unregister_captures(view, e);
|
1311
1357
|
}
|
1312
1358
|
|
1313
1359
|
void
|
1314
|
-
View_call_wheel_event (View* view,
|
1360
|
+
View_call_wheel_event (View* view, WheelEvent* event)
|
1315
1361
|
{
|
1316
|
-
if (!view)
|
1362
|
+
if (!view || !event)
|
1317
1363
|
argument_error(__FILE__, __LINE__);
|
1318
1364
|
|
1365
|
+
if (view->hidden()) return;
|
1366
|
+
|
1319
1367
|
const Bounds& frame = view->frame();
|
1320
1368
|
|
1321
|
-
if (!frame.is_include(event
|
1369
|
+
if (!frame.is_include(event->position()))
|
1322
1370
|
return;
|
1323
1371
|
|
1324
|
-
WheelEvent e = event;
|
1325
|
-
e.position()
|
1372
|
+
WheelEvent e = event->dup();
|
1373
|
+
WheelEvent_set_position(&e, e.position() - frame.position());
|
1326
1374
|
|
1327
|
-
view
|
1375
|
+
call_children(view, [&](View* child) {
|
1376
|
+
View_call_wheel_event(child, &e);
|
1377
|
+
return !e.is_blocked();
|
1378
|
+
});
|
1379
|
+
|
1380
|
+
if (e.is_blocked()) return;
|
1328
1381
|
|
1329
|
-
|
1382
|
+
view->on_wheel(&e);
|
1330
1383
|
}
|
1331
1384
|
|
1332
1385
|
void
|
1333
|
-
View_call_contact_event (View* view,
|
1386
|
+
View_call_contact_event (View* view, ContactEvent* event)
|
1334
1387
|
{
|
1335
|
-
if (!view)
|
1388
|
+
if (!view || !event)
|
1336
1389
|
argument_error(__FILE__, __LINE__);
|
1337
1390
|
|
1338
|
-
ContactEvent e = event;
|
1391
|
+
ContactEvent e = event->dup();
|
1339
1392
|
view->on_contact(&e);
|
1340
1393
|
|
1341
|
-
switch (e.
|
1394
|
+
switch (e.action())
|
1342
1395
|
{
|
1343
1396
|
case ContactEvent::BEGIN: view->on_contact_begin(&e); break;
|
1344
1397
|
case ContactEvent::END: view->on_contact_end(&e); break;
|
1345
|
-
|
1398
|
+
default: break;
|
1346
1399
|
}
|
1347
1400
|
}
|
1348
1401
|
|
@@ -1462,22 +1515,29 @@ namespace Reflex
|
|
1462
1515
|
Point
|
1463
1516
|
View::from_parent (const Point& point) const
|
1464
1517
|
{
|
1465
|
-
|
1466
|
-
|
1518
|
+
if (!parent())
|
1519
|
+
invalid_state_error(__FILE__, __LINE__);
|
1520
|
+
|
1521
|
+
return point - frame().position();
|
1467
1522
|
}
|
1468
1523
|
|
1469
1524
|
Point
|
1470
1525
|
View::to_parent (const Point& point) const
|
1471
1526
|
{
|
1472
|
-
|
1473
|
-
|
1527
|
+
if (!parent())
|
1528
|
+
invalid_state_error(__FILE__, __LINE__);
|
1529
|
+
|
1530
|
+
return point + frame().position();
|
1474
1531
|
}
|
1475
1532
|
|
1476
1533
|
Point
|
1477
1534
|
View::from_window (const Point& point) const
|
1478
1535
|
{
|
1536
|
+
if (!window())
|
1537
|
+
invalid_state_error(__FILE__, __LINE__);
|
1538
|
+
|
1479
1539
|
Point p = point;
|
1480
|
-
for (const View* v =
|
1540
|
+
for (const View* v = this; v; v = v->parent())
|
1481
1541
|
p -= v->frame().position();
|
1482
1542
|
return p;
|
1483
1543
|
}
|
@@ -1485,22 +1545,33 @@ namespace Reflex
|
|
1485
1545
|
Point
|
1486
1546
|
View::to_window (const Point& point) const
|
1487
1547
|
{
|
1488
|
-
|
1489
|
-
|
1548
|
+
if (!window())
|
1549
|
+
invalid_state_error(__FILE__, __LINE__);
|
1550
|
+
|
1551
|
+
Point p = point;
|
1552
|
+
for (const View* v = this; v; v = v->parent())
|
1553
|
+
p += v->frame().position();
|
1554
|
+
return p;
|
1490
1555
|
}
|
1491
1556
|
|
1492
1557
|
Point
|
1493
1558
|
View::from_screen (const Point& point) const
|
1494
1559
|
{
|
1495
|
-
|
1496
|
-
|
1560
|
+
const Window* w = window();
|
1561
|
+
if (!w)
|
1562
|
+
invalid_state_error(__FILE__, __LINE__);
|
1563
|
+
|
1564
|
+
return w->from_screen(from_window(point));
|
1497
1565
|
}
|
1498
1566
|
|
1499
1567
|
Point
|
1500
1568
|
View::to_screen (const Point& point) const
|
1501
1569
|
{
|
1502
|
-
|
1503
|
-
|
1570
|
+
const Window* w = window();
|
1571
|
+
if (!w)
|
1572
|
+
invalid_state_error(__FILE__, __LINE__);
|
1573
|
+
|
1574
|
+
return w->to_screen(to_window(point));
|
1504
1575
|
}
|
1505
1576
|
|
1506
1577
|
static void
|
@@ -1682,7 +1753,7 @@ namespace Reflex
|
|
1682
1753
|
Style*
|
1683
1754
|
View::get_style (const Selector& selector, bool create)
|
1684
1755
|
{
|
1685
|
-
if (selector.
|
1756
|
+
if (selector.empty())
|
1686
1757
|
return style(create);
|
1687
1758
|
|
1688
1759
|
StyleList* pstyles = self->pstyles.get();
|
@@ -1989,18 +2060,23 @@ namespace Reflex
|
|
1989
2060
|
void
|
1990
2061
|
View::scroll_to (coord x, coord y, coord z)
|
1991
2062
|
{
|
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();
|
2063
|
+
scroll_to(Point(x, y, z));
|
1998
2064
|
}
|
1999
2065
|
|
2000
2066
|
void
|
2001
2067
|
View::scroll_to (const Point& scroll)
|
2002
2068
|
{
|
2003
|
-
|
2069
|
+
if (scroll == this->scroll()) return;
|
2070
|
+
|
2071
|
+
Point old = self->scroll();
|
2072
|
+
self->scroll() = scroll;
|
2073
|
+
|
2074
|
+
ScrollEvent e(
|
2075
|
+
scroll.x, scroll.y, scroll.z,
|
2076
|
+
scroll.x - old.x, scroll.y - old.y, scroll.z - old.z);
|
2077
|
+
on_scroll(&e);
|
2078
|
+
|
2079
|
+
redraw();
|
2004
2080
|
}
|
2005
2081
|
|
2006
2082
|
void
|
@@ -2028,6 +2104,11 @@ namespace Reflex
|
|
2028
2104
|
void
|
2029
2105
|
View::set_zoom (float zoom)
|
2030
2106
|
{
|
2107
|
+
if (zoom == self->zoom) return;
|
2108
|
+
|
2109
|
+
if (zoom == 0)
|
2110
|
+
argument_error(__FILE__, __LINE__);
|
2111
|
+
|
2031
2112
|
self->zoom = zoom;
|
2032
2113
|
redraw();
|
2033
2114
|
}
|
@@ -2041,7 +2122,8 @@ namespace Reflex
|
|
2041
2122
|
void
|
2042
2123
|
View::set_capture (uint types)
|
2043
2124
|
{
|
2044
|
-
|
2125
|
+
Window* w = window();
|
2126
|
+
if (!w || types == self->capture) return;
|
2045
2127
|
|
2046
2128
|
uint old = self->capture;
|
2047
2129
|
self->capture = types;
|
@@ -2050,9 +2132,9 @@ namespace Reflex
|
|
2050
2132
|
bool capture = types != CAPTURE_NONE;
|
2051
2133
|
|
2052
2134
|
if (capture && !registered)
|
2053
|
-
|
2135
|
+
Window_register_capture(w, this);
|
2054
2136
|
else if (!capture && registered)
|
2055
|
-
|
2137
|
+
Window_unregister_capture(w, this);
|
2056
2138
|
|
2057
2139
|
CaptureEvent e(~old & types, old & ~types);
|
2058
2140
|
on_capture(&e);
|
@@ -2508,6 +2590,11 @@ namespace Reflex
|
|
2508
2590
|
{
|
2509
2591
|
}
|
2510
2592
|
|
2593
|
+
void
|
2594
|
+
View::on_pointer_cancel (PointerEvent* e)
|
2595
|
+
{
|
2596
|
+
}
|
2597
|
+
|
2511
2598
|
void
|
2512
2599
|
View::on_wheel (WheelEvent* e)
|
2513
2600
|
{
|
data/src/view.h
CHANGED
@@ -30,24 +30,19 @@ namespace Reflex
|
|
30
30
|
void View_update_tree (View* view, const UpdateEvent& event);
|
31
31
|
|
32
32
|
void View_draw_tree (
|
33
|
-
View* view, const
|
34
|
-
const Point& offset, const Bounds& clip);
|
33
|
+
View* view, DrawEvent* event, const Point& offset, const Bounds& clip);
|
35
34
|
|
36
35
|
void View_update_styles (View* view, const Selector& selector);
|
37
36
|
|
38
37
|
void View_update_shapes (View* view);
|
39
38
|
|
40
|
-
void
|
39
|
+
void View_call_key_event (View* view, KeyEvent* event);
|
41
40
|
|
42
|
-
void
|
41
|
+
void View_call_pointer_event (View* view, PointerEvent* event);
|
43
42
|
|
44
|
-
void
|
43
|
+
void View_call_wheel_event (View* view, WheelEvent* event);
|
45
44
|
|
46
|
-
void
|
47
|
-
|
48
|
-
void View_call_wheel_event (View* view, const WheelEvent& event);
|
49
|
-
|
50
|
-
void View_call_contact_event (View* view, const ContactEvent& event);
|
45
|
+
void View_call_contact_event (View* view, ContactEvent* event);
|
51
46
|
|
52
47
|
|
53
48
|
}// Reflex
|