glimmer-dsl-opal 0.6.0 → 0.6.1

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: c73ae51d66f5e2955bd4c4c8b639d6081a8445594699d4a2f2b71244903d3277
4
- data.tar.gz: bff8c03439d137acd926baece557b609e0805adbf28b822984cd70f7b63666fc
3
+ metadata.gz: 2989fcd48ddac2b782271cebca14b5a7615926251c14f2aef3fe878d177f7e41
4
+ data.tar.gz: 7001fa83285f8e16bf5ba5a86004963324f271a5a795c6c45b0aa71c5fd53a3c
5
5
  SHA512:
6
- metadata.gz: 1bfba5a1bc6d5f6267e0622d3376d1567c40b5c06a7fcb49a8e7f3c5845a8b66214eaa897b2ebf9a8cb68d2a5cfbf5a83d3c4870250e6d9d901c39bbe9bf7d59
7
- data.tar.gz: 285627b7e3d843d9c3f54ef169d96463e4abe3047580a92eacb314d0b302675e9b5799b92e2be02c73f8af039743f35610b4d25ce84cabf4c60d826c797dd150
6
+ metadata.gz: e24b36f65ca89e2e4880b81ae6ac6fba81c4a1ae2c832a87e43a6401ee6f90b2014a223cac2c218374dc895cfece65c5c145ed9a637256310f1b3a7fac9e3e2b
7
+ data.tar.gz: d0f249102835911d3eb48f15ac87303376c935b54f17dd4f94ff5ab4db0d8ac6f780ea49ed8cd3c98e52d11c5dbad6975f34635f33f9064f26adca1dee47166e
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.6.1
4
+
5
+ - Fix issue with rendering date_time without a block
6
+ - Made listener event handling async to improve performance when triggering multiple events
7
+ - Brought Tic Tac Toe sample up-to-date with changes in Glimmer DSL for SWT
8
+ - Fixed silent error encountered in rendering custom widgets
9
+
3
10
  ## 0.6.0
4
11
 
5
12
  - Hello, Date Time! Sample
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.6.0 (Auto-Webify Desktop Apps)
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 (Auto-Webify Desktop Apps)
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
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  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 powerful Glimmer desktop [data-binding](https://github.com/AndyObtiva/glimmer#data-binding) capabilities for the web.
10
10
 
11
- NOTE: Alpha Version 0.6.0 only supports bare-minimum capabilities for the following [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) [samples](https://github.com/AndyObtiva/glimmer#samples):
11
+ NOTE: Alpha Version 0.6.1 only supports bare-minimum capabilities for the following [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) [samples](https://github.com/AndyObtiva/glimmer#samples):
12
12
 
13
13
  Hello:
14
14
 
@@ -102,9 +102,13 @@ Event loop:
102
102
 
103
103
  ## Setup
104
104
 
105
- (NOTE: if you run into issues, keep in mind this is a very early experimental and incomplete alpha. Also, there is a slight chance issues you encounter are fixed in master or some other branch that you could check out instead)
105
+ (NOTE: if you run into issues, keep in mind this is a very early experimental and incomplete alpha. Also, there is a slight chance any issues you encounter are fixed in master or some other branch that you could check out instead)
106
106
 
107
- Please install a Rails 5 gem:
107
+ The [glimmer-dsl-opal](https://rubygems.org/gems/glimmer-dsl-opal) gem is a Rails Engine gem that includes assets.
108
+
109
+ Please follow the following steps to setup.
110
+
111
+ Install a Rails 5 gem:
108
112
 
109
113
  ```
110
114
  gem install rails -v5.2.4.4
@@ -122,7 +126,7 @@ Add the following to `Gemfile`:
122
126
  gem 'opal-rails', '~> 1.1.2'
123
127
  gem 'opal-async', '~> 1.2.0'
124
128
  gem 'opal-jquery', '~> 0.4.4'
125
- gem 'glimmer-dsl-opal', '~> 0.6.0'
129
+ gem 'glimmer-dsl-opal', '~> 0.6.1'
126
130
  gem 'glimmer-dsl-xml', '~> 1.1.0', require: false
127
131
  gem 'glimmer-dsl-css', '~> 1.1.0', require: false
128
132
 
@@ -156,7 +160,7 @@ require 'glimmer-dsl-opal' # brings opal and other dependencies automatically
156
160
  Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
157
161
 
158
162
  ```erb
159
- <%= stylesheet_link_tag 'glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
163
+ <%= stylesheet_link_tag 'glimmer/glimmer', media: 'all', 'data-turbolinks-track': 'reload' %>
160
164
  ```
161
165
 
162
166
  Open a `Document.ready?` block and add inside it Glimmer GUI DSL code or a require statement for one of the samples below.
@@ -1769,6 +1773,7 @@ class TicTacToe
1769
1773
  @tic_tac_toe_board = Board.new
1770
1774
  @shell = shell {
1771
1775
  text "Tic-Tac-Toe"
1776
+ minimum_size 150, 178
1772
1777
  composite {
1773
1778
  grid_layout 3, true
1774
1779
  (1..3).each { |row|
@@ -1777,6 +1782,7 @@ class TicTacToe
1777
1782
  layout_data :fill, :fill, true, true
1778
1783
  text bind(@tic_tac_toe_board[row, column], :sign)
1779
1784
  enabled bind(@tic_tac_toe_board[row, column], :empty)
1785
+ font style: :bold, height: 20
1780
1786
  on_widget_selected {
1781
1787
  @tic_tac_toe_board.mark(row, column)
1782
1788
  }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -10,6 +10,6 @@
10
10
  * files in this directory. Styles in this file should be added after the last require_* statement.
11
11
  * It is generally better to create a new file per style scope.
12
12
  *
13
- *= require_tree ./glimmer
13
+ *= require_tree .
14
14
  *= require_self
15
15
  */
@@ -5,7 +5,7 @@ GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
5
5
 
6
6
  $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
7
7
 
8
- if RUBY_PLATFORM == 'opal'
8
+ if RUBY_ENGINE == 'opal'
9
9
  # GLIMMER_DSL_OPAL_MISSING = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
10
10
 
11
11
  # $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_MISSING) # missing Ruby classes/methods
@@ -56,5 +56,5 @@ if RUBY_PLATFORM == 'opal'
56
56
  result ||= method == 'handle'
57
57
  end
58
58
  else
59
- require "glimmer/engine"
59
+ require_relative 'glimmer/engine'
60
60
  end
@@ -1,3 +1,24 @@
1
+ # Copyright (c) 2007-2020 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
+
1
22
  require_relative "tic_tac_toe/board"
2
23
 
3
24
  class TicTacToe
@@ -7,6 +28,7 @@ class TicTacToe
7
28
  @tic_tac_toe_board = Board.new
8
29
  @shell = shell {
9
30
  text "Tic-Tac-Toe"
31
+ minimum_size 150, 178
10
32
  composite {
11
33
  grid_layout 3, true
12
34
  (1..3).each { |row|
@@ -15,6 +37,7 @@ class TicTacToe
15
37
  layout_data :fill, :fill, true, true
16
38
  text bind(@tic_tac_toe_board[row, column], :sign)
17
39
  enabled bind(@tic_tac_toe_board[row, column], :empty)
40
+ font style: :bold, height: 20
18
41
  on_widget_selected {
19
42
  @tic_tac_toe_board.mark(row, column)
20
43
  }
@@ -44,7 +44,7 @@ module Glimmer
44
44
  def interpret(parent, keyword, *args, &block)
45
45
  custom_widget_class = UI::CustomWidget.for(keyword)
46
46
  # TODO clean code by extracting methods into CustomShell
47
- if !Glimmer::UI::CustomShell.requested? && custom_widget_class.ancestors.include?(Glimmer::UI::CustomShell)
47
+ if !Glimmer::UI::CustomShell.requested? && custom_widget_class&.ancestors&.to_a.include?(Glimmer::UI::CustomShell)
48
48
  if Glimmer::SWT::DisplayProxy.instance.shells.empty?
49
49
  custom_widget_class.new(parent, *args, {}, &block)
50
50
  else
@@ -16,7 +16,7 @@ module Glimmer
16
16
  end
17
17
 
18
18
  def interpret(parent, keyword, *args, &block)
19
- Glimmer::SWT::WidgetProxy.for(keyword, parent, args)
19
+ Glimmer::SWT::WidgetProxy.for(keyword, parent, args, block)
20
20
  end
21
21
 
22
22
  def add_content(parent, &block)
@@ -3,7 +3,7 @@ module Glimmer
3
3
  isolate_namespace Glimmer
4
4
 
5
5
  initializer "glimmer.assets.precompile" do |app|
6
- app.config.assets.precompile += %w( glimmer.css jquery-ui.css jquery-ui.structure.css jquery-ui.theme.css jquery.ui.timepicker.css )
6
+ app.config.assets.precompile += %w( glimmer/glimmer.css )
7
7
  end
8
8
  end
9
9
  end
@@ -6,13 +6,13 @@ module Glimmer
6
6
  module SWT
7
7
  class ButtonProxy < WidgetProxy
8
8
  class << self
9
- def create(keyword, parent, args)
9
+ def create(keyword, parent, args, block)
10
10
  if args.to_a.include?(:radio)
11
- RadioProxy.new(parent, args)
11
+ RadioProxy.new(parent, args, block)
12
12
  elsif args.to_a.include?(:check)
13
- CheckboxProxy.new(parent, args)
13
+ CheckboxProxy.new(parent, args, block)
14
14
  else
15
- new(parent, args)
15
+ new(parent, args, block)
16
16
  end
17
17
  end
18
18
  end
@@ -44,7 +44,7 @@ module Glimmer
44
44
  input_disabled = @enabled ? {} : {'disabled': 'disabled'}
45
45
  input_args = input_args.merge(type: 'password') if has_style?(:password)
46
46
  @dom ||= html {
47
- button(input_args.merge(id: input_id, class: name, style: input_style, style: 'min-width: 27px; min-height: 27px;').merge(input_disabled)) {
47
+ button(input_args.merge(id: input_id, class: name, style: input_style, style: 'min-width: 32px; min-height: 32px;').merge(input_disabled)) {
48
48
  input_text.to_s == '' ? '&nbsp;' : input_text
49
49
  }
50
50
  }.to_s
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -28,44 +28,44 @@ module Glimmer
28
28
  # Follows the Proxy Design Pattern
29
29
  class ColorProxy
30
30
  SWT_COLOR_TRANSLATION = {
31
- "widget_foreground" => [0, 0, 0],
32
- "blue" => [0, 0, 255],
33
- "widget_dark_shadow" => [0, 0, 0],
34
- "title_foreground" => [0, 0, 0],
35
- "yellow" => [255, 255, 0],
36
- "widget_highlight_shadow" => [255, 255, 255],
37
- "dark_cyan" => [0, 128, 128],
38
- "list_foreground" => [0, 0, 0],
39
- "dark_blue" => [0, 0, 128],
40
- "dark_yellow" => [128, 128, 0],
41
- "cyan" => [0, 255, 255],
42
- "info_background" => [236, 235, 236],
43
- "link_foreground" => [0, 104, 218],
44
- "title_inactive_foreground" => [0, 0, 0],
45
- "title_background_gradient" => [179, 215, 255],
46
- "red" => [255, 0, 0],
47
- "title_inactive_background_gradient" => [220, 220, 220],
48
- "transparent" => [255, 255, 255],
49
- "widget_light_shadow" => [232, 232, 232],
50
- "dark_magenta" => [128, 0, 128],
51
- "white" => [255, 255, 255],
52
- "list_selection" => [179, 215, 255],
53
- "gray" => [192, 192, 192],
54
- "widget_border" => [0, 0, 0],
55
- "widget_background" => [236, 236, 236],
56
- "info_foreground" => [0, 0, 0],
57
- "title_inactive_background" => [220, 220, 220],
58
- "widget_disabled_foreground" => [220, 220, 220],
59
- "list_background" => [255, 255, 255],
60
- "magenta" => [255, 0, 255],
61
- "title_background" => [0, 99, 225],
62
- "text_disabled_background" => [255, 255, 255],
63
- "black" => [0, 0, 0],
64
- "dark_gray" => [128, 128, 128],
65
- "list_selection_text" => [0, 0, 0],
66
- "dark_red" => [128, 0, 0],
67
- "widget_normal_shadow" => [159, 159, 159],
68
- "dark_green" => [0, 128, 0],
31
+ "widget_foreground" => [0, 0, 0],
32
+ "blue" => [0, 0, 255],
33
+ "widget_dark_shadow" => [0, 0, 0],
34
+ "title_foreground" => [0, 0, 0],
35
+ "yellow" => [255, 255, 0],
36
+ "widget_highlight_shadow" => [255, 255, 255],
37
+ "dark_cyan" => [0, 128, 128],
38
+ "list_foreground" => [0, 0, 0],
39
+ "dark_blue" => [0, 0, 128],
40
+ "dark_yellow" => [128, 128, 0],
41
+ "cyan" => [0, 255, 255],
42
+ "info_background" => [236, 235, 236],
43
+ "link_foreground" => [0, 104, 218],
44
+ "title_inactive_foreground" => [0, 0, 0],
45
+ "title_background_gradient" => [179, 215, 255],
46
+ "red" => [255, 0, 0],
47
+ "title_inactive_background_gradient" => [220, 220, 220],
48
+ "transparent" => [255, 255, 255],
49
+ "widget_light_shadow" => [232, 232, 232],
50
+ "dark_magenta" => [128, 0, 128],
51
+ "white" => [255, 255, 255],
52
+ "list_selection" => [179, 215, 255],
53
+ "gray" => [192, 192, 192],
54
+ "widget_border" => [0, 0, 0],
55
+ "widget_background" => [236, 236, 236],
56
+ "info_foreground" => [0, 0, 0],
57
+ "title_inactive_background" => [220, 220, 220],
58
+ "widget_disabled_foreground" => [220, 220, 220],
59
+ "list_background" => [255, 255, 255],
60
+ "magenta" => [255, 0, 255],
61
+ "title_background" => [0, 99, 225],
62
+ "text_disabled_background" => [255, 255, 255],
63
+ "black" => [0, 0, 0],
64
+ "dark_gray" => [128, 128, 128],
65
+ "list_selection_text" => [0, 0, 0],
66
+ "dark_red" => [128, 0, 0],
67
+ "widget_normal_shadow" => [159, 159, 159],
68
+ "dark_green" => [0, 128, 0],
69
69
  "green" => [0, 255, 0]
70
70
  }
71
71
 
@@ -87,19 +87,19 @@ module Glimmer
87
87
  # rgba is 4 arguments representing Red, Green, Blue, and Alpha numeric values
88
88
  #
89
89
  def initialize(*args)
90
- @args = args
90
+ @args = args
91
91
  case @args.size
92
92
  when 1
93
93
  @alpha = nil
94
- if @args.first.is_a?(String) || @args.first.is_a?(Symbol)
95
- standard_color = @args.first.to_s.downcase.sub('COLOR_', '')
94
+ if @args.first.is_a?(String) || @args.first.is_a?(Symbol)
95
+ standard_color = @args.first.to_s.downcase.sub('COLOR_', '')
96
96
  @red, @green, @blue = SWT_COLOR_TRANSLATION[standard_color]
97
97
  else
98
98
  @red, @green, @blue = [0, 0, 0]
99
99
  end
100
100
  when 3..4
101
101
  @red, @green, @blue, @alpha = @args
102
- end
102
+ end
103
103
  end
104
104
 
105
105
  def to_css
@@ -7,8 +7,8 @@ module Glimmer
7
7
  include Glimmer::DataBinding::ObservableElement
8
8
  attr_reader :text, :items
9
9
 
10
- def initialize(parent, args)
11
- super(parent, args)
10
+ def initialize(parent, args, block)
11
+ super(parent, args, block)
12
12
  @items = []
13
13
  end
14
14
 
@@ -6,8 +6,8 @@ module Glimmer
6
6
  class CompositeProxy < WidgetProxy
7
7
  attr_reader :layout
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  @layout = GridLayoutProxy.new(self, [])
12
12
  end
13
13
 
@@ -4,7 +4,7 @@ module Glimmer
4
4
  module SWT
5
5
  class DateTimeProxy < WidgetProxy
6
6
  class << self
7
- def create(keyword, parent, args)
7
+ def create(keyword, parent, args, block)
8
8
  case keyword
9
9
  when 'date'
10
10
  args += [:date]
@@ -15,12 +15,13 @@ module Glimmer
15
15
  when 'calendar'
16
16
  args += [:calendar]
17
17
  end
18
- new(parent, args)
18
+ new(parent, args, block)
19
19
  end
20
20
  end
21
21
 
22
- def initialize(parent, args)
23
- super(parent, args)
22
+ def initialize(parent, args, block)
23
+ super(parent, args, block)
24
+ post_add_content if block.nil?
24
25
  end
25
26
 
26
27
  def post_add_content
@@ -66,10 +66,10 @@ module Glimmer
66
66
  event_listener.call(event) if event.key_code != 13 && (event.key_code == 127 || event.key_code <= 31)
67
67
  }
68
68
  }
69
- }
69
+ }
70
70
  ]
71
71
  }
72
- end
72
+ end
73
73
 
74
74
  def shells
75
75
  @shells ||= []
@@ -68,7 +68,7 @@ module Glimmer
68
68
  elsif vertical?
69
69
  margin_bottom "#{@spacing}px"
70
70
  end
71
- }
71
+ }
72
72
  s("##{@parent.id} > :last-child") {
73
73
  if horizontal?
74
74
  margin_right 0
@@ -6,8 +6,8 @@ module Glimmer
6
6
  class LabelProxy < WidgetProxy
7
7
  attr_reader :text, :background_image, :image, :alignment
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  self.alignment = [:left, :center, :right].detect {|align| args.detect { |arg| SWTProxy[align] == arg } }
12
12
  end
13
13
 
@@ -4,14 +4,14 @@ module Glimmer
4
4
  module SWT
5
5
  class LayoutDataProxy
6
6
  include Glimmer::SWT::PropertyOwner
7
- attr_reader :parent,
8
- :args,
9
- :horizontal_alignment,
10
- :vertical_alignment,
11
- :horizontal_span,
12
- :vertical_span,
13
- :horizontal_indent,
14
- :vertical_indent,
7
+ attr_reader :parent,
8
+ :args,
9
+ :horizontal_alignment,
10
+ :vertical_alignment,
11
+ :horizontal_span,
12
+ :vertical_span,
13
+ :horizontal_indent,
14
+ :vertical_indent,
15
15
  :grab_excess_horizontal_space,
16
16
  :grab_excess_vertical_space,
17
17
  :width_hint,
@@ -25,21 +25,21 @@ module Glimmer
25
25
  def layout_exists?(keyword)
26
26
  !!layout_class(keyword)
27
27
  end
28
- end
28
+ end
29
29
 
30
30
  attr_reader :parent, :args
31
31
 
32
- def initialize(parent, args)
32
+ def initialize(parent, args)
33
33
  @parent = parent
34
34
  @parent = parent.body_root if @parent.is_a?(Glimmer::UI::CustomWidget)
35
35
  @parent.css_classes.each do |css_class|
36
36
  @parent.remove_css_class(css_class) if css_class.include?('layout')
37
37
  end
38
- @args = args
38
+ @args = args
39
39
  @parent.add_css_class(css_class)
40
40
  @parent.layout = self
41
41
  self.margin_width = 15 if respond_to?(:margin_width=)
42
- self.margin_height = 15 if respond_to?(:margin_height=)
42
+ self.margin_height = 15 if respond_to?(:margin_height=)
43
43
  end
44
44
 
45
45
  def css_class
@@ -6,8 +6,8 @@ module Glimmer
6
6
  ITEM_EMPTY = '_____'
7
7
  attr_reader :items, :selection
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  @selection = []
12
12
  end
13
13
 
@@ -5,10 +5,11 @@ module Glimmer
5
5
  class MessageBoxProxy < WidgetProxy
6
6
  attr_reader :text, :message
7
7
 
8
- def initialize(parent, args)
8
+ def initialize(parent, args, block)
9
9
  i = 0
10
10
  @parent = parent
11
11
  @args = args
12
+ @block = block
12
13
  @children = Set.new
13
14
  @enabled = true
14
15
  content do
@@ -5,8 +5,8 @@ module Glimmer
5
5
  class TabFolderProxy < WidgetProxy
6
6
  attr_reader :tabs
7
7
 
8
- def initialize(parent, args)
9
- super(parent, args)
8
+ def initialize(parent, args, block)
9
+ super(parent, args, block)
10
10
  @tabs = []
11
11
  end
12
12
 
@@ -4,10 +4,10 @@ module Glimmer
4
4
  module SWT
5
5
  class TabItemProxy < CompositeProxy
6
6
  include Glimmer
7
- attr_reader :text, :content_visible
7
+ attr_reader :text, :content_visible
8
8
 
9
- def initialize(parent, args)
10
- super(parent, args)
9
+ def initialize(parent, args, block)
10
+ super(parent, args, block)
11
11
  content {
12
12
  on_widget_selected {
13
13
  @parent.hide_all_tab_content
@@ -35,7 +35,7 @@ module Glimmer
35
35
 
36
36
  def selector
37
37
  super + '-tab'
38
- end
38
+ end
39
39
 
40
40
  def observation_request_to_event_mapping
41
41
  {
@@ -47,7 +47,7 @@ module Glimmer
47
47
 
48
48
  def listener_path
49
49
  tab_path
50
- end
50
+ end
51
51
 
52
52
  def tab_path
53
53
  "#{parent.tabs_path} > ##{tab_id}"
@@ -72,13 +72,13 @@ module Glimmer
72
72
 
73
73
  # This contains the tab content
74
74
  def dom
75
- tab_item_id = id
75
+ tab_item_id = id
76
76
  tab_item_class_string = [name, 'hide'].join(' ')
77
77
  @dom ||= html {
78
78
  div(id: tab_item_id, class: tab_item_class_string) {
79
79
  }
80
80
  }.to_s
81
- end
81
+ end
82
82
  end
83
83
  end
84
84
  end
@@ -5,8 +5,8 @@ module Glimmer
5
5
  class TableItemProxy < WidgetProxy
6
6
  attr_reader :data
7
7
 
8
- def initialize(parent, args)
9
- super(parent, args)
8
+ def initialize(parent, args, block)
9
+ super(parent, args, block)
10
10
  on_widget_selected { |event|
11
11
  parent.select(parent.index_of(self), event.meta?)
12
12
  }
@@ -70,11 +70,11 @@ module Glimmer
70
70
  redraw
71
71
  end
72
72
  end
73
- table_item_edit_cancel_handler = lambda do |event|
73
+ table_item_edit_cancel_handler = lambda do |event|
74
74
  Async::Task.new do
75
75
  table_item_edit_handler.call(event, true)
76
76
  end
77
- end
77
+ end
78
78
  table_item_edit_key_handler = lambda do |event|
79
79
  Async::Task.new do
80
80
  if event.key_code == 13
@@ -91,7 +91,7 @@ module Glimmer
91
91
  Async::Task.new do
92
92
  table_item_input.focus
93
93
  table_item_input.on('keyup', &table_item_edit_key_handler)
94
- table_item_input.on('focusout', &table_item_edit_cancel_handler)
94
+ table_item_input.on('focusout', &table_item_edit_cancel_handler)
95
95
  end
96
96
  end
97
97
  end
@@ -132,7 +132,7 @@ module Glimmer
132
132
  tr(id: table_item_id, style: table_item_id_style, class: table_item_css_classes.to_a.join(' ')) {
133
133
  table_item_text_array.each_with_index do |table_item_text, column_index|
134
134
  td('data-column-index' => column_index) {
135
- if @edit_column_index == column_index
135
+ if @edit_column_index == column_index
136
136
  input(type: 'text', value: table_item_text, style: "max-width: #{table_item_max_width - 11}px;")
137
137
  else
138
138
  table_item_text
@@ -8,8 +8,8 @@ module Glimmer
8
8
  attr_accessor :column_properties
9
9
  alias items children
10
10
 
11
- def initialize(parent, args)
12
- super(parent, args)
11
+ def initialize(parent, args, block)
12
+ super(parent, args, block)
13
13
  @columns = []
14
14
  @children = []
15
15
  @selection = []
@@ -33,9 +33,9 @@ module Glimmer
33
33
 
34
34
  class << self
35
35
  # Factory Method that translates a Glimmer DSL keyword into a WidgetProxy object
36
- def for(keyword, parent, args)
36
+ def for(keyword, parent, args, block)
37
37
  the_widget_class = widget_class(keyword)
38
- the_widget_class.respond_to?(:create) ? the_widget_class.create(keyword, parent, args) : the_widget_class.new(parent, args)
38
+ the_widget_class.respond_to?(:create) ? the_widget_class.create(keyword, parent, args, block) : the_widget_class.new(parent, args, block)
39
39
  end
40
40
 
41
41
  def widget_class(keyword)
@@ -97,9 +97,10 @@ module Glimmer
97
97
  # end,
98
98
  }
99
99
 
100
- def initialize(parent, args)
100
+ def initialize(parent, args, block)
101
101
  @parent = parent
102
102
  @args = args
103
+ @block = block
103
104
  @children = Set.new # TODO consider moving to composite
104
105
  @enabled = true
105
106
  DEFAULT_INITIALIZERS[self.class.underscored_widget_name(self)]&.call(self)
@@ -305,16 +306,23 @@ module Glimmer
305
306
  @observation_requests[keyword] << event_listener
306
307
  event = mapping[:event]
307
308
  event_handler = mapping[:event_handler]
309
+ event_element_css_selector = mapping[:event_element_css_selector]
308
310
  potential_event_listener = event_handler&.call(event_listener)
309
311
  event_listener = potential_event_listener || event_listener
310
- delegate = listener_dom_element.on(event, &event_listener)
312
+ async_event_listener = lambda do |event|
313
+ Async::Task.new do
314
+ event_listener.call(event)
315
+ end
316
+ end
317
+ the_listener_dom_element = event_element_css_selector ? Element[event_element_css_selector] : listener_dom_element
318
+ delegate = the_listener_dom_element.on(event, &async_event_listener)
311
319
  end
312
320
  # TODO update code below for new WidgetProxy API
313
321
  EventListenerProxy.new(element_proxy: self, event: event, selector: selector, delegate: delegate)
314
322
  end
315
323
 
316
324
  def add_observer(observer, property_name)
317
- property_listener_installers = self.class.ancestors.map {|ancestor| widget_property_listener_installers[ancestor]}.compact
325
+ property_listener_installers = self.class&.ancestors&.to_a.map {|ancestor| widget_property_listener_installers[ancestor]}.compact
318
326
  widget_listener_installers = property_listener_installers.map{|installer| installer[property_name.to_s.to_sym]}.compact if !property_listener_installers.empty?
319
327
  widget_listener_installers.to_a.each do |widget_listener_installer|
320
328
  widget_listener_installer.call(observer)
@@ -466,7 +474,7 @@ module Glimmer
466
474
  # }
467
475
  # end,
468
476
  # },
469
- DateTimeProxy => { #radio?
477
+ DateTimeProxy => {
470
478
  :date_time => lambda do |observer|
471
479
  on_widget_selected { |selection_event|
472
480
  observer.call(date_time)
@@ -506,6 +514,7 @@ require 'glimmer/swt/button_proxy'
506
514
  require 'glimmer/swt/combo_proxy'
507
515
  require 'glimmer/swt/checkbox_proxy'
508
516
  require 'glimmer/swt/composite_proxy'
517
+ require 'glimmer/swt/display_proxy'
509
518
  require 'glimmer/swt/date_time_proxy'
510
519
  require 'glimmer/swt/group_proxy'
511
520
  require 'glimmer/swt/label_proxy'
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020 Andy Maleh
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -89,7 +89,7 @@ module Glimmer
89
89
  def included(klass)
90
90
  klass.extend(ClassMethods)
91
91
  unless klass.name.include?('Glimmer::UI::CustomShell')
92
- klass.include(Glimmer)
92
+ klass.include(Glimmer)
93
93
  Glimmer::UI::CustomWidget.add_custom_widget_namespaces_for(klass)
94
94
  end
95
95
  end
@@ -107,7 +107,7 @@ module Glimmer
107
107
  end
108
108
  begin
109
109
  constant = result.const_get(namespace)
110
- return constant if constant.ancestors.include?(Glimmer::UI::CustomWidget)
110
+ return constant if constant&.respond_to?(:ancestors) && constant&.ancestors&.to_a.include?(Glimmer::UI::CustomWidget)
111
111
  constant
112
112
  rescue => e
113
113
  # Glimmer::Config.logger.debug {"#{e.message}\n#{e.backtrace.join("\n")}"}
@@ -158,7 +158,7 @@ module Glimmer
158
158
  args = []
159
159
  end
160
160
  options ||= {}
161
- args = options.delete('swt_style').split(',').map(&:to_sym) if options['swt_style']
161
+ args = options.delete('swt_style').split(',').map(&:to_sym) if options['swt_style']
162
162
  @args = args
163
163
  @swt_style = SWT::SWTProxy[*@args]
164
164
  options ||= {}
@@ -244,7 +244,7 @@ module Glimmer
244
244
 
245
245
  def has_style?(symbol)
246
246
  @args.include?(symbol) # not a very solid implementation. Bring SWT constants eventually
247
- end
247
+ end
248
248
 
249
249
  def async_exec(&block)
250
250
  SWT::DisplayProxy.instance.async_exec(&block)
@@ -273,7 +273,7 @@ module Glimmer
273
273
  end
274
274
  end
275
275
 
276
- alias local_respond_to? respond_to?
276
+ alias local_respond_to? respond_to?
277
277
  def respond_to?(method, *args, &block)
278
278
  super or
279
279
  can_handle_observation_request?(method) or
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-13 00:00:00.000000000 Z
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -217,7 +217,7 @@ files:
217
217
  - app/assets/images/glimmer/images/ui-icons_777777_256x240.png
218
218
  - app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png
219
219
  - app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png
220
- - app/assets/stylesheets/glimmer.css
220
+ - app/assets/stylesheets/glimmer/glimmer.css
221
221
  - app/assets/stylesheets/glimmer/jquery-ui.css
222
222
  - app/assets/stylesheets/glimmer/jquery-ui.structure.css
223
223
  - app/assets/stylesheets/glimmer/jquery-ui.theme.css