glimmer-dsl-opal 0.2.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +47 -0
  3. data/README.md +1022 -190
  4. data/VERSION +1 -1
  5. data/app/assets/images/glimmer/images/calendar.gif +0 -0
  6. data/app/assets/images/glimmer/images/ui-icons_222222_256x240.png +0 -0
  7. data/app/assets/images/glimmer/images/ui-icons_444444_256x240.png +0 -0
  8. data/app/assets/images/glimmer/images/ui-icons_555555_256x240.png +0 -0
  9. data/app/assets/images/glimmer/images/ui-icons_777620_256x240.png +0 -0
  10. data/app/assets/images/glimmer/images/ui-icons_777777_256x240.png +0 -0
  11. data/app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png +0 -0
  12. data/app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png +0 -0
  13. data/app/assets/stylesheets/glimmer.css +15 -0
  14. data/app/assets/stylesheets/glimmer/jquery-ui.css +1312 -0
  15. data/app/assets/stylesheets/glimmer/jquery-ui.structure.css +886 -0
  16. data/app/assets/stylesheets/glimmer/jquery-ui.theme.css +443 -0
  17. data/app/assets/stylesheets/glimmer/jquery.ui.timepicker.css +57 -0
  18. data/lib/glimmer-dsl-opal.rb +23 -8
  19. data/lib/glimmer-dsl-opal/ext/date.rb +48 -0
  20. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +5 -5
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +3 -3
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +3 -3
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +63 -0
  26. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
  27. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
  28. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +108 -0
  29. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +84 -0
  30. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
  31. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
  32. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
  33. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
  34. data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
  35. data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
  36. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
  37. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
  38. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
  39. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
  40. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
  41. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
  42. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
  43. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
  44. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
  45. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
  46. data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
  47. data/lib/glimmer-dsl-swt.rb +37 -0
  48. data/lib/glimmer/data_binding/element_binding.rb +2 -1
  49. data/lib/glimmer/dsl/opal/async_exec_expression.rb +23 -7
  50. data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
  51. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +42 -5
  52. data/lib/glimmer/dsl/opal/display_expression.rb +40 -0
  53. data/lib/glimmer/dsl/opal/dsl.rb +7 -0
  54. data/lib/glimmer/dsl/opal/exec_expression.rb +55 -0
  55. data/lib/glimmer/dsl/opal/layout_expression.rb +1 -1
  56. data/lib/glimmer/dsl/opal/property_expression.rb +4 -3
  57. data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
  58. data/lib/glimmer/dsl/opal/shell_expression.rb +23 -1
  59. data/lib/glimmer/dsl/opal/swt_expression.rb +1 -1
  60. data/lib/glimmer/dsl/opal/sync_exec_expression.rb +33 -0
  61. data/lib/glimmer/dsl/opal/widget_expression.rb +5 -0
  62. data/lib/glimmer/engine.rb +9 -0
  63. data/lib/glimmer/swt.rb +3 -3
  64. data/lib/glimmer/swt/button_proxy.rb +15 -1
  65. data/lib/glimmer/swt/checkbox_proxy.rb +81 -0
  66. data/lib/glimmer/swt/combo_proxy.rb +4 -4
  67. data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
  68. data/lib/glimmer/swt/custom/radio_group.rb +143 -0
  69. data/lib/glimmer/swt/date_time_proxy.rb +144 -0
  70. data/lib/glimmer/swt/display_proxy.rb +55 -1
  71. data/lib/glimmer/swt/fill_layout_proxy.rb +2 -2
  72. data/lib/glimmer/swt/grid_layout_proxy.rb +21 -10
  73. data/lib/glimmer/swt/group_proxy.rb +38 -0
  74. data/lib/glimmer/swt/label_proxy.rb +27 -7
  75. data/lib/glimmer/swt/layout_data_proxy.rb +59 -6
  76. data/lib/glimmer/swt/layout_proxy.rb +2 -1
  77. data/lib/glimmer/swt/list_proxy.rb +2 -2
  78. data/lib/glimmer/swt/make_shift_shell_proxy.rb +38 -0
  79. data/lib/glimmer/swt/message_box_proxy.rb +7 -7
  80. data/lib/glimmer/swt/radio_proxy.rb +82 -0
  81. data/lib/glimmer/swt/row_layout_proxy.rb +35 -12
  82. data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
  83. data/lib/glimmer/swt/shell_proxy.rb +25 -10
  84. data/lib/glimmer/swt/styled_text_proxy.rb +44 -0
  85. data/lib/glimmer/swt/tab_folder_proxy.rb +3 -3
  86. data/lib/glimmer/swt/table_proxy.rb +10 -10
  87. data/lib/glimmer/swt/text_proxy.rb +2 -2
  88. data/lib/glimmer/swt/widget_proxy.rb +67 -33
  89. data/lib/glimmer/ui/custom_shell.rb +21 -2
  90. data/lib/glimmer/ui/custom_widget.rb +3 -1
  91. data/lib/{glimmer-dsl-opal/missing/net → net}/http.rb +0 -0
  92. data/lib/uri.rb +64 -0
  93. metadata +57 -4
  94. data/lib/glimmer-dsl-opal/missing/uri.rb +0 -26
@@ -29,8 +29,9 @@ module Glimmer
29
29
 
30
30
  attr_reader :parent, :args
31
31
 
32
- def initialize(parent, args)
32
+ def initialize(parent, args)
33
33
  @parent = parent
34
+ @parent = parent.body_root if @parent.is_a?(Glimmer::UI::CustomWidget)
34
35
  @parent.css_classes.each do |css_class|
35
36
  @parent.remove_css_class(css_class) if css_class.include?('layout')
36
37
  end
@@ -6,7 +6,7 @@ module Glimmer
6
6
  ITEM_EMPTY = '_____'
7
7
  attr_reader :items, :selection
8
8
 
9
- def initialize(parent, args)
9
+ def initialize(parent, args)
10
10
  super(parent, args)
11
11
  @selection = []
12
12
  end
@@ -62,7 +62,7 @@ module Glimmer
62
62
  if event.target.prop('nodeName') == 'LI'
63
63
  selected_item = event.target.text
64
64
  select(index_of(selected_item), event.meta_key)
65
- event_listener.call(event)
65
+ event_listener.call(event)
66
66
  end
67
67
  }
68
68
  }
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ module Glimmer
23
+ module SWT
24
+ class MakeShiftShellProxy < Glimmer::SWT::ShellProxy
25
+ def initialize(*args, &block)
26
+ # No Op
27
+ end
28
+
29
+ def post_initialize_child(child)
30
+ # No Op
31
+ end
32
+
33
+ def open
34
+ # No Op
35
+ end
36
+ end
37
+ end
38
+ end
@@ -37,7 +37,7 @@ module Glimmer
37
37
  end
38
38
 
39
39
  def open
40
- document.add_child(self)
40
+ document.post_initialize_child(self)
41
41
  end
42
42
 
43
43
  def hide
@@ -53,11 +53,11 @@ module Glimmer
53
53
  end
54
54
 
55
55
  def selector
56
- super + ' .close'
56
+ super + ' .close'
57
57
  end
58
58
 
59
59
  def listener_path
60
- path + ' .close'
60
+ path + ' .close'
61
61
  end
62
62
 
63
63
  def observation_request_to_event_mapping
@@ -66,7 +66,7 @@ module Glimmer
66
66
  event: 'click'
67
67
  },
68
68
  }
69
- end
69
+ end
70
70
 
71
71
  def style_dom_modal_css
72
72
  <<~CSS
@@ -93,7 +93,7 @@ module Glimmer
93
93
  }
94
94
  .modal-content {
95
95
  background-color: #fefefe;
96
- margin: auto;
96
+ padding-bottom: 15px;
97
97
  border: 1px solid #888;
98
98
  display: inline-block;
99
99
  min-width: 200px;
@@ -119,11 +119,11 @@ module Glimmer
119
119
  modal_text = text
120
120
  modal_message = message
121
121
  modal_class = ['modal', name].join(' ')
122
- @dom ||= html {
122
+ @dom ||= html {
123
123
  div(id: modal_id, style: modal_style, class: modal_class) {
124
124
  style(class: 'modal-style') {
125
125
  style_dom_modal_css #.split("\n").map(&:strip).join(' ')
126
- }
126
+ }
127
127
  div(class: 'modal-content') {
128
128
  header(class: 'text') {
129
129
  modal_text
@@ -0,0 +1,82 @@
1
+ require 'glimmer/swt/widget_proxy'
2
+
3
+ module Glimmer
4
+ module SWT
5
+ class RadioProxy < WidgetProxy
6
+ # TODO add a create method that ensures passing :radio style in if not there
7
+ STYLE=<<~CSS
8
+ .radio {
9
+ display: inline;
10
+ }
11
+ .radio-label {
12
+ display: inline;
13
+ }
14
+ .radio-container {
15
+ }
16
+ CSS
17
+
18
+ def text
19
+ label_dom_element.html
20
+ end
21
+
22
+ def text=(value)
23
+ label_dom_element.html(value)
24
+ end
25
+
26
+ def selection
27
+ dom_element.prop('checked')
28
+ end
29
+
30
+ def selection=(value)
31
+ dom_element.prop('checked', value)
32
+ end
33
+
34
+ def element
35
+ 'input'
36
+ end
37
+
38
+ def label_id
39
+ "#{id}-label"
40
+ end
41
+
42
+ def label_name
43
+ "#{name}-label"
44
+ end
45
+
46
+ def label_path
47
+ "#{parent_path} ##{label_id}"
48
+ end
49
+
50
+ def label_dom_element
51
+ Document.find(label_path)
52
+ end
53
+
54
+ def container_id
55
+ "#{id}-container"
56
+ end
57
+
58
+ def container_name
59
+ "#{name}-container"
60
+ end
61
+
62
+ def observation_request_to_event_mapping
63
+ {
64
+ 'on_widget_selected' => {
65
+ event: 'change'
66
+ },
67
+ }
68
+ end
69
+
70
+ def dom
71
+ @dom ||= html {
72
+ span(id: container_id, class: container_name) {
73
+ input(type: 'radio', id: id, class: name, name: parent&.id)
74
+ label(id: label_id, class: label_name, for: id) {
75
+ text
76
+ }
77
+ }
78
+ }.to_s
79
+ end
80
+ end
81
+ end
82
+ end
@@ -8,18 +8,19 @@ module Glimmer
8
8
  STYLE = <<~CSS
9
9
  .row-layout {
10
10
  display: flex;
11
+ align-items: flex-start;
11
12
  }
12
13
 
13
- .row-layout-pack {
14
- display: initial;
14
+ .row-layout-pack-false {
15
+ align-items: stretch;
15
16
  }
16
17
 
17
18
  .row-layout-horizontal {
18
19
  flex-direction: row;
19
20
  }
20
21
 
21
- .row-layout-horizontal.row-layout-pack {
22
- flex-direction: none;
22
+ .row-layout-horizontal.row-layout-pack-false {
23
+ flex-direction: unset;
23
24
  }
24
25
 
25
26
  .row-layout-vertical {
@@ -27,11 +28,11 @@ module Glimmer
27
28
  }
28
29
 
29
30
  .row-layout-vertical.row-layout-pack {
30
- flex-direction: none;
31
+ flex-direction: none;
31
32
  }
32
33
  CSS
33
34
 
34
- attr_reader :type, :margin_width, :margin_height, :spacing, :pack
35
+ attr_reader :type, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left, :spacing, :pack
35
36
 
36
37
  def initialize(parent, args)
37
38
  super(parent, args)
@@ -51,7 +52,7 @@ module Glimmer
51
52
  @type == :vertical
52
53
  end
53
54
 
54
- def dom(widget_dom)
55
+ def dom(widget_dom)
55
56
  dom_result = widget_dom
56
57
  dom_result += '<br />' if vertical? && @pack
57
58
  dom_result
@@ -60,9 +61,9 @@ module Glimmer
60
61
  def pack=(value)
61
62
  @pack = value
62
63
  if @pack
63
- @parent.dom_element.add_class('row-layout-pack')
64
+ @parent.dom_element.remove_class('row-layout-pack-false')
64
65
  else
65
- @parent.dom_element.remove_class('row-layout-pack')
66
+ @parent.dom_element.add_class('row-layout-pack-false')
66
67
  end
67
68
  end
68
69
 
@@ -75,8 +76,30 @@ module Glimmer
75
76
 
76
77
  def margin_height=(pixels)
77
78
  @margin_height = pixels
78
- @parent.dom_element.css('margin-top', @margin_height)
79
- @parent.dom_element.css('margin-bottom', @margin_height)
79
+ @parent.dom_element.css('padding-top', @margin_height)
80
+ @parent.dom_element.css('padding-bottom', @margin_height)
81
+ end
82
+
83
+ def margin_top=(pixels)
84
+ @margin_top = pixels
85
+ # Using padding for width since margin-right isn't getting respected with width 100%
86
+ @parent.dom_element.css('padding-top', @margin_top)
87
+ end
88
+
89
+ def margin_right=(pixels)
90
+ @margin_right = pixels
91
+ @parent.dom_element.css('padding-right', @margin_right)
92
+ end
93
+
94
+ def margin_bottom=(pixels)
95
+ @margin_bottom = pixels
96
+ # Using padding for width since margin-right isn't getting respected with width 100%
97
+ @parent.dom_element.css('padding-bottom', @margin_bottom)
98
+ end
99
+
100
+ def margin_left=(pixels)
101
+ @margin_left = pixels
102
+ @parent.dom_element.css('padding-left', @margin_left)
80
103
  end
81
104
 
82
105
  def spacing=(spacing)
@@ -89,7 +112,7 @@ module Glimmer
89
112
  elsif vertical?
90
113
  margin_bottom "#{@spacing}px"
91
114
  end
92
- }
115
+ }
93
116
  s("##{@parent.id} > :last-child") {
94
117
  if horizontal?
95
118
  margin_right 0
@@ -0,0 +1,20 @@
1
+ require 'glimmer/swt/grid_layout_proxy'
2
+ require 'glimmer/swt/widget_proxy'
3
+
4
+ module Glimmer
5
+ module SWT
6
+ class ScrolledCompositeProxy < CompositeProxy
7
+ STYLE = <<~CSS
8
+ .scrolled-composite {
9
+ }
10
+ CSS
11
+
12
+ # TODO set overflow-y and overflow-x based on :v_scroll and :h_scroll styles.... though consider also that it might not be needed in web browsers where scrollbars are always present
13
+ # height: 100px;
14
+ # overflow-y: auto;
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -1,4 +1,5 @@
1
1
  require 'glimmer/swt/widget_proxy'
2
+ require 'glimmer/swt/display_proxy'
2
3
  require 'glimmer/swt/point'
3
4
 
4
5
  module Glimmer
@@ -9,7 +10,7 @@ module Glimmer
9
10
 
10
11
  WIDTH_MIN = 130
11
12
  HEIGHT_MIN = 0
12
-
13
+
13
14
  def initialize(args)
14
15
  @args = args
15
16
  @children = []
@@ -53,7 +54,7 @@ module Glimmer
53
54
  .selected, .tabs .tab.selected {
54
55
  background: rgb(80, 116, 211);
55
56
  color: white;
56
- }
57
+ }
57
58
  CSS
58
59
  end
59
60
 
@@ -121,11 +122,11 @@ module Glimmer
121
122
  /* Create an selected/current tablink class */
122
123
  .tabs .tab.selected {
123
124
  background-color: #ccc;
124
- }
125
+ }
125
126
  /* Change background color of buttons on hover */
126
127
  .tabs .tab:hover {
127
128
  background-color: #ddd;
128
- }
129
+ }
129
130
  /* Style the tab content */
130
131
  .tab-item {
131
132
  padding: 6px 12px;
@@ -189,14 +190,14 @@ module Glimmer
189
190
  end
190
191
 
191
192
  def style_dom_table_css
192
- <<~CSS
193
+ <<~CSS
193
194
  table {
194
195
  border-spacing: 0;
195
196
  }
196
197
 
197
198
  table tr th,td {
198
199
  cursor: default;
199
- }
200
+ }
200
201
  CSS
201
202
  end
202
203
 
@@ -217,14 +218,14 @@ module Glimmer
217
218
  }
218
219
  style(class: 'tab-style') {
219
220
  style_dom_tab_css
220
- }
221
+ }
221
222
  # style(class: 'tab-item-style') {
222
223
  # style_dom_tab_item_css
223
- # }
224
+ # }
224
225
  # style(class: 'modal-style') {
225
226
  # style_dom_modal_css
226
- # }
227
- style(class: 'table-style') {
227
+ # }
228
+ style(class: 'table-style') {
228
229
  style_dom_table_css
229
230
  }
230
231
  style(class: 'fill-layout-style') {
@@ -233,12 +234,26 @@ module Glimmer
233
234
  style(class: 'row-layout-style') {
234
235
  Glimmer::SWT::RowLayoutProxy::STYLE
235
236
  }
237
+ style(class: 'grid-layout-style') {
238
+ Glimmer::SWT::GridLayoutProxy::STYLE
239
+ }
240
+ style(class: 'checkbox-style') {
241
+ Glimmer::SWT::CheckboxProxy::STYLE
242
+ }
243
+ style(class: 'radio-style') {
244
+ Glimmer::SWT::RadioProxy::STYLE
245
+ }
246
+ style(class: 'scrolled-composite-style') {
247
+ Glimmer::SWT::ScrolledCompositeProxy::STYLE
248
+ }
236
249
  }
237
250
  }.to_s
238
251
  end
239
252
 
240
253
  def open
254
+ # TODO consider the idea of delaying rendering till the open method
241
255
  # TODO make it start as hidden and show shell upon open
256
+ Glimmer::SWT::DisplayProxy.instance.shells << self
242
257
  end
243
258
  end
244
259
  end
@@ -0,0 +1,44 @@
1
+ require 'glimmer/swt/widget_proxy'
2
+ require 'glimmer/swt/text_proxy'
3
+ require 'glimmer/swt/swt_proxy'
4
+
5
+ module Glimmer
6
+ module SWT
7
+ class StyledTextProxy < TextProxy
8
+ attr_reader :alignment, :right_margin, :editable, :caret
9
+
10
+ def alignment=(value)
11
+ @alignment = %w[left center right].detect {|alignment_value| SWTProxy[alignment_value] == value}
12
+ dom_element.css('text-align', @alignment)
13
+ end
14
+
15
+ def right_margin=(value)
16
+ @right_margin = value.to_i
17
+ dom_element.css('padding-right', @right_margin)
18
+ end
19
+
20
+ def editable=(value)
21
+ @editable = value
22
+ if !@editable
23
+ dom_element.attr('disabled', true)
24
+ dom_element.css('background', :white)
25
+ dom_element.css('border', 'solid 1px rgb(118, 118, 118)')
26
+ dom_element.css('border-radius', '3px')
27
+ # :hover {
28
+ # border-color: rgb(80, 80, 80);
29
+ # }
30
+ else
31
+ dom_element.prop('disabled', false)
32
+ dom_element.css('background', nil)
33
+ dom_element.css('border', nil)
34
+ dom_element.css('border-radius', nil)
35
+ end
36
+ end
37
+
38
+ def caret=(value)
39
+ @caret = value
40
+ # TODO implement (not needed for disabling caret though)
41
+ end
42
+ end
43
+ end
44
+ end