shoes-swt 4.0.0.pre2 → 4.0.0.pre3

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.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -200
  3. data/Rakefile +1 -0
  4. data/bin/shoes-swt +11 -0
  5. data/lib/shoes/swt.rb +5 -2
  6. data/lib/shoes/swt/animation.rb +2 -2
  7. data/lib/shoes/swt/app.rb +45 -50
  8. data/lib/shoes/swt/arc.rb +7 -7
  9. data/lib/shoes/swt/background.rb +1 -1
  10. data/lib/shoes/swt/border.rb +1 -2
  11. data/lib/shoes/swt/click_listener.rb +70 -0
  12. data/lib/shoes/swt/color.rb +5 -5
  13. data/lib/shoes/swt/common/clickable.rb +2 -53
  14. data/lib/shoes/swt/common/fill.rb +1 -1
  15. data/lib/shoes/swt/common/painter.rb +7 -7
  16. data/lib/shoes/swt/common/painter_updates_position.rb +2 -2
  17. data/lib/shoes/swt/common/remove.rb +2 -3
  18. data/lib/shoes/swt/common/resource.rb +1 -1
  19. data/lib/shoes/swt/common/selection_listener.rb +14 -14
  20. data/lib/shoes/swt/common/stroke.rb +1 -2
  21. data/lib/shoes/swt/common/update_position.rb +1 -1
  22. data/lib/shoes/swt/dialog.rb +3 -45
  23. data/lib/shoes/swt/disposed_protection.rb +1 -1
  24. data/lib/shoes/swt/download.rb +0 -1
  25. data/lib/shoes/swt/font.rb +4 -4
  26. data/lib/shoes/swt/generate-backend.rb +9 -0
  27. data/lib/shoes/swt/gradient.rb +17 -16
  28. data/lib/shoes/swt/image.rb +3 -5
  29. data/lib/shoes/swt/image_pattern.rb +2 -2
  30. data/lib/shoes/swt/input_box.rb +3 -3
  31. data/lib/shoes/swt/key_listener.rb +6 -6
  32. data/lib/shoes/swt/line.rb +4 -24
  33. data/lib/shoes/swt/link.rb +2 -2
  34. data/lib/shoes/swt/link_segment.rb +3 -3
  35. data/lib/shoes/swt/list_box.rb +4 -4
  36. data/lib/shoes/swt/mouse_move_listener.rb +6 -5
  37. data/lib/shoes/swt/oval.rb +2 -3
  38. data/lib/shoes/swt/packager.rb +82 -0
  39. data/lib/shoes/swt/progress.rb +2 -2
  40. data/lib/shoes/swt/radio.rb +0 -2
  41. data/lib/shoes/swt/radio_group.rb +54 -54
  42. data/lib/shoes/swt/rect_painter.rb +7 -7
  43. data/lib/shoes/swt/redrawing_aspect.rb +32 -34
  44. data/lib/shoes/swt/shape.rb +1 -1
  45. data/lib/shoes/swt/shoes_layout.rb +5 -2
  46. data/lib/shoes/swt/slot.rb +2 -3
  47. data/lib/shoes/swt/sound.rb +17 -22
  48. data/lib/shoes/swt/star.rb +30 -8
  49. data/lib/shoes/swt/swt_button.rb +3 -2
  50. data/lib/shoes/swt/text_block.rb +3 -3
  51. data/lib/shoes/swt/text_block/cursor_painter.rb +2 -2
  52. data/lib/shoes/swt/text_block/fitter.rb +5 -3
  53. data/lib/shoes/swt/text_block/painter.rb +9 -9
  54. data/lib/shoes/swt/text_block/text_font_factory.rb +3 -3
  55. data/lib/shoes/swt/text_block/text_segment.rb +9 -9
  56. data/lib/shoes/swt/text_block/text_segment_collection.rb +2 -0
  57. data/lib/shoes/swt/text_block/text_style_factory.rb +9 -3
  58. data/lib/shoes/swt/timer.rb +1 -1
  59. data/lib/shoes/swt/version.rb +1 -1
  60. data/shoes-swt.gemspec +7 -6
  61. data/spec/shoes/cli_spec.rb +2 -2
  62. data/spec/{swt_shoes → shoes/swt}/animation_spec.rb +1 -1
  63. data/spec/{swt_shoes → shoes/swt}/app_spec.rb +36 -3
  64. data/spec/{swt_shoes → shoes/swt}/arc_spec.rb +1 -1
  65. data/spec/{swt_shoes → shoes/swt}/background_spec.rb +1 -1
  66. data/spec/{swt_shoes → shoes/swt}/border_spec.rb +1 -1
  67. data/spec/{swt_shoes → shoes/swt}/button_spec.rb +1 -1
  68. data/spec/{swt_shoes → shoes/swt}/check_spec.rb +1 -1
  69. data/spec/shoes/swt/click_listener_spec.rb +162 -0
  70. data/spec/{swt_shoes → shoes/swt}/color_factory_spec.rb +1 -1
  71. data/spec/{swt_shoes → shoes/swt}/color_spec.rb +1 -1
  72. data/spec/{swt_shoes → shoes/swt}/common/painter_spec.rb +1 -1
  73. data/spec/{swt_shoes → shoes/swt}/common/remove_spec.rb +4 -11
  74. data/spec/{swt_shoes → shoes/swt}/configuration_spec.rb +1 -1
  75. data/spec/{swt_shoes → shoes/swt}/dialog_spec.rb +1 -7
  76. data/spec/{swt_shoes → shoes/swt}/disposed_protection_spec.rb +0 -0
  77. data/spec/{swt_shoes → shoes/swt}/flow_spec.rb +1 -1
  78. data/spec/{swt_shoes → shoes/swt}/font_spec.rb +1 -1
  79. data/spec/{swt_shoes → shoes/swt}/gradient_spec.rb +1 -1
  80. data/spec/{swt_shoes → shoes/swt}/image_pattern_spec.rb +1 -1
  81. data/spec/{swt_shoes → shoes/swt}/image_spec.rb +4 -3
  82. data/spec/{swt_shoes → shoes/swt}/input_box_spec.rb +1 -1
  83. data/spec/{swt_shoes → shoes/swt}/integration_spec.rb +1 -1
  84. data/spec/{swt_shoes → shoes/swt}/key_listener_spec.rb +1 -1
  85. data/spec/{swt_shoes → shoes/swt}/line_spec.rb +4 -8
  86. data/spec/{swt_shoes → shoes/swt}/link_segment_spec.rb +1 -1
  87. data/spec/{swt_shoes → shoes/swt}/link_spec.rb +3 -10
  88. data/spec/{swt_shoes → shoes/swt}/list_box_spec.rb +5 -3
  89. data/spec/{swt_shoes → shoes/swt}/minimal.png +0 -0
  90. data/spec/{swt_shoes → shoes/swt}/mouse_move_listener_spec.rb +1 -1
  91. data/spec/{swt_shoes → shoes/swt}/oval_spec.rb +1 -1
  92. data/spec/{swt_shoes → shoes/swt}/progress_spec.rb +1 -1
  93. data/spec/{swt_shoes → shoes/swt}/radio_group_spec.rb +1 -1
  94. data/spec/{swt_shoes → shoes/swt}/radio_spec.rb +1 -1
  95. data/spec/{swt_shoes → shoes/swt}/rect_painter_spec.rb +1 -1
  96. data/spec/{swt_shoes → shoes/swt}/rect_spec.rb +1 -1
  97. data/spec/{swt_shoes → shoes/swt}/shape_spec.rb +1 -1
  98. data/spec/{swt_shoes → shoes/swt}/shared_examples/button.rb +0 -0
  99. data/spec/shoes/swt/shared_examples/clickable.rb +13 -0
  100. data/spec/{swt_shoes → shoes/swt}/shared_examples/movable.rb +0 -0
  101. data/spec/{swt_shoes → shoes/swt}/shared_examples/paintable.rb +0 -0
  102. data/spec/{swt_shoes → shoes/swt}/shared_examples/painter.rb +0 -0
  103. data/spec/{swt_shoes → shoes/swt}/shared_examples/pattern.rb +0 -0
  104. data/spec/{swt_shoes → shoes/swt}/shared_examples/removable.rb +1 -3
  105. data/spec/{swt_shoes → shoes/swt}/shared_examples/swt_app_context.rb +11 -3
  106. data/spec/{swt_shoes → shoes/swt}/shared_examples/visibility.rb +0 -0
  107. data/spec/{swt_shoes → shoes/swt}/shell_control_listener_spec.rb +1 -1
  108. data/spec/{swt_shoes → shoes/swt}/slot_spec.rb +1 -1
  109. data/spec/{swt_shoes → shoes/swt}/spec_helper.rb +0 -1
  110. data/spec/{swt_shoes → shoes/swt}/star_spec.rb +1 -1
  111. data/spec/{swt_shoes → shoes/swt}/text_block/centered_text_segment_spec.rb +1 -1
  112. data/spec/{swt_shoes → shoes/swt}/text_block/cursor_painter_spec.rb +8 -4
  113. data/spec/{swt_shoes → shoes/swt}/text_block/fitter_spec.rb +5 -5
  114. data/spec/{swt_shoes → shoes/swt}/text_block/painter_spec.rb +1 -1
  115. data/spec/{swt_shoes → shoes/swt}/text_block/text_font_factory_spec.rb +1 -1
  116. data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_collection_spec.rb +7 -2
  117. data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_spec.rb +1 -1
  118. data/spec/{swt_shoes → shoes/swt}/text_block_spec.rb +2 -5
  119. data/spec/spec_helper.rb +7 -3
  120. metadata +132 -331
  121. data/CHANGELOG +0 -84
  122. data/Gemfile +0 -24
  123. data/Guardfile +0 -11
  124. data/manifests/common.rb +0 -34
  125. data/manifests/shoes-swt.rb +0 -29
  126. data/spec/code_coverage.rb +0 -14
  127. data/spec/shoes/animation_spec.rb +0 -65
  128. data/spec/shoes/app_spec.rb +0 -484
  129. data/spec/shoes/arc_spec.rb +0 -51
  130. data/spec/shoes/background_spec.rb +0 -53
  131. data/spec/shoes/border_spec.rb +0 -47
  132. data/spec/shoes/builtin_methods_spec.rb +0 -110
  133. data/spec/shoes/button_spec.rb +0 -44
  134. data/spec/shoes/check_spec.rb +0 -35
  135. data/spec/shoes/color_spec.rb +0 -408
  136. data/spec/shoes/common/inspect_spec.rb +0 -26
  137. data/spec/shoes/common/remove_spec.rb +0 -38
  138. data/spec/shoes/common/style_normalizer_spec.rb +0 -28
  139. data/spec/shoes/common/style_spec.rb +0 -147
  140. data/spec/shoes/configuration_spec.rb +0 -36
  141. data/spec/shoes/constants_spec.rb +0 -38
  142. data/spec/shoes/dialog_spec.rb +0 -163
  143. data/spec/shoes/dimension_spec.rb +0 -407
  144. data/spec/shoes/dimensions_spec.rb +0 -837
  145. data/spec/shoes/download_spec.rb +0 -142
  146. data/spec/shoes/flow_spec.rb +0 -133
  147. data/spec/shoes/font_spec.rb +0 -37
  148. data/spec/shoes/framework_learning_spec.rb +0 -30
  149. data/spec/shoes/gradient_spec.rb +0 -32
  150. data/spec/shoes/helpers/fake_element.rb +0 -17
  151. data/spec/shoes/helpers/inspect_helpers.rb +0 -5
  152. data/spec/shoes/helpers/sample17_helper.rb +0 -66
  153. data/spec/shoes/image_spec.rb +0 -49
  154. data/spec/shoes/images/shoe.jpg +0 -0
  155. data/spec/shoes/input_box_spec.rb +0 -80
  156. data/spec/shoes/integration_spec.rb +0 -20
  157. data/spec/shoes/internal_app_spec.rb +0 -141
  158. data/spec/shoes/keypress_spec.rb +0 -11
  159. data/spec/shoes/keyrelease_spec.rb +0 -12
  160. data/spec/shoes/line_spec.rb +0 -49
  161. data/spec/shoes/link_spec.rb +0 -105
  162. data/spec/shoes/list_box_spec.rb +0 -74
  163. data/spec/shoes/logger/ruby_spec.rb +0 -8
  164. data/spec/shoes/logger_spec.rb +0 -45
  165. data/spec/shoes/oval_spec.rb +0 -24
  166. data/spec/shoes/point_spec.rb +0 -71
  167. data/spec/shoes/progress_spec.rb +0 -54
  168. data/spec/shoes/radio_spec.rb +0 -32
  169. data/spec/shoes/rect_spec.rb +0 -39
  170. data/spec/shoes/renamed_delegate_spec.rb +0 -70
  171. data/spec/shoes/shape_spec.rb +0 -95
  172. data/spec/shoes/shared_examples/button.rb +0 -6
  173. data/spec/shoes/shared_examples/changeable.rb +0 -26
  174. data/spec/shoes/shared_examples/clickable.rb +0 -5
  175. data/spec/shoes/shared_examples/common_methods.rb +0 -35
  176. data/spec/shoes/shared_examples/dimensions.rb +0 -32
  177. data/spec/shoes/shared_examples/dsl.rb +0 -44
  178. data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
  179. data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
  180. data/spec/shoes/shared_examples/dsl/background.rb +0 -26
  181. data/spec/shoes/shared_examples/dsl/border.rb +0 -10
  182. data/spec/shoes/shared_examples/dsl/button.rb +0 -5
  183. data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
  184. data/spec/shoes/shared_examples/dsl/check.rb +0 -11
  185. data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
  186. data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
  187. data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
  188. data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
  189. data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
  190. data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
  191. data/spec/shoes/shared_examples/dsl/image.rb +0 -21
  192. data/spec/shoes/shared_examples/dsl/line.rb +0 -9
  193. data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
  194. data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
  195. data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
  196. data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
  197. data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
  198. data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
  199. data/spec/shoes/shared_examples/dsl/rgb.rb +0 -26
  200. data/spec/shoes/shared_examples/dsl/shape.rb +0 -21
  201. data/spec/shoes/shared_examples/dsl/star.rb +0 -48
  202. data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
  203. data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
  204. data/spec/shoes/shared_examples/dsl/style.rb +0 -32
  205. data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -81
  206. data/spec/shoes/shared_examples/dsl/video.rb +0 -5
  207. data/spec/shoes/shared_examples/dsl_app_context.rb +0 -8
  208. data/spec/shoes/shared_examples/hover_leave.rb +0 -11
  209. data/spec/shoes/shared_examples/parent.rb +0 -6
  210. data/spec/shoes/shared_examples/scroll.rb +0 -41
  211. data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
  212. data/spec/shoes/shared_examples/slot.rb +0 -331
  213. data/spec/shoes/shared_examples/state.rb +0 -19
  214. data/spec/shoes/shared_examples/style.rb +0 -82
  215. data/spec/shoes/slot_spec.rb +0 -130
  216. data/spec/shoes/sound_spec.rb +0 -15
  217. data/spec/shoes/span_spec.rb +0 -112
  218. data/spec/shoes/spec_helper.rb +0 -24
  219. data/spec/shoes/stack_spec.rb +0 -79
  220. data/spec/shoes/star_spec.rb +0 -31
  221. data/spec/shoes/text_block_dimensions_spec.rb +0 -75
  222. data/spec/shoes/text_block_spec.rb +0 -270
  223. data/spec/shoes/url_spec.rb +0 -68
  224. data/spec/shoes/widget_spec.rb +0 -70
  225. data/spec/shoes_spec.rb +0 -44
  226. data/spec/swt_shoes/shared_examples/clickable.rb +0 -85
  227. data/spec/swt_shoes/sound.rb +0 -10
data/lib/shoes/swt/arc.rb CHANGED
@@ -35,14 +35,14 @@ class Shoes
35
35
  end
36
36
 
37
37
  private
38
+
38
39
  def radians_to_degrees(radians)
39
40
  radians * 180 / ::Shoes::PI
40
41
  end
41
42
 
42
- public
43
43
  class Painter < Common::Painter
44
44
  def fill(graphics_context)
45
- if (@obj.wedge?)
45
+ if @obj.wedge?
46
46
  graphics_context.fill_arc(@obj.element_left, @obj.element_top,
47
47
  @obj.element_width, @obj.element_height,
48
48
  @obj.angle1, @obj.angle2 * -1)
@@ -57,11 +57,11 @@ class Shoes
57
57
 
58
58
  def draw(graphics_context)
59
59
  sw = graphics_context.get_line_width
60
- if (@obj.element_left and @obj.element_top and @obj.element_width and @obj.element_height)
61
- graphics_context.draw_arc(@obj.element_left+sw/2,
62
- @obj.element_top+sw/2,
63
- @obj.element_width-sw,
64
- @obj.element_height-sw,
60
+ if @obj.element_left && @obj.element_top && @obj.element_width && @obj.element_height
61
+ graphics_context.draw_arc(@obj.element_left + sw / 2,
62
+ @obj.element_top + sw / 2,
63
+ @obj.element_width - sw,
64
+ @obj.element_height - sw,
65
65
  @obj.angle1, @obj.angle2 * -1)
66
66
  end
67
67
  end
@@ -32,7 +32,7 @@ class Shoes
32
32
  end
33
33
 
34
34
  class Painter < RectPainter
35
- def draw_setup(gc)
35
+ def draw_setup(_gc)
36
36
  # don't draw
37
37
  end
38
38
  end
@@ -26,8 +26,7 @@ class Shoes
26
26
  end
27
27
 
28
28
  class Painter < RectPainter
29
-
30
- def fill_setup(gc)
29
+ def fill_setup(_gc)
31
30
  # don't draw
32
31
  end
33
32
 
@@ -0,0 +1,70 @@
1
+ class Shoes
2
+ module Swt
3
+ # This class is intended as the single click listener held onto by the app.
4
+ # That lets us control dispatch of events to our DSL objects however we
5
+ # please, instead of relying on whatever SWT thinks is right. See #882.
6
+ class ClickListener
7
+ include ::Swt::Widgets::Listener
8
+
9
+ attr_reader :clickable_elements
10
+
11
+ def initialize(swt_app)
12
+ @clickable_elements = []
13
+ @clicks = {}
14
+ @releases = {}
15
+ swt_app.add_listener ::Swt::SWT::MouseDown, self
16
+ swt_app.add_listener ::Swt::SWT::MouseUp, self
17
+ end
18
+
19
+ def add_click_listener(dsl, block)
20
+ add_clickable_element(dsl)
21
+ @clicks[dsl] = block
22
+ end
23
+
24
+ def add_release_listener(dsl, block)
25
+ add_clickable_element(dsl)
26
+ @releases[dsl] = block
27
+ end
28
+
29
+ def remove_listeners_for(dsl)
30
+ @clickable_elements.delete(dsl)
31
+ @clicks.delete(dsl)
32
+ @releases.delete(dsl)
33
+ end
34
+
35
+ def add_clickable_element(dsl)
36
+ @clickable_elements << dsl unless @clickable_elements.include?(dsl)
37
+ end
38
+
39
+ def handle_event(event)
40
+ handlers = case event.type
41
+ when ::Swt::SWT::MouseDown then @clicks
42
+ when ::Swt::SWT::MouseUp then @releases
43
+ else nil
44
+ end
45
+ return if handlers.nil? || handlers.empty?
46
+
47
+ handlers = handlers.to_a.
48
+ select { |dsl, _| !dsl.hidden? }.
49
+ select { |dsl, _| dsl.in_bounds?(event.x, event.y) }
50
+
51
+ # Take the last handler as an approximation of the "top-most" element
52
+ # since we don't have a true z-index. For layouts that aren't too
53
+ # dynamic this is sufficient to give the behavior we want.
54
+ dsl, block = handlers.last
55
+
56
+ eval_block(event, dsl, block)
57
+ end
58
+
59
+ def eval_block(event, dsl, block)
60
+ return if block.nil?
61
+
62
+ if dsl.pass_coordinates?
63
+ block.call event.button, event.x, event.y
64
+ else
65
+ block.call(dsl)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -27,13 +27,13 @@ class Shoes
27
27
  # @param [Swt::Graphics::GC] gc the graphics context on which to apply fill
28
28
  # @note left, top, width, height, and angle are not used in this method, and only
29
29
  # exist to satisfy the Pattern interface
30
- def apply_as_fill(gc, left = nil, top = nil, width = nil, height = nil, angle = nil)
30
+ def apply_as_fill(gc, _left = nil, _top = nil, _width = nil, _height = nil, _angle = nil)
31
31
  gc.set_background real
32
32
  gc.set_alpha alpha
33
33
  end
34
34
 
35
35
  # @param [Swt::Graphics::GC] gc the graphics context on which to apply stroke
36
- def apply_as_stroke(gc, left = nil, top = nil, width = nil, height = nil, angle = nil)
36
+ def apply_as_stroke(gc, _left = nil, _top = nil, _width = nil, _height = nil, _angle = nil)
37
37
  gc.set_foreground real
38
38
  gc.set_alpha alpha
39
39
  end
@@ -41,9 +41,9 @@ class Shoes
41
41
 
42
42
  class NullColor
43
43
  attr_reader :alpha, :dsl, :real
44
- def apply_as_fill(gc); end
45
- def apply_as_stroke(gc); end
44
+ def apply_as_fill(_gc); end
45
+
46
+ def apply_as_stroke(_gc); end
46
47
  end
47
48
  end
48
49
  end
49
-
@@ -2,66 +2,15 @@ class Shoes
2
2
  module Swt
3
3
  module Common
4
4
  module Clickable
5
-
6
5
  attr_accessor :click_listener
7
6
 
8
- # object = self is there for compatibility reasons for now
9
- # it's for link (defined in text.rb) and the listener is added in the
10
- # swt/text_block.rb ... moving it around would be too hard now
11
- def clickable(object = self, block)
12
- add_listener_for object, ::Swt::SWT::MouseDown, block
13
- end
14
-
15
7
  def click(block)
16
- remove_listener_for ::Swt::SWT::MouseDown
17
- add_listener_for ::Swt::SWT::MouseDown, block
8
+ app.click_listener.add_click_listener(dsl, block)
18
9
  end
19
10
 
20
11
  def release(block)
21
- remove_listener_for ::Swt::SWT::MouseUp
22
- add_listener_for ::Swt::SWT::MouseUp, block
23
- end
24
-
25
- private
26
- def add_listener_for(swt_object = self, event, block)
27
- # dsl objects take care of in bounds checking etc.
28
- dsl_object = swt_object.dsl
29
- listener = ClickListener.new(dsl_object, block)
30
- swt_object.click_listener = listener
31
- app.add_clickable_element dsl_object
32
- app.add_listener event, listener
33
- end
34
-
35
- def remove_listener_for(swt_object = self, event)
36
- dsl_object = swt_object.dsl
37
- app.clickable_elements.delete(dsl_object)
38
- app.remove_listener event, swt_object.click_listener
12
+ app.click_listener.add_release_listener(dsl, block)
39
13
  end
40
-
41
- class ClickListener
42
- include ::Swt::Widgets::Listener
43
-
44
- def initialize(clickable_object, block)
45
- @clickable_object = clickable_object
46
- @block = block
47
- end
48
-
49
- def handleEvent(mouse_event)
50
- return if @clickable_object.respond_to?(:hidden?) && @clickable_object.hidden?
51
- if @clickable_object.in_bounds?(mouse_event.x, mouse_event.y)
52
- eval_block mouse_event
53
- end
54
- end
55
-
56
- def eval_block(mouse_event)
57
- if @clickable_object.pass_coordinates?
58
- @block.call mouse_event.button, mouse_event.x, mouse_event.y
59
- else
60
- @block.call @clickable_object
61
- end
62
- end
63
- end
64
-
65
14
  end
66
15
  end
67
16
  end
@@ -27,7 +27,7 @@ class Shoes
27
27
 
28
28
  def apply_fill(context)
29
29
  if fill
30
- left, top = self.is_a?(Star) ? [element_left - element_width/2.0, element_top - element_height/2.0] : [element_left, element_top]
30
+ left, top = self.is_a?(Star) ? [element_left - element_width / 2.0, element_top - element_height / 2.0] : [element_left, element_top]
31
31
  fill.apply_as_fill(context, left, top, element_width, element_height, angle)
32
32
  true
33
33
  end
@@ -37,8 +37,8 @@ class Shoes
37
37
  case obj
38
38
  when ::Shoes::Oval, ::Shoes::Rect
39
39
  set_rotate graphics_context, obj.rotate,
40
- obj.element_left + obj.element_width/2.0,
41
- obj.element_top + obj.element_height/2.0 do
40
+ obj.element_left + obj.element_width / 2.0,
41
+ obj.element_top + obj.element_height / 2.0 do
42
42
  fill graphics_context if fill_setup(graphics_context)
43
43
  draw graphics_context if draw_setup(graphics_context)
44
44
  end
@@ -54,7 +54,7 @@ class Shoes
54
54
  end
55
55
 
56
56
  # Implement in subclass
57
- def fill(graphics_context)
57
+ def fill(_graphics_context)
58
58
  end
59
59
 
60
60
  # Override in subclass and return something falsy if not using draw
@@ -63,10 +63,10 @@ class Shoes
63
63
  end
64
64
 
65
65
  # Implement in subclass
66
- def draw(graphics_context)
66
+ def draw(_graphics_context)
67
67
  end
68
68
 
69
- def set_rotate graphics_context, angle, left, top
69
+ def set_rotate(graphics_context, angle, left, top)
70
70
  angle, left, top = angle.to_i, left.to_i, top.to_i
71
71
  if block_given?
72
72
  begin
@@ -80,10 +80,10 @@ class Shoes
80
80
  end
81
81
  end
82
82
 
83
- def reset_rotate transform, graphics_context, angle, left, top
83
+ def reset_rotate(transform, graphics_context, angle, left, top)
84
84
  transform.translate left, top
85
85
  transform.rotate angle
86
- transform.translate -left, -top
86
+ transform.translate(-left, -top)
87
87
  graphics_context.setTransform transform
88
88
  end
89
89
  end
@@ -2,11 +2,11 @@ class Shoes
2
2
  module Swt
3
3
  module Common
4
4
  module PainterUpdatesPosition
5
- # No-op. This object manages its own position with its own painter. The
5
+ # No-op. This object manages its own position with its own painter. The
6
6
  # painter is triggered automatically in the event loop.
7
7
  def update_position
8
8
  end
9
9
  end
10
10
  end
11
11
  end
12
- end
12
+ end
@@ -19,10 +19,9 @@ class Shoes
19
19
  end
20
20
 
21
21
  private
22
+
22
23
  def remove_click_listeners
23
- app.remove_listener ::Swt::SWT::MouseDown, @click_listener
24
- app.remove_listener ::Swt::SWT::MouseUp, @click_listener
25
- app.clickable_elements.delete self.dsl
24
+ app.click_listener.remove_listeners_for(dsl)
26
25
  end
27
26
  end
28
27
  end
@@ -10,7 +10,7 @@ class Shoes
10
10
 
11
11
  def dispose_previous_contexts
12
12
  @graphic_contexts ||= []
13
- @graphic_contexts.each{|g| g.dispose if g}
13
+ @graphic_contexts.each { |g| g.dispose if g }
14
14
  @graphic_contexts.clear
15
15
  end
16
16
 
@@ -1,14 +1,14 @@
1
- class Shoes
2
- module Swt
3
- class SelectionListener
4
-
5
- def initialize radio, &blk
6
- @radio = radio
7
- @blk = blk
8
- end
9
- def widget_selected event
10
- @blk.call @radio, event
11
- end
12
- end
13
- end
14
- end
1
+ class Shoes
2
+ module Swt
3
+ class SelectionListener
4
+ def initialize(radio, &blk)
5
+ @radio = radio
6
+ @blk = blk
7
+ end
8
+
9
+ def widget_selected(event)
10
+ @blk.call @radio, event
11
+ end
12
+ end
13
+ end
14
+ end
@@ -27,10 +27,9 @@ class Shoes
27
27
  dsl.strokewidth
28
28
  end
29
29
 
30
-
31
30
  def apply_stroke(context)
32
31
  if stroke
33
- l, t = self.is_a?(Star) ? [element_left - element_width/2.0, element_top - element_height/2.0] : [element_left, element_top]
32
+ l, t = self.is_a?(Star) ? [element_left - element_width / 2.0, element_top - element_height / 2.0] : [element_left, element_top]
34
33
  stroke.apply_as_stroke(context, l, t, element_width, element_height, angle)
35
34
  context.set_line_width strokewidth
36
35
  true
@@ -12,4 +12,4 @@ class Shoes
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -15,7 +15,7 @@ class Shoes
15
15
  confirmed? answer_id
16
16
  end
17
17
 
18
- def dialog_chooser title, folder=false
18
+ def dialog_chooser(title, folder = false)
19
19
  style = ::Swt::SWT::OPEN
20
20
  shell = ::Swt::Widgets::Shell.new Shoes.display
21
21
  fd = folder ? ::Swt::Widgets::DirectoryDialog.new(shell, style) : ::Swt::Widgets::FileDialog.new(shell, style)
@@ -23,11 +23,7 @@ class Shoes
23
23
  fd.open
24
24
  end
25
25
 
26
- def ask msg, args
27
- Swt::AskDialog.new(::Swt::Widgets::Shell.new, msg, args).open
28
- end
29
-
30
- def ask_color title
26
+ def ask_color(title)
31
27
  shell = ::Swt::Widgets::Shell.new Shoes.display
32
28
  cd = ::Swt::Widgets::ColorDialog.new shell
33
29
  cd.setText title
@@ -36,6 +32,7 @@ class Shoes
36
32
  end
37
33
 
38
34
  private
35
+
39
36
  def open_message_box(style, msg)
40
37
  shell = ::Swt::Widgets::Shell.new ::Swt.display
41
38
  @message_box = ::Swt::Widgets::MessageBox.new shell, style
@@ -47,44 +44,5 @@ class Shoes
47
44
  answer_id == SWT::YES
48
45
  end
49
46
  end
50
-
51
- class AskDialog < ::Swt::Widgets::Dialog
52
- def initialize shell, msg, args
53
- @shell, @msg, @args= shell, msg, args
54
- super shell
55
- end
56
-
57
- def open
58
- display = getParent.getDisplay
59
- icon = ::Swt::Graphics::Image.new display, ::Shoes::Swt::ICON
60
- @shell.setImage icon
61
- @shell.setSize 300, 125
62
- @shell.setText 'Shoes 4 asks:'
63
- label = ::Swt::Widgets::Label.new @shell, ::Swt::SWT::NONE
64
- label.setText @msg
65
- label.setLocation 10, 10
66
- label.pack
67
- styles = @args[:secret] ? ::Swt::SWT::BORDER | ::Swt::SWT::SINGLE | ::Swt::SWT::PASSWORD : ::Swt::SWT::BORDER | ::Swt::SWT::SINGLE
68
- text = ::Swt::Widgets::Text.new @shell, styles
69
- text.setLocation 10, 30
70
- text.setSize 270, 20
71
- b = ::Swt::Widgets::Button.new @shell, ::Swt::SWT::NULL
72
- b.setText 'OK'
73
- b.setLocation 180, 55
74
- b.pack
75
- b.addSelectionListener{|e| @ret = text.getText; @shell.close}
76
- b = ::Swt::Widgets::Button.new @shell, ::Swt::SWT::NULL
77
- b.setText 'CANCEL'
78
- b.setLocation 222, 55
79
- b.pack
80
- b.addSelectionListener{|e| @ret = nil; @shell.close}
81
- @shell.open
82
- while !@shell.isDisposed do
83
- display.sleep unless display.readAndDispatch
84
- end
85
- icon.dispose
86
- @ret
87
- end
88
- end
89
47
  end
90
48
  end
@@ -15,7 +15,7 @@ class Shoes
15
15
  @real.respond_to? method
16
16
  end
17
17
 
18
- def method_missing(method, *args)
18
+ def method_missing(_method, *_args)
19
19
  end
20
20
  end
21
21
  end