glimmer-dsl-opal 0.28.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +175 -28
  5. data/VERSION +1 -1
  6. data/app/assets/images/glimmer/images/ui-icons_444444_256x240.png +0 -0
  7. data/app/assets/images/glimmer/images/ui-icons_555555_256x240.png +0 -0
  8. data/app/assets/images/glimmer/images/ui-icons_777620_256x240.png +0 -0
  9. data/app/assets/images/glimmer/images/ui-icons_777777_256x240.png +0 -0
  10. data/app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png +0 -0
  11. data/app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png +0 -0
  12. data/app/assets/stylesheets/glimmer/jquery-ui.css +109 -106
  13. data/app/assets/stylesheets/glimmer/jquery-ui.structure.css +91 -91
  14. data/app/assets/stylesheets/glimmer/jquery-ui.theme.css +18 -15
  15. data/app/controllers/glimmer/image_paths_controller.rb +0 -1
  16. data/config/routes.rb +1 -1
  17. data/lib/display.rb +1 -1
  18. data/lib/glimmer/data_binding/table_items_binding.rb +1 -1
  19. data/lib/glimmer/dsl/opal/async_exec_expression.rb +1 -1
  20. data/lib/glimmer/dsl/opal/bind_expression.rb +1 -1
  21. data/lib/glimmer/dsl/opal/block_property_expression.rb +1 -1
  22. data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +1 -1
  23. data/lib/glimmer/dsl/opal/color_expression.rb +1 -1
  24. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +3 -3
  25. data/lib/glimmer/dsl/opal/data_binding_expression.rb +1 -1
  26. data/lib/glimmer/dsl/opal/dialog_expression.rb +1 -1
  27. data/lib/glimmer/dsl/opal/display_expression.rb +1 -1
  28. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  29. data/lib/glimmer/dsl/opal/exec_expression.rb +1 -1
  30. data/lib/glimmer/dsl/opal/font_expression.rb +1 -1
  31. data/lib/glimmer/dsl/opal/image_expression.rb +64 -0
  32. data/lib/glimmer/dsl/opal/menu_bar_expression.rb +1 -1
  33. data/lib/glimmer/dsl/opal/menu_expression.rb +2 -2
  34. data/lib/glimmer/dsl/opal/message_box_expression.rb +1 -1
  35. data/lib/glimmer/dsl/opal/property_expression.rb +2 -3
  36. data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +1 -1
  37. data/lib/glimmer/dsl/opal/rgb_expression.rb +1 -1
  38. data/lib/glimmer/dsl/opal/rgba_expression.rb +1 -1
  39. data/lib/glimmer/dsl/opal/shape_expression.rb +6 -4
  40. data/lib/glimmer/dsl/opal/shell_expression.rb +2 -2
  41. data/lib/glimmer/dsl/opal/shine_data_binding_expression.rb +1 -1
  42. data/lib/glimmer/dsl/opal/swt_expression.rb +1 -1
  43. data/lib/glimmer/dsl/opal/sync_exec_expression.rb +1 -1
  44. data/lib/glimmer/dsl/opal/widget_expression.rb +1 -1
  45. data/lib/glimmer/engine.rb +1 -1
  46. data/lib/glimmer/swt/arrow_proxy.rb +7 -1
  47. data/lib/glimmer/swt/button_proxy.rb +4 -3
  48. data/lib/glimmer/swt/c_combo_proxy.rb +1 -1
  49. data/lib/glimmer/swt/c_tab_folder_proxy.rb +1 -1
  50. data/lib/glimmer/swt/c_tab_item_proxy.rb +1 -1
  51. data/lib/glimmer/swt/checkbox_proxy.rb +3 -2
  52. data/lib/glimmer/swt/color_proxy.rb +1 -1
  53. data/lib/glimmer/swt/composite_proxy.rb +1 -1
  54. data/lib/glimmer/swt/control_editor.rb +1 -1
  55. data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
  56. data/lib/glimmer/swt/custom/radio_group.rb +1 -1
  57. data/lib/glimmer/swt/custom/shape/arc.rb +75 -0
  58. data/lib/glimmer/swt/custom/shape/image.rb +98 -0
  59. data/lib/glimmer/swt/custom/shape/line.rb +4 -1
  60. data/lib/glimmer/swt/custom/shape/oval.rb +1 -1
  61. data/lib/glimmer/swt/custom/shape/point.rb +4 -1
  62. data/lib/glimmer/swt/custom/shape/polygon.rb +4 -1
  63. data/lib/glimmer/swt/custom/shape/polyline.rb +4 -1
  64. data/lib/glimmer/swt/custom/shape/rectangle.rb +53 -2
  65. data/lib/glimmer/swt/custom/shape/text.rb +52 -2
  66. data/lib/glimmer/swt/custom/shape.rb +101 -5
  67. data/lib/glimmer/swt/date_time_proxy.rb +2 -2
  68. data/lib/glimmer/swt/dialog_proxy.rb +1 -1
  69. data/lib/glimmer/swt/font_proxy.rb +1 -1
  70. data/lib/glimmer/swt/image_proxy.rb +29 -0
  71. data/lib/glimmer/swt/label_proxy.rb +1 -1
  72. data/lib/glimmer/swt/latest_dialog_proxy.rb +1 -1
  73. data/lib/glimmer/swt/latest_message_box_proxy.rb +1 -1
  74. data/lib/glimmer/swt/latest_shell_proxy.rb +4 -4
  75. data/lib/glimmer/swt/layout_proxy.rb +1 -1
  76. data/lib/glimmer/swt/make_shift_shell_proxy.rb +1 -1
  77. data/lib/glimmer/swt/menu_item_proxy.rb +3 -3
  78. data/lib/glimmer/swt/menu_proxy.rb +22 -16
  79. data/lib/glimmer/swt/message_box_proxy.rb +1 -1
  80. data/lib/glimmer/swt/progress_bar_proxy.rb +1 -1
  81. data/lib/glimmer/swt/scale_proxy.rb +7 -1
  82. data/lib/glimmer/swt/shell_proxy.rb +1 -1
  83. data/lib/glimmer/swt/slider_proxy.rb +6 -0
  84. data/lib/glimmer/swt/spinner_proxy.rb +4 -3
  85. data/lib/glimmer/swt/style_constantizable.rb +1 -1
  86. data/lib/glimmer/swt/swt_proxy.rb +1 -1
  87. data/lib/glimmer/swt/tab_folder_proxy.rb +1 -1
  88. data/lib/glimmer/swt/tab_item_proxy.rb +1 -1
  89. data/lib/glimmer/swt/table_editor.rb +1 -1
  90. data/lib/glimmer/swt/table_item_proxy.rb +3 -3
  91. data/lib/glimmer/swt/table_proxy.rb +1 -1
  92. data/lib/glimmer/swt/widget_proxy.rb +29 -28
  93. data/lib/glimmer/swt.rb +1 -1
  94. data/lib/glimmer/ui/custom_shell.rb +1 -5
  95. data/lib/glimmer/ui/custom_widget.rb +5 -5
  96. data/lib/glimmer/util/proc_tracker.rb +3 -3
  97. data/lib/glimmer-dsl-opal/ext/date.rb +8 -8
  98. data/lib/glimmer-dsl-opal/ext/file.rb +1 -1
  99. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +1 -1
  100. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_repository.rb +1 -1
  101. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +1 -1
  102. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/block.rb +1 -1
  103. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/game.rb +1 -1
  104. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/past_game.rb +1 -1
  105. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/model/tetromino.rb +1 -1
  106. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/block.rb +45 -1
  107. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/high_score_dialog.rb +1 -1
  108. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/playfield.rb +1 -1
  109. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/score_lane.rb +1 -1
  110. data/lib/glimmer-dsl-opal/samples/elaborate/tetris/view/tetris_menu_bar.rb +1 -1
  111. data/lib/glimmer-dsl-opal/samples/elaborate/tetris.rb +3 -3
  112. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +1 -1
  113. data/lib/glimmer-dsl-opal/samples/elaborate/user_profile.rb +1 -1
  114. data/lib/glimmer-dsl-opal/samples/elaborate/weather.rb +5 -4
  115. data/lib/glimmer-dsl-opal/samples/hello/hello_arrow.rb +1 -1
  116. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +1 -1
  117. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
  118. data/lib/glimmer-dsl-opal/samples/hello/hello_c_combo.rb +1 -1
  119. data/lib/glimmer-dsl-opal/samples/hello/hello_c_tab.rb +1 -1
  120. data/lib/glimmer-dsl-opal/samples/hello/hello_canvas.rb +25 -2
  121. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +1 -1
  122. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +1 -1
  123. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
  124. data/lib/glimmer-dsl-opal/samples/hello/hello_composite.rb +1 -1
  125. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +1 -1
  126. data/lib/glimmer-dsl-opal/samples/hello/hello_cursor.rb +1 -1
  127. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +1 -1
  128. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
  129. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +1 -1
  130. data/lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb +1 -1
  131. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +1 -1
  132. data/lib/glimmer-dsl-opal/samples/hello/hello_label.rb +1 -1
  133. data/lib/glimmer-dsl-opal/samples/hello/hello_layout.rb +1 -1
  134. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
  135. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
  136. data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +1 -1
  137. data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +1 -1
  138. data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +1 -1
  139. data/lib/glimmer-dsl-opal/samples/hello/hello_print.rb +1 -1
  140. data/lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb +1 -1
  141. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +1 -1
  142. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +1 -1
  143. data/lib/glimmer-dsl-opal/samples/hello/hello_scale.rb +1 -1
  144. data/lib/glimmer-dsl-opal/samples/hello/hello_slider.rb +1 -1
  145. data/lib/glimmer-dsl-opal/samples/hello/hello_spinner.rb +1 -1
  146. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +1 -1
  147. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +1 -1
  148. data/lib/glimmer-dsl-opal/samples/hello/hello_text.rb +1 -1
  149. data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +1 -1
  150. data/lib/glimmer-dsl-opal/samples/hello/images/scaffold_app.png +0 -0
  151. data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +35 -1
  152. data/lib/glimmer-dsl-opal/vendor/jquery-ui/index.html +503 -0
  153. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +4 -4
  154. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +3 -10
  155. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +2 -2
  156. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +2 -2
  157. data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +26 -26
  158. data/lib/glimmer-dsl-opal/vendor/jquery.js +10881 -2
  159. data/lib/glimmer-dsl-opal/vendor/two.min.js +24 -0
  160. data/lib/glimmer-dsl-opal.rb +2 -1
  161. data/lib/glimmer-dsl-swt.rb +1 -1
  162. data/lib/net/http.rb +1 -1
  163. data/lib/os.rb +1 -1
  164. metadata +16 -16
  165. data/app/assets/images/glimmer/images/ui-icons_222222_256x240.png +0 -0
  166. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
  167. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
  168. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
  169. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
  170. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
  171. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Line < Shape
33
+ def parameter_names
34
+ [:x1, :y1, :x2, :y2]
35
+ end
33
36
 
34
37
  def element
35
38
  'line'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Point < Shape
33
+ def parameter_names
34
+ [:x, :y]
35
+ end
33
36
 
34
37
  def element
35
38
  'rect'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Polygon < Shape
33
+ def parameter_names
34
+ [:point_array]
35
+ end
33
36
 
34
37
  def element
35
38
  'polygon'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -30,6 +30,9 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Polyline < Shape
33
+ def parameter_names
34
+ [:point_array]
35
+ end
33
36
 
34
37
  def element
35
38
  'polyline'
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -30,6 +30,57 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Rectangle < Shape
33
+
34
+ def parameter_names
35
+ if @parameter_names.nil?
36
+ if rectangle_parameter_names.size == @args.size
37
+ @parameter_names = rectangle_parameter_names
38
+ elsif rectangle_round_parameter_names.size == @args.size
39
+ @parameter_names = rectangle_round_parameter_names
40
+ elsif rectangle_gradient_parameter_names.size == @args.size
41
+ @parameter_names = rectangle_gradient_parameter_names
42
+ elsif rectangle_rectangle_parameter_names.size == @args.size
43
+ @parameter_names = rectangle_rectangle_parameter_names
44
+ end
45
+ end
46
+ @parameter_names || rectangle_parameter_names
47
+ end
48
+
49
+ def possible_parameter_names
50
+ # TODO refactor and improve this method through meta-programming (and share across other shapes)
51
+ (rectangle_round_parameter_names + rectangle_parameter_names + rectangle_gradient_parameter_names + rectangle_rectangle_parameter_names).uniq
52
+ end
53
+
54
+ def rectangle_round_parameter_names
55
+ [:x, :y, :width, :height, :arc_width, :arc_height]
56
+ end
57
+
58
+ def rectangle_gradient_parameter_names
59
+ [:x, :y, :width, :height, :vertical]
60
+ end
61
+
62
+ def rectangle_parameter_names
63
+ [:x, :y, :width, :height]
64
+ end
65
+
66
+ def rectangle_rectangle_parameter_names
67
+ # this receives a Rectangle object
68
+ [:rectangle]
69
+ end
70
+
71
+ def set_parameter_attribute(attribute_name, *args)
72
+ return super(attribute_name, *args) if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
73
+ if rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
74
+ @parameter_names = rectangle_parameter_names
75
+ elsif rectangle_round_parameter_names.map(&:to_s).include?(attribute_name.to_s)
76
+ @parameter_names = rectangle_round_parameter_names
77
+ elsif rectangle_gradient_parameter_names.map(&:to_s).include?(attribute_name.to_s)
78
+ @parameter_names = rectangle_gradient_parameter_names
79
+ elsif rectangle_rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
80
+ @parameter_names = rectangle_rectangle_parameter_names
81
+ end
82
+ super(attribute_name, *args)
83
+ end
33
84
 
34
85
  def element
35
86
  'rect'
@@ -39,7 +90,7 @@ module Glimmer
39
90
  shape_id = id
40
91
  shape_class = name
41
92
  @dom ||= xml {
42
- rect(id: shape_id, class: shape_class, x: @args[0], y: @args[1], width: @args[2], height: @args[3], rx: @args[4], ry: @args[5])
93
+ rect(id: shape_id, class: shape_class, x: @args[0], y: @args[1], width: @args[2], height: @args[3], rx: @args[4].to_f/2.0, ry: @args[5].to_f/2.0)
43
94
  }.to_s
44
95
  end
45
96
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -30,7 +30,57 @@ module Glimmer
30
30
  module Custom
31
31
  class Shape
32
32
  class Text < Shape
33
-
33
+ def parameter_names
34
+ if text_parameter_names.size == @args.size
35
+ @parameter_names = text_parameter_names
36
+ elsif text_transparent_parameter_names.size == @args.size
37
+ @parameter_names = text_transparent_parameter_names
38
+ elsif text_flags_parameter_names.size == @args.size
39
+ @parameter_names = text_flags_parameter_names
40
+ end
41
+ @parameter_names || text_parameter_names
42
+ end
43
+
44
+ def possible_parameter_names
45
+ # TODO refactor and improve this method through meta-programming (and share across other shapes)
46
+ (text_parameter_names + text_transparent_parameter_names + text_flags_parameter_names).uniq
47
+ end
48
+
49
+ def text_parameter_names
50
+ [:string, :x, :y]
51
+ end
52
+
53
+ def text_transparent_parameter_names
54
+ [:string, :x, :y, :is_transparent]
55
+ end
56
+
57
+ def text_flags_parameter_names
58
+ [:string, :x, :y, :flags]
59
+ end
60
+
61
+ def set_parameter_attribute(attribute_name, *args)
62
+ if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
63
+ super(attribute_name, *args)
64
+ build_dom
65
+ reattach(dom_element)
66
+ return
67
+ end
68
+ if text_parameter_names.map(&:to_s).include?(attribute_name.to_s)
69
+ @parameter_names = text_parameter_names
70
+ elsif text_transparent_parameter_names.map(&:to_s).include?(attribute_name.to_s)
71
+ @parameter_names = text_transparent_parameter_names
72
+ elsif text_flags_parameter_names.map(&:to_s).include?(attribute_name.to_s)
73
+ @parameter_names = text_flags_parameter_names
74
+ end
75
+ super(attribute_name, *args)
76
+ end
77
+
78
+ def reattach(old_element)
79
+ old_element.attr('x', Element[@dom].attr('x'))
80
+ old_element.attr('y', Element[@dom].attr('y'))
81
+ old_element.text(Element[@dom].html)
82
+ end
83
+
34
84
  def background=(value)
35
85
  # TODO override background= to fill a rectangle containing text, matching its size
36
86
  # For now, disable background when foreground is not set
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2007-2021 Andy Maleh
1
+ # Copyright (c) 2007-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -40,9 +40,9 @@ module Glimmer
40
40
  def create(parent, keyword, args, &property_block)
41
41
  potential_shape_class_name = keyword.to_s.camelcase(:upper).to_sym
42
42
  if constants.include?(potential_shape_class_name)
43
- const_get(potential_shape_class_name).new(parent, args, &property_block)
43
+ const_get(potential_shape_class_name).new(parent, args, property_block)
44
44
  else
45
- new(parent, args, &property_block)
45
+ new(parent, args, property_block)
46
46
  end
47
47
  end
48
48
 
@@ -61,18 +61,112 @@ module Glimmer
61
61
  end
62
62
 
63
63
  def background=(value)
64
- value = ColorProxy.new(value) if value.is_a?(String)
64
+ value = ColorProxy.new(value) if value.is_a?(String) || value.is_a?(Symbol)
65
65
  @background = value
66
66
  dom_element.css('fill', background.to_css) unless background.nil?
67
67
  end
68
68
 
69
69
  def foreground=(value)
70
- value = ColorProxy.new(value) if value.is_a?(String)
70
+ value = ColorProxy.new(value) if value.is_a?(String) || value.is_a?(Symbol)
71
71
  @foreground = value
72
72
  dom_element.css('stroke', foreground.to_css) unless foreground.nil?
73
73
  dom_element.css('fill', 'transparent') if background.nil?
74
74
  end
75
75
 
76
+ def post_add_content
77
+ # TODO avoid rendering unless args changed from initialize args (due to setting of piecemeal attributes)
78
+ render
79
+ end
80
+
81
+ def render(custom_parent_dom_element: nil, brand_new: false)
82
+ super(custom_parent_dom_element: nil, brand_new: false)
83
+ self.background = background
84
+ self.foreground = foreground
85
+ self.font = font
86
+ end
87
+
88
+ # parameter names for arguments to pass to SWT GC.xyz method for rendering shape (e.g. draw_image(image, x, y) yields :image, :x, :y parameter names)
89
+ def parameter_names
90
+ [:x, :y, :width, :height]
91
+ end
92
+
93
+ # subclasses may override to specify location parameter names if different from x and y (e.g. all polygon points are location parameters)
94
+ # used in calculating movement changes
95
+ def location_parameter_names
96
+ [:x, :y]
97
+ end
98
+
99
+ def possible_parameter_names
100
+ parameter_names
101
+ end
102
+
103
+ def parameter_name?(attribute_name)
104
+ possible_parameter_names.map(&:to_s).include?(attribute_getter(attribute_name))
105
+ end
106
+
107
+ def current_parameter_name?(attribute_name)
108
+ parameter_names.include?(attribute_name.to_s.to_sym)
109
+ end
110
+
111
+ def parameter_index(attribute_name)
112
+ parameter_names.index(attribute_name.to_s.to_sym)
113
+ end
114
+
115
+ def get_parameter_attribute(attribute_name)
116
+ @args[parameter_index(attribute_getter(attribute_name))]
117
+ end
118
+
119
+ def set_parameter_attribute(attribute_name, *args)
120
+ @args[parameter_index(attribute_getter(attribute_name))] = args.size == 1 ? args.first : args
121
+ end
122
+
123
+ def has_attribute?(attribute_name, *args)
124
+ parameter_name?(attribute_name) or
125
+ (respond_to?(attribute_name, super: true) and respond_to?(attribute_setter(attribute_name), super: true))
126
+ end
127
+
128
+ def set_attribute(attribute_name, *args)
129
+ attribute_getter_name = attribute_getter(attribute_name)
130
+ attribute_setter_name = attribute_setter(attribute_name)
131
+ if parameter_name?(attribute_name)
132
+ return if attribute_getter_name == (args.size == 1 ? args.first : args)
133
+ set_parameter_attribute(attribute_getter_name, *args)
134
+ elsif (respond_to?(attribute_name, super: true) and respond_to?(attribute_setter_name, super: true))
135
+ return if self.send(attribute_getter_name) == (args.size == 1 ? args.first : args)
136
+ self.send(attribute_setter_name, *args)
137
+ end
138
+ end
139
+
140
+ def get_attribute(attribute_name)
141
+ if parameter_name?(attribute_name)
142
+ arg_index = parameter_index(attribute_name)
143
+ @args[arg_index] if arg_index
144
+ elsif (respond_to?(attribute_name, super: true) and respond_to?(attribute_setter(attribute_name), super: true))
145
+ self.send(attribute_name)
146
+ end
147
+ end
148
+
149
+ # TODO look why image is not working with the method_missing and respond_to? on shape
150
+ def method_missing(method_name, *args, &block)
151
+ if method_name.to_s.end_with?('=')
152
+ set_attribute(method_name, *args)
153
+ elsif has_attribute?(method_name) && args.empty?
154
+ get_attribute(method_name)
155
+ else # TODO support proxying calls to handle_observation_request for listeners just like WidgetProxy
156
+ super(method_name, *args, &block)
157
+ end
158
+ end
159
+
160
+ def respond_to?(method_name, *args, &block)
161
+ options = args.last if args.last.is_a?(Hash)
162
+ super_invocation = options && options[:super]
163
+ if !super_invocation && has_attribute?(method_name)
164
+ true
165
+ else
166
+ super(method_name, (args.first if args.first == true), &block)
167
+ end
168
+ end
169
+
76
170
  def attach(the_parent_dom_element)
77
171
  the_parent_dom_element.html("#{the_parent_dom_element.html()}\n#{@dom}")
78
172
  end
@@ -100,6 +194,8 @@ module Glimmer
100
194
 
101
195
  end
102
196
 
197
+ require 'glimmer/swt/custom/shape/arc'
198
+ require 'glimmer/swt/custom/shape/image'
103
199
  require 'glimmer/swt/custom/shape/line'
104
200
  require 'glimmer/swt/custom/shape/oval'
105
201
  require 'glimmer/swt/custom/shape/point'
@@ -34,10 +34,10 @@ module Glimmer
34
34
  showNowButton: true,
35
35
  showCloseButton: true,
36
36
  button: "##{time_button_id}",
37
- onClose: ->(v) {
37
+ onClose: proc do |v|
38
38
  @timepicker_done = true
39
39
  dom_element.trigger('change')
40
- },
40
+ end,
41
41
  })
42
42
  else
43
43
  options = {}
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -0,0 +1,29 @@
1
+ module Glimmer
2
+ module SWT
3
+ # emulating org.eclipse.swt.graphics.Image
4
+ class ImageProxy
5
+ class << self
6
+ def create(*args, &content)
7
+ if args.size == 1 && args.first.is_a?(ImageProxy)
8
+ args.first
9
+ else
10
+ new(*args, &content)
11
+ end
12
+ end
13
+ end
14
+
15
+ attr_reader :file_path, :width, :height
16
+
17
+ def initialize(*args)
18
+ options = args.last.is_a?(Hash) ? args.last : {}
19
+ # TODO support a parent as a first argument before the file path
20
+ @file_path = args.first
21
+ @width = options[:width]
22
+ @height = options[:height]
23
+ end
24
+
25
+ # TODO implement scale_to
26
+ end
27
+ # TODO alias as org.eclipse.swt.graphics.Image
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -24,7 +24,7 @@ require 'glimmer/swt/shell_proxy'
24
24
  module Glimmer
25
25
  module SWT
26
26
  class LatestShellProxy < ShellProxy
27
- def initialize(parent, args, block)
27
+ def initialize
28
28
  # No Op
29
29
  end
30
30
 
@@ -36,8 +36,8 @@ module Glimmer
36
36
  end
37
37
  end
38
38
 
39
- def respond_to?(method, *args, &block)
40
- super || latest_shell&.respond_to?(method, *args, &block)
39
+ def respond_to?(method_name, include_private = false)
40
+ super(method_name, include_private) || latest_shell&.respond_to?(method_name, include_private)
41
41
  end
42
42
 
43
43
  def open
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -43,9 +43,9 @@ module Glimmer
43
43
 
44
44
  attr_accessor :accelerator # TODO consider doing something with it
45
45
 
46
- def initialize(parent, args)
46
+ def initialize(parent, args, block)
47
47
  args.push(:push) if args.empty?
48
- super(parent, args)
48
+ super(parent, args, block)
49
49
  # TODO do not add the following event till post_add_content to avoid adding if already one on_widget_selected event existed
50
50
  on_widget_selected {
51
51
  # No Op, just trigger selection
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -98,7 +98,7 @@ module Glimmer
98
98
 
99
99
  attr_reader :menu_item_proxy, :menu_parent
100
100
 
101
- def initialize(parent, args)
101
+ def initialize(parent, args, block = nil)
102
102
  # TODO refactor/simplify code below
103
103
  @children = []
104
104
  index = args.delete(args.last) if args.last.is_a?(Numeric)
@@ -111,21 +111,22 @@ module Glimmer
111
111
  args = args.unshift(:pop_up)
112
112
  end
113
113
  if parent.is_a?(MenuProxy)
114
- @menu_item_proxy = SWT::WidgetProxy.for('menu_item', parent, [:cascade] + [index].compact)
115
- super(@menu_item_proxy, args)
114
+ @menu_item_proxy = SWT::WidgetProxy.for('menu_item', parent, [:cascade] + [index].compact, block)
115
+ super(@menu_item_proxy, args, nil)
116
116
  @menu_item_proxy.menu = self
117
117
  elsif parent.is_a?(ShellProxy)
118
- super(parent, args)
118
+ super(parent, args, nil)
119
119
  else # widget pop up
120
- super(parent, args)
120
+ super(parent, args, nil)
121
121
  end
122
-
122
+
123
123
  if bar?
124
124
  # Assumes a parent shell
125
125
  parent.menu_bar = self
126
126
  elsif pop_up?
127
127
  parent.menu = self
128
128
  end
129
+
129
130
  # TODO IMPLEMENT PROPERLY
130
131
  # on_focus_lost {
131
132
  # dispose
@@ -195,25 +196,30 @@ module Glimmer
195
196
 
196
197
  def post_add_content
197
198
  if bar?
198
- # delay this till all children rendered (perhaps post_add_content block)
199
199
  parent_dom_element.css('position', 'relative')
200
200
  parent_dom_element.css('margin-top', '30px')
201
- redraw
201
+ parent_dom_element.css('height', '114%')
202
+ render
202
203
  `$(#{path}).menu({
203
204
  position: { my: "top", at: "bottom" },
204
205
  icons: { submenu: "ui-icon-blank" }
205
206
  });`
206
207
  the_element = dom_element
207
- the_element.on('mouseover') { |event|
208
+ the_element.on('mouseenter') do |event|
208
209
  if event.page_x.between?(the_element.offset.left, the_element.offset.left + the_element.width) and
209
210
  event.page_y.between?(the_element.offset.top, the_element.offset.top + the_element.height)
210
211
  `$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' })`
211
212
  end
212
- }
213
- the_element.on('menublur') {
214
- `$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' })`
215
- }
216
- minimum_width = children.to_a.map(&:dom_element).map(&:width).reduce(:+)
213
+ end
214
+ the_element.on('mouseout') do |event|
215
+ if event.page_x.between?(the_element.offset.left, the_element.offset.left + the_element.width) and
216
+ event.page_y.between?(the_element.offset.top, the_element.offset.top + the_element.height)
217
+ `$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' })`
218
+ else
219
+ `$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' })`
220
+ end
221
+ end
222
+ minimum_width = children.to_a.map(&:dom_element).map(&:width).map(&:to_f).reduce(:+)
217
223
  the_element.css('min-width', minimum_width)
218
224
  end
219
225
  end
@@ -250,7 +256,7 @@ module Glimmer
250
256
 
251
257
  def close
252
258
  dom_element.remove
253
- Element['body'].off('click', &@close_event_handler)
259
+ Element['body'].off('click', @close_event_handler)
254
260
  @visible = false
255
261
  end
256
262
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -24,6 +24,12 @@ require 'glimmer/swt/widget_proxy'
24
24
  module Glimmer
25
25
  module SWT
26
26
  class ScaleProxy < WidgetProxy
27
+ STYLE = <<~CSS
28
+ .scale {
29
+ width: 100%;
30
+ }
31
+ CSS
32
+
27
33
  attr_reader :selection, :minimum, :maximum, :increment
28
34
 
29
35
  def initialize(parent, args, block)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -24,6 +24,12 @@ require 'glimmer/swt/widget_proxy'
24
24
  module Glimmer
25
25
  module SWT
26
26
  class SliderProxy < WidgetProxy
27
+ STYLE = <<~CSS
28
+ .slider {
29
+ width: 100%;
30
+ }
31
+ CSS
32
+
27
33
  attr_reader :selection, :minimum, :maximum, :page_increment
28
34
 
29
35
  def initialize(parent, args, block)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
@@ -159,9 +159,10 @@ module Glimmer
159
159
  def dom
160
160
  text_text = @text
161
161
  text_id = id
162
- text_style = css
162
+ text_style = "min-width: 27px; #{css}"
163
163
  text_class = name
164
- options = {type: 'text', id: text_id, style: text_style, class: text_class, value: text_text, style: 'min-width: 27px;'}
164
+ # TODO `:style` key is duplicated twice
165
+ options = {type: 'text', id: text_id, style: text_style, class: text_class, value: text_text}
165
166
  options = options.merge('disabled': 'disabled') unless @enabled
166
167
  @dom ||= html {
167
168
  input(options)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
1
+ # Copyright (c) 2020-2022 Andy Maleh
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the