shoes-core 4.0.0.pre8 → 4.0.0.pre9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/bin/shoes-picker +1 -0
  3. data/lib/shoes.rb +1 -0
  4. data/lib/shoes/animation.rb +1 -0
  5. data/lib/shoes/app.rb +7 -1
  6. data/lib/shoes/arc.rb +2 -3
  7. data/lib/shoes/arrow.rb +2 -3
  8. data/lib/shoes/background.rb +2 -2
  9. data/lib/shoes/border.rb +2 -2
  10. data/lib/shoes/builtin_methods.rb +2 -2
  11. data/lib/shoes/button.rb +2 -2
  12. data/lib/shoes/check_button.rb +2 -2
  13. data/lib/shoes/color.rb +1 -0
  14. data/lib/shoes/color/dsl.rb +1 -0
  15. data/lib/shoes/color/dsl_helpers.rb +1 -0
  16. data/lib/shoes/color/hex_converter.rb +1 -0
  17. data/lib/shoes/common/art_element.rb +6 -9
  18. data/lib/shoes/common/attachable.rb +1 -0
  19. data/lib/shoes/common/background_element.rb +2 -11
  20. data/lib/shoes/common/changeable.rb +1 -0
  21. data/lib/shoes/common/clickable.rb +1 -0
  22. data/lib/shoes/common/fill.rb +1 -0
  23. data/lib/shoes/common/hover.rb +2 -1
  24. data/lib/shoes/common/inspect.rb +1 -0
  25. data/lib/shoes/common/link_finder.rb +1 -0
  26. data/lib/shoes/common/positioning.rb +1 -0
  27. data/lib/shoes/common/registration.rb +1 -0
  28. data/lib/shoes/common/remove.rb +1 -0
  29. data/lib/shoes/common/rotate.rb +1 -0
  30. data/lib/shoes/common/safely_evaluate.rb +13 -0
  31. data/lib/shoes/common/state.rb +4 -10
  32. data/lib/shoes/common/stroke.rb +1 -0
  33. data/lib/shoes/common/style.rb +13 -3
  34. data/lib/shoes/common/style_normalizer.rb +1 -0
  35. data/lib/shoes/common/translate.rb +1 -0
  36. data/lib/shoes/common/ui_element.rb +67 -5
  37. data/lib/shoes/common/visibility.rb +7 -6
  38. data/lib/shoes/configuration.rb +5 -16
  39. data/lib/shoes/console.rb +91 -0
  40. data/lib/shoes/core.rb +1 -1
  41. data/lib/shoes/core/version.rb +1 -1
  42. data/lib/shoes/dialog.rb +1 -0
  43. data/lib/shoes/dimension.rb +1 -0
  44. data/lib/shoes/dimensions.rb +1 -0
  45. data/lib/shoes/download.rb +1 -0
  46. data/lib/shoes/dsl.rb +28 -588
  47. data/lib/shoes/dsl/animate.rb +51 -0
  48. data/lib/shoes/dsl/art.rb +256 -0
  49. data/lib/shoes/dsl/element.rb +56 -0
  50. data/lib/shoes/dsl/interaction.rb +76 -0
  51. data/lib/shoes/dsl/media.rb +38 -0
  52. data/lib/shoes/dsl/setup.rb +42 -0
  53. data/lib/shoes/dsl/style.rb +81 -0
  54. data/lib/shoes/dsl/text.rb +50 -0
  55. data/lib/shoes/file_not_found_error.rb +1 -0
  56. data/lib/shoes/font.rb +2 -1
  57. data/lib/shoes/gradient.rb +1 -0
  58. data/lib/shoes/image.rb +2 -2
  59. data/lib/shoes/image_pattern.rb +1 -0
  60. data/lib/shoes/input_box.rb +11 -2
  61. data/lib/shoes/internal_app.rb +16 -3
  62. data/lib/shoes/key_event.rb +1 -0
  63. data/lib/shoes/line.rb +2 -3
  64. data/lib/shoes/link.rb +2 -0
  65. data/lib/shoes/list_box.rb +3 -3
  66. data/lib/shoes/logger_collection.rb +38 -0
  67. data/lib/shoes/mock.rb +1 -0
  68. data/lib/shoes/mock/animation.rb +1 -0
  69. data/lib/shoes/mock/app.rb +1 -0
  70. data/lib/shoes/mock/arc.rb +1 -0
  71. data/lib/shoes/mock/arrow.rb +1 -0
  72. data/lib/shoes/mock/background.rb +1 -0
  73. data/lib/shoes/mock/border.rb +1 -0
  74. data/lib/shoes/mock/button.rb +1 -0
  75. data/lib/shoes/mock/check.rb +1 -0
  76. data/lib/shoes/mock/clickable.rb +1 -0
  77. data/lib/shoes/mock/common_methods.rb +1 -0
  78. data/lib/shoes/mock/dialog.rb +1 -0
  79. data/lib/shoes/mock/download.rb +1 -0
  80. data/lib/shoes/mock/font.rb +1 -0
  81. data/lib/shoes/mock/image.rb +1 -0
  82. data/lib/shoes/mock/image_pattern.rb +1 -0
  83. data/lib/shoes/mock/input_box.rb +4 -0
  84. data/lib/shoes/mock/keypress.rb +1 -0
  85. data/lib/shoes/mock/keyrelease.rb +1 -0
  86. data/lib/shoes/mock/line.rb +1 -0
  87. data/lib/shoes/mock/link.rb +1 -0
  88. data/lib/shoes/mock/list_box.rb +1 -0
  89. data/lib/shoes/mock/oval.rb +1 -0
  90. data/lib/shoes/mock/packager.rb +3 -0
  91. data/lib/shoes/mock/progress.rb +1 -0
  92. data/lib/shoes/mock/radio.rb +1 -0
  93. data/lib/shoes/mock/rect.rb +1 -0
  94. data/lib/shoes/mock/shape.rb +1 -0
  95. data/lib/shoes/mock/slot.rb +1 -0
  96. data/lib/shoes/mock/sound.rb +1 -0
  97. data/lib/shoes/mock/star.rb +1 -0
  98. data/lib/shoes/mock/text_block.rb +1 -0
  99. data/lib/shoes/mock/timer.rb +1 -0
  100. data/lib/shoes/not_implemented_error.rb +1 -0
  101. data/lib/shoes/oval.rb +2 -3
  102. data/lib/shoes/packager.rb +13 -0
  103. data/lib/shoes/point.rb +1 -0
  104. data/lib/shoes/progress.rb +2 -3
  105. data/lib/shoes/radio.rb +1 -0
  106. data/lib/shoes/rect.rb +2 -3
  107. data/lib/shoes/renamed_delegate.rb +1 -0
  108. data/lib/shoes/shape.rb +2 -4
  109. data/lib/shoes/slot.rb +3 -3
  110. data/lib/shoes/slot_contents.rb +1 -0
  111. data/lib/shoes/sound.rb +1 -0
  112. data/lib/shoes/span.rb +1 -0
  113. data/lib/shoes/standard_logger.rb +14 -0
  114. data/lib/shoes/star.rb +2 -3
  115. data/lib/shoes/text.rb +1 -0
  116. data/lib/shoes/text_block.rb +4 -4
  117. data/lib/shoes/text_block_dimensions.rb +1 -0
  118. data/lib/shoes/timer.rb +1 -0
  119. data/lib/shoes/ui/cli.rb +5 -0
  120. data/lib/shoes/ui/picker.rb +2 -1
  121. data/lib/shoes/url.rb +1 -0
  122. data/lib/shoes/version.rb +1 -1
  123. data/lib/shoes/widget.rb +1 -0
  124. data/lib/shoes/window.rb +1 -0
  125. metadata +14 -5
  126. data/lib/shoes/common/initialization.rb +0 -71
  127. data/lib/shoes/logger.rb +0 -65
  128. data/lib/shoes/logger/ruby.rb +0 -15
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ class Shoes
3
+ module DSL
4
+ module Animate
5
+ # Creates an animation that runs the given block of code.
6
+ #
7
+ # @overload animate &blk
8
+ # @param [Proc] blk Code to run for each animation frame
9
+ # @return [Shoes::Animation]
10
+ # Defaults to framerate of 24 frames per second
11
+ # @example
12
+ # # 24 frames per second
13
+ # animate do
14
+ # # animation code
15
+ # end
16
+ # @overload animate(framerate, &blk)
17
+ # @param [Integer] framerate Frames per second
18
+ # @param [Proc] blk Code to run for each animation frame
19
+ # @return [Shoes::Animation]
20
+ # @example
21
+ # # 10 frames per second
22
+ # animate 10 do
23
+ # # animation code
24
+ # end
25
+ # @overload animate(opts = {}, &blk)
26
+ # @param [Hash] opts Animation options
27
+ # @param [Proc] blk Code to run for each animation frame
28
+ # @option opts [Integer] :framerate Frames per second
29
+ # @return [Shoes::Animation]
30
+ # @example
31
+ # # 10 frames per second
32
+ # animate :framerate => 10 do
33
+ # # animation code
34
+ # end
35
+ #
36
+ def animate(opts = {}, &blk)
37
+ opts = { framerate: opts } unless opts.is_a? Hash
38
+ Shoes::Animation.new @__app__, opts, blk
39
+ end
40
+
41
+ def every(n = 1, &blk)
42
+ animate 1.0 / n, &blk
43
+ end
44
+
45
+ def timer(n = 1, &blk)
46
+ n *= 1000
47
+ Timer.new @__app__, n, &blk
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,256 @@
1
+ # frozen_string_literal: true
2
+ class Shoes
3
+ module DSL
4
+ module Art
5
+ # Creates an arrow
6
+ #
7
+ # @overload arrow(left, top, width, opts)
8
+ # Creates an arrow centered at (left, top)
9
+ # @param [Integer] left the x-coordinate of the element center
10
+ # @param [Integer] top the y-coordinate of the element center
11
+ # @param [Integer] width the width of the arrow
12
+ # @param [Hash] opts Arrow style options
13
+ # @option opts [Integer] rotate (false)
14
+ # @overload arrow(opts)
15
+ # Creates an arrow using values from the opts Hash.
16
+ # @param [Hash] opts
17
+ # @option styles [Integer] left (0) the x-coordinate of the top-left corner
18
+ # @option styles [Integer] top (0) the y-coordinate of the top-left corner
19
+ # @option styles [Integer] width (0) the width
20
+ # @option styles [Integer] rotate (false)
21
+ def arrow(*args, &blk)
22
+ opts = style_normalizer.normalize pop_style(args)
23
+
24
+ left, top, width, *leftovers = args
25
+
26
+ message = <<EOS
27
+ Too many arguments. Must be one of:
28
+ - arrow(left, top, width, [opts])
29
+ - arrow(left, top, [opts])
30
+ - arrow(left, [opts])
31
+ - arrow([opts])
32
+ EOS
33
+ raise ArgumentError, message if leftovers.any?
34
+
35
+ create Shoes::Arrow, left, top, width, opts, blk
36
+ end
37
+
38
+ # Creates an arc at (left, top)
39
+ #
40
+ # @param [Integer] left the x-coordinate of the top-left corner
41
+ # @param [Integer] top the y-coordinate of the top-left corner
42
+ # @param [Integer] width width of the arc's ellipse
43
+ # @param [Integer] height height of the arc's ellipse
44
+ # @param [Float] angle1 angle in radians marking the beginning of the arc segment
45
+ # @param [Float] angle2 angle in radians marking the end of the arc segment
46
+ # @param [Hash] opts Arc style options
47
+ # @option opts [Boolean] wedge (false)
48
+ # @option opts [Boolean] center (false) is (left, top) the center of the rectangle?
49
+ def arc(*args, &blk)
50
+ opts = style_normalizer.normalize pop_style(args)
51
+
52
+ left, top, width, height, angle1, angle2, *leftovers = args
53
+
54
+ message = <<EOS
55
+ Too many arguments. Must be one of:
56
+ - arc(left, top, width, height, angle1, angle2, [opts])
57
+ - arc(left, top, width, height, angle1, [opts])
58
+ - arc(left, top, width, height, [opts])
59
+ - arc(left, top, width, [opts])
60
+ - arc(left, top, [opts])
61
+ - arc(left, [opts])
62
+ - arc([opts])
63
+ EOS
64
+ raise ArgumentError, message if leftovers.any?
65
+
66
+ create Shoes::Arc, left, top, width, height, angle1, angle2, opts, blk
67
+ end
68
+
69
+ # Draws a line from point A (x1,y1) to point B (x2,y2)
70
+ #
71
+ # @param [Integer] x1 The x-value of point A
72
+ # @param [Integer] y1 The y-value of point A
73
+ # @param [Integer] x2 The x-value of point B
74
+ # @param [Integer] y2 The y-value of point B
75
+ # @param [Hash] opts Style options
76
+ def line(*args, &blk)
77
+ opts = style_normalizer.normalize pop_style(args)
78
+
79
+ x1, y1, x2, y2, *leftovers = args
80
+
81
+ message = <<EOS
82
+ Too many arguments. Must be one of:
83
+ - line(x1, y1, x2, y2, [opts])
84
+ - line(x1, y1, x2, [opts])
85
+ - line(x1, y1, [opts])
86
+ - line(x1, [opts])
87
+ - line([opts])
88
+ EOS
89
+ raise ArgumentError, message if leftovers.any?
90
+
91
+ create Shoes::Line, x1, y1, x2, y2, opts, blk
92
+ end
93
+
94
+ # Creates an oval at (left, top)
95
+ #
96
+ # @overload oval(left, top, diameter)
97
+ # Creates a circle at (left, top), with the given diameter
98
+ # @param [Integer] left the x-coordinate of the top-left corner
99
+ # @param [Integer] top the y-coordinate of the top-left corner
100
+ # @param [Integer] diameter the diameter
101
+ # @overload oval(left, top, width, height)
102
+ # Creates an oval at (left, top), with the given width and height
103
+ # @param [Integer] left the x-coordinate of the top-left corner
104
+ # @param [Integer] top the y-coordinate of the top-left corner
105
+ # @param [Integer] width the width
106
+ # @param [Integer] height the height
107
+ # @overload oval(styles)
108
+ # Creates an oval using values from the styles Hash.
109
+ # @param [Hash] styles
110
+ # @option styles [Integer] left (0) the x-coordinate of the top-left corner
111
+ # @option styles [Integer] top (0) the y-coordinate of the top-left corner
112
+ # @option styles [Integer] width (0) the width
113
+ # @option styles [Integer] height (0) the height
114
+ # @option styles [Integer] top (0) the y-coordinate of the top-left corner
115
+ # @option styles [Boolean] center (false) is (left, top) the center of the oval
116
+ def oval(*args, &blk)
117
+ opts = style_normalizer.normalize pop_style(args)
118
+
119
+ left, top, width, height, *leftovers = args
120
+
121
+ message = <<EOS
122
+ Wrong number of arguments. Must be one of:
123
+ - oval(left, top, width, height, [opts])
124
+ - oval(left, top, diameter, [opts])
125
+ - oval(left, top, [opts])
126
+ - oval(left, [opts])
127
+ - oval(styles)
128
+ EOS
129
+ raise ArgumentError, message if leftovers.any?
130
+
131
+ create Shoes::Oval, left, top, width, height, opts, blk
132
+ end
133
+
134
+ # Creates a rectangle
135
+ #
136
+ # @overload rect(left, top, side, styles)
137
+ # Creates a square at (left, top), with sides of the given length
138
+ # @param [Integer] left the x-coordinate of the top-left corner
139
+ # @param [Integer] top the y-coordinate of the top-left corner
140
+ # @param [Integer] side the length of a side
141
+ # @overload rect(left, top, width, height, rounded = 0, styles)
142
+ # Creates a rectangle at (left, top), with the given width and height
143
+ # @param [Integer] left the x-coordinate of the top-left corner
144
+ # @param [Integer] top the y-coordinate of the top-left corner
145
+ # @param [Integer] width the width
146
+ # @param [Integer] height the height
147
+ # @overload rect(styles)
148
+ # Creates a rectangle using values from the styles Hash.
149
+ # @param [Hash] styles
150
+ # @option styles [Integer] left (0) the x-coordinate of the top-left corner
151
+ # @option styles [Integer] top (0) the y-coordinate of the top-left corner
152
+ # @option styles [Integer] width (0) the width
153
+ # @option styles [Integer] height (0) the height
154
+ # @option styles [Integer] top (0) the y-coordinate of the top-left corner
155
+ # @option styles [Boolean] center (false) is (left, top) the center of the rectangle?
156
+ def rect(*args, &blk)
157
+ opts = style_normalizer.normalize pop_style(args)
158
+
159
+ left, top, width, height, curve, *leftovers = args
160
+ opts[:curve] = curve if curve
161
+
162
+ message = <<EOS
163
+ Wrong number of arguments. Must be one of:
164
+ - rect(left, top, width, height, curve, [opts])
165
+ - rect(left, top, width, height, [opts])
166
+ - rect(left, top, side, [opts])
167
+ - rect(left, top, [opts])
168
+ - rect(left, [opts])
169
+ - rect(styles)
170
+ EOS
171
+
172
+ raise ArgumentError, message if leftovers.any?
173
+
174
+ create Shoes::Rect, left, top, width, height, style.merge(opts), blk
175
+ end
176
+
177
+ # Creates a new Shoes::Star object
178
+ #
179
+ # @overload star(left, top, styles, &block)
180
+ # Creates a star at (left, top) with the given style
181
+ # @param [Integer] left the x-coordinate of the top-left corner
182
+ # @param [Integer] top the y-coordinate of the top-left corner
183
+ # @param [Hash] styles optional, additional styling for the element
184
+ # @overload star(left, top, points, styles, &block)
185
+ # Creates a star at (left, top) with the given style
186
+ # @param [Integer] left the x-coordinate of the top-left corner
187
+ # @param [Integer] top the y-coordinate of the top-left corner
188
+ # @param [Integer] points count of points on the star
189
+ # @param [Hash] styles optional, additional styling for the element
190
+ # @overload star(left, top, points, outer, styles, &block)
191
+ # Creates a star at (left, top) with the given style
192
+ # @param [Integer] left the x-coordinate of the top-left corner
193
+ # @param [Integer] top the y-coordinate of the top-left corner
194
+ # @param [Integer] points count of points on the star
195
+ # @param [Integer] outer outer radius of star
196
+ # @param [Hash] styles optional, additional styling for the element
197
+ # @overload star(left, top, points, outer, inner, styles, &block)
198
+ # Creates a star at (left, top) with the given style
199
+ # @param [Integer] left the x-coordinate of the top-left corner
200
+ # @param [Integer] top the y-coordinate of the top-left corner
201
+ # @param [Integer] points count of points on the star
202
+ # @param [Integer] outer outer radius of star
203
+ # @param [Integer] inner inner radius of star
204
+ # @param [Hash] styles optional, additional styling for the element
205
+ def star(*args, &blk)
206
+ styles = style_normalizer.normalize pop_style(args)
207
+
208
+ left, top, points, outer, inner, *leftovers = args
209
+
210
+ message = <<EOS
211
+ Wrong number of arguments. Must be one of:
212
+ - star([styles])
213
+ - star(left, [styles])
214
+ - star(left, top, [styles])
215
+ - star(left, top, points, [styles])
216
+ - star(left, top, points, outer, [styles])
217
+ - star(left, top, points, outer, inner, [styles])
218
+ EOS
219
+ raise ArgumentError, message if leftovers.any?
220
+
221
+ create Shoes::Star, left, top, points, outer, inner, styles, blk
222
+ end
223
+
224
+ # Creates a new Shoes::Shape object
225
+ #
226
+ # @overload shape(left, top, styles, &block)
227
+ # Creates a shape at (left, top) with the given style
228
+ # @param [Integer] left the x-coordinate of the top-left corner
229
+ # @param [Integer] top the y-coordinate of the top-left corner
230
+ # @overload shape(left, top)
231
+ # Creates a shape at (left, top, &block)
232
+ # @param [Integer] left the x-coordinate of the top-left corner
233
+ # @param [Integer] top the y-coordinate of the top-left corner
234
+ # @overload shape(styles, &block)
235
+ # Creates a shape at (0, 0)
236
+ # @option styles [Integer] left (0) the x-coordinate of the top-left corner
237
+ # @option styles [Integer] top (0) the y-coordinate of the top-left corner
238
+ def shape(*args, &blk)
239
+ opts = style_normalizer.normalize pop_style(args)
240
+
241
+ left, top, *leftovers = args
242
+
243
+ message = <<EOS
244
+ Wrong number of arguments. Must be one of:
245
+ - shape(left, top, [opts])
246
+ - shape(left, [opts])
247
+ - shape([opts])
248
+ EOS
249
+
250
+ raise ArgumentError, message if leftovers.any?
251
+
252
+ create Shoes::Shape, left, top, opts, blk
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ class Shoes
3
+ module DSL
4
+ module Element
5
+ def border(color, styles = {})
6
+ create Shoes::Border, pattern(color), styles
7
+ end
8
+
9
+ def background(color, styles = {})
10
+ create Shoes::Background, pattern(color), style_normalizer.normalize(styles)
11
+ end
12
+
13
+ def edit_line(*args, &blk)
14
+ style = pop_style(args)
15
+ text = args.first || ''
16
+ create Shoes::EditLine, text, style, blk
17
+ end
18
+
19
+ def edit_box(*args, &blk)
20
+ style = pop_style(args)
21
+ text = args.first || ''
22
+ create Shoes::EditBox, text, style, blk
23
+ end
24
+
25
+ def progress(opts = {}, &blk)
26
+ create Shoes::Progress, opts, blk
27
+ end
28
+
29
+ def check(opts = {}, &blk)
30
+ create Shoes::Check, opts, blk
31
+ end
32
+
33
+ def radio(*args, &blk)
34
+ style = pop_style(args)
35
+ group = args.first
36
+ create Shoes::Radio, group, style, blk
37
+ end
38
+
39
+ def list_box(opts = {}, &blk)
40
+ create Shoes::ListBox, opts, blk
41
+ end
42
+
43
+ def flow(opts = {}, &blk)
44
+ create Shoes::Flow, opts, blk
45
+ end
46
+
47
+ def stack(opts = {}, &blk)
48
+ create Shoes::Stack, opts, blk
49
+ end
50
+
51
+ def button(text = nil, opts = {}, &blk)
52
+ create Shoes::Button, text, opts, blk
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+ class Shoes
3
+ module DSL
4
+ module Interaction
5
+ def mouse
6
+ [@__app__.mouse_button, @__app__.mouse_pos[0], @__app__.mouse_pos[1]]
7
+ end
8
+
9
+ def motion(&blk)
10
+ @__app__.mouse_motion << blk
11
+ end
12
+
13
+ def resize(&blk)
14
+ @__app__.add_resize_callback blk
15
+ end
16
+
17
+ # hover and leave just delegate to the current slot as hover and leave
18
+ # are just defined for slots but self is always the app.
19
+ def hover(&blk)
20
+ @__app__.current_slot.hover(&blk)
21
+ end
22
+
23
+ def leave(&blk)
24
+ @__app__.current_slot.leave(&blk)
25
+ end
26
+
27
+ def keypress(&blk)
28
+ Shoes::Keypress.new @__app__, &blk
29
+ end
30
+
31
+ def keyrelease(&blk)
32
+ Shoes::Keyrelease.new @__app__, &blk
33
+ end
34
+
35
+ def append
36
+ yield if block_given?
37
+ end
38
+
39
+ def visit(url)
40
+ match_data = nil
41
+ url_data = Shoes::URL.urls.find { |page, _| match_data = page.match url }
42
+ return unless url_data
43
+ action_proc = url_data[1]
44
+ url_argument = match_data[1]
45
+ clear do
46
+ @__app__.location = url
47
+ action_proc.call self, url_argument
48
+ end
49
+ end
50
+
51
+ def scroll_top
52
+ @__app__.scroll_top
53
+ end
54
+
55
+ def scroll_top=(n)
56
+ @__app__.scroll_top = n
57
+ end
58
+
59
+ def clipboard
60
+ @__app__.clipboard
61
+ end
62
+
63
+ def clipboard=(str)
64
+ @__app__.clipboard = str
65
+ end
66
+
67
+ def download(name, args = {}, &blk)
68
+ create(Shoes::Download, name, args, &blk).tap(&:start)
69
+ end
70
+
71
+ def gutter
72
+ @__app__.gutter
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ class Shoes
3
+ module DSL
4
+ module Media
5
+ def image(*args, &blk)
6
+ if blk
7
+ raise Shoes::NotImplementedError,
8
+ 'Sorry image does not support the block form in Shoes 4!' \
9
+ ' Check out github issue #1309 for any changes/updates or if you' \
10
+ ' want to help :)'
11
+ else
12
+ opts = style_normalizer.normalize pop_style(args)
13
+ path, *leftovers = args
14
+
15
+ message = <<EOS
16
+ Wrong number of arguments. Must be:
17
+ - image(path, [opts])
18
+ EOS
19
+ raise ArgumentError, message if leftovers.any?
20
+
21
+ create Shoes::Image, path, opts
22
+ end
23
+ end
24
+
25
+ def video(*_args)
26
+ raise Shoes::NotImplementedError,
27
+ 'Sorry video support has been cut from shoes 4!' \
28
+ ' Check out github issue #113 for any changes/updates or if you' \
29
+ ' want to help :)'
30
+ end
31
+
32
+ # similar controls as Shoes::Video (#video)
33
+ def sound(soundfile, opts = {}, &blk)
34
+ Shoes::Sound.new @__app__, soundfile, opts, &blk
35
+ end
36
+ end
37
+ end
38
+ end