glimmer-dsl-opal 0.22.1 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b25cb50adf580107747fab7e5e98f1eb5d93bbf91e0a460d8ed1a3bc671bde84
4
- data.tar.gz: 12c5551fc10de17736f0186e10582e4fdbb2ec08176e33813d1cc2b77fedc523
3
+ metadata.gz: 97154ebca855643dd407d82d30a6d7e127814fe5365bec2020a9f5ac14a20fbf
4
+ data.tar.gz: bc7dc89a573bff5406666a6b59ecf8cfc623493f6f680190ce42655236f79dec
5
5
  SHA512:
6
- metadata.gz: 1f9940b3b91abb63277fddbb9186996ab5433e512f58981516bdcb24e40504c23c2960a22182fd498a255937478f0dab6e9eb5e2d499200036c619abe7724445
7
- data.tar.gz: 10608c56db367b7dea3a0a2c8b55b747eef1a2407c23ee3b88208255fc488462f4e0b6fafb3b7c741d382956ce06982b6913f870d71623f74aa7f236323f0991
6
+ metadata.gz: 65032ea2c5274c6d4b168225d321dbeb586084d7af987cd06fdc8f5cd9f640b7d1aabb5bb46de18c18b7e36116b337dacb39cfd48ac7a98afbd18a2c6cd666ef
7
+ data.tar.gz: 2d663340cc508c4a7c20b4dfd7878ef52c2084868921610d07a2765b9a62e28902b1f2b4c4959f8b18e5ccbe7efe9152d848b588a795a9cfea9f1b9a7c281e6e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.23.0
4
+
5
+ - Hello, Label! sample
6
+ - Support `label` `:separator` SWT style along with `:horizontal` or `:vertical`
7
+ - Support `label` `image` attribute
8
+
3
9
  ## 0.22.1
4
10
 
5
11
  - User Profile elaborate sample
data/README.md CHANGED
@@ -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.22.1 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))
146
+ **Alpha Version** 0.23.0 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)
@@ -166,6 +166,7 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
166
166
  - [Hello, Composite!](#hello-composite)
167
167
  - [Hello, Computed!](#hello-computed)
168
168
  - [Hello, Cursor!](#hello-cursor)
169
+ - [Hello, Label!](#hello-label)
169
170
  - [Hello, Layout!](#hello-layout)
170
171
  - [Hello, List Single Selection!](#hello-list-single-selection)
171
172
  - [Hello, List Multi Selection!](#hello-list-multi-selection)
@@ -263,7 +264,7 @@ gem 'opal', '1.0.4'
263
264
  gem 'opal-rails', '1.1.2'
264
265
  gem 'opal-async', '~> 1.2.0'
265
266
  gem 'opal-jquery', '~> 0.4.4'
266
- gem 'glimmer-dsl-opal', '~> 0.22.1'
267
+ gem 'glimmer-dsl-opal', '~> 0.23.0'
267
268
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
268
269
  gem 'glimmer-dsl-css', '~> 1.2.0', require: false
269
270
 
@@ -691,6 +692,56 @@ You should see "Hello, Cursor!"
691
692
 
692
693
  ![Glimmer DSL for Opal Hello Cursor](images/glimmer-dsl-opal-hello-cursor.gif)
693
694
 
695
+ #### Hello, Label!
696
+
697
+ Add the following require statement to `app/assets/javascripts/application.rb`
698
+
699
+
700
+ ```ruby
701
+ require 'glimmer-dsl-opal/samples/hello/hello_label'
702
+ ```
703
+
704
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
705
+
706
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-left-aligned.png)
707
+
708
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-center-aligned.png)
709
+
710
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-right-aligned.png)
711
+
712
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-images.png)
713
+
714
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-background_images.png)
715
+
716
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-horizontal-separator.png)
717
+
718
+ ![Glimmer DSL for SWT Hello Label](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-label-vertical-separator.png)
719
+
720
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
721
+
722
+ Start the Rails server:
723
+ ```
724
+ rails s
725
+ ```
726
+
727
+ Visit `http://localhost:3000`
728
+
729
+ You should see "Hello, Label!"
730
+
731
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-left-aligned.png)
732
+
733
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-center-aligned.png)
734
+
735
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-right-aligned.png)
736
+
737
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-images.png)
738
+
739
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-background_images.png)
740
+
741
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-horizontal-separator.png)
742
+
743
+ ![Glimmer DSL for Opal Hello Label](images/glimmer-dsl-opal-hello-label-vertical-separator.png)
744
+
694
745
  #### Hello, Layout!
695
746
 
696
747
  Add the following require statement to `app/assets/javascripts/application.rb`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.22.1
1
+ 0.23.0
@@ -0,0 +1,192 @@
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 HelloLabel
23
+ include Glimmer::UI::CustomShell
24
+
25
+ body {
26
+ shell {
27
+ text 'Hello, Label!'
28
+
29
+ tab_folder {
30
+ tab_item {
31
+ text 'left-aligned'
32
+
33
+ grid_layout 2, true
34
+
35
+ 1.upto(3) do |n|
36
+ label(:left) { # :left is default in English, so it is unnecessary
37
+ layout_data :fill, :center, true, false
38
+ text "Field #{n}"
39
+ }
40
+ text {
41
+ layout_data :fill, :center, true, false
42
+ text "Enter Field #{n}"
43
+ }
44
+ end
45
+ }
46
+
47
+ tab_item {
48
+ text 'center-aligned'
49
+
50
+ grid_layout 2, true
51
+
52
+ 1.upto(3) do |n|
53
+ label(:center) {
54
+ layout_data :fill, :center, true, false
55
+ text "Field #{n}"
56
+ }
57
+ text {
58
+ layout_data :fill, :center, true, false
59
+ text "Enter Field #{n}"
60
+ }
61
+ end
62
+ }
63
+
64
+ tab_item {
65
+ text 'right-aligned'
66
+
67
+ grid_layout 2, true
68
+
69
+ 1.upto(3) do |n|
70
+ label(:right) {
71
+ layout_data :fill, :center, true, false
72
+ text "Field #{n}"
73
+ }
74
+ text {
75
+ layout_data :fill, :center, true, false
76
+ text "Enter Field #{n}"
77
+ }
78
+ end
79
+ }
80
+
81
+ tab_item {
82
+ text 'images'
83
+
84
+ grid_layout 2, true
85
+
86
+ ['denmark', 'finland', 'norway'].each do |image_name|
87
+ label {
88
+ layout_data :center, :center, true, false
89
+ image File.expand_path("images/#{image_name}.png", __dir__)
90
+ }
91
+ text {
92
+ layout_data :fill, :center, true, false
93
+ text "Enter Field #{image_name.capitalize}"
94
+ }
95
+ end
96
+ }
97
+
98
+ tab_item {
99
+ text 'background images'
100
+
101
+ grid_layout 2, true
102
+
103
+ ['italy', 'france', 'mexico'].each do |image_name|
104
+ label {
105
+ layout_data :center, :center, true, false
106
+ background_image File.expand_path("images/#{image_name}.png", __dir__)
107
+ text image_name.capitalize
108
+ font height: 26, style: :bold
109
+ }
110
+ text {
111
+ layout_data :fill, :center, true, false
112
+ text "Enter Field #{image_name.capitalize}"
113
+ }
114
+ end
115
+ }
116
+
117
+ tab_item {
118
+ text 'horizontal separator'
119
+
120
+ grid_layout 2, true
121
+
122
+ label {
123
+ layout_data :fill, :center, true, false
124
+ text "Field 1"
125
+ }
126
+ text {
127
+ layout_data :fill, :center, true, false
128
+ text "Enter Field 1"
129
+ }
130
+
131
+ label(:separator, :horizontal) {
132
+ layout_data(:fill, :center, true, false) {
133
+ horizontal_span 2
134
+ }
135
+ }
136
+
137
+ label {
138
+ layout_data :fill, :center, true, false
139
+ text "Field 2"
140
+ }
141
+ text {
142
+ layout_data :fill, :center, true, false
143
+ text "Enter Field 2"
144
+ }
145
+ }
146
+
147
+ tab_item {
148
+ text 'vertical separator'
149
+
150
+ grid_layout 3, true
151
+
152
+ label {
153
+ layout_data :fill, :center, true, false
154
+ text "Field 1"
155
+ }
156
+ label(:separator, :vertical) {
157
+ layout_data(:center, :center, false, false) {
158
+ vertical_span 3
159
+ }
160
+ }
161
+ text {
162
+ layout_data :fill, :center, true, false
163
+ text "Enter Field 1"
164
+ }
165
+
166
+ label {
167
+ layout_data :fill, :center, true, false
168
+ text "Field 2"
169
+ }
170
+ text {
171
+ layout_data :fill, :center, true, false
172
+ text "Enter Field 2"
173
+ }
174
+
175
+ label {
176
+ layout_data :fill, :center, true, false
177
+ text "Field 3"
178
+ }
179
+ text {
180
+ layout_data :fill, :center, true, false
181
+ text "Enter Field 3"
182
+ }
183
+ }
184
+
185
+ }
186
+
187
+ }
188
+
189
+ }
190
+ end
191
+
192
+ HelloLabel.launch
@@ -28,7 +28,7 @@ module Glimmer
28
28
  attr_accessor :closeable
29
29
 
30
30
  def initialize(parent, args, block)
31
- @closeable = args.detect { |arg| SWTProxy[:close] == SWTProxy[arg] }
31
+ @closeable = args.detect { |arg| SWTProxy[arg] == SWTProxy[:close] }
32
32
  super(parent, args, block)
33
33
  # TODO attach listener if :close style is set
34
34
  close_dom_element.on('click') { dispose }
@@ -25,43 +25,39 @@ require 'glimmer/swt/widget_proxy'
25
25
  module Glimmer
26
26
  module SWT
27
27
  class LabelProxy < WidgetProxy
28
- attr_reader :text, :background_image, :image
28
+ attr_reader :text, :background_image, :image, :separator, :vertical
29
+ alias separator? separator
30
+ alias vertical? vertical
29
31
 
30
32
  def initialize(parent, args, block)
33
+ @separator = args.detect { |arg| SWTProxy[arg] == SWTProxy[:separator] }
34
+ @vertical = args.detect { |arg| SWTProxy[arg] == SWTProxy[:vertical] }
31
35
  super(parent, args, block)
32
36
  end
37
+
38
+ def horizontal
39
+ !vertical
40
+ end
41
+ alias horizontal? horizontal
33
42
 
34
43
  def text=(value)
35
44
  @text = value
36
- dom_element.html(html_text) # TODO deal with issue of handling lines and escaping at the same time
45
+ dom_element.html(html_text) unless @image
37
46
  end
38
47
 
39
48
  def html_text
40
49
  text && CGI.escape_html(text).gsub("\n", '<br />')
41
50
  end
42
51
 
43
- # def background_image=(*image_options)
44
- # TODO consider if there is a difference between background_image and image in label and to have one reuse the other
45
- # TODO finish implementation
46
- # @background_image = Glimmer::SWT::ImageProxy.create(*image_options)
47
- # dom_element.css('background-image', @background_image.image_data.dom_element.src)
48
- # end
49
-
50
- def image=(*image_options)
51
- # TODO finish implementation
52
- # @image = Glimmer::SWT::ImageProxy.create(*image_options)
53
- # dom_element.css('background-image', @image.image_data.dom_element.src)
54
- end
55
-
56
- # background image
57
- def background_image
58
- @background_image
52
+ def image=(value)
53
+ @image = value
54
+ dom_element.html("<img src='#{@image}' />")
59
55
  end
60
56
 
61
57
  # background image is stretched by default
62
58
  def background_image=(value)
63
59
  @background_image = value
64
- dom_element.css('background-image', "url(#{background_image})")
60
+ dom_element.css('background-image', "url(#{@background_image})")
65
61
  dom_element.css('background-repeat', 'no-repeat')
66
62
  dom_element.css('background-size', 'cover')
67
63
  end
@@ -88,8 +84,11 @@ module Glimmer
88
84
  def dom
89
85
  label_id = id
90
86
  label_class = name
87
+ label_style = "text-align: #{alignment}; "
88
+ label_style += "border-top: 1px solid rgb(207, 207, 207); " if separator? && horizontal?
89
+ label_style += "border-right: 1px solid rgb(207, 207, 207); height: 100%; " if separator? && vertical?
91
90
  @dom ||= html {
92
- label(id: label_id, class: label_class, style: "text-align: #{alignment};") {
91
+ label(id: label_id, class: label_class, style: label_style) {
93
92
  html_text
94
93
  }
95
94
  }.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.1
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
@@ -301,6 +301,7 @@ files:
301
301
  - lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb
302
302
  - lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb
303
303
  - lib/glimmer-dsl-opal/samples/hello/hello_group.rb
304
+ - lib/glimmer-dsl-opal/samples/hello/hello_label.rb
304
305
  - lib/glimmer-dsl-opal/samples/hello/hello_layout.rb
305
306
  - lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb
306
307
  - lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb