glimmer-dsl-opal 0.16.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +56 -4
- data/VERSION +1 -1
- data/lib/cgi.rb +14 -0
- data/lib/glimmer-dsl-opal.rb +1 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_layout.rb +241 -0
- data/lib/glimmer/swt/fill_layout_proxy.rb +9 -3
- data/lib/glimmer/swt/grid_layout_proxy.rb +33 -1
- data/lib/glimmer/swt/label_proxy.rb +2 -2
- data/lib/glimmer/swt/row_layout_proxy.rb +33 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73ea5888d9b6351e59225c868c98bf3c5f8d7bf20e1314bf2289be1528cd5d65
|
4
|
+
data.tar.gz: 0d5420f934e0d29a8fcdb15e68f2e30365f2d70d9d89e2dc19bbd24d14a91626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e7aae7f3b6e5342e2231f08330cf50e2c5574444b3f07c86b2166722e356e18ca6fb89a2ad21509951360432a42e8f6c449a19b5ff5737b08f521b8f473b79
|
7
|
+
data.tar.gz: 6f4be96f8c26c160b0d8d8d2dfc92d40cfa95fc79a76cfe886567cd2f55671861adf9b19cfdbc5d1f6fa78a1ce516f7ab46c330bdef2821a1a312b8b165c91cc
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.16.2
|
4
|
+
|
5
|
+
- Support `grid_layout` `margin_top`, `margin_right`, `margin_bottom`, and `margin_left` attributes
|
6
|
+
- Support `row_layout` `wrap` and `justify` attributes
|
7
|
+
- Hello, Layout! sample
|
8
|
+
- Partial CGI implementation to have `escapeHTML` (alias: `escape_html`) method
|
9
|
+
- HTML Escape label text content
|
10
|
+
- Fix issue with `row_layout` `fill` attribute not working
|
11
|
+
|
3
12
|
## 0.16.1
|
4
13
|
|
5
|
-
- Support
|
14
|
+
- Support `grid_layout` `make_columns_equal_width`, `horizontal_spacing`, and `vertical_spacing` attributes
|
6
15
|
- Hello, Composite! sample
|
7
16
|
|
8
17
|
## 0.16.0
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal 0.16.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Opal 0.16.2 (Pure Ruby Web GUI)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
|
3
3
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
4
|
|
@@ -143,7 +143,7 @@ Hello, Table! Game Booked
|
|
143
143
|
|
144
144
|
NOTE: Glimmer DSL for Opal is an alpha project. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
|
145
145
|
|
146
|
-
**Alpha Version** 0.16.
|
146
|
+
**Alpha Version** 0.16.2 only supports bare-minimum capabilities for the included [samples](https://github.com/AndyObtiva/glimmer-dsl-opal#samples) (originally written for [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt))
|
147
147
|
|
148
148
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
149
149
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
@@ -153,7 +153,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
|
153
153
|
|
154
154
|
## Table of Contents
|
155
155
|
|
156
|
-
- [Glimmer DSL for Opal 0.16.
|
156
|
+
- [Glimmer DSL for Opal 0.16.2 (Pure Ruby Web GUI)](#-glimmer-dsl-for-opal-0162-pure-ruby-web-gui)
|
157
157
|
- [Principles](#principles)
|
158
158
|
- [Background](#background)
|
159
159
|
- [Pre-requisites](#pre-requisites)
|
@@ -257,7 +257,7 @@ gem 'opal', '1.0.4'
|
|
257
257
|
gem 'opal-rails', '1.1.2'
|
258
258
|
gem 'opal-async', '~> 1.2.0'
|
259
259
|
gem 'opal-jquery', '~> 0.4.4'
|
260
|
-
gem 'glimmer-dsl-opal', '~> 0.16.
|
260
|
+
gem 'glimmer-dsl-opal', '~> 0.16.2'
|
261
261
|
gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
|
262
262
|
gem 'glimmer-dsl-css', '~> 1.2.0', require: false
|
263
263
|
|
@@ -656,6 +656,58 @@ You should see "Hello, Computed!"
|
|
656
656
|
|
657
657
|
![Glimmer DSL for Opal Hello Computed](images/glimmer-dsl-opal-hello-computed.png)
|
658
658
|
|
659
|
+
#### Hello, Layout!
|
660
|
+
|
661
|
+
Add the following require statement to `app/assets/javascripts/application.rb`
|
662
|
+
|
663
|
+
|
664
|
+
```ruby
|
665
|
+
require 'glimmer-dsl-opal/samples/hello/hello_layout'
|
666
|
+
```
|
667
|
+
|
668
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
669
|
+
|
670
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab1.png)
|
671
|
+
|
672
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab2.png)
|
673
|
+
|
674
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab3.png)
|
675
|
+
|
676
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab4.png)
|
677
|
+
|
678
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab5.png)
|
679
|
+
|
680
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab6.png)
|
681
|
+
|
682
|
+
![Glimmer DSL for SWT Hello Layout](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-layout-tab7.png)
|
683
|
+
|
684
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
685
|
+
|
686
|
+
Start the Rails server:
|
687
|
+
```
|
688
|
+
rails s
|
689
|
+
```
|
690
|
+
|
691
|
+
Visit `http://localhost:3000`
|
692
|
+
|
693
|
+
You should see "Hello, Layout!"
|
694
|
+
|
695
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab1.png)
|
696
|
+
|
697
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab2.png)
|
698
|
+
|
699
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab3.png)
|
700
|
+
|
701
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab4.png)
|
702
|
+
|
703
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab4-shrunk.png)
|
704
|
+
|
705
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab5.png)
|
706
|
+
|
707
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab6.png)
|
708
|
+
|
709
|
+
![Glimmer DSL for Opal Hello Layout](images/glimmer-dsl-opal-hello-layout-tab7.png)
|
710
|
+
|
659
711
|
#### Hello, List Single Selection!
|
660
712
|
|
661
713
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.16.
|
1
|
+
0.16.2
|
data/lib/cgi.rb
ADDED
data/lib/glimmer-dsl-opal.rb
CHANGED
@@ -0,0 +1,241 @@
|
|
1
|
+
# Copyright (c) 2020-2021 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
|
+
class HelloLayout
|
23
|
+
include Glimmer::UI::CustomShell
|
24
|
+
|
25
|
+
body {
|
26
|
+
shell {
|
27
|
+
# shell (which is a composite) has fill_layout(:horizontal) by default with no margins
|
28
|
+
text 'Hello, Layout!'
|
29
|
+
tab_folder {
|
30
|
+
|
31
|
+
# every tab item has its own composite, which can set a layout
|
32
|
+
tab_item {
|
33
|
+
text 'Fill Layout (horizontal)'
|
34
|
+
|
35
|
+
fill_layout(:horizontal) {
|
36
|
+
margin_width 30
|
37
|
+
margin_height 40
|
38
|
+
spacing 5
|
39
|
+
}
|
40
|
+
|
41
|
+
10.times { |n|
|
42
|
+
label {
|
43
|
+
text "<label #{n+1}>"
|
44
|
+
}
|
45
|
+
|
46
|
+
}
|
47
|
+
|
48
|
+
}
|
49
|
+
|
50
|
+
tab_item {
|
51
|
+
text 'Fill Layout (vertical)'
|
52
|
+
|
53
|
+
fill_layout {
|
54
|
+
type :vertical # alternative way of specifying orientation
|
55
|
+
margin_width 40
|
56
|
+
margin_height 30
|
57
|
+
spacing 10
|
58
|
+
}
|
59
|
+
|
60
|
+
10.times { |n|
|
61
|
+
label(:center) {
|
62
|
+
text "<label #{n+1}>"
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
tab_item {
|
70
|
+
text 'Row Layout (horizontal)'
|
71
|
+
|
72
|
+
row_layout(:horizontal) {
|
73
|
+
# row layout has margin attributes for top, left, right, and bottom
|
74
|
+
# in addition to width and height (and sets margin_width and margin_height to 5 by default)
|
75
|
+
margin_top 40
|
76
|
+
margin_left 30
|
77
|
+
spacing 5
|
78
|
+
wrap false
|
79
|
+
center true
|
80
|
+
justify true
|
81
|
+
}
|
82
|
+
|
83
|
+
10.times { |n|
|
84
|
+
label {
|
85
|
+
text "<label #{n+1}>"
|
86
|
+
}
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
}
|
91
|
+
|
92
|
+
tab_item {
|
93
|
+
text 'Row Layout (wrap on shrink)'
|
94
|
+
|
95
|
+
row_layout { # :horizontal is the default type
|
96
|
+
margin_height 40
|
97
|
+
margin_width 30
|
98
|
+
spacing 35
|
99
|
+
# wrap true # is the default
|
100
|
+
}
|
101
|
+
|
102
|
+
10.times { |n|
|
103
|
+
label {
|
104
|
+
text "<label #{n+1}>"
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
tab_item {
|
112
|
+
text 'Row Layout (vertical)'
|
113
|
+
background :yellow
|
114
|
+
|
115
|
+
row_layout(:vertical) { |l|
|
116
|
+
margin_height 0
|
117
|
+
margin_width 0
|
118
|
+
spacing 10
|
119
|
+
fill true # fills horizontally to match the widest child (opposite to row layout orientation)
|
120
|
+
center false # enable and disable fill to see what this does
|
121
|
+
}
|
122
|
+
|
123
|
+
10.times { |n|
|
124
|
+
label {
|
125
|
+
# layout_data allows a widget to tweak its layout configuration (generating RowData object for RowLayout)
|
126
|
+
layout_data {
|
127
|
+
height 30
|
128
|
+
# width unspecified yet calculated
|
129
|
+
}
|
130
|
+
text "<this is a ver#{'r'*(rand*200).to_i}y wide label #{n+1}>"
|
131
|
+
background :green
|
132
|
+
}
|
133
|
+
|
134
|
+
}
|
135
|
+
|
136
|
+
}
|
137
|
+
|
138
|
+
tab_item {
|
139
|
+
text 'Grid Layout'
|
140
|
+
|
141
|
+
grid_layout {
|
142
|
+
num_columns 5
|
143
|
+
make_columns_equal_width true
|
144
|
+
horizontal_spacing 15
|
145
|
+
vertical_spacing 10
|
146
|
+
|
147
|
+
# grid layout has margin attributes for top, left, right, and bottom
|
148
|
+
# in addition to width and height (and sets margin_width and margin_height to 5 by default)
|
149
|
+
margin_height 0
|
150
|
+
margin_top 20
|
151
|
+
}
|
152
|
+
|
153
|
+
10.times { |n|
|
154
|
+
label {
|
155
|
+
text "<this label is wide enough to fill #{n+1}>"
|
156
|
+
background :white
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
label {
|
161
|
+
# layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
|
162
|
+
layout_data {
|
163
|
+
width_hint 120
|
164
|
+
height_hint 40
|
165
|
+
}
|
166
|
+
text "<this label is clipped>"
|
167
|
+
background :cyan
|
168
|
+
}
|
169
|
+
|
170
|
+
label {
|
171
|
+
# layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
|
172
|
+
layout_data {
|
173
|
+
horizontal_span 2
|
174
|
+
}
|
175
|
+
text "<this label spans two columns, so it can contain more text than normal>"
|
176
|
+
background :green
|
177
|
+
}
|
178
|
+
|
179
|
+
label {
|
180
|
+
# layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
|
181
|
+
layout_data {
|
182
|
+
vertical_span 2
|
183
|
+
vertical_alignment :fill
|
184
|
+
}
|
185
|
+
text "<this label spans two rows, \nso it can contain new lines\n1\n2\n3\n4\n5\n6\n7>"
|
186
|
+
background :yellow
|
187
|
+
}
|
188
|
+
|
189
|
+
5.times { label } # just filler
|
190
|
+
|
191
|
+
label {
|
192
|
+
|
193
|
+
# layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
|
194
|
+
layout_data {
|
195
|
+
horizontal_span 5
|
196
|
+
horizontal_alignment :fill # could be :beginning, :center or :end too
|
197
|
+
vertical_alignment :fill # could be :beginning, :center, or :end too
|
198
|
+
grab_excess_horizontal_space true
|
199
|
+
grab_excess_vertical_space true
|
200
|
+
}
|
201
|
+
|
202
|
+
# this is a short alternative for specifying what is above
|
203
|
+
# layout_data(:fill, :fill, true, true) {
|
204
|
+
# horizontal_span 5
|
205
|
+
# }
|
206
|
+
|
207
|
+
text "<this label fills all the space it can get\nhorizontally and vertically>"
|
208
|
+
background :magenta
|
209
|
+
}
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
tab_item {
|
215
|
+
text 'Grid Layout (non-equal columns)'
|
216
|
+
|
217
|
+
grid_layout(2, false) # alt syntax: (numColumns, make_columns_equal_width)
|
218
|
+
|
219
|
+
10.times { |n|
|
220
|
+
label {
|
221
|
+
text "Field #{n+1}"
|
222
|
+
}
|
223
|
+
text {
|
224
|
+
layout_data {
|
225
|
+
width_hint 600
|
226
|
+
}
|
227
|
+
|
228
|
+
text "Please enter text"
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
}
|
233
|
+
|
234
|
+
}
|
235
|
+
|
236
|
+
}
|
237
|
+
|
238
|
+
}
|
239
|
+
end
|
240
|
+
|
241
|
+
HelloLayout.launch
|
@@ -28,13 +28,11 @@ module Glimmer
|
|
28
28
|
|
29
29
|
def initialize(parent, args)
|
30
30
|
super(parent, args)
|
31
|
-
|
31
|
+
self.type = @args.first || :horizontal
|
32
32
|
self.margin_width = 15
|
33
33
|
self.margin_height = 15
|
34
34
|
@parent.css_classes << 'fill-layout'
|
35
|
-
@parent.css_classes << (horizontal? ? 'fill-layout-horizontal' : 'fill-layout-vertical')
|
36
35
|
@parent.dom_element.add_class('fill-layout')
|
37
|
-
@parent.dom_element.add_class(horizontal? ? 'fill-layout-horizontal' : 'fill-layout-vertical')
|
38
36
|
end
|
39
37
|
|
40
38
|
def horizontal?
|
@@ -44,6 +42,14 @@ module Glimmer
|
|
44
42
|
def vertical?
|
45
43
|
@type == :vertical
|
46
44
|
end
|
45
|
+
|
46
|
+
def type=(value)
|
47
|
+
@parent.dom_element.remove_class(horizontal? ? 'fill-layout-horizontal' : 'fill-layout-vertical')
|
48
|
+
@parent.css_classes.delete(horizontal? ? 'fill-layout-horizontal' : 'fill-layout-vertical')
|
49
|
+
@type = value
|
50
|
+
@parent.dom_element.add_class(horizontal? ? 'fill-layout-horizontal' : 'fill-layout-vertical')
|
51
|
+
@parent.css_classes << horizontal? ? 'fill-layout-horizontal' : 'fill-layout-vertical'
|
52
|
+
end
|
47
53
|
|
48
54
|
def margin_width=(pixels)
|
49
55
|
@margin_width = pixels
|
@@ -12,7 +12,7 @@ module Glimmer
|
|
12
12
|
}
|
13
13
|
CSS
|
14
14
|
|
15
|
-
attr_reader :num_columns, :make_columns_equal_width, :horizontal_spacing, :vertical_spacing, :margin_width, :margin_height
|
15
|
+
attr_reader :num_columns, :make_columns_equal_width, :horizontal_spacing, :vertical_spacing, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left
|
16
16
|
|
17
17
|
def num_columns=(columns)
|
18
18
|
@num_columns = columns
|
@@ -55,6 +55,38 @@ module Glimmer
|
|
55
55
|
@parent.dom_element.css('padding-top', effective_margin_height)
|
56
56
|
@parent.dom_element.css('padding-bottom', effective_margin_height)
|
57
57
|
end
|
58
|
+
|
59
|
+
def margin_top=(pixels)
|
60
|
+
@margin_top = pixels
|
61
|
+
# Using padding for width since margin-right isn't getting respected with width 100%
|
62
|
+
effective_margin_top = @margin_top
|
63
|
+
effective_margin_top += 9 if @parent.is_a?(GroupProxy)
|
64
|
+
@parent.dom_element.css('padding-top', effective_margin_top)
|
65
|
+
end
|
66
|
+
|
67
|
+
def margin_right=(pixels)
|
68
|
+
@margin_right = pixels
|
69
|
+
effective_margin_right = @margin_right
|
70
|
+
effective_margin_right += 6 if @parent.is_a?(GroupProxy)
|
71
|
+
@parent.dom_element.css('padding-right', effective_margin_right)
|
72
|
+
end
|
73
|
+
|
74
|
+
def margin_bottom=(pixels)
|
75
|
+
@margin_bottom = pixels
|
76
|
+
# Using padding for width since margin-right isn't getting respected with width 100%
|
77
|
+
effective_margin_bottom = @margin_bottom
|
78
|
+
effective_margin_bottom += 9 if @parent.is_a?(GroupProxy)
|
79
|
+
@parent.dom_element.css('padding-bottom', effective_margin_bottom)
|
80
|
+
end
|
81
|
+
|
82
|
+
def margin_left=(pixels)
|
83
|
+
@margin_left = pixels
|
84
|
+
effective_margin_left = @margin_left
|
85
|
+
effective_margin_left += 6 if @parent.is_a?(GroupProxy)
|
86
|
+
@parent.dom_element.css('padding-left', effective_margin_left)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
58
90
|
|
59
91
|
def initialize(parent, args)
|
60
92
|
super(parent, args)
|
@@ -33,11 +33,11 @@ module Glimmer
|
|
33
33
|
|
34
34
|
def text=(value)
|
35
35
|
@text = value
|
36
|
-
dom_element.html(html_text)
|
36
|
+
dom_element.html(html_text) # TODO deal with issue of handling lines and escaping at the same time
|
37
37
|
end
|
38
38
|
|
39
39
|
def html_text
|
40
|
-
text
|
40
|
+
text && CGI.escape_html(text).gsub("\n", '<br />')
|
41
41
|
end
|
42
42
|
|
43
43
|
# def background_image=(*image_options)
|
@@ -24,6 +24,14 @@ module Glimmer
|
|
24
24
|
margin-left: auto;
|
25
25
|
margin-right: auto;
|
26
26
|
}
|
27
|
+
|
28
|
+
.row-layout-wrap {
|
29
|
+
flex-wrap: wrap;
|
30
|
+
}
|
31
|
+
|
32
|
+
.row-layout-justify {
|
33
|
+
justify-content: space-around;
|
34
|
+
}
|
27
35
|
|
28
36
|
.row-layout-horizontal {
|
29
37
|
flex-direction: row;
|
@@ -42,13 +50,14 @@ module Glimmer
|
|
42
50
|
}
|
43
51
|
CSS
|
44
52
|
|
45
|
-
attr_reader :type, :
|
53
|
+
attr_reader :type, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left, :spacing, :pack, :center, :wrap, :justify
|
46
54
|
|
47
55
|
def initialize(parent, args)
|
48
56
|
super(parent, args)
|
49
57
|
@parent.dom_element.add_class('row-layout')
|
50
58
|
self.type = args.first || :horizontal
|
51
59
|
self.pack = true
|
60
|
+
self.wrap = true
|
52
61
|
end
|
53
62
|
|
54
63
|
def type=(value)
|
@@ -79,9 +88,13 @@ module Glimmer
|
|
79
88
|
end
|
80
89
|
end
|
81
90
|
|
91
|
+
def fill
|
92
|
+
!pack
|
93
|
+
end
|
94
|
+
|
82
95
|
def fill=(value)
|
83
96
|
# TODO verify this is a correct implementation and interpretation of RowLayout in SWT
|
84
|
-
self.pack
|
97
|
+
self.pack = !value
|
85
98
|
end
|
86
99
|
|
87
100
|
def center=(center_value)
|
@@ -94,6 +107,24 @@ module Glimmer
|
|
94
107
|
end
|
95
108
|
end
|
96
109
|
|
110
|
+
def wrap=(wrap_value)
|
111
|
+
@wrap = wrap_value
|
112
|
+
if @wrap
|
113
|
+
parent.dom_element.add_class("row-layout-wrap")
|
114
|
+
else
|
115
|
+
parent.dom_element.remove_class("row-layout-wrap")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def justify=(justify_value)
|
120
|
+
@justify = justify_value
|
121
|
+
if @justify
|
122
|
+
parent.dom_element.add_class("row-layout-justify")
|
123
|
+
else
|
124
|
+
parent.dom_element.remove_class("row-layout-justify")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
97
128
|
def margin_width=(pixels)
|
98
129
|
@margin_width = pixels
|
99
130
|
# Using padding for width since margin-right isn't getting respected with width 100%
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- app/controllers/glimmer/image_paths_controller.rb
|
268
268
|
- app/views/glimmer/image_paths/index.html.erb
|
269
269
|
- config/routes.rb
|
270
|
+
- lib/cgi.rb
|
270
271
|
- lib/display.rb
|
271
272
|
- lib/glimmer-dsl-opal.rb
|
272
273
|
- lib/glimmer-dsl-opal/ext/class.rb
|
@@ -295,6 +296,7 @@ files:
|
|
295
296
|
- lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb
|
296
297
|
- lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb
|
297
298
|
- lib/glimmer-dsl-opal/samples/hello/hello_group.rb
|
299
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_layout.rb
|
298
300
|
- lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb
|
299
301
|
- lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb
|
300
302
|
- lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb
|