glimmer-dsl-opal 0.25.0 → 0.25.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +10 -6
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +3 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_progress_bar.rb +8 -8
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +3 -3
- data/lib/glimmer/swt/button_proxy.rb +5 -0
- data/lib/glimmer/swt/c_combo_proxy.rb +30 -1
- data/lib/glimmer/swt/combo_proxy.rb +10 -2
- data/lib/glimmer/swt/fill_layout_proxy.rb +2 -2
- data/lib/glimmer/swt/progress_bar_proxy.rb +27 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82f0649f5baefa289ee1facb6102608e4d84e5a98e84a775ab1112f1698cc3d
|
4
|
+
data.tar.gz: da29c7ccd153e217867d2dd47afc7611311d79511461bb9395529a6561551cca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427deabace568823bb59fc9e09dbbbdc7c37c22c25dd131daa41fa61a88cc61a7cc746480d733b2862055fe798a05728ca1a809bacba839068ae346f9ce005da
|
7
|
+
data.tar.gz: bf34f31729b7c49c25442f12292042c92faf9eeb97e02582d87ad25f548a201ba574af4d00d5280166235c157509b95c2e5412a9e06f3f3924ea2738c6a3555a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.25.4
|
4
|
+
|
5
|
+
- Upgrade to opal-async 1.4.0
|
6
|
+
- Update Hello, Custom Widget! to utilize `Array#async_cycle` instead of `Array#cycle`
|
7
|
+
|
8
|
+
## 0.25.3
|
9
|
+
|
10
|
+
- Fix `c_combo`'s data-binding of selection receiving model changes
|
11
|
+
- Fix Hello, C Combo!'s reset button
|
12
|
+
- Fix Login sample by removing unnecessary require statement at the top
|
13
|
+
|
14
|
+
## 0.25.2
|
15
|
+
|
16
|
+
- Fix sizing of buttons with font height specified to fit text
|
17
|
+
|
18
|
+
## 0.25.1
|
19
|
+
|
20
|
+
- Support `progress_bar` `:vertical` SWT style
|
21
|
+
- Add `progress_bar` `:vertical` SWT style to Hello, Progress Bar!
|
22
|
+
|
3
23
|
## 0.25.0
|
4
24
|
|
5
25
|
- Support `progress_bar` widget without `:vertical` SWT style support
|
data/README.md
CHANGED
@@ -12,6 +12,8 @@ Use in one of two ways:
|
|
12
12
|
|
13
13
|
Glimmer DSL for Opal successfully reuses the entire [Glimmer](https://github.com/AndyObtiva/glimmer) core DSL engine in [Opal Ruby](https://opalrb.com/) inside a web browser, and as such inherits the full range of Glimmer desktop [data-binding](https://github.com/AndyObtiva/glimmer#data-binding) capabilities for the web (including Shine syntax using `<=>` and `<=` for bidirectional [two-way] and unidirectional [one-way] data-binding respectively).
|
14
14
|
|
15
|
+
(note that auto-webification of desktop apps that involve multiple threads might involve extra changes to the code to utilize web async calls due to the async nature of transpiled JavaScript code)
|
16
|
+
|
15
17
|
#### Hello, Table! Sample
|
16
18
|
|
17
19
|
Code: [lib/glimmer-dsl-opal/samples/hello/hello_table.rb](lib/glimmer-dsl-opal/samples/hello/hello_table.rb)
|
@@ -143,7 +145,7 @@ Hello, Table! Game Booked
|
|
143
145
|
|
144
146
|
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
147
|
|
146
|
-
**Alpha Version** 0.
|
148
|
+
**Alpha Version** 0.25.4 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
149
|
|
148
150
|
Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
|
149
151
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
@@ -232,7 +234,7 @@ Alternatively, web developers may directly use [Glimmer DSL for Opal](https://ru
|
|
232
234
|
|
233
235
|
## Pre-requisites
|
234
236
|
|
235
|
-
- Rails 5: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
|
237
|
+
- Rails 5.2: [https://github.com/rails/rails/tree/5-2-stable](https://github.com/rails/rails/tree/5-2-stable)
|
236
238
|
- Opal 1.0.4: [https://github.com/opal/opal](https://github.com/opal/opal)
|
237
239
|
- Opal-Rails 1.1.2: [https://github.com/opal/opal-rails](https://github.com/opal/opal-rails)
|
238
240
|
- jQuery 3: [https://code.jquery.com/](https://code.jquery.com/) (jQuery 3.5.1 is included in the [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem)
|
@@ -264,9 +266,9 @@ Add the following to `Gemfile`:
|
|
264
266
|
```
|
265
267
|
gem 'opal', '1.0.4'
|
266
268
|
gem 'opal-rails', '1.1.2'
|
267
|
-
gem 'opal-async', '~> 1.
|
269
|
+
gem 'opal-async', '~> 1.4.0'
|
268
270
|
gem 'opal-jquery', '~> 0.4.4'
|
269
|
-
gem 'glimmer-dsl-opal', '~> 0.
|
271
|
+
gem 'glimmer-dsl-opal', '~> 0.25.4'
|
270
272
|
gem 'glimmer-dsl-xml', '~> 1.2.0', require: false
|
271
273
|
gem 'glimmer-dsl-css', '~> 1.2.0', require: false
|
272
274
|
|
@@ -1035,7 +1037,7 @@ Add the following require statement to `app/assets/javascripts/application.rb`
|
|
1035
1037
|
require 'glimmer-dsl-opal/samples/hello/hello_custom_widget'
|
1036
1038
|
```
|
1037
1039
|
|
1038
|
-
Or add the Glimmer code directly if you prefer to play around with it:
|
1040
|
+
Or add the Glimmer code directly if you prefer to play around with it (note that the Opal version needs `Array#async_cycle` from the opal-async gem instead of `Array#cycle` due to the async nature of JavaScript):
|
1039
1041
|
|
1040
1042
|
```ruby
|
1041
1043
|
# This class declares a `greeting_label` custom widget (by convention)
|
@@ -1060,7 +1062,7 @@ class GreetingLabel
|
|
1060
1062
|
return if colors.nil?
|
1061
1063
|
|
1062
1064
|
Thread.new { # imported from Glimmer DSL for SWT. In Opal, avoid Threads and sleep to avoid blocking GUI.
|
1063
|
-
colors.
|
1065
|
+
colors.async_cycle { |color|
|
1064
1066
|
async_exec {
|
1065
1067
|
self.color = color
|
1066
1068
|
}
|
@@ -1881,6 +1883,8 @@ Visit `http://localhost:3000`
|
|
1881
1883
|
|
1882
1884
|
You should see "Hello, Progress Bar!"
|
1883
1885
|
|
1886
|
+
![Glimmer DSL for Opal Hello Progress Bar](https://github.com/AndyObtiva/glimmer-dsl-opal/raw/master/images/glimmer-dsl-opal-hello-progress-bar.gif)
|
1887
|
+
|
1884
1888
|
#### Hello, Pop Up Context Menu!
|
1885
1889
|
|
1886
1890
|
Add the following require statement to `app/assets/javascripts/application.rb`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.25.
|
1
|
+
0.25.4
|
@@ -19,8 +19,6 @@
|
|
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-dsl-swt'
|
23
|
-
|
24
22
|
class LoginPresenter
|
25
23
|
|
26
24
|
attr_accessor :user_name
|
@@ -64,10 +62,10 @@ end
|
|
64
62
|
|
65
63
|
class Login
|
66
64
|
include Glimmer::UI::CustomShell
|
67
|
-
|
68
|
-
before_body
|
65
|
+
|
66
|
+
before_body do
|
69
67
|
@presenter = LoginPresenter.new
|
70
|
-
|
68
|
+
end
|
71
69
|
|
72
70
|
body {
|
73
71
|
shell {
|
@@ -91,14 +91,14 @@ class HelloProgressBar
|
|
91
91
|
}
|
92
92
|
|
93
93
|
# :vertical SWT style is unsupported for now
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
102
|
|
103
103
|
button {
|
104
104
|
layout_data(:fill, :center, true, false) {
|
@@ -6,17 +6,17 @@ require 'glimmer/swt/combo_proxy'
|
|
6
6
|
module Glimmer
|
7
7
|
module DSL
|
8
8
|
module Opal
|
9
|
-
class ComboSelectionDataBindingExpression < Expression
|
9
|
+
class ComboSelectionDataBindingExpression < Expression
|
10
10
|
def can_interpret?(parent, keyword, *args, &block)
|
11
11
|
keyword == 'selection' and
|
12
12
|
block.nil? and
|
13
|
-
parent.is_a?(Glimmer::SWT::ComboProxy) and
|
13
|
+
(parent.is_a?(Glimmer::SWT::ComboProxy) || parent.is_a?(Glimmer::SWT::CComboProxy)) and
|
14
14
|
args.size == 1 and
|
15
15
|
args[0].is_a?(DataBinding::ModelBinding) and
|
16
16
|
args[0].evaluate_options_property.is_a?(Array)
|
17
17
|
end
|
18
18
|
|
19
|
-
def interpret(parent, keyword, *args, &block)
|
19
|
+
def interpret(parent, keyword, *args, &block)
|
20
20
|
model_binding = args[0]
|
21
21
|
|
22
22
|
#TODO make this options observer dependent and all similar observers in element specific data binding handlers
|
@@ -26,7 +26,7 @@ module Glimmer
|
|
26
26
|
module SWT
|
27
27
|
class CComboProxy < ComboProxy
|
28
28
|
def post_add_content
|
29
|
-
|
29
|
+
dom_element.selectmenu
|
30
30
|
c_combo_dom_element.css('width', 'initial')
|
31
31
|
end
|
32
32
|
|
@@ -38,6 +38,11 @@ module Glimmer
|
|
38
38
|
c_combo_dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
|
39
39
|
end
|
40
40
|
|
41
|
+
def text=(value)
|
42
|
+
super(value)
|
43
|
+
c_combo_text_element.text(value)
|
44
|
+
end
|
45
|
+
|
41
46
|
def c_combo_path
|
42
47
|
"##{id}-button"
|
43
48
|
end
|
@@ -45,6 +50,30 @@ module Glimmer
|
|
45
50
|
def c_combo_dom_element
|
46
51
|
Document.find(c_combo_path)
|
47
52
|
end
|
53
|
+
|
54
|
+
def c_combo_text_path
|
55
|
+
c_combo_path + ' .ui-selectmenu-text'
|
56
|
+
end
|
57
|
+
|
58
|
+
def c_combo_text_element
|
59
|
+
Document.find(c_combo_text_path)
|
60
|
+
end
|
61
|
+
|
62
|
+
def observation_request_to_event_mapping
|
63
|
+
super.merge(
|
64
|
+
'on_widget_selected' => [
|
65
|
+
{
|
66
|
+
event: 'selectmenuchange',
|
67
|
+
event_handler: -> (event_listener) {
|
68
|
+
-> (event) {
|
69
|
+
self.text = event.target.value
|
70
|
+
event_listener.call(event)
|
71
|
+
}
|
72
|
+
}
|
73
|
+
},
|
74
|
+
],
|
75
|
+
)
|
76
|
+
end
|
48
77
|
end
|
49
78
|
end
|
50
79
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
require 'glimmer/data_binding/observable_element'
|
2
3
|
require 'glimmer/swt/widget_proxy'
|
3
4
|
|
@@ -6,7 +7,6 @@ module Glimmer
|
|
6
7
|
class ComboProxy < WidgetProxy
|
7
8
|
include Glimmer::DataBinding::ObservableElement
|
8
9
|
attr_reader :text, :items
|
9
|
-
attr_accessor :selection # virtual attribute just to pass the shine data-binding test (TODO THINK OF A BETTER WAY OF HANDLING THIS)
|
10
10
|
|
11
11
|
def initialize(parent, args, block)
|
12
12
|
super(parent, args, block)
|
@@ -19,7 +19,15 @@ module Glimmer
|
|
19
19
|
|
20
20
|
def text=(value)
|
21
21
|
@text = value
|
22
|
-
|
22
|
+
dom_element.val(value)
|
23
|
+
end
|
24
|
+
|
25
|
+
def selection
|
26
|
+
text
|
27
|
+
end
|
28
|
+
|
29
|
+
def selection=(value)
|
30
|
+
self.text = value
|
23
31
|
end
|
24
32
|
|
25
33
|
def items=(the_items)
|
@@ -26,8 +26,11 @@ module Glimmer
|
|
26
26
|
class ProgressBarProxy < WidgetProxy
|
27
27
|
STYLE = <<~CSS
|
28
28
|
.ui-progressbar.vertical {
|
29
|
-
|
30
|
-
|
29
|
+
transform: rotate(-180deg);
|
30
|
+
height: 140px;
|
31
|
+
width: 28px;
|
32
|
+
margin-left: auto;
|
33
|
+
margin-right: auto;
|
31
34
|
}
|
32
35
|
CSS
|
33
36
|
|
@@ -40,7 +43,8 @@ module Glimmer
|
|
40
43
|
@vertical = args.detect { |arg| SWTProxy[arg] == SWTProxy[:vertical] }
|
41
44
|
@indeterminate = args.detect { |arg| SWTProxy[arg] == SWTProxy[:indeterminate] }
|
42
45
|
super(parent, args, block)
|
43
|
-
|
46
|
+
# initialize manually if vertical
|
47
|
+
dom_element.progressbar if horizontal?
|
44
48
|
self.minimum = 0
|
45
49
|
self.selection = false if indeterminate?
|
46
50
|
end
|
@@ -59,26 +63,41 @@ module Glimmer
|
|
59
63
|
|
60
64
|
def maximum=(value)
|
61
65
|
@maximum = value
|
62
|
-
|
66
|
+
if horizontal?
|
67
|
+
dom_element.progressbar('option', 'max', @maximum - @minimum)
|
68
|
+
end
|
63
69
|
end
|
64
70
|
|
65
71
|
def selection=(selection_value)
|
66
72
|
@selection = selection_value
|
67
|
-
|
68
|
-
|
73
|
+
if horizontal?
|
74
|
+
value = @selection ? (@selection - @minimum) : @selection
|
75
|
+
dom_element.progressbar('option', 'value', value)
|
76
|
+
else
|
77
|
+
value = ((@selection - @minimum) / (@maximum - @minimum)) * 100
|
78
|
+
selection_dom_element.css('height', "#{value}%")
|
79
|
+
end
|
69
80
|
end
|
70
81
|
|
71
82
|
def element
|
72
83
|
'div'
|
73
84
|
end
|
74
85
|
|
86
|
+
def selection_dom_element
|
87
|
+
dom_element.find('.ui-progressbar-value')
|
88
|
+
end
|
89
|
+
|
75
90
|
def dom
|
76
91
|
progress_bar_id = id
|
77
92
|
progress_bar_class = name
|
78
|
-
progress_bar_class += ' vertical' if vertical?
|
93
|
+
progress_bar_class += ' vertical ui-progressbar ui-corner-all ui-widget ui-widget-content' if vertical?
|
79
94
|
progress_bar_class += ' indeterminate' if indeterminate?
|
80
95
|
@dom ||= html {
|
81
|
-
div(id: progress_bar_id, class: progress_bar_class)
|
96
|
+
div(id: progress_bar_id, class: progress_bar_class) {
|
97
|
+
if vertical?
|
98
|
+
div(class: 'ui-progressbar-value ui-corner-left ui-widget-header', style: 'height: 0%;')
|
99
|
+
end
|
100
|
+
}
|
82
101
|
}.to_s
|
83
102
|
end
|
84
103
|
end
|
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.25.
|
4
|
+
version: 0.25.4
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.4.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.
|
68
|
+
version: 1.4.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: to_collection
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|