cyberarm_engine 0.19.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/.rubocop.yml +7 -7
- data/.travis.yml +5 -5
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +74 -74
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/cyberarm_engine.gemspec +39 -39
- data/lib/cyberarm_engine/animator.rb +219 -219
- data/lib/cyberarm_engine/background.rb +179 -179
- data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
- data/lib/cyberarm_engine/bounding_box.rb +150 -150
- data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
- data/lib/cyberarm_engine/cache/download_manager.rb +121 -121
- data/lib/cyberarm_engine/cache.rb +4 -4
- data/lib/cyberarm_engine/common.rb +113 -113
- data/lib/cyberarm_engine/config_file.rb +46 -46
- data/lib/cyberarm_engine/console/command.rb +157 -157
- data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
- data/lib/cyberarm_engine/console/subcommand.rb +99 -99
- data/lib/cyberarm_engine/console.rb +248 -248
- data/lib/cyberarm_engine/game_object.rb +248 -248
- data/lib/cyberarm_engine/game_state.rb +97 -97
- data/lib/cyberarm_engine/model/material.rb +21 -21
- data/lib/cyberarm_engine/model/model_object.rb +131 -131
- data/lib/cyberarm_engine/model/parser.rb +74 -74
- data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
- data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
- data/lib/cyberarm_engine/model.rb +212 -212
- data/lib/cyberarm_engine/model_cache.rb +31 -31
- data/lib/cyberarm_engine/opengl/light.rb +50 -50
- data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
- data/lib/cyberarm_engine/opengl/perspective_camera.rb +38 -38
- data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
- data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +164 -164
- data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +298 -298
- data/lib/cyberarm_engine/opengl/renderer/renderer.rb +22 -22
- data/lib/cyberarm_engine/opengl/shader.rb +406 -406
- data/lib/cyberarm_engine/opengl/texture.rb +69 -69
- data/lib/cyberarm_engine/opengl.rb +28 -28
- data/lib/cyberarm_engine/ray.rb +56 -56
- data/lib/cyberarm_engine/stats.rb +21 -21
- data/lib/cyberarm_engine/text.rb +197 -197
- data/lib/cyberarm_engine/timer.rb +23 -23
- data/lib/cyberarm_engine/transform.rb +296 -296
- data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
- data/lib/cyberarm_engine/ui/dsl.rb +139 -139
- data/lib/cyberarm_engine/ui/element.rb +488 -488
- data/lib/cyberarm_engine/ui/elements/button.rb +97 -97
- data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
- data/lib/cyberarm_engine/ui/elements/container.rb +256 -256
- data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
- data/lib/cyberarm_engine/ui/elements/edit_line.rb +263 -263
- data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
- data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
- data/lib/cyberarm_engine/ui/elements/list_box.rb +88 -82
- data/lib/cyberarm_engine/ui/elements/progress.rb +51 -51
- data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
- data/lib/cyberarm_engine/ui/elements/slider.rb +104 -104
- data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
- data/lib/cyberarm_engine/ui/elements/text_block.rb +162 -162
- data/lib/cyberarm_engine/ui/elements/toggle_button.rb +65 -65
- data/lib/cyberarm_engine/ui/event.rb +54 -54
- data/lib/cyberarm_engine/ui/gui_state.rb +256 -256
- data/lib/cyberarm_engine/ui/style.rb +49 -49
- data/lib/cyberarm_engine/ui/theme.rb +207 -207
- data/lib/cyberarm_engine/vector.rb +293 -293
- data/lib/cyberarm_engine/version.rb +4 -4
- data/lib/cyberarm_engine/window.rb +120 -120
- data/lib/cyberarm_engine.rb +71 -71
- metadata +3 -3
@@ -1,263 +1,263 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class Element
|
3
|
-
class EditLine < Button
|
4
|
-
def initialize(text, options = {}, block = nil)
|
5
|
-
@filter = options.delete(:filter)
|
6
|
-
super(text, options, block)
|
7
|
-
|
8
|
-
@type = default(:type)
|
9
|
-
|
10
|
-
@caret_width = default(:caret_width)
|
11
|
-
@caret_height = @text.textobject.height
|
12
|
-
@caret_color = default(:caret_color)
|
13
|
-
@caret_interval = default(:caret_interval)
|
14
|
-
@caret_last_interval = Gosu.milliseconds
|
15
|
-
@show_caret = true
|
16
|
-
|
17
|
-
@text_input = Gosu::TextInput.new
|
18
|
-
@text_input.text = text
|
19
|
-
@last_text_value = text
|
20
|
-
|
21
|
-
if @filter && @filter.respond_to?(:call)
|
22
|
-
@text_input.instance_variable_set(:@filter, @filter)
|
23
|
-
|
24
|
-
def @text_input.filter(text_in)
|
25
|
-
@filter.call(text_in)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
@offset_x = 0
|
30
|
-
@offset_y = 0
|
31
|
-
|
32
|
-
event(:begin_drag)
|
33
|
-
event(:drag_update)
|
34
|
-
event(:end_drag)
|
35
|
-
end
|
36
|
-
|
37
|
-
def render
|
38
|
-
Gosu.clip_to(@text.x, @text.y, @width, @height) do
|
39
|
-
Gosu.translate(-@offset_x, -@offset_y) do
|
40
|
-
draw_selection
|
41
|
-
draw_caret if @focus && @show_caret
|
42
|
-
draw_text
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def draw_text
|
48
|
-
@text.draw(:draw_text)
|
49
|
-
end
|
50
|
-
|
51
|
-
def draw_caret
|
52
|
-
Gosu.draw_rect(caret_position, @text.y, @caret_width, @caret_height, @caret_color, @z)
|
53
|
-
end
|
54
|
-
|
55
|
-
def draw_selection
|
56
|
-
selection_width = caret_position - selection_start_position
|
57
|
-
|
58
|
-
Gosu.draw_rect(selection_start_position, @text.y, selection_width, @text.height, default(:selection_color), @z)
|
59
|
-
end
|
60
|
-
|
61
|
-
def update
|
62
|
-
@style_event = :active if @focus
|
63
|
-
|
64
|
-
@text.text = if @type == :password
|
65
|
-
default(:password_character) * @text_input.text.length
|
66
|
-
else
|
67
|
-
@text_input.text
|
68
|
-
end
|
69
|
-
|
70
|
-
if @last_text_value != value
|
71
|
-
@last_text_value = value
|
72
|
-
@show_caret = true
|
73
|
-
@caret_last_interval = Gosu.milliseconds
|
74
|
-
|
75
|
-
publish(:changed, value)
|
76
|
-
end
|
77
|
-
|
78
|
-
if Gosu.milliseconds >= @caret_last_interval + @caret_interval
|
79
|
-
@caret_last_interval = Gosu.milliseconds
|
80
|
-
|
81
|
-
@show_caret = !@show_caret
|
82
|
-
end
|
83
|
-
|
84
|
-
keep_caret_visible
|
85
|
-
end
|
86
|
-
|
87
|
-
def button_down(id)
|
88
|
-
handle_keyboard_shortcuts(id)
|
89
|
-
end
|
90
|
-
|
91
|
-
def handle_keyboard_shortcuts(id)
|
92
|
-
return unless @focus && @enabled
|
93
|
-
|
94
|
-
if Gosu.button_down?(Gosu::KB_LEFT_CONTROL) || Gosu.button_down?(Gosu::KB_RIGHT_CONTROL)
|
95
|
-
case id
|
96
|
-
when Gosu::KB_A
|
97
|
-
@text_input.selection_start = 0
|
98
|
-
@text_input.caret_pos = @text_input.text.length
|
99
|
-
|
100
|
-
when Gosu::KB_C
|
101
|
-
if @text_input.selection_start < @text_input.caret_pos
|
102
|
-
Clipboard.copy(@text_input.text[@text_input.selection_start...@text_input.caret_pos])
|
103
|
-
else
|
104
|
-
Clipboard.copy(@text_input.text[@text_input.caret_pos...@text_input.selection_start])
|
105
|
-
end
|
106
|
-
|
107
|
-
when Gosu::KB_X
|
108
|
-
chars = @text_input.text.chars
|
109
|
-
|
110
|
-
if @text_input.selection_start < @text_input.caret_pos
|
111
|
-
Clipboard.copy(@text_input.text[@text_input.selection_start...@text_input.caret_pos])
|
112
|
-
chars.slice!(@text_input.selection_start, @text_input.caret_pos)
|
113
|
-
else
|
114
|
-
Clipboard.copy(@text_input.text[@text_input.caret_pos...@text_input.selection_start])
|
115
|
-
chars.slice!(@text_input.caret_pos, @text_input.selection_start)
|
116
|
-
end
|
117
|
-
|
118
|
-
@text_input.text = chars.join
|
119
|
-
|
120
|
-
when Gosu::KB_V
|
121
|
-
if instance_of?(EditLine) # EditLine assumes a single line of text
|
122
|
-
@text_input.text = @text_input.text.insert(@text_input.caret_pos,
|
123
|
-
Clipboard.paste.encode("UTF-8").gsub("\n", ""))
|
124
|
-
else
|
125
|
-
@text_input.text = @text_input.text.insert(@text_input.caret_pos, Clipboard.paste.encode("UTF-8"))
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def caret_position_under_mouse(mouse_x)
|
132
|
-
1.upto(@text.text.length) do |i|
|
133
|
-
return i - 1 if mouse_x < @text.x - @offset_x + @text.width(@text.text[0...i])
|
134
|
-
end
|
135
|
-
|
136
|
-
@text_input.text.length
|
137
|
-
end
|
138
|
-
|
139
|
-
def move_caret_to_mouse(mouse_x, _mouse_y)
|
140
|
-
@text_input.caret_pos = @text_input.selection_start = caret_position_under_mouse(mouse_x)
|
141
|
-
end
|
142
|
-
|
143
|
-
def keep_caret_visible
|
144
|
-
caret_pos = (caret_position - @text.x) + @caret_width
|
145
|
-
|
146
|
-
@last_text ||= "/\\"
|
147
|
-
@last_pos ||= -1
|
148
|
-
|
149
|
-
@last_text = @text.text
|
150
|
-
@last_pos = caret_pos
|
151
|
-
|
152
|
-
if caret_pos.between?(@offset_x, @width + @offset_x)
|
153
|
-
# Do nothing
|
154
|
-
|
155
|
-
elsif caret_pos < @offset_x
|
156
|
-
@offset_x = if caret_pos > @width
|
157
|
-
caret_pos + @width
|
158
|
-
else
|
159
|
-
0
|
160
|
-
end
|
161
|
-
|
162
|
-
elsif caret_pos > @width
|
163
|
-
@offset_x = caret_pos - @width
|
164
|
-
|
165
|
-
else
|
166
|
-
# Reset to Zero
|
167
|
-
@offset_x = 0
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def caret_position
|
172
|
-
text_input_position_for(:caret_pos)
|
173
|
-
end
|
174
|
-
|
175
|
-
def selection_start_position
|
176
|
-
text_input_position_for(:selection_start)
|
177
|
-
end
|
178
|
-
|
179
|
-
def text_input_position_for(method)
|
180
|
-
if @type == :password
|
181
|
-
@text.x + @text.width(default(:password_character) * @text_input.text[0...@text_input.send(method)].length)
|
182
|
-
else
|
183
|
-
@text.x + @text.width(@text_input.text[0...@text_input.send(method)])
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
def left_mouse_button(sender, x, y)
|
188
|
-
super
|
189
|
-
window.text_input = @text_input
|
190
|
-
|
191
|
-
@caret_last_interval = Gosu.milliseconds
|
192
|
-
@show_caret = true
|
193
|
-
|
194
|
-
move_caret_to_mouse(x, y)
|
195
|
-
|
196
|
-
:handled
|
197
|
-
end
|
198
|
-
|
199
|
-
def focus(sender)
|
200
|
-
super
|
201
|
-
|
202
|
-
window.text_input = @text_input
|
203
|
-
@text_input.caret_pos = @text_input.selection_start = @text_input.text.length
|
204
|
-
|
205
|
-
:handled
|
206
|
-
end
|
207
|
-
|
208
|
-
def enter(sender)
|
209
|
-
_has_focus = @focus
|
210
|
-
|
211
|
-
super
|
212
|
-
|
213
|
-
@focus = _has_focus
|
214
|
-
|
215
|
-
:handled
|
216
|
-
end
|
217
|
-
|
218
|
-
def blur(_sender)
|
219
|
-
super
|
220
|
-
window.text_input = nil
|
221
|
-
|
222
|
-
:handled
|
223
|
-
end
|
224
|
-
|
225
|
-
def draggable?(button)
|
226
|
-
button == :left
|
227
|
-
end
|
228
|
-
|
229
|
-
def begin_drag(_sender, x, _y, _button)
|
230
|
-
@drag_start = x
|
231
|
-
@offset_drag_start = @offset_x
|
232
|
-
@drag_caret_position = @text_input.caret_pos
|
233
|
-
|
234
|
-
:handled
|
235
|
-
end
|
236
|
-
|
237
|
-
def drag_update(_sender, x, _y, _button)
|
238
|
-
@text_input.caret_pos = caret_position_under_mouse(x)
|
239
|
-
|
240
|
-
:handled
|
241
|
-
end
|
242
|
-
|
243
|
-
def end_drag(_sender, _x, _y, _button)
|
244
|
-
:handled
|
245
|
-
end
|
246
|
-
|
247
|
-
def recalculate
|
248
|
-
super
|
249
|
-
|
250
|
-
@width = dimensional_size(@style.width, :width) || default(:width)
|
251
|
-
update_background
|
252
|
-
end
|
253
|
-
|
254
|
-
def value
|
255
|
-
@text_input.text
|
256
|
-
end
|
257
|
-
|
258
|
-
def value=(string)
|
259
|
-
@text_input.text = string
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class Element
|
3
|
+
class EditLine < Button
|
4
|
+
def initialize(text, options = {}, block = nil)
|
5
|
+
@filter = options.delete(:filter)
|
6
|
+
super(text, options, block)
|
7
|
+
|
8
|
+
@type = default(:type)
|
9
|
+
|
10
|
+
@caret_width = default(:caret_width)
|
11
|
+
@caret_height = @text.textobject.height
|
12
|
+
@caret_color = default(:caret_color)
|
13
|
+
@caret_interval = default(:caret_interval)
|
14
|
+
@caret_last_interval = Gosu.milliseconds
|
15
|
+
@show_caret = true
|
16
|
+
|
17
|
+
@text_input = Gosu::TextInput.new
|
18
|
+
@text_input.text = text
|
19
|
+
@last_text_value = text
|
20
|
+
|
21
|
+
if @filter && @filter.respond_to?(:call)
|
22
|
+
@text_input.instance_variable_set(:@filter, @filter)
|
23
|
+
|
24
|
+
def @text_input.filter(text_in)
|
25
|
+
@filter.call(text_in)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
@offset_x = 0
|
30
|
+
@offset_y = 0
|
31
|
+
|
32
|
+
event(:begin_drag)
|
33
|
+
event(:drag_update)
|
34
|
+
event(:end_drag)
|
35
|
+
end
|
36
|
+
|
37
|
+
def render
|
38
|
+
Gosu.clip_to(@text.x, @text.y, @width, @height) do
|
39
|
+
Gosu.translate(-@offset_x, -@offset_y) do
|
40
|
+
draw_selection
|
41
|
+
draw_caret if @focus && @show_caret
|
42
|
+
draw_text
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def draw_text
|
48
|
+
@text.draw(:draw_text)
|
49
|
+
end
|
50
|
+
|
51
|
+
def draw_caret
|
52
|
+
Gosu.draw_rect(caret_position, @text.y, @caret_width, @caret_height, @caret_color, @z)
|
53
|
+
end
|
54
|
+
|
55
|
+
def draw_selection
|
56
|
+
selection_width = caret_position - selection_start_position
|
57
|
+
|
58
|
+
Gosu.draw_rect(selection_start_position, @text.y, selection_width, @text.height, default(:selection_color), @z)
|
59
|
+
end
|
60
|
+
|
61
|
+
def update
|
62
|
+
@style_event = :active if @focus
|
63
|
+
|
64
|
+
@text.text = if @type == :password
|
65
|
+
default(:password_character) * @text_input.text.length
|
66
|
+
else
|
67
|
+
@text_input.text
|
68
|
+
end
|
69
|
+
|
70
|
+
if @last_text_value != value
|
71
|
+
@last_text_value = value
|
72
|
+
@show_caret = true
|
73
|
+
@caret_last_interval = Gosu.milliseconds
|
74
|
+
|
75
|
+
publish(:changed, value)
|
76
|
+
end
|
77
|
+
|
78
|
+
if Gosu.milliseconds >= @caret_last_interval + @caret_interval
|
79
|
+
@caret_last_interval = Gosu.milliseconds
|
80
|
+
|
81
|
+
@show_caret = !@show_caret
|
82
|
+
end
|
83
|
+
|
84
|
+
keep_caret_visible
|
85
|
+
end
|
86
|
+
|
87
|
+
def button_down(id)
|
88
|
+
handle_keyboard_shortcuts(id)
|
89
|
+
end
|
90
|
+
|
91
|
+
def handle_keyboard_shortcuts(id)
|
92
|
+
return unless @focus && @enabled
|
93
|
+
|
94
|
+
if Gosu.button_down?(Gosu::KB_LEFT_CONTROL) || Gosu.button_down?(Gosu::KB_RIGHT_CONTROL)
|
95
|
+
case id
|
96
|
+
when Gosu::KB_A
|
97
|
+
@text_input.selection_start = 0
|
98
|
+
@text_input.caret_pos = @text_input.text.length
|
99
|
+
|
100
|
+
when Gosu::KB_C
|
101
|
+
if @text_input.selection_start < @text_input.caret_pos
|
102
|
+
Clipboard.copy(@text_input.text[@text_input.selection_start...@text_input.caret_pos])
|
103
|
+
else
|
104
|
+
Clipboard.copy(@text_input.text[@text_input.caret_pos...@text_input.selection_start])
|
105
|
+
end
|
106
|
+
|
107
|
+
when Gosu::KB_X
|
108
|
+
chars = @text_input.text.chars
|
109
|
+
|
110
|
+
if @text_input.selection_start < @text_input.caret_pos
|
111
|
+
Clipboard.copy(@text_input.text[@text_input.selection_start...@text_input.caret_pos])
|
112
|
+
chars.slice!(@text_input.selection_start, @text_input.caret_pos)
|
113
|
+
else
|
114
|
+
Clipboard.copy(@text_input.text[@text_input.caret_pos...@text_input.selection_start])
|
115
|
+
chars.slice!(@text_input.caret_pos, @text_input.selection_start)
|
116
|
+
end
|
117
|
+
|
118
|
+
@text_input.text = chars.join
|
119
|
+
|
120
|
+
when Gosu::KB_V
|
121
|
+
if instance_of?(EditLine) # EditLine assumes a single line of text
|
122
|
+
@text_input.text = @text_input.text.insert(@text_input.caret_pos,
|
123
|
+
Clipboard.paste.encode("UTF-8").gsub("\n", ""))
|
124
|
+
else
|
125
|
+
@text_input.text = @text_input.text.insert(@text_input.caret_pos, Clipboard.paste.encode("UTF-8"))
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def caret_position_under_mouse(mouse_x)
|
132
|
+
1.upto(@text.text.length) do |i|
|
133
|
+
return i - 1 if mouse_x < @text.x - @offset_x + @text.width(@text.text[0...i])
|
134
|
+
end
|
135
|
+
|
136
|
+
@text_input.text.length
|
137
|
+
end
|
138
|
+
|
139
|
+
def move_caret_to_mouse(mouse_x, _mouse_y)
|
140
|
+
@text_input.caret_pos = @text_input.selection_start = caret_position_under_mouse(mouse_x)
|
141
|
+
end
|
142
|
+
|
143
|
+
def keep_caret_visible
|
144
|
+
caret_pos = (caret_position - @text.x) + @caret_width
|
145
|
+
|
146
|
+
@last_text ||= "/\\"
|
147
|
+
@last_pos ||= -1
|
148
|
+
|
149
|
+
@last_text = @text.text
|
150
|
+
@last_pos = caret_pos
|
151
|
+
|
152
|
+
if caret_pos.between?(@offset_x, @width + @offset_x)
|
153
|
+
# Do nothing
|
154
|
+
|
155
|
+
elsif caret_pos < @offset_x
|
156
|
+
@offset_x = if caret_pos > @width
|
157
|
+
caret_pos + @width
|
158
|
+
else
|
159
|
+
0
|
160
|
+
end
|
161
|
+
|
162
|
+
elsif caret_pos > @width
|
163
|
+
@offset_x = caret_pos - @width
|
164
|
+
|
165
|
+
else
|
166
|
+
# Reset to Zero
|
167
|
+
@offset_x = 0
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def caret_position
|
172
|
+
text_input_position_for(:caret_pos)
|
173
|
+
end
|
174
|
+
|
175
|
+
def selection_start_position
|
176
|
+
text_input_position_for(:selection_start)
|
177
|
+
end
|
178
|
+
|
179
|
+
def text_input_position_for(method)
|
180
|
+
if @type == :password
|
181
|
+
@text.x + @text.width(default(:password_character) * @text_input.text[0...@text_input.send(method)].length)
|
182
|
+
else
|
183
|
+
@text.x + @text.width(@text_input.text[0...@text_input.send(method)])
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def left_mouse_button(sender, x, y)
|
188
|
+
super
|
189
|
+
window.text_input = @text_input
|
190
|
+
|
191
|
+
@caret_last_interval = Gosu.milliseconds
|
192
|
+
@show_caret = true
|
193
|
+
|
194
|
+
move_caret_to_mouse(x, y)
|
195
|
+
|
196
|
+
:handled
|
197
|
+
end
|
198
|
+
|
199
|
+
def focus(sender)
|
200
|
+
super
|
201
|
+
|
202
|
+
window.text_input = @text_input
|
203
|
+
@text_input.caret_pos = @text_input.selection_start = @text_input.text.length
|
204
|
+
|
205
|
+
:handled
|
206
|
+
end
|
207
|
+
|
208
|
+
def enter(sender)
|
209
|
+
_has_focus = @focus
|
210
|
+
|
211
|
+
super
|
212
|
+
|
213
|
+
@focus = _has_focus
|
214
|
+
|
215
|
+
:handled
|
216
|
+
end
|
217
|
+
|
218
|
+
def blur(_sender)
|
219
|
+
super
|
220
|
+
window.text_input = nil
|
221
|
+
|
222
|
+
:handled
|
223
|
+
end
|
224
|
+
|
225
|
+
def draggable?(button)
|
226
|
+
button == :left
|
227
|
+
end
|
228
|
+
|
229
|
+
def begin_drag(_sender, x, _y, _button)
|
230
|
+
@drag_start = x
|
231
|
+
@offset_drag_start = @offset_x
|
232
|
+
@drag_caret_position = @text_input.caret_pos
|
233
|
+
|
234
|
+
:handled
|
235
|
+
end
|
236
|
+
|
237
|
+
def drag_update(_sender, x, _y, _button)
|
238
|
+
@text_input.caret_pos = caret_position_under_mouse(x)
|
239
|
+
|
240
|
+
:handled
|
241
|
+
end
|
242
|
+
|
243
|
+
def end_drag(_sender, _x, _y, _button)
|
244
|
+
:handled
|
245
|
+
end
|
246
|
+
|
247
|
+
def recalculate
|
248
|
+
super
|
249
|
+
|
250
|
+
@width = dimensional_size(@style.width, :width) || default(:width)
|
251
|
+
update_background
|
252
|
+
end
|
253
|
+
|
254
|
+
def value
|
255
|
+
@text_input.text
|
256
|
+
end
|
257
|
+
|
258
|
+
def value=(string)
|
259
|
+
@text_input.text = string
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
module CyberarmEngine
|
2
|
-
class Element
|
3
|
-
class Flow < Container
|
4
|
-
def layout
|
5
|
-
@children.each do |child|
|
6
|
-
if fits_on_line?(child)
|
7
|
-
position_on_current_line(child)
|
8
|
-
else
|
9
|
-
position_on_next_line(child)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
1
|
+
module CyberarmEngine
|
2
|
+
class Element
|
3
|
+
class Flow < Container
|
4
|
+
def layout
|
5
|
+
@children.each do |child|
|
6
|
+
if fits_on_line?(child)
|
7
|
+
position_on_current_line(child)
|
8
|
+
else
|
9
|
+
position_on_next_line(child)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|