reflexion 0.1.6 → 0.1.7
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 +7 -0
- data/.doc/ext/reflex/application.cpp +54 -39
- data/.doc/ext/reflex/capture_event.cpp +87 -0
- data/.doc/ext/reflex/draw_event.cpp +103 -0
- data/.doc/ext/reflex/event.cpp +73 -0
- data/.doc/ext/reflex/focus_event.cpp +98 -0
- data/.doc/ext/reflex/frame_event.cpp +133 -0
- data/.doc/ext/reflex/image_view.cpp +74 -0
- data/.doc/ext/reflex/key_event.cpp +124 -0
- data/.doc/ext/reflex/native.cpp +45 -6
- data/.doc/ext/reflex/pointer_event.cpp +181 -0
- data/.doc/ext/reflex/reflex.cpp +17 -41
- data/.doc/ext/reflex/scroll_event.cpp +141 -0
- data/.doc/ext/reflex/selector.cpp +135 -0
- data/.doc/ext/reflex/style.cpp +253 -0
- data/.doc/ext/reflex/style_length.cpp +133 -0
- data/.doc/ext/reflex/style_length2.cpp +149 -0
- data/.doc/ext/reflex/style_length4.cpp +192 -0
- data/.doc/ext/reflex/update_event.cpp +77 -0
- data/.doc/ext/reflex/view.cpp +408 -88
- data/.doc/ext/reflex/wheel_event.cpp +146 -0
- data/.doc/ext/reflex/window.cpp +95 -92
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +67 -49
- data/ext/reflex/capture_event.cpp +92 -0
- data/ext/reflex/draw_event.cpp +110 -0
- data/ext/reflex/event.cpp +77 -0
- data/ext/reflex/extconf.rb +18 -68
- data/ext/reflex/focus_event.cpp +104 -0
- data/ext/reflex/frame_event.cpp +143 -0
- data/ext/reflex/image_view.cpp +77 -0
- data/ext/reflex/key_event.cpp +133 -0
- data/ext/reflex/native.cpp +45 -6
- data/ext/reflex/pointer_event.cpp +195 -0
- data/ext/reflex/reflex.cpp +21 -47
- data/ext/reflex/scroll_event.cpp +152 -0
- data/ext/reflex/selector.cpp +144 -0
- data/ext/reflex/style.cpp +277 -0
- data/ext/reflex/style_length.cpp +140 -0
- data/ext/reflex/style_length2.cpp +157 -0
- data/ext/reflex/style_length4.cpp +204 -0
- data/ext/reflex/update_event.cpp +81 -0
- data/ext/reflex/view.cpp +469 -114
- data/ext/reflex/wheel_event.cpp +158 -0
- data/ext/reflex/window.cpp +130 -123
- data/include/reflex/application.h +12 -7
- data/include/reflex/defs.h +13 -89
- data/include/reflex/event.h +260 -0
- data/include/reflex/exception.h +17 -11
- data/include/reflex/image_view.h +45 -0
- data/include/reflex/reflex.h +2 -6
- data/include/reflex/ruby/application.h +40 -13
- data/include/reflex/ruby/event.h +72 -0
- data/include/reflex/ruby/image_view.h +25 -0
- data/include/reflex/ruby/selector.h +27 -0
- data/include/reflex/ruby/style.h +27 -0
- data/include/reflex/ruby/style_length.h +37 -0
- data/include/reflex/ruby/view.h +193 -38
- data/include/reflex/ruby/window.h +123 -39
- data/include/reflex/ruby.h +3 -2
- data/include/reflex/selector.h +64 -0
- data/include/reflex/style.h +144 -0
- data/include/reflex/style_length.h +147 -0
- data/include/reflex/view.h +182 -19
- data/include/reflex/window.h +35 -19
- data/include/reflex.h +7 -0
- data/lib/reflex/application.rb +14 -5
- data/lib/reflex/arc_shape.rb +20 -0
- data/lib/reflex/button.rb +75 -0
- data/lib/reflex/capture_event.rb +37 -0
- data/lib/reflex/color.rb +13 -0
- data/lib/reflex/color_space.rb +13 -0
- data/lib/reflex/draw_event.rb +19 -0
- data/lib/reflex/ellipse_shape.rb +20 -0
- data/lib/reflex/ext.rb +1 -1
- data/lib/reflex/flags.rb +18 -0
- data/lib/reflex/focus_event.rb +38 -0
- data/lib/reflex/font.rb +13 -0
- data/lib/reflex/frame_event.rb +42 -0
- data/lib/reflex/helper.rb +87 -30
- data/lib/reflex/image_view.rb +25 -0
- data/lib/reflex/key_event.rb +38 -0
- data/lib/reflex/line_shape.rb +20 -0
- data/lib/reflex/list_view.rb +15 -0
- data/lib/reflex/model.rb +149 -0
- data/lib/reflex/model_owner.rb +57 -0
- data/lib/reflex/model_view.rb +22 -0
- data/lib/reflex/module.rb +11 -7
- data/lib/reflex/pointer_event.rb +85 -0
- data/lib/reflex/rect_shape.rb +20 -0
- data/lib/reflex/reflex.rb +13 -2
- data/lib/reflex/scroll_event.rb +19 -0
- data/lib/reflex/selector.rb +31 -0
- data/lib/reflex/shader.rb +13 -0
- data/lib/reflex/shape.rb +34 -0
- data/lib/reflex/style.rb +55 -0
- data/lib/reflex/style_length.rb +30 -0
- data/lib/reflex/style_length2.rb +34 -0
- data/lib/reflex/style_length4.rb +38 -0
- data/lib/reflex/text_view.rb +55 -0
- data/lib/reflex/update_event.rb +19 -0
- data/lib/reflex/view.rb +38 -4
- data/lib/reflex/wheel_event.rb +19 -0
- data/lib/reflex/window.rb +7 -5
- data/lib/reflex.rb +38 -1
- data/lib/reflexion/include.rb +5 -0
- data/lib/reflexion.rb +100 -0
- data/reflex.gemspec +3 -4
- data/samples/app.rb +13 -0
- data/samples/bats.rb +91 -0
- data/samples/checker.rb +36 -0
- data/{examples/ruby/shapes.rb → samples/fans.rb} +12 -16
- data/samples/fps.rb +46 -0
- data/samples/grid.rb +60 -0
- data/{examples/ruby → samples}/hello.rb +14 -16
- data/samples/image.rb +44 -0
- data/samples/ios/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- data/samples/ios/hello/hello/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
- data/samples/ios/hello/hello/en.lproj/InfoPlist.strings +2 -0
- data/samples/ios/hello/hello/hello-Info.plist +47 -0
- data/samples/ios/hello/hello/hello-Prefix.pch +10 -0
- data/samples/ios/hello/hello/main.cpp +79 -0
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +725 -0
- data/{examples/ruby → samples}/key.rb +11 -14
- data/samples/layout.rb +89 -0
- data/samples/model.rb +86 -0
- data/samples/osx/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
- data/samples/osx/hello/hello/en.lproj/Credits.rtf +29 -0
- data/samples/osx/hello/hello/en.lproj/InfoPlist.strings +2 -0
- data/samples/osx/hello/hello/hello-Info.plist +32 -0
- data/samples/osx/hello/hello/hello-Prefix.pch +3 -0
- data/samples/osx/hello/hello/main.cpp +79 -0
- data/samples/osx/hello/hello.xcodeproj/project.pbxproj +725 -0
- data/samples/reflexion/hello.rb +24 -0
- data/samples/reflexion/paint.rb +40 -0
- data/samples/reflexion/pulse.rb +34 -0
- data/samples/repl.rb +69 -0
- data/samples/shader.rb +41 -0
- data/samples/shapes.rb +30 -0
- data/{examples/ruby → samples}/text.rb +7 -8
- data/samples/tree.rb +71 -0
- data/samples/views.rb +41 -0
- data/samples/visuals.rb +22 -0
- data/src/event.cpp +225 -0
- data/src/exception.cpp +24 -15
- data/src/image_view.cpp +70 -0
- data/src/ios/app_delegate.h +17 -0
- data/src/ios/app_delegate.mm +120 -0
- data/src/ios/application.mm +116 -0
- data/src/{cocoa/applicationdata.h → ios/application_data.h} +6 -6
- data/src/ios/event.h +26 -0
- data/src/ios/event.mm +31 -0
- data/src/ios/native_window.h +37 -0
- data/src/ios/native_window.mm +220 -0
- data/src/ios/opengl_view.h +13 -0
- data/src/ios/opengl_view.mm +131 -0
- data/src/{cocoa → ios}/reflex.mm +8 -12
- data/src/ios/window.mm +303 -0
- data/src/ios/window_data.h +75 -0
- data/src/osx/app_delegate.h +17 -0
- data/src/{cocoa/cocoaapplication.mm → osx/app_delegate.mm} +90 -48
- data/src/osx/application.mm +132 -0
- data/src/osx/application_data.h +45 -0
- data/src/osx/event.h +42 -0
- data/src/osx/event.mm +112 -0
- data/src/osx/native_window.h +26 -0
- data/src/osx/native_window.mm +322 -0
- data/src/{cocoa/openglview.h → osx/opengl_view.h} +0 -4
- data/src/{cocoa/openglview.mm → osx/opengl_view.mm} +66 -23
- data/src/osx/reflex.mm +50 -0
- data/src/osx/window.mm +308 -0
- data/src/osx/window_data.h +75 -0
- data/src/selector.cpp +121 -0
- data/src/style.cpp +576 -0
- data/src/style_length.cpp +341 -0
- data/src/view.cpp +1228 -129
- data/src/win32/application.cpp +1 -1
- data/src/window.cpp +54 -26
- data/test/helper.rb +8 -4
- data/test/test_capture_event.rb +41 -0
- data/test/test_event.rb +20 -0
- data/test/test_has_frame.rb +45 -0
- data/test/test_model.rb +9 -0
- data/test/test_model_owner.rb +9 -0
- data/test/test_selector.rb +75 -0
- data/test/test_style.rb +70 -0
- data/test/test_style_length.rb +38 -0
- data/test/test_style_length2.rb +50 -0
- data/test/test_style_length4.rb +56 -0
- data/test/test_view.rb +97 -23
- data/test/test_window.rb +54 -46
- metadata +205 -84
- data/.doc/ext/reflex/defs.cpp +0 -8
- data/.doc/ext/reflex/key.cpp +0 -122
- data/.doc/ext/reflex/points.cpp +0 -151
- data/.gitignore +0 -14
- data/ChangeLog +0 -8
- data/examples/hello/.gitignore +0 -2
- data/examples/hello/Rakefile +0 -41
- data/examples/hello/main.cpp +0 -18
- data/examples/ruby/app.rb +0 -13
- data/examples/ruby/checker.rb +0 -41
- data/examples/ruby/fps.rb +0 -49
- data/examples/ruby/grid.rb +0 -65
- data/examples/ruby/views.rb +0 -88
- data/examples/ruby/visuals.rb +0 -27
- data/ext/reflex/defs.cpp +0 -8
- data/ext/reflex/key.cpp +0 -129
- data/ext/reflex/points.cpp +0 -161
- data/include/reflex/ruby/key.h +0 -39
- data/include/reflex/ruby/points.h +0 -39
- data/lib/reflex/visuals/string.rb +0 -53
- data/src/cocoa/application.mm +0 -101
- data/src/cocoa/cocoaapplication.h +0 -21
- data/src/cocoa/cocoawindow.h +0 -46
- data/src/cocoa/cocoawindow.mm +0 -230
- data/src/cocoa/defs.h +0 -34
- data/src/cocoa/defs.mm +0 -87
- data/src/cocoa/window.mm +0 -148
- data/src/cocoa/windowdata.h +0 -56
- data/src/defs.cpp +0 -47
- data/src/helper.h +0 -12
- data/src/reflex.cpp +0 -43
- /data/{README → README.md} +0 -0
data/lib/reflex/model.rb
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'xot/invoker'
|
|
5
|
+
require 'xot/setter'
|
|
6
|
+
require 'xot/block_util'
|
|
7
|
+
require 'reflex/color'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module Reflex
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Model
|
|
14
|
+
|
|
15
|
+
include Enumerable
|
|
16
|
+
include Xot::Invoker
|
|
17
|
+
include Xot::Setter
|
|
18
|
+
|
|
19
|
+
attr_reader :data
|
|
20
|
+
|
|
21
|
+
def initialize (data = nil, &block)
|
|
22
|
+
self.data = data if data
|
|
23
|
+
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def data= (data)
|
|
27
|
+
skip, data = apply_filters(data).tap do |filtered|
|
|
28
|
+
skip = filtered.nil? && !data.nil?
|
|
29
|
+
break skip, filtered
|
|
30
|
+
end
|
|
31
|
+
if !skip && data != @data
|
|
32
|
+
@data = data
|
|
33
|
+
invoke :update
|
|
34
|
+
end
|
|
35
|
+
@data
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def add_handler (handler)
|
|
39
|
+
super
|
|
40
|
+
invoke :attach, {}, only: handler
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def remove_handler (handler)
|
|
44
|
+
invoke :detach, {}, only: handler
|
|
45
|
+
super
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def invoke (name, attributes = {}, options = {})
|
|
49
|
+
attributes[:data] ||= @data
|
|
50
|
+
super "on_data_#{name}".intern, attributes, options
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def add_filter (&block)
|
|
54
|
+
(@filters ||= []).push block
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def remove_filter (&block)
|
|
58
|
+
@filters.delete block if @filters
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
alias filter add_filter
|
|
62
|
+
|
|
63
|
+
def validate (&block)
|
|
64
|
+
filter {|data| block.call(data) ? data : nil}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def min= (min)
|
|
68
|
+
filter {|data| data < min ? min : data}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def max= (max)
|
|
72
|
+
filter {|data| data > max ? max : data}
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def minmax= (range)
|
|
76
|
+
min, max = range.min, range.max
|
|
77
|
+
filter {|data| data < min ? min : data > max ? max : data}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def int (defvar = nil)
|
|
81
|
+
call_symbols INT_SYMS
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def float (defvar = nil)
|
|
85
|
+
call_symbols FLOAT_SYMS
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def string (defvar = nil)
|
|
89
|
+
call_symbols STRING_SYMS
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def [] (*args)
|
|
93
|
+
call_symbols ARRAY_GET_SYMS, *args
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def []= (*args)
|
|
97
|
+
ret = call_symbols ARRAY_SET_SYMS, *args
|
|
98
|
+
invoke :update
|
|
99
|
+
ret
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def size ()
|
|
103
|
+
call_symbols(ARRAY_SIZE_SYMS) || 0
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def each (&block)
|
|
107
|
+
data.each &block if block && data.respond_to?(:each)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def inspect ()
|
|
111
|
+
"#<Model data:#{@data.inspect}>"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
private
|
|
115
|
+
|
|
116
|
+
INT_SYMS = [:to_i, :to_int]
|
|
117
|
+
|
|
118
|
+
FLOAT_SYMS = [:to_f, :to_float]
|
|
119
|
+
|
|
120
|
+
STRING_SYMS = [:to_s, :to_str, :to_string]
|
|
121
|
+
|
|
122
|
+
ARRAY_GET_SYMS = [:[], :at]
|
|
123
|
+
|
|
124
|
+
ARRAY_SET_SYMS = [:[]=, :set_at]
|
|
125
|
+
|
|
126
|
+
ARRAY_SIZE_SYMS = [:size, :length]
|
|
127
|
+
|
|
128
|
+
def apply_filters (data)
|
|
129
|
+
return data unless @filters
|
|
130
|
+
@filters.each do |filter|
|
|
131
|
+
break if data.nil?
|
|
132
|
+
data = filter.call data
|
|
133
|
+
end
|
|
134
|
+
data
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def call_symbols (symbols, *args)
|
|
138
|
+
if dat = data
|
|
139
|
+
symbols.each do |symbol|
|
|
140
|
+
return dat.send symbol, *args if dat.respond_to? symbol
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
nil
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
end# Model
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
end# Reflex
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'reflex/model'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Reflex
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module ModelOwner
|
|
11
|
+
|
|
12
|
+
attr_reader :model
|
|
13
|
+
|
|
14
|
+
def model= (model)
|
|
15
|
+
return if model == @model
|
|
16
|
+
@model.remove_handler self if @model
|
|
17
|
+
@model = model
|
|
18
|
+
@model.add_handler self if @model
|
|
19
|
+
model
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def data= (data)
|
|
23
|
+
unless data.nil?
|
|
24
|
+
self.model = Model.new unless @model
|
|
25
|
+
@model.data = data
|
|
26
|
+
else
|
|
27
|
+
self.model = nil
|
|
28
|
+
end
|
|
29
|
+
data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def data ()
|
|
33
|
+
@model ? @model.data : nil
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def invoke (*args)
|
|
37
|
+
@model.invoke *args if @model
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def on_data_attach (e)
|
|
41
|
+
invoke :update, {}, only: self
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def on_data_detach (e)
|
|
45
|
+
invoke :update, {}, only: self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
[:int, :float, :string, :[], :[]=].each do |name|
|
|
49
|
+
define_method name do |*args|
|
|
50
|
+
@model ? @model.send(name, *args) : nil
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end# ModelOwner
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
end# Reflex
|
data/lib/reflex/module.rb
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
module Reflex
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
module Module
|
|
8
|
+
|
|
9
|
+
def name ()
|
|
10
|
+
super.split('::')[-2]
|
|
11
|
+
end
|
|
8
12
|
|
|
9
13
|
def version ()
|
|
10
14
|
open(root_dir 'VERSION') {|f| f.readline.chomp}
|
|
@@ -14,12 +18,12 @@ module Reflex
|
|
|
14
18
|
File.expand_path "../../../#{path}", __FILE__
|
|
15
19
|
end
|
|
16
20
|
|
|
17
|
-
def
|
|
18
|
-
|
|
21
|
+
def include_dir ()
|
|
22
|
+
root_dir 'include'
|
|
19
23
|
end
|
|
20
24
|
|
|
21
|
-
def
|
|
22
|
-
|
|
25
|
+
def lib_dir ()
|
|
26
|
+
root_dir 'lib'
|
|
23
27
|
end
|
|
24
28
|
|
|
25
29
|
def task_dir ()
|
|
@@ -37,9 +41,9 @@ module Reflex
|
|
|
37
41
|
end
|
|
38
42
|
end
|
|
39
43
|
|
|
40
|
-
self
|
|
44
|
+
extend self
|
|
41
45
|
|
|
42
|
-
end#
|
|
46
|
+
end# Module
|
|
43
47
|
|
|
44
48
|
|
|
45
49
|
end# Reflex
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'reflex/ext'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Reflex
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PointerEvent
|
|
11
|
+
|
|
12
|
+
alias pos position
|
|
13
|
+
|
|
14
|
+
def type ()
|
|
15
|
+
TYPE2SYM[get_type] || :none
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def down? ()
|
|
19
|
+
get_type == TYPE_DOWN
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def up? ()
|
|
23
|
+
get_type == TYPE_UP
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def move? ()
|
|
27
|
+
get_type == TYPE_MOVE
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def left? ()
|
|
31
|
+
pointer_type.include? :mouse_left
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def right? ()
|
|
35
|
+
pointer_type.include? :mouse_right
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def middle? ()
|
|
39
|
+
pointer_type.include? :mouse_middle
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def touch? ()
|
|
43
|
+
pointer_type.include? :touch
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def pen? ()
|
|
47
|
+
pointer_type.include? :pen
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def pointer_type ()
|
|
51
|
+
type_, array = get_pointer_type, []
|
|
52
|
+
POINTER_TYPE_LAST.to_s(2).sub(/^0+/, '').size.times do |i|
|
|
53
|
+
bit = 0x1 << i
|
|
54
|
+
if (type_ & bit) != 0
|
|
55
|
+
sym = POINTERTYPE2SYM[bit]
|
|
56
|
+
array << sym if sym
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
array
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def inspect ()
|
|
63
|
+
"#<Reflex::PointerEvent type:#{type}/#{pointer_type} x:#{x} y:#{y} size:#{size} mod:#{modifiers} count:#{count} drag:#{drag?}>"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
TYPE2SYM = {
|
|
69
|
+
TYPE_DOWN => :down,
|
|
70
|
+
TYPE_UP => :up,
|
|
71
|
+
TYPE_MOVE => :move
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
POINTERTYPE2SYM = {
|
|
75
|
+
POINTER_MOUSE_LEFT => :mouse_left,
|
|
76
|
+
POINTER_MOUSE_RIGHT => :mouse_right,
|
|
77
|
+
POINTER_MOUSE_MIDDLE => :mouse_middle,
|
|
78
|
+
POINTER_TOUCH => :touch,
|
|
79
|
+
POINTER_PEN => :pen,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
end# PointerEvent
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
end# Reflex
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'reflex/shape'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Reflex
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RectShape < Shape
|
|
11
|
+
|
|
12
|
+
def on_draw (e)
|
|
13
|
+
p, b = e.painter, e.bounds
|
|
14
|
+
attach_color_and_border(p) {p.rect b}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end# RectShape
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
end# Reflex
|
data/lib/reflex/reflex.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
require 'reflex/ext'
|
|
5
|
+
require 'reflex/window'
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
module Reflex
|
|
@@ -9,8 +10,18 @@ module Reflex
|
|
|
9
10
|
|
|
10
11
|
extend module ClassMethods
|
|
11
12
|
|
|
12
|
-
def
|
|
13
|
-
|
|
13
|
+
def start (*args, &block)
|
|
14
|
+
Application.new(*args, &block).start
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def quit ()
|
|
18
|
+
Application.instance.quit
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def window (*args, &block)
|
|
22
|
+
w = Window.new *args, &block
|
|
23
|
+
w.show
|
|
24
|
+
w
|
|
14
25
|
end
|
|
15
26
|
|
|
16
27
|
self
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'reflex/ext'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Reflex
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ScrollEvent
|
|
11
|
+
|
|
12
|
+
def inspect ()
|
|
13
|
+
"#<Reflex::ScrollEvent x:#{x} y:#{y} z:#{z} dx:#{dx} dy:#{dy} dz:#{dz}>"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end# ScrollEvent
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
end# Reflex
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'xot/setter'
|
|
5
|
+
require 'xot/block_util'
|
|
6
|
+
require 'reflex/ext'
|
|
7
|
+
require 'reflex/helper'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module Reflex
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Selector
|
|
14
|
+
|
|
15
|
+
include Xot::Setter
|
|
16
|
+
include HasTags
|
|
17
|
+
|
|
18
|
+
def initialize (opts = {}, &block)
|
|
19
|
+
super()
|
|
20
|
+
set opts
|
|
21
|
+
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def inspect ()
|
|
25
|
+
"#<#{self.class} name:'#{name}' tags:[#{tags.map{|s| "'#{s}'"}.to_a.join ','}]>"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end# Selector
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
end# Reflex
|
data/lib/reflex/shape.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'reflex/view'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Reflex
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Shape < View
|
|
11
|
+
|
|
12
|
+
attr_accessor :color, :border
|
|
13
|
+
|
|
14
|
+
def initialize (*args, &block)
|
|
15
|
+
@color = :white
|
|
16
|
+
@border = :none
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def attach_color_and_border (painter, &block)
|
|
23
|
+
fill, stroke = painter.color @color, @border
|
|
24
|
+
if block
|
|
25
|
+
block.call
|
|
26
|
+
painter.color fill, stroke
|
|
27
|
+
end
|
|
28
|
+
return fill, stroke
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end# Shape
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
end# Reflex
|
data/lib/reflex/style.rb
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'xot/setter'
|
|
5
|
+
require 'xot/block_util'
|
|
6
|
+
require 'reflex/ext'
|
|
7
|
+
require 'reflex/helper'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module Reflex
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Style
|
|
14
|
+
|
|
15
|
+
include Xot::Setter
|
|
16
|
+
include HasTags
|
|
17
|
+
|
|
18
|
+
def initialize (opts = {}, &block)
|
|
19
|
+
super()
|
|
20
|
+
set opts
|
|
21
|
+
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def flow= (*syms)
|
|
25
|
+
set_flow *syms.flatten.map {|sym| sym2flow sym}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def flow ()
|
|
29
|
+
get_flow.map {|n| flow2sym n}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
SYM2FLOW = {
|
|
35
|
+
none: FLOW_NONE,
|
|
36
|
+
down: FLOW_DOWN,
|
|
37
|
+
right: FLOW_RIGHT,
|
|
38
|
+
up: FLOW_UP,
|
|
39
|
+
left: FLOW_LEFT,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
FLOW2SYM = SYM2FLOW.inject({}) {|h, (k, v)| h[v] = k; h}
|
|
43
|
+
|
|
44
|
+
def sym2flow (sym)
|
|
45
|
+
SYM2FLOW[sym] || FLOW_NONE
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def flow2sym (flow)
|
|
49
|
+
FLOW2SYM[flow] || :none
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end# Style
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
end# Reflex
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'reflex/ext'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module Reflex
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class StyleLength
|
|
11
|
+
|
|
12
|
+
def initialize (*args)
|
|
13
|
+
return if args.empty?
|
|
14
|
+
case args[0]
|
|
15
|
+
when Numeric
|
|
16
|
+
args << :px if args.size < 2
|
|
17
|
+
setup_num *args
|
|
18
|
+
when String
|
|
19
|
+
setup_str *args
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def inspect ()
|
|
24
|
+
"#<Reflex::StyleLength #{value}#{unit}>"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end# StyleLength
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
end# Reflex
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'xot/setter'
|
|
5
|
+
require 'xot/block_util'
|
|
6
|
+
require 'reflex/ext'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module Reflex
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class StyleLength2
|
|
13
|
+
|
|
14
|
+
include Xot::Setter
|
|
15
|
+
|
|
16
|
+
alias w= width=
|
|
17
|
+
alias w width
|
|
18
|
+
alias h= height=
|
|
19
|
+
alias h height
|
|
20
|
+
|
|
21
|
+
def initialize (opts = {}, &block)
|
|
22
|
+
super()
|
|
23
|
+
set opts
|
|
24
|
+
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_a ()
|
|
28
|
+
[width, height]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end# StyleLength2
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
end# Reflex
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
require 'xot/setter'
|
|
5
|
+
require 'xot/block_util'
|
|
6
|
+
require 'reflex/ext'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module Reflex
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class StyleLength4
|
|
13
|
+
|
|
14
|
+
include Xot::Setter
|
|
15
|
+
|
|
16
|
+
alias l= left=
|
|
17
|
+
alias l left
|
|
18
|
+
alias t= top=
|
|
19
|
+
alias t top
|
|
20
|
+
alias r= right=
|
|
21
|
+
alias r right
|
|
22
|
+
alias b= bottom=
|
|
23
|
+
alias b bottom
|
|
24
|
+
|
|
25
|
+
def initialize (opts = {}, &block)
|
|
26
|
+
super()
|
|
27
|
+
set opts
|
|
28
|
+
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_a ()
|
|
32
|
+
[left, top, right, bottom]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end# StyleLength4
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
end# Reflex
|