glimmer-dsl-opal 0.4.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -0
  3. data/README.md +892 -16
  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/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 +16 -9
  19. data/lib/glimmer-dsl-opal/ext/date.rb +49 -3
  20. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +23 -0
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +5 -5
  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/samples/hello/hello_table.rb +283 -0
  31. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
  32. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
  33. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
  34. data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
  35. data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
  36. data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
  37. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
  38. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
  39. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
  40. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
  41. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
  42. data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
  43. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
  44. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
  45. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
  46. data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
  47. data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
  48. data/lib/glimmer-dsl-swt.rb +1 -0
  49. data/lib/glimmer/data_binding/element_binding.rb +2 -1
  50. data/lib/glimmer/data_binding/table_items_binding.rb +29 -18
  51. data/lib/glimmer/dsl/opal/block_property_expression.rb +41 -0
  52. data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
  53. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +8 -6
  54. data/lib/glimmer/dsl/opal/dsl.rb +6 -0
  55. data/lib/glimmer/dsl/opal/property_expression.rb +4 -3
  56. data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
  57. data/lib/glimmer/dsl/opal/shell_expression.rb +7 -2
  58. data/lib/glimmer/dsl/opal/widget_expression.rb +6 -1
  59. data/lib/glimmer/engine.rb +9 -0
  60. data/lib/glimmer/swt.rb +3 -3
  61. data/lib/glimmer/swt/button_proxy.rb +16 -2
  62. data/lib/glimmer/swt/checkbox_proxy.rb +81 -0
  63. data/lib/glimmer/swt/color_proxy.rb +45 -45
  64. data/lib/glimmer/swt/combo_proxy.rb +6 -6
  65. data/lib/glimmer/swt/composite_proxy.rb +2 -2
  66. data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
  67. data/lib/glimmer/swt/custom/radio_group.rb +143 -0
  68. data/lib/glimmer/swt/date_time_proxy.rb +145 -0
  69. data/lib/glimmer/swt/display_proxy.rb +6 -2
  70. data/lib/glimmer/swt/fill_layout_proxy.rb +1 -1
  71. data/lib/glimmer/swt/grid_layout_proxy.rb +19 -8
  72. data/lib/glimmer/swt/group_proxy.rb +38 -0
  73. data/lib/glimmer/swt/label_proxy.rb +27 -7
  74. data/lib/glimmer/swt/layout_data_proxy.rb +39 -21
  75. data/lib/glimmer/swt/layout_proxy.rb +4 -4
  76. data/lib/glimmer/swt/list_proxy.rb +3 -3
  77. data/lib/glimmer/swt/make_shift_shell_proxy.rb +4 -4
  78. data/lib/glimmer/swt/message_box_proxy.rb +10 -8
  79. data/lib/glimmer/swt/property_owner.rb +2 -2
  80. data/lib/glimmer/swt/radio_proxy.rb +82 -0
  81. data/lib/glimmer/swt/row_layout_proxy.rb +33 -10
  82. data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
  83. data/lib/glimmer/swt/shell_proxy.rb +29 -9
  84. data/lib/glimmer/swt/tab_folder_proxy.rb +5 -5
  85. data/lib/glimmer/swt/tab_item_proxy.rb +7 -7
  86. data/lib/glimmer/swt/table_column_proxy.rb +62 -12
  87. data/lib/glimmer/swt/table_item_proxy.rb +14 -7
  88. data/lib/glimmer/swt/table_proxy.rb +225 -16
  89. data/lib/glimmer/swt/text_proxy.rb +50 -2
  90. data/lib/glimmer/swt/widget_proxy.rb +88 -39
  91. data/lib/glimmer/ui/custom_widget.rb +8 -8
  92. data/lib/net/http.rb +1 -5
  93. data/lib/uri.rb +3 -3
  94. metadata +56 -9
  95. data/lib/glimmer/data_binding/ext/observable_model.rb +0 -40
@@ -6,8 +6,8 @@ module Glimmer
6
6
  ITEM_EMPTY = '_____'
7
7
  attr_reader :items, :selection
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  @selection = []
12
12
  end
13
13
 
@@ -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
  }
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020 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
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -26,7 +26,7 @@ module Glimmer
26
26
  # No Op
27
27
  end
28
28
 
29
- def add_child(child)
29
+ def post_initialize_child(child)
30
30
  # No Op
31
31
  end
32
32
 
@@ -1,14 +1,16 @@
1
1
  require 'glimmer/swt/widget_proxy'
2
+ require 'glimmer/swt/display_proxy'
2
3
 
3
4
  module Glimmer
4
5
  module SWT
5
6
  class MessageBoxProxy < WidgetProxy
6
7
  attr_reader :text, :message
7
8
 
8
- def initialize(parent, args)
9
+ def initialize(parent, args, block)
9
10
  i = 0
10
- @parent = parent
11
+ @parent = parent || DisplayProxy.instance.shells.first
11
12
  @args = args
13
+ @block = block
12
14
  @children = Set.new
13
15
  @enabled = true
14
16
  content do
@@ -37,7 +39,7 @@ module Glimmer
37
39
  end
38
40
 
39
41
  def open
40
- document.add_child(self)
42
+ document.post_initialize_child(self)
41
43
  end
42
44
 
43
45
  def hide
@@ -53,11 +55,11 @@ module Glimmer
53
55
  end
54
56
 
55
57
  def selector
56
- super + ' .close'
58
+ super + ' .close'
57
59
  end
58
60
 
59
61
  def listener_path
60
- path + ' .close'
62
+ path + ' .close'
61
63
  end
62
64
 
63
65
  def observation_request_to_event_mapping
@@ -66,7 +68,7 @@ module Glimmer
66
68
  event: 'click'
67
69
  },
68
70
  }
69
- end
71
+ end
70
72
 
71
73
  def style_dom_modal_css
72
74
  <<~CSS
@@ -119,11 +121,11 @@ module Glimmer
119
121
  modal_text = text
120
122
  modal_message = message
121
123
  modal_class = ['modal', name].join(' ')
122
- @dom ||= html {
124
+ @dom ||= html {
123
125
  div(id: modal_id, style: modal_style, class: modal_class) {
124
126
  style(class: 'modal-style') {
125
127
  style_dom_modal_css #.split("\n").map(&:strip).join(' ')
126
- }
128
+ }
127
129
  div(class: 'modal-content') {
128
130
  header(class: 'text') {
129
131
  modal_text
@@ -7,7 +7,7 @@ module Glimmer
7
7
  end
8
8
 
9
9
  def set_attribute(attribute_name, *args)
10
- send(attribute_setter(attribute_name), *args) unless send(attribute_getter(attribute_name)) == args.first
10
+ send(attribute_setter(attribute_name), *args) unless args.size == 1 && send(attribute_getter(attribute_name)) == args.first
11
11
  end
12
12
 
13
13
  def attribute_setter(attribute_name)
@@ -16,7 +16,7 @@ module Glimmer
16
16
 
17
17
  def attribute_getter(attribute_name)
18
18
  attribute_name.to_s.underscore
19
- end
19
+ end
20
20
  end
21
21
  end
22
22
  end
@@ -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
 
@@ -79,6 +80,28 @@ module Glimmer
79
80
  @parent.dom_element.css('padding-bottom', @margin_height)
80
81
  end
81
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)
103
+ end
104
+
82
105
  def spacing=(spacing)
83
106
  @spacing = spacing.to_i
84
107
  # TODO implement changes to accomodate layout_data in the future
@@ -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
@@ -21,6 +21,7 @@ module Glimmer
21
21
  @layout.margin_width = 0
22
22
  @layout.margin_height = 0
23
23
  self.minimum_size = Point.new(WIDTH_MIN, HEIGHT_MIN)
24
+ DisplayProxy.instance.shells << self
24
25
  end
25
26
 
26
27
  def element
@@ -54,7 +55,7 @@ module Glimmer
54
55
  .selected, .tabs .tab.selected {
55
56
  background: rgb(80, 116, 211);
56
57
  color: white;
57
- }
58
+ }
58
59
  CSS
59
60
  end
60
61
 
@@ -122,11 +123,11 @@ module Glimmer
122
123
  /* Create an selected/current tablink class */
123
124
  .tabs .tab.selected {
124
125
  background-color: #ccc;
125
- }
126
+ }
126
127
  /* Change background color of buttons on hover */
127
128
  .tabs .tab:hover {
128
129
  background-color: #ddd;
129
- }
130
+ }
130
131
  /* Style the tab content */
131
132
  .tab-item {
132
133
  padding: 6px 12px;
@@ -190,14 +191,14 @@ module Glimmer
190
191
  end
191
192
 
192
193
  def style_dom_table_css
193
- <<~CSS
194
+ <<~CSS
194
195
  table {
195
196
  border-spacing: 0;
196
197
  }
197
198
 
198
199
  table tr th,td {
199
200
  cursor: default;
200
- }
201
+ }
201
202
  CSS
202
203
  end
203
204
 
@@ -207,6 +208,7 @@ module Glimmer
207
208
  body_class = ([name] + css_classes.to_a).join(' ')
208
209
  @dom ||= html {
209
210
  div(id: body_id, class: body_class) {
211
+ # TODO support the idea of dynamic CSS building on close of shell that adds only as much CSS as needed for widgets that were mentioned
210
212
  style(class: 'common-style') {
211
213
  style_dom_css
212
214
  }
@@ -218,14 +220,14 @@ module Glimmer
218
220
  }
219
221
  style(class: 'tab-style') {
220
222
  style_dom_tab_css
221
- }
223
+ }
222
224
  # style(class: 'tab-item-style') {
223
225
  # style_dom_tab_item_css
224
- # }
226
+ # }
225
227
  # style(class: 'modal-style') {
226
228
  # style_dom_modal_css
227
- # }
228
- style(class: 'table-style') {
229
+ # }
230
+ style(class: 'table-style') {
229
231
  style_dom_table_css
230
232
  }
231
233
  style(class: 'fill-layout-style') {
@@ -234,6 +236,24 @@ module Glimmer
234
236
  style(class: 'row-layout-style') {
235
237
  Glimmer::SWT::RowLayoutProxy::STYLE
236
238
  }
239
+ style(class: 'grid-layout-style') {
240
+ Glimmer::SWT::GridLayoutProxy::STYLE
241
+ }
242
+ style(class: 'checkbox-style') {
243
+ Glimmer::SWT::CheckboxProxy::STYLE
244
+ }
245
+ style(class: 'radio-style') {
246
+ Glimmer::SWT::RadioProxy::STYLE
247
+ }
248
+ style(class: 'scrolled-composite-style') {
249
+ Glimmer::SWT::ScrolledCompositeProxy::STYLE
250
+ }
251
+ style(class: 'table-item-style') {
252
+ Glimmer::SWT::TableItemProxy::STYLE
253
+ }
254
+ style(class: 'table-column-style') {
255
+ Glimmer::SWT::TableColumnProxy::STYLE
256
+ }
237
257
  }
238
258
  }.to_s
239
259
  end
@@ -2,17 +2,17 @@ require 'glimmer/swt/widget_proxy'
2
2
 
3
3
  module Glimmer
4
4
  module SWT
5
- class TabFolderProxy < WidgetProxy
5
+ class TabFolderProxy < WidgetProxy
6
6
  attr_reader :tabs
7
7
 
8
- def initialize(parent, args)
9
- super(parent, args)
8
+ def initialize(parent, args, block)
9
+ super(parent, args, block)
10
10
  @tabs = []
11
11
  end
12
12
 
13
- def add_child(child)
13
+ def post_initialize_child(child)
14
14
  unless @children.include?(child)
15
- @children << child
15
+ @children << child
16
16
  tabs_dom_element.append(child.tab_dom)
17
17
  child.render
18
18
  end