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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3acd64cce93e2c522567f6b10967489a8edb74e19aad32d9b6aef070f8339715
4
- data.tar.gz: 78adb831387641339c046839bf8ccd034354881a1a963c0eb7084c4065167c2b
3
+ metadata.gz: d82f0649f5baefa289ee1facb6102608e4d84e5a98e84a775ab1112f1698cc3d
4
+ data.tar.gz: da29c7ccd153e217867d2dd47afc7611311d79511461bb9395529a6561551cca
5
5
  SHA512:
6
- metadata.gz: 340aa792a59e2577c818461ef4ebe88a01b06a8becf19e2f138c8895cdfa691872d227ea9c490f1bb48d14fd6edf3bb2b65aabe8f21bb0982e8fcf4bfdb2d5e1
7
- data.tar.gz: c5509de40b089c73879d46aabb4c7440698eda864acd80509e1496b7bb1ca0558b47c399c96d28b295fa9ec088dffdaf7958861f23dcb9b4b24bbb58a798561d
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.24.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))
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.3.0'
269
+ gem 'opal-async', '~> 1.4.0'
268
270
  gem 'opal-jquery', '~> 0.4.4'
269
- gem 'glimmer-dsl-opal', '~> 0.24.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.cycle { |color|
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.0
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 {
@@ -41,7 +41,7 @@ class GreetingLabel
41
41
  return if colors.nil?
42
42
 
43
43
  Thread.new {
44
- colors.cycle { |color|
44
+ colors.async_cycle { |color|
45
45
  async_exec {
46
46
  self.color = color
47
47
  }
@@ -91,14 +91,14 @@ class HelloProgressBar
91
91
  }
92
92
 
93
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
- # }
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
@@ -47,6 +47,11 @@ module Glimmer
47
47
  dom_element.html(@text)
48
48
  end
49
49
 
50
+ def font=(value)
51
+ super(value)
52
+ dom_element.css('height', @font.height + 10) if @font&.height
53
+ end
54
+
50
55
  def element
51
56
  'button'
52
57
  end
@@ -26,7 +26,7 @@ module Glimmer
26
26
  module SWT
27
27
  class CComboProxy < ComboProxy
28
28
  def post_add_content
29
- `$(#{path}).selectmenu()`
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
- Document.find(path).value = value
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)
@@ -11,8 +11,8 @@ module Glimmer
11
11
  }
12
12
 
13
13
  .fill-layout > * {
14
- width: 100%;
15
- height: 100%;
14
+ width: 100% !important;
15
+ height: 100% !important;
16
16
  }
17
17
 
18
18
  .fill-layout-horizontal {
@@ -26,8 +26,11 @@ module Glimmer
26
26
  class ProgressBarProxy < WidgetProxy
27
27
  STYLE = <<~CSS
28
28
  .ui-progressbar.vertical {
29
- /* Not Supported */
30
- /* transform: rotate(-90deg); */
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
- dom_element.progressbar
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
- dom_element.progressbar('option', 'max', @maximum - @minimum)
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
- value = @selection ? (@selection - @minimum) : @selection
68
- dom_element.progressbar('option', 'value', value)
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.0
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-18 00:00:00.000000000 Z
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.3.0
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.3.0
68
+ version: 1.4.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: to_collection
71
71
  requirement: !ruby/object:Gem::Requirement