glimmer-dsl-opal 0.9.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +211 -102
  4. data/VERSION +1 -1
  5. data/lib/display.rb +1 -1
  6. data/lib/glimmer-dsl-opal.rb +4 -3
  7. data/lib/glimmer-dsl-opal/ext/file.rb +1 -1
  8. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +7 -3
  9. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_repository.rb +4 -4
  10. data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +1 -1
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +1 -1
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +1 -1
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +1 -1
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +1 -1
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb +1 -1
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +1 -1
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
  20. data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +1 -1
  21. data/lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb +78 -0
  22. data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +1 -1
  23. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
  24. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
  25. data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +1 -1
  26. data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +1 -1
  27. data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +1 -1
  28. data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +1 -1
  29. data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +1 -1
  30. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +1 -1
  31. data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +1 -1
  32. data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +1 -1
  33. data/lib/glimmer-dsl-swt.rb +1 -1
  34. data/lib/glimmer/dsl/opal/async_exec_expression.rb +1 -1
  35. data/lib/glimmer/dsl/opal/block_property_expression.rb +1 -1
  36. data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +1 -1
  37. data/lib/glimmer/dsl/opal/color_expression.rb +1 -1
  38. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +2 -2
  39. data/lib/glimmer/dsl/opal/dialog_expression.rb +20 -0
  40. data/lib/glimmer/dsl/opal/display_expression.rb +1 -1
  41. data/lib/glimmer/dsl/opal/dsl.rb +3 -1
  42. data/lib/glimmer/dsl/opal/exec_expression.rb +1 -1
  43. data/lib/glimmer/dsl/opal/font_expression.rb +1 -1
  44. data/lib/glimmer/dsl/opal/menu_bar_expression.rb +1 -1
  45. data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
  46. data/lib/glimmer/dsl/opal/message_box_expression.rb +1 -1
  47. data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +1 -1
  48. data/lib/glimmer/dsl/opal/rgb_expression.rb +1 -1
  49. data/lib/glimmer/dsl/opal/rgba_expression.rb +1 -1
  50. data/lib/glimmer/dsl/opal/shape_expression.rb +26 -0
  51. data/lib/glimmer/dsl/opal/swt_expression.rb +4 -4
  52. data/lib/glimmer/dsl/opal/sync_exec_expression.rb +1 -1
  53. data/lib/glimmer/swt.rb +1 -1
  54. data/lib/glimmer/swt/color_proxy.rb +1 -1
  55. data/lib/glimmer/swt/composite_proxy.rb +18 -2
  56. data/lib/glimmer/swt/control_editor.rb +1 -1
  57. data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
  58. data/lib/glimmer/swt/custom/radio_group.rb +1 -1
  59. data/lib/glimmer/swt/dialog_proxy.rb +188 -0
  60. data/lib/glimmer/swt/display_proxy.rb +131 -9
  61. data/lib/glimmer/swt/font_proxy.rb +1 -1
  62. data/lib/glimmer/swt/grid_layout_proxy.rb +28 -33
  63. data/lib/glimmer/swt/label_proxy.rb +1 -1
  64. data/lib/{glimmer-dsl-opal/ext/struct.rb → glimmer/swt/latest_dialog_proxy.rb} +19 -12
  65. data/lib/glimmer/swt/latest_message_box_proxy.rb +4 -2
  66. data/lib/glimmer/swt/latest_shell_proxy.rb +23 -6
  67. data/lib/glimmer/swt/layout_data_proxy.rb +4 -0
  68. data/lib/glimmer/swt/layout_proxy.rb +9 -6
  69. data/lib/glimmer/swt/make_shift_shell_proxy.rb +1 -1
  70. data/lib/glimmer/swt/menu_item_proxy.rb +1 -1
  71. data/lib/glimmer/swt/menu_proxy.rb +3 -3
  72. data/lib/glimmer/swt/message_box_proxy.rb +22 -16
  73. data/lib/glimmer/swt/row_layout_proxy.rb +34 -7
  74. data/lib/glimmer/swt/shell_proxy.rb +43 -9
  75. data/lib/glimmer/swt/style_constantizable.rb +1 -1
  76. data/lib/glimmer/swt/swt_proxy.rb +1 -1
  77. data/lib/glimmer/swt/tab_folder_proxy.rb +1 -1
  78. data/lib/glimmer/swt/table_editor.rb +1 -1
  79. data/lib/glimmer/swt/table_item_proxy.rb +1 -1
  80. data/lib/glimmer/swt/table_proxy.rb +1 -1
  81. data/lib/glimmer/swt/widget_proxy.rb +50 -17
  82. data/lib/glimmer/ui/custom_shell.rb +16 -2
  83. data/lib/glimmer/ui/custom_widget.rb +1 -1
  84. data/lib/glimmer/util/proc_tracker.rb +17 -6
  85. data/lib/net/http.rb +10 -3
  86. data/lib/os.rb +1 -1
  87. metadata +31 -9
  88. data/CHANGELOG.md +0 -199
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Andy Maleh
1
+ # Copyright (c) 2020-2021 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
@@ -14,39 +14,46 @@ module Glimmer
14
14
 
15
15
  attr_reader :num_columns, :make_columns_equal_width, :horizontal_spacing, :vertical_spacing, :margin_width, :margin_height
16
16
 
17
- def initialize(parent, args)
18
- super(parent, args)
19
- self.horizontal_spacing = 10
20
- self.vertical_spacing = 10
21
- self.margin_width = 15
22
- self.margin_height = 15
23
- self.num_columns = @args.first || 1
24
- reapply
25
- end
26
-
27
17
  def num_columns=(columns)
28
18
  @num_columns = columns
29
19
  # TODO do the following instead of reapply
30
20
  # @parent.add_css_class("num-columns-#{@num_columns}")
31
- reapply
21
+ # reinitialize # TODO reimplement without using reinitialize
22
+ layout_css = <<~CSS
23
+ grid-template-columns: #{'auto ' * @num_columns.to_i};
24
+ grid-row-gap: #{@vertical_spacing}px;
25
+ grid-column-gap: #{@horizontal_spacing}px;
26
+ CSS
27
+ if @parent.css_classes.include?('grid-layout')
28
+ layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
29
+ @parent.dom_element.css(key, value) unless key.nil?
30
+ end
31
+ if @parent.is_a?(GroupProxy)
32
+ @parent.dom_element.find('legend').css('grid-column-start', "span #{@num_columns.to_i}")
33
+ end
34
+ else
35
+ layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
36
+ @parent.dom_element.css(key, 'initial') unless key.nil?
37
+ end
38
+ end
32
39
  end
33
40
 
34
41
  def make_columns_equal_width=(equal_width)
35
42
  @make_columns_equal_width = equal_width
36
43
  # @parent.add_css_class('make_columns_equal_width') if @make_columns_equal_width
37
- reapply
44
+ # reinitialize # TODO reimplement without using reinitialize
38
45
  end
39
46
 
40
47
  def horizontal_spacing=(spacing)
41
48
  @horizontal_spacing = spacing
42
49
  # @parent.add_css_class("horizontal-spacing-#{@horizontal_spacing}")
43
- reapply
50
+ # reinitialize # TODO reimplement without using reinitialize
44
51
  end
45
52
 
46
53
  def vertical_spacing=(spacing)
47
54
  @vertical_spacing = spacing
48
55
  # @parent.add_css_class("vertical-spacing-#{@vertical_spacing}")
49
- reapply
56
+ # reinitialize # TODO reimplement without using reinitialize
50
57
  end
51
58
 
52
59
  def margin_width=(pixels)
@@ -66,25 +73,13 @@ module Glimmer
66
73
  @parent.dom_element.css('padding-bottom', effective_margin_height)
67
74
  end
68
75
 
69
- def reapply
70
- # TODO get rid of this method
71
- layout_css = <<~CSS
72
- grid-template-columns: #{'auto ' * @num_columns.to_i};
73
- grid-row-gap: #{@vertical_spacing}px;
74
- grid-column-gap: #{@horizontal_spacing}px;
75
- CSS
76
- if @parent.css_classes.include?('grid-layout')
77
- layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
78
- @parent.dom_element.css(key, value) unless key.nil?
79
- end
80
- if @parent.is_a?(GroupProxy)
81
- @parent.dom_element.find('legend').css('grid-column-start', "span #{@num_columns.to_i}")
82
- end
83
- else
84
- layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
85
- @parent.dom_element.css(key, 'initial') unless key.nil?
86
- end
87
- end
76
+ def initialize(parent, args)
77
+ super(parent, args)
78
+ self.horizontal_spacing = 10
79
+ self.vertical_spacing = 10
80
+ self.margin_width = 15
81
+ self.margin_height = 15
82
+ self.num_columns = @args.first || 1
88
83
  end
89
84
  end
90
85
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Andy Maleh
1
+ # Copyright (c) 2020-2021 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 Andy Maleh
1
+ # Copyright (c) 2020-2021 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
@@ -19,19 +19,26 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- class Struct
23
- class << self
24
- alias new_original new
25
- def new(*args, &block)
26
- new_original(*args, &block).tap do |struct_class|
27
- if args.size >= 2 && args.last.is_a?(Hash) && args.last[:keyword_init]
28
- struct_class.define_method(:initialize) do |struct_class_keyword_args|
29
- struct_class_keyword_args.each do |attribute, value|
30
- send("#{attribute}=", value)
31
- end
32
- end
22
+ module Glimmer
23
+ module SWT
24
+ class LatestDialogProxy #< DialogProxy
25
+ # TODO consider overriding all methods from DialogProxy and proxying to them
26
+ # TODO consider the idea of promoting this object into the real dialog once Document is ready
27
+
28
+ def initialize(parent, args, block)
29
+ # No Op
30
+ end
31
+
32
+ def open
33
+ Document.ready? do
34
+ DisplayProxy.instance.async_exec {
35
+ DisplayProxy.instance.dialogs.last&.open
36
+ }
33
37
  end
34
38
  end
39
+
35
40
  end
41
+
36
42
  end
43
+
37
44
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Andy Maleh
1
+ # Copyright (c) 2020-2021 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
@@ -31,7 +31,9 @@ module Glimmer
31
31
 
32
32
  def open
33
33
  Document.ready? do
34
- DisplayProxy.instance.message_boxes.last&.open
34
+ DisplayProxy.instance.async_exec {
35
+ DisplayProxy.instance.message_boxes.last&.open
36
+ }
35
37
  end
36
38
  end
37
39
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Andy Maleh
1
+ # Copyright (c) 2020-2021 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
@@ -19,21 +19,38 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
+ require 'glimmer/swt/shell_proxy'
23
+
22
24
  module Glimmer
23
25
  module SWT
24
- class LatestShellProxy #< ShellProxy
25
- # TODO consider overriding all methods from ShellProxy and proxying to them
26
- # TODO consider the idea of promoting this object into the real shell once Document is ready
27
-
26
+ class LatestShellProxy < ShellProxy
28
27
  def initialize(parent, args, block)
29
28
  # No Op
30
29
  end
31
30
 
31
+ def method_missing(method, *args, &block)
32
+ if latest_shell.nil?
33
+ super(method, *args, &block)
34
+ else
35
+ latest_shell.send(method, *args, &block)
36
+ end
37
+ end
38
+
39
+ def respond_to?(method, *args, &block)
40
+ super || latest_shell&.respond_to?(method, *args, &block)
41
+ end
42
+
32
43
  def open
33
44
  Document.ready? do
34
- DisplayProxy.instance.shells.last&.open
45
+ DisplayProxy.instance.async_exec {
46
+ latest_shell&.open
47
+ }
35
48
  end
36
49
  end
50
+
51
+ def latest_shell
52
+ @latest_shell ||= DisplayProxy.instance.shells.last
53
+ end
37
54
 
38
55
  end
39
56
 
@@ -17,6 +17,8 @@ module Glimmer
17
17
  :grab_excess_vertical_space,
18
18
  :width_hint,
19
19
  :height_hint
20
+ alias width width_hint
21
+ alias height height_hint
20
22
 
21
23
  def initialize(parent, args)
22
24
  @parent = parent
@@ -35,12 +37,14 @@ module Glimmer
35
37
  @parent.dom_element.css('width', "#{@width_hint}px")
36
38
  # reapply
37
39
  end
40
+ alias width= width_hint=
38
41
 
39
42
  def height_hint=(height_hint)
40
43
  @height_hint = height_hint
41
44
  @parent.dom_element.css('height', "#{@height_hint}px")
42
45
  # reapply
43
46
  end
47
+ alias height= height_hint=
44
48
 
45
49
  def horizontal_alignment=(horizontal_alignment)
46
50
  @horizontal_alignment = horizontal_alignment
@@ -31,29 +31,32 @@ module Glimmer
31
31
 
32
32
  def initialize(parent, args)
33
33
  @parent = parent
34
+ @args = args
34
35
  @parent = parent.body_root if @parent.is_a?(Glimmer::UI::CustomWidget)
35
36
  @parent.css_classes.each do |css_class|
36
37
  @parent.remove_css_class(css_class) if css_class.include?('layout')
37
38
  end
38
- @args = args
39
39
  @parent.add_css_class(css_class)
40
40
  @parent.layout = self
41
41
  self.margin_width = 15 if respond_to?(:margin_width=)
42
42
  self.margin_height = 15 if respond_to?(:margin_height=)
43
43
  end
44
-
45
- def css_class
46
- self.class.name.split('::').last.underscore.sub(/_proxy$/, '').gsub('_', '-')
44
+
45
+ def layout​(composite = nil, flush_cache = false)
46
+ # TODO implement def layout​(composite = nil, flush_cache = false) as per SWT API
47
+ composite ||= @parent
48
+ initialize(composite, @args)
47
49
  end
48
50
 
49
- def reapply
50
- # subclasses can override this
51
+ def css_class
52
+ self.class.name.split('::').last.underscore.sub(/_proxy$/, '').gsub('_', '-')
51
53
  end
52
54
 
53
55
  # Decorates widget dom. Subclasses may override. Returns widget dom by default.
54
56
  def dom(widget_dom)
55
57
  widget_dom
56
58
  end
59
+
57
60
  end
58
61
  end
59
62
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Andy Maleh
1
+ # Copyright (c) 2020-2021 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 Andy Maleh
1
+ # Copyright (c) 2020-2021 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 Andy Maleh
1
+ # Copyright (c) 2020-2021 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
@@ -207,11 +207,11 @@ module Glimmer
207
207
  the_element.on('mouseover') { |event|
208
208
  if event.page_x.between?(the_element.offset.left, the_element.offset.left + the_element.width) and
209
209
  event.page_y.between?(the_element.offset.top, the_element.offset.top + the_element.height)
210
- `$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' });`
210
+ `$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' })`
211
211
  end
212
212
  }
213
213
  the_element.on('menublur') {
214
- `$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' });`
214
+ `$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' })`
215
215
  }
216
216
  minimum_width = children.to_a.map(&:dom_element).map(&:width).reduce(:+)
217
217
  the_element.css('min-width', minimum_width)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020 Andy Maleh
1
+ # Copyright (c) 2020-2021 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
@@ -26,9 +26,9 @@ module Glimmer
26
26
  module SWT
27
27
  class MessageBoxProxy < WidgetProxy
28
28
  STYLE = <<~CSS
29
- .modal {
29
+ .message-box {
30
30
  position: fixed;
31
- z-index: 1;
31
+ z-index: 1000;
32
32
  padding-top: 100px;
33
33
  left: 0;
34
34
  top: 0;
@@ -39,15 +39,15 @@ module Glimmer
39
39
  background-color: rgba(0,0,0,0.4);
40
40
  text-align: center;
41
41
  }
42
- .modal-content .text {
42
+ .message-box-content .text {
43
43
  background: rgb(80, 116, 211);
44
44
  color: white;
45
45
  padding: 5px;
46
46
  }
47
- .modal-content .message {
47
+ .message-box-content .message {
48
48
  padding: 20px;
49
49
  }
50
- .modal-content {
50
+ .message-box-content {
51
51
  background-color: #fefefe;
52
52
  padding-bottom: 15px;
53
53
  border: 1px solid #888;
@@ -74,7 +74,7 @@ module Glimmer
74
74
  i = 0
75
75
  @parent = parent
76
76
  @parent = nil if parent.is_a?(LatestShellProxy)
77
- @parent ||= DisplayProxy.instance.shells.last || ShellProxy.new([])
77
+ @parent ||= DisplayProxy.instance.shells.detect(&:open?) || ShellProxy.new([])
78
78
  @args = args
79
79
  @block = block
80
80
  @children = Set.new
@@ -87,7 +87,7 @@ module Glimmer
87
87
 
88
88
  def text=(txt)
89
89
  @text = txt
90
- dom_element.find('.modal-content .text').html(@text)
90
+ dom_element.find('.message-box-content .text').html(@text)
91
91
  end
92
92
 
93
93
  def html_message
@@ -96,25 +96,31 @@ module Glimmer
96
96
 
97
97
  def message=(msg)
98
98
  @message = msg
99
- dom_element.find('.modal-content .message').html(html_message)
99
+ dom_element.find('.message-box-content .message').html(html_message)
100
+ end
101
+
102
+ def open?
103
+ @open
100
104
  end
101
105
 
102
106
  def open
103
- parent.post_initialize_child(self)
107
+ shell.open(async: false) unless shell.open?
108
+ owned_proc = Glimmer::Util::ProcTracker.new(owner: self, invoked_from: :open) {
109
+ parent.post_initialize_child(self)
110
+ @open = true
111
+ }
112
+ DisplayProxy.instance.async_exec(owned_proc)
104
113
  end
105
114
 
106
115
  def hide
107
116
  dom_element.remove
117
+ @open = false
108
118
  end
109
119
 
110
120
  def content(&block)
111
121
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::MessageBoxExpression.new, &block)
112
122
  end
113
123
 
114
- def name
115
- 'div'
116
- end
117
-
118
124
  def selector
119
125
  super + ' .close'
120
126
  end
@@ -134,9 +140,9 @@ module Glimmer
134
140
  def dom
135
141
  @dom ||= html {
136
142
  div(id: id, class: "modal #{name}") {
137
- div(class: 'modal-content') {
143
+ div(class: 'message-box-content') {
138
144
  header(class: 'text') {
139
- text
145
+ "#{text}&nbsp;" # ensure title area occuppied when there is no text by adding non-breaking space (&nbsp;)
140
146
  }
141
147
  tag(_name: 'p', id: 'message', class: 'message') {
142
148
  html_message
@@ -14,6 +14,16 @@ module Glimmer
14
14
  .row-layout-pack-false {
15
15
  align-items: stretch;
16
16
  }
17
+
18
+ .row-layout-center.row-layout-horizontal > * {
19
+ margin-top: auto;
20
+ margin-bottom: auto;
21
+ }
22
+
23
+ .row-layout-center.row-layout-vertical > * {
24
+ margin-left: auto;
25
+ margin-right: auto;
26
+ }
17
27
 
18
28
  .row-layout-horizontal {
19
29
  flex-direction: row;
@@ -32,15 +42,17 @@ module Glimmer
32
42
  }
33
43
  CSS
34
44
 
35
- attr_reader :type, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left, :spacing, :pack
36
-
45
+ attr_reader :type, :fill, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left, :spacing, :pack, :center
46
+
37
47
  def initialize(parent, args)
38
48
  super(parent, args)
39
- @type = @args.first || :horizontal
40
- @marign_width = 15
41
- @margin_height = 15
42
- self.pack = true
43
49
  @parent.dom_element.add_class('row-layout')
50
+ self.type = args.first || :horizontal
51
+ self.pack = true
52
+ end
53
+
54
+ def type=(value)
55
+ @type = value
44
56
  @parent.dom_element.add_class(horizontal? ? 'row-layout-horizontal' : 'row-layout-vertical')
45
57
  end
46
58
 
@@ -67,6 +79,21 @@ module Glimmer
67
79
  end
68
80
  end
69
81
 
82
+ def fill=(value)
83
+ # TODO verify this is a correct implementation and interpretation of RowLayout in SWT
84
+ self.pack(!value)
85
+ end
86
+
87
+ def center=(center_value)
88
+ @center = center_value
89
+ # Using padding for width since margin-right isn't getting respected with width 100%
90
+ if @center
91
+ parent.dom_element.add_class("row-layout-center")
92
+ else
93
+ parent.dom_element.remove_class("row-layout-center")
94
+ end
95
+ end
96
+
70
97
  def margin_width=(pixels)
71
98
  @margin_width = pixels
72
99
  # Using padding for width since margin-right isn't getting respected with width 100%
@@ -101,7 +128,7 @@ module Glimmer
101
128
  @margin_left = pixels
102
129
  @parent.dom_element.css('padding-left', @margin_left)
103
130
  end
104
-
131
+
105
132
  def spacing=(spacing)
106
133
  @spacing = spacing.to_i
107
134
  # TODO implement changes to accomodate layout_data in the future