glimmer-dsl-opal 0.24.0 → 0.25.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: f974d9526112e11c32284c5fbcd30e08226aafa3f799c08ccd67deabddf9f0ac
4
- data.tar.gz: e77d826d4afb7a359a24f2a87dc49672e7d17e4da265feef11c278403370d468
3
+ metadata.gz: 3acd64cce93e2c522567f6b10967489a8edb74e19aad32d9b6aef070f8339715
4
+ data.tar.gz: 78adb831387641339c046839bf8ccd034354881a1a963c0eb7084c4065167c2b
5
5
  SHA512:
6
- metadata.gz: 9295b9a8da3867580a975a43cc61708d635de4f03d30fae6d07913d9147783c2372fe1fe9f673d0f8bfe20988684579b0aaeaa6fbebcec189c4111bba3b62935
7
- data.tar.gz: 5ea143577dc7c59c8c8b5d423f0a17580c71bcbefb29cd200c770e8078ca78cca75f29de4354801b38a2a440365285832f96a48ec50290afbe941b865aa73f14
6
+ metadata.gz: 340aa792a59e2577c818461ef4ebe88a01b06a8becf19e2f138c8895cdfa691872d227ea9c490f1bb48d14fd6edf3bb2b65aabe8f21bb0982e8fcf4bfdb2d5e1
7
+ data.tar.gz: c5509de40b089c73879d46aabb4c7440698eda864acd80509e1496b7bb1ca0558b47c399c96d28b295fa9ec088dffdaf7958861f23dcb9b4b24bbb58a798561d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.25.0
4
+
5
+ - Support `progress_bar` widget without `:vertical` SWT style support
6
+ - Hello, Progress Bar! sample without `:vertical` SWT style
7
+
3
8
  ## 0.24.0
4
9
 
5
10
  - `widget#print` method
data/README.md CHANGED
@@ -187,6 +187,8 @@ Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
187
187
  - [Hello, Arrow!](#hello-arrow)
188
188
  - [Hello, Message Box!](#hello-message-box)
189
189
  - [Hello, Pop Up Context Menu!](#hello-pop-up-context-menu)
190
+ - [Hello, Print!](#hello-print)
191
+ - [Hello, Progress Bar!](#hello-progress-bar)
190
192
  - [Hello, Menu Bar!](#hello-menu-bar)
191
193
  - [Hello, Dialog!](#hello-dialog)
192
194
  - [Elaborate Samples](#elaborate-samples)
@@ -262,7 +264,7 @@ Add the following to `Gemfile`:
262
264
  ```
263
265
  gem 'opal', '1.0.4'
264
266
  gem 'opal-rails', '1.1.2'
265
- gem 'opal-async', '~> 1.2.0'
267
+ gem 'opal-async', '~> 1.3.0'
266
268
  gem 'opal-jquery', '~> 0.4.4'
267
269
  gem 'glimmer-dsl-opal', '~> 0.24.0'
268
270
  gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
@@ -1833,6 +1835,52 @@ You should see "Hello, Message Box!"
1833
1835
  ![Glimmer DSL for Opal Hello Message Box](images/glimmer-dsl-opal-hello-message-box.png)
1834
1836
  ![Glimmer DSL for Opal Hello Message Box Dialog](images/glimmer-dsl-opal-hello-message-box-dialog.png)
1835
1837
 
1838
+ #### Hello, Print!
1839
+
1840
+ Add the following require statement to `app/assets/javascripts/application.rb`
1841
+
1842
+ ```ruby
1843
+ require 'glimmer-dsl-opal/samples/hello/hello_print'
1844
+ ```
1845
+
1846
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1847
+
1848
+ ![Glimmer DSL for SWT Hello Print](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-print.png)
1849
+
1850
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1851
+
1852
+ Start the Rails server:
1853
+ ```
1854
+ rails s
1855
+ ```
1856
+
1857
+ Visit `http://localhost:3000`
1858
+
1859
+ You should see "Hello, Print!"
1860
+
1861
+ #### Hello, Progress Bar!
1862
+
1863
+ Add the following require statement to `app/assets/javascripts/application.rb`
1864
+
1865
+ ```ruby
1866
+ require 'glimmer-dsl-opal/samples/hello/hello_progress_bar'
1867
+ ```
1868
+
1869
+ Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
1870
+
1871
+ ![Glimmer DSL for SWT Hello Progress Bar](https://github.com/AndyObtiva/glimmer-dsl-swt/raw/master/images/glimmer-hello-progress-bar.gif)
1872
+
1873
+ Glimmer app on the web (using `glimmer-dsl-opal` gem):
1874
+
1875
+ Start the Rails server:
1876
+ ```
1877
+ rails s
1878
+ ```
1879
+
1880
+ Visit `http://localhost:3000`
1881
+
1882
+ You should see "Hello, Progress Bar!"
1883
+
1836
1884
  #### Hello, Pop Up Context Menu!
1837
1885
 
1838
1886
  Add the following require statement to `app/assets/javascripts/application.rb`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.24.0
1
+ 0.25.0
@@ -0,0 +1,126 @@
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 HelloProgressBar
23
+ include Glimmer::UI::CustomShell
24
+
25
+ class ProgressModel
26
+ attr_accessor :minimum, :maximum, :selection, :delay
27
+ end
28
+
29
+ before_body do
30
+ @progress_model = ProgressModel.new
31
+ @progress_model.minimum = 0
32
+ @progress_model.maximum = 100
33
+ @progress_model.selection = 0
34
+ @progress_model.delay = 0.01
35
+ end
36
+
37
+ body {
38
+ shell {
39
+ grid_layout(4, true)
40
+
41
+ text 'Hello, Progress Bar!'
42
+
43
+ progress_bar(:indeterminate) {
44
+ layout_data(:fill, :center, true, false) {
45
+ horizontal_span 4
46
+ }
47
+ }
48
+
49
+ label {
50
+ text 'Minimum'
51
+ }
52
+
53
+ label {
54
+ text 'Maximum'
55
+ }
56
+
57
+ label {
58
+ text 'Selection'
59
+ }
60
+
61
+ label {
62
+ text 'Delay in Seconds'
63
+ }
64
+
65
+ spinner {
66
+ selection <=> [@progress_model, :minimum]
67
+ }
68
+
69
+ spinner {
70
+ selection <=> [@progress_model, :maximum]
71
+ }
72
+
73
+ spinner {
74
+ selection <=> [@progress_model, :selection]
75
+ }
76
+
77
+ spinner {
78
+ digits 2
79
+ minimum 1
80
+ maximum 200
81
+ selection <=> [@progress_model, :delay, on_read: ->(v) {v.to_f*100.0}, on_write: ->(v) {v.to_f/100.0}]
82
+ }
83
+
84
+ progress_bar {
85
+ layout_data(:fill, :center, true, false) {
86
+ horizontal_span 4
87
+ }
88
+ minimum <= [@progress_model, :minimum]
89
+ maximum <= [@progress_model, :maximum]
90
+ selection <= [@progress_model, :selection]
91
+ }
92
+
93
+ # :vertical SWT style is unsupported for now
94
+ # progress_bar(:vertical) {
95
+ # layout_data(:fill, :center, true, false) {
96
+ # horizontal_span 4
97
+ # }
98
+ # minimum <= [@progress_model, :minimum]
99
+ # maximum <= [@progress_model, :maximum]
100
+ # selection <= [@progress_model, :selection]
101
+ # }
102
+
103
+ button {
104
+ layout_data(:fill, :center, true, false) {
105
+ horizontal_span 4
106
+ }
107
+ text "Start"
108
+
109
+ on_widget_selected do
110
+ # if a previous thread is running, then kill first
111
+ # (killing is not dangerous since it is only a thread about updating progress)
112
+ @current_thread&.kill
113
+ @current_thread = Thread.new do
114
+ @progress_model.selection = @progress_model.minimum
115
+ (@progress_model.minimum..@progress_model.maximum).to_a.each do |n|
116
+ @progress_model.selection = n
117
+ sleep(@progress_model.delay)
118
+ end
119
+ end
120
+ end
121
+ }
122
+ }
123
+ }
124
+ end
125
+
126
+ HelloProgressBar.launch
@@ -0,0 +1,86 @@
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
+ require 'glimmer/swt/widget_proxy'
23
+
24
+ module Glimmer
25
+ module SWT
26
+ class ProgressBarProxy < WidgetProxy
27
+ STYLE = <<~CSS
28
+ .ui-progressbar.vertical {
29
+ /* Not Supported */
30
+ /* transform: rotate(-90deg); */
31
+ }
32
+ CSS
33
+
34
+ attr_reader :vertical, :indeterminate, :maximum, :selection
35
+ attr_accessor :state, :minimum #ignored, only there for API compatibility
36
+ alias vertical? vertical
37
+ alias indeterminate? indeterminate
38
+
39
+ def initialize(parent, args, block)
40
+ @vertical = args.detect { |arg| SWTProxy[arg] == SWTProxy[:vertical] }
41
+ @indeterminate = args.detect { |arg| SWTProxy[arg] == SWTProxy[:indeterminate] }
42
+ super(parent, args, block)
43
+ dom_element.progressbar
44
+ self.minimum = 0
45
+ self.selection = false if indeterminate?
46
+ end
47
+
48
+ def horizontal
49
+ !vertical
50
+ end
51
+ alias horizontal? horizontal
52
+
53
+ def minimum=(value)
54
+ @minimum = value
55
+ # re-update maximum and selection since they depend on minimum
56
+ self.maximum = @maximum if @maximum
57
+ self.selection = @selection if @selection
58
+ end
59
+
60
+ def maximum=(value)
61
+ @maximum = value
62
+ dom_element.progressbar('option', 'max', @maximum - @minimum)
63
+ end
64
+
65
+ def selection=(selection_value)
66
+ @selection = selection_value
67
+ value = @selection ? (@selection - @minimum) : @selection
68
+ dom_element.progressbar('option', 'value', value)
69
+ end
70
+
71
+ def element
72
+ 'div'
73
+ end
74
+
75
+ def dom
76
+ progress_bar_id = id
77
+ progress_bar_class = name
78
+ progress_bar_class += ' vertical' if vertical?
79
+ progress_bar_class += ' indeterminate' if indeterminate?
80
+ @dom ||= html {
81
+ div(id: progress_bar_id, class: progress_bar_class)
82
+ }.to_s
83
+ end
84
+ end
85
+ end
86
+ end
@@ -1037,6 +1037,7 @@ require 'glimmer/swt/table_column_proxy'
1037
1037
  require 'glimmer/swt/table_item_proxy'
1038
1038
  require 'glimmer/swt/table_proxy'
1039
1039
  require 'glimmer/swt/text_proxy'
1040
+ require 'glimmer/swt/progress_bar_proxy'
1040
1041
  require 'glimmer/swt/radio_proxy'
1041
1042
  require 'glimmer/swt/scale_proxy'
1042
1043
  require 'glimmer/swt/scrolled_composite_proxy'
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.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: 1.3.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: 1.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: to_collection
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -309,6 +309,7 @@ files:
309
309
  - lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb
310
310
  - lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb
311
311
  - lib/glimmer-dsl-opal/samples/hello/hello_print.rb
312
+ - lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb
312
313
  - lib/glimmer-dsl-opal/samples/hello/hello_radio.rb
313
314
  - lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
314
315
  - lib/glimmer-dsl-opal/samples/hello/hello_scale.rb
@@ -422,6 +423,7 @@ files:
422
423
  - lib/glimmer/swt/menu_proxy.rb
423
424
  - lib/glimmer/swt/message_box_proxy.rb
424
425
  - lib/glimmer/swt/point.rb
426
+ - lib/glimmer/swt/progress_bar_proxy.rb
425
427
  - lib/glimmer/swt/property_owner.rb
426
428
  - lib/glimmer/swt/radio_proxy.rb
427
429
  - lib/glimmer/swt/row_layout_proxy.rb