cyberarm_engine 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 074b1687997e6415e2af20d723a2641823e3f3704ae5485bdda305124e5babcc
4
- data.tar.gz: 01a0161471ff3492f6267b0f2f6460e547c03a937dc305ea0e46de1746774e31
3
+ metadata.gz: f56e0894e554ea377926ea847706be912da3b8728e4f599270ea2e031ef2dece
4
+ data.tar.gz: 7e04146fad95f4bb551a131064cdb35e6c6ea2176568570198cf12d44055512a
5
5
  SHA512:
6
- metadata.gz: 9c35814f0690460e76d8d4050c1ad6fd1599f287de40477976252c228b7a2051545d55f98f223518d148cff6aa3ea8cdd01291871bb28639167a9bbee1fc469f
7
- data.tar.gz: bf2b94247d7f3ed5519d884235c51298f19f433a11acb198a36c8a29d976f26b68cd2bca159d0088e65ca02f51651113ff3b0da0ff6129c9165a06bedf0c7685
6
+ metadata.gz: d4be426b99a485bdfb11c5a405c298f9967d25a90cdf947ebc922016945da6aebeb713caa96e16e44c7dd0247db38e1e5435d7f01a8dd9f4b6271c0316d70e1e
7
+ data.tar.gz: aa497324a9fa4c1678a9c2e8a8ed65c938a7b01f9da4079e3579ebd1f271d1bd1e9b6c9c8c1bfece05821f39843b18ee546dbfe6ef0b54a806e6e593345cefb3
@@ -29,11 +29,11 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency "clipboard", "~> 1.3.5"
31
31
  spec.add_dependency "excon", "~> 0.78.0"
32
- spec.add_dependency "gosu", "~> 1.0.0"
32
+ spec.add_dependency "gosu", "~> 1.1"
33
33
  spec.add_dependency "gosu_more_drawables", "~> 0.3"
34
34
  # spec.add_dependency "ffi", :platforms => [:mswin, :mingw] # Required by Clipboard on Windows
35
35
 
36
- spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "bundler", "~> 2.2"
37
37
  spec.add_development_dependency "minitest", "~> 5.0"
38
38
  spec.add_development_dependency "rake", "~> 13.0"
39
39
  end
@@ -226,6 +226,22 @@ module CyberarmEngine
226
226
  (@style.border_thickness_top + @style.padding_top) + (@style.padding_bottom + @style.border_thickness_bottom)
227
227
  end
228
228
 
229
+ def scroll_width
230
+ @children.sum { |c| c.width } + noncontent_width
231
+ end
232
+
233
+ def scroll_height
234
+ @children.sum { |c| c.height } + noncontent_height
235
+ end
236
+
237
+ def max_scroll_width
238
+ scroll_width - width
239
+ end
240
+
241
+ def max_scroll_height
242
+ scroll_height - height
243
+ end
244
+
229
245
  def dimensional_size(size, dimension)
230
246
  raise "dimension must be either :width or :height" unless %i[width height].include?(dimension)
231
247
 
@@ -4,19 +4,20 @@ module CyberarmEngine
4
4
  include Common
5
5
 
6
6
  attr_accessor :stroke_color, :fill_color
7
- attr_reader :children, :gui_state, :scroll_x, :scroll_y
7
+ attr_reader :children, :gui_state, :scroll_position
8
8
 
9
9
  def initialize(options = {}, block = nil)
10
10
  @gui_state = options.delete(:gui_state)
11
11
  super
12
12
 
13
- @scroll_x = 0
14
- @scroll_y = 0
15
- @scroll_speed = 10
13
+ @scroll_position = Vector.new(0, 0)
14
+ @scroll_speed = 40
16
15
 
17
16
  @text_color = options[:color]
18
17
 
19
18
  @children = []
19
+
20
+ event(:window_size_changed)
20
21
  end
21
22
 
22
23
  def build
@@ -44,6 +45,17 @@ module CyberarmEngine
44
45
  root.gui_state.request_recalculate
45
46
  end
46
47
 
48
+ def apend(&block)
49
+ old_container = $__current_container__
50
+
51
+ $__current_container__ = self
52
+ block.call(self) if block
53
+
54
+ $__current_container__ = old_container
55
+
56
+ root.gui_state.request_recalculate
57
+ end
58
+
47
59
  def render
48
60
  Gosu.clip_to(@x, @y, width, height) do
49
61
  @children.each(&:draw)
@@ -98,6 +110,8 @@ module CyberarmEngine
98
110
 
99
111
  def recalculate
100
112
  @current_position = Vector.new(@style.margin_left + @style.padding_left, @style.margin_top + @style.padding_top)
113
+ @current_position += @scroll_position
114
+
101
115
  return unless visible?
102
116
 
103
117
  Stats.increment(:gui_recalculations_last_frame, 1)
@@ -189,15 +203,31 @@ module CyberarmEngine
189
203
  @current_position.y += element.outer_height
190
204
  end
191
205
 
192
- # def mouse_wheel_up(sender, x, y)
193
- # @children.each {|c| c.y -= @scroll_speed}
194
- # @children.each {|c| c.recalculate}
195
- # end
206
+ def mouse_wheel_up(sender, x, y)
207
+ return unless @style.scroll
208
+ return if height < max_scroll_height
209
+
210
+ if @scroll_position.y < 0
211
+ @scroll_position.y += @scroll_speed
212
+ @scroll_position.y = 0 if @scroll_position.y > 0
213
+ recalculate
214
+
215
+ return :handled
216
+ end
217
+ end
218
+
219
+ def mouse_wheel_down(sender, x, y)
220
+ return unless @style.scroll
221
+ return if height < max_scroll_height
222
+
223
+ if @scroll_position.y.abs < max_scroll_height
224
+ @scroll_position.y -= @scroll_speed
225
+ @scroll_position.y = -max_scroll_height if @scroll_position.y.abs > max_scroll_height
226
+ recalculate
196
227
 
197
- # def mouse_wheel_down(sender, x, y)
198
- # @children.each {|c| c.y += @scroll_speed}
199
- # @children.each {|c| c.recalculate}
200
- # end
228
+ return :handled
229
+ end
230
+ end
201
231
 
202
232
  def value
203
233
  @children.map { |c| c.class }.join(", ")
@@ -67,6 +67,8 @@ module CyberarmEngine
67
67
 
68
68
  if @last_text_value != value
69
69
  @last_text_value = value
70
+ @show_caret = true
71
+ @caret_last_interval = Gosu.milliseconds
70
72
 
71
73
  publish(:changed, value)
72
74
  end
@@ -251,6 +253,10 @@ module CyberarmEngine
251
253
  def value
252
254
  @text_input.text
253
255
  end
256
+
257
+ def value=(string)
258
+ @text_input.text = string
259
+ end
254
260
  end
255
261
  end
256
262
  end
@@ -105,7 +105,10 @@ module CyberarmEngine
105
105
  @last_mouse_pos = Vector.new(window.mouse_x, window.mouse_y)
106
106
  @mouse_pos = @last_mouse_pos.clone
107
107
 
108
- request_recalculate if @active_width != window.width || @active_height != window.height
108
+ if @active_width != window.width || @active_height != window.height
109
+ request_recalculate
110
+ @root_container.publish(:window_size_changed)
111
+ end
109
112
 
110
113
  @active_width = window.width
111
114
  @active_height = window.height
@@ -1,4 +1,4 @@
1
1
  module CyberarmEngine
2
2
  NAME = "InDev".freeze
3
- VERSION = "0.16.0".freeze
3
+ VERSION = "0.17.0".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyberarm_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyberarm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-18 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: gosu_more_drawables
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.16'
75
+ version: '2.2'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.16'
82
+ version: '2.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: minitest
85
85
  requirement: !ruby/object:Gem::Requirement