glimmer 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +212 -161
  3. data/RUBY_VERSION +1 -0
  4. data/VERSION +1 -0
  5. data/icons/scaffold_app.icns +0 -0
  6. data/lib/glimmer.rb +5 -47
  7. data/lib/glimmer/config.rb +35 -0
  8. data/lib/glimmer/css/{rule_set.rb → rule.rb} +3 -5
  9. data/lib/glimmer/css/style_sheet.rb +4 -5
  10. data/lib/glimmer/data_binding/observable_model.rb +1 -1
  11. data/lib/glimmer/dsl/css/dsl.rb +2 -2
  12. data/lib/glimmer/dsl/css/dynamic_property_expression.rb +12 -0
  13. data/lib/glimmer/dsl/css/property_expression.rb +3 -3
  14. data/lib/glimmer/dsl/css/pv_expression.rb +17 -0
  15. data/lib/glimmer/dsl/css/{rule_set_expression.rb → rule_expression.rb} +4 -4
  16. data/lib/glimmer/dsl/css/s_expression.rb +3 -3
  17. data/lib/glimmer/dsl/engine.rb +35 -5
  18. data/lib/glimmer/dsl/expression_handler.rb +3 -3
  19. data/lib/glimmer/dsl/swt/color_expression.rb +2 -0
  20. data/lib/glimmer/dsl/swt/dsl.rb +2 -0
  21. data/lib/glimmer/dsl/swt/tab_item_expression.rb +1 -1
  22. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +5 -5
  23. data/lib/glimmer/dsl/xml/name_space_expression.rb +1 -1
  24. data/lib/glimmer/launcher.rb +64 -19
  25. data/lib/glimmer/rake_task.rb +64 -23
  26. data/lib/glimmer/scaffold.rb +442 -0
  27. data/lib/glimmer/swt/layout_data_proxy.rb +1 -1
  28. data/lib/glimmer/swt/layout_proxy.rb +2 -2
  29. data/lib/glimmer/swt/swt_proxy.rb +3 -3
  30. data/lib/glimmer/swt/widget_proxy.rb +5 -5
  31. data/lib/glimmer/ui/custom_widget.rb +3 -3
  32. data/lib/glimmer/xml/node.rb +1 -1
  33. data/lib/glimmer/xml/xml_visitor.rb +2 -2
  34. metadata +16 -42
  35. data/bin/gladiator +0 -6
  36. data/lib/glimmer/dsl/css/p_expression.rb +0 -25
  37. data/lib/glimmer/ui/video.rb +0 -289
  38. data/samples/gladiator.rb +0 -765
@@ -31,7 +31,7 @@ module Glimmer
31
31
  begin
32
32
  @swt_layout_data = swt_layout_data_class.new(*args)
33
33
  rescue => e
34
- Glimmer.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
34
+ Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
35
35
  @swt_layout_data = args.first if args.count == 1
36
36
  end
37
37
  @widget_proxy.swt_widget.setLayoutData(@swt_layout_data)
@@ -34,8 +34,8 @@ module Glimmer
34
34
  end
35
35
  swt_layout_class
36
36
  rescue => e
37
- Glimmer.logger&.debug e.message
38
- # Glimmer.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
37
+ Glimmer::Config.logger&.debug e.message
38
+ # Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
39
39
  raise e
40
40
  end
41
41
  end
@@ -43,12 +43,12 @@ module Glimmer
43
43
  negative ? ~bit_value : bit_value
44
44
  rescue => e
45
45
  begin
46
- # Glimmer.logger&.debug(e.full_message)
46
+ # Glimmer::Config.logger&.debug(e.full_message)
47
47
  alternative_swt_constant_symbol = SWT.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s.upcase}
48
48
  bit_value = SWT.const_get(alternative_swt_constant_symbol)
49
49
  negative ? ~bit_value : bit_value
50
50
  rescue => e
51
- # Glimmer.logger&.debug(e.full_message)
51
+ # Glimmer::Config.logger&.debug(e.full_message)
52
52
  bit_value = Glimmer::SWT::SWTProxy::EXTRA_STYLES[swt_constant_symbol]
53
53
  if bit_value
54
54
  negative ? ~bit_value : bit_value
@@ -88,7 +88,7 @@ module Glimmer
88
88
  def deconstruct(integer)
89
89
  SWT.constants.reduce([]) do |found, c|
90
90
  constant_value = SWT.const_get(c) rescue -1
91
- is_found = constant_value.is_a?(Integer) && (constant_value & style) == constant_value
91
+ is_found = constant_value.is_a?(Integer) && (constant_value & integer) == constant_value
92
92
  is_found ? found += [c] : found
93
93
  end
94
94
  end
@@ -191,17 +191,17 @@ module Glimmer
191
191
  swt_widget_name = underscored_widget_name.camelcase(:upper)
192
192
  swt_widget_class = eval(swt_widget_name)
193
193
  unless swt_widget_class.ancestors.include?(org.eclipse.swt.widgets.Widget)
194
- Glimmer.logger&.debug("Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget")
194
+ Glimmer::Config.logger&.debug("Class #{swt_widget_class} matching #{underscored_widget_name} is not a subclass of org.eclipse.swt.widgets.Widget")
195
195
  return nil
196
196
  end
197
197
  swt_widget_class
198
198
  rescue NameError => e
199
- Glimmer.logger&.debug e.message
200
- # Glimmer.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
199
+ Glimmer::Config.logger&.debug e.message
200
+ # Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
201
201
  nil
202
202
  rescue => e
203
- Glimmer.logger&.debug e.message
204
- # Glimmer.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
203
+ Glimmer::Config.logger&.debug e.message
204
+ # Glimmer::Config.logger&.debug("#{e.message}\n#{e.backtrace.join("\n")}")
205
205
  nil
206
206
  end
207
207
 
@@ -36,15 +36,15 @@ module Glimmer
36
36
  return constant if constant.ancestors.include?(Glimmer::UI::CustomWidget)
37
37
  constant
38
38
  rescue => e
39
- # Glimmer.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
39
+ # Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
40
40
  result
41
41
  end
42
42
  end
43
43
  end
44
44
  raise "#{underscored_custom_widget_name} has no custom widget class!"
45
45
  rescue => e
46
- Glimmer.logger&.debug e.message
47
- Glimmer.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
46
+ Glimmer::Config.logger&.debug e.message
47
+ Glimmer::Config.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
48
48
  nil
49
49
  end
50
50
 
@@ -37,7 +37,7 @@ module Glimmer
37
37
  attribute.parent = nil #attributes do not usually have parents
38
38
  end
39
39
  end
40
- Glimmer.logger&.debug(attributes)
40
+ Glimmer::Config.logger&.debug(attributes)
41
41
  end
42
42
  end
43
43
 
@@ -50,8 +50,8 @@ module Glimmer
50
50
  end
51
51
 
52
52
  def append_attributes(node)
53
- Glimmer.logger&.debug "Take 3"
54
- Glimmer.logger&.debug(node.attributes)
53
+ Glimmer::Config.logger&.debug "Take 3"
54
+ Glimmer::Config.logger&.debug(node.attributes)
55
55
  node.attributes.each do |attribute, value|
56
56
  attribute_name = attribute
57
57
  attribute_name = "#{attribute.name_space.name}:#{attribute.name}" if attribute.is_a?(Node)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -97,31 +97,17 @@ dependencies:
97
97
  - !ruby/object:Gem::Dependency
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: 1.1.1
103
- name: filewatcher
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 1.1.1
111
- - !ruby/object:Gem::Dependency
112
- requirement: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
100
+ - - '='
115
101
  - !ruby/object:Gem::Version
116
- version: 1.3.4
117
- name: clipboard
102
+ version: 2.3.9
103
+ name: jeweler
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
- - - "~>"
108
+ - - '='
123
109
  - !ruby/object:Gem::Version
124
- version: 1.3.4
110
+ version: 2.3.9
125
111
  - !ruby/object:Gem::Dependency
126
112
  requirement: !ruby/object:Gem::Requirement
127
113
  requirements:
@@ -164,20 +150,6 @@ dependencies:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
152
  version: 2.3.0
167
- - !ruby/object:Gem::Dependency
168
- requirement: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: 2.3.9
173
- name: jeweler
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: 2.3.9
181
153
  - !ruby/object:Gem::Dependency
182
154
  requirement: !ruby/object:Gem::Requirement
183
155
  requirements:
@@ -227,7 +199,6 @@ email: andy.am@gmail.com
227
199
  executables:
228
200
  - glimmer
229
201
  - girb
230
- - gladiator
231
202
  extensions: []
232
203
  extra_rdoc_files:
233
204
  - LICENSE.txt
@@ -235,12 +206,15 @@ extra_rdoc_files:
235
206
  files:
236
207
  - LICENSE.txt
237
208
  - README.markdown
209
+ - RUBY_VERSION
210
+ - VERSION
238
211
  - bin/girb
239
212
  - bin/girb_runner.rb
240
- - bin/gladiator
241
213
  - bin/glimmer
214
+ - icons/scaffold_app.icns
242
215
  - lib/glimmer.rb
243
- - lib/glimmer/css/rule_set.rb
216
+ - lib/glimmer/config.rb
217
+ - lib/glimmer/css/rule.rb
244
218
  - lib/glimmer/css/style_sheet.rb
245
219
  - lib/glimmer/data_binding/list_selection_binding.rb
246
220
  - lib/glimmer/data_binding/model_binding.rb
@@ -255,9 +229,10 @@ files:
255
229
  - lib/glimmer/data_binding/widget_binding.rb
256
230
  - lib/glimmer/dsl/css/css_expression.rb
257
231
  - lib/glimmer/dsl/css/dsl.rb
258
- - lib/glimmer/dsl/css/p_expression.rb
232
+ - lib/glimmer/dsl/css/dynamic_property_expression.rb
259
233
  - lib/glimmer/dsl/css/property_expression.rb
260
- - lib/glimmer/dsl/css/rule_set_expression.rb
234
+ - lib/glimmer/dsl/css/pv_expression.rb
235
+ - lib/glimmer/dsl/css/rule_expression.rb
261
236
  - lib/glimmer/dsl/css/s_expression.rb
262
237
  - lib/glimmer/dsl/engine.rb
263
238
  - lib/glimmer/dsl/expression.rb
@@ -306,6 +281,7 @@ files:
306
281
  - lib/glimmer/launcher.rb
307
282
  - lib/glimmer/package.rb
308
283
  - lib/glimmer/rake_task.rb
284
+ - lib/glimmer/scaffold.rb
309
285
  - lib/glimmer/swt/color_proxy.rb
310
286
  - lib/glimmer/swt/display_proxy.rb
311
287
  - lib/glimmer/swt/font_proxy.rb
@@ -320,14 +296,12 @@ files:
320
296
  - lib/glimmer/swt/widget_proxy.rb
321
297
  - lib/glimmer/ui/custom_shell.rb
322
298
  - lib/glimmer/ui/custom_widget.rb
323
- - lib/glimmer/ui/video.rb
324
299
  - lib/glimmer/util/proc_tracker.rb
325
300
  - lib/glimmer/xml/depth_first_search_iterator.rb
326
301
  - lib/glimmer/xml/name_space_visitor.rb
327
302
  - lib/glimmer/xml/node.rb
328
303
  - lib/glimmer/xml/node_visitor.rb
329
304
  - lib/glimmer/xml/xml_visitor.rb
330
- - samples/gladiator.rb
331
305
  - vendor/swt/linux/swt.jar
332
306
  - vendor/swt/mac/swt.jar
333
307
  - vendor/swt/windows/swt.jar
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/glimmer/launcher'
4
-
5
- gladiator = File.expand_path('../../samples/gladiator.rb', __FILE__)
6
- Glimmer::Launcher.new([gladiator, '-J-Xrs'] + ARGV).launch
@@ -1,25 +0,0 @@
1
- require 'glimmer/dsl/static_expression'
2
- require 'glimmer/css/style_sheet'
3
- require 'glimmer/css/rule_set'
4
-
5
- module Glimmer
6
- module DSL
7
- module CSS
8
- class PExpression < StaticExpression
9
- include ParentExpression
10
-
11
- def can_interpret?(parent, keyword, *args, &block)
12
- keyword == 'p' and
13
- parent.is_a?(Glimmer::CSS::RuleSet) and
14
- !block_given? and
15
- !args.empty? and
16
- args.size > 1
17
- end
18
-
19
- def interpret(parent, keyword, *args, &block)
20
- parent.add_property(args[0], args[1])
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,289 +0,0 @@
1
- require 'glimmer/ui/custom_widget'
2
- require 'glimmer/swt/color_proxy'
3
-
4
- module Glimmer
5
- module UI
6
- class Video
7
- include Glimmer::UI::CustomWidget
8
- include_package 'org.eclipse.swt.browser'
9
-
10
- options :file, :url
11
- option :autoplay, true
12
- option :controls, true
13
- option :looped, false
14
- option :background, :white
15
- option :fit_to_width, true
16
- option :fit_to_height, true
17
- option :offset_x, 0
18
- option :offset_y, 0
19
-
20
- alias autoplay? autoplay
21
- alias controls? controls
22
- alias looped? looped
23
- alias fit_to_width? fit_to_width
24
- alias fit_to_height? fit_to_height
25
-
26
- body {
27
- browser(:no_scroll) {
28
- text html {
29
- head {
30
- style(id: "style") {
31
- css {
32
- body {
33
- margin 0
34
- padding 0
35
- overflow :hidden
36
- }
37
- }
38
- }
39
- style(id: "style-body-background") {
40
- css {
41
- body {
42
- p 'background', browser_body_background
43
- }
44
- }
45
- }
46
- style(id: "style-body-offset-x") {
47
- css {
48
- body {
49
- margin_left "#{browser_body_offset_x}px"
50
- }
51
- }
52
- }
53
- style(id: "style-body-offset-y") {
54
- css {
55
- body {
56
- margin_top "#{browser_body_offset_y}px"
57
- }
58
- }
59
- }
60
- }
61
- body {
62
- video(browser_video_loop, browser_video_controls, browser_video_autoplay, id: 'video', src: source, width: browser_video_width, height: browser_video_height)
63
- }
64
- }
65
- on_completed {
66
- @completed = true
67
- }
68
- }
69
- }
70
-
71
- def source
72
- file_source = file
73
- if file_source
74
- if file_source.start_with?('uri:classloader')
75
- file_path = file_source.split(/\/\//).last
76
- file_name = File.basename(file_source)
77
- # supporting windows ENV['temp'] or mac/unix /tmp
78
- tmp_dir = ENV['temp'] ? File.expand_path(ENV['temp']) : '/tmp'
79
- tmp_dir += '/glimmer/lib/glimmer/ui/video'
80
- FileUtils.mkdir_p(tmp_dir)
81
- tmp_file = File.join(tmp_dir, file_name)
82
- file_content = File.binread(file_source) rescue File.binread(file_path)
83
- File.binwrite(tmp_file, file_content)
84
- "file://#{tmp_file}"
85
- else
86
- "file://#{file_source}"
87
- end
88
- else
89
- url
90
- end
91
- end
92
-
93
- def file=(a_file)
94
- options[:file] = a_file
95
- set_video_source
96
- end
97
-
98
- def url=(a_url)
99
- options[:url] = a_url
100
- set_video_source
101
- end
102
-
103
- def play
104
- video_action('play')
105
- end
106
-
107
- def pause
108
- video_action('pause')
109
- end
110
-
111
- def reload
112
- video_action('load')
113
- end
114
-
115
- def paused?
116
- video_attribute('paused')
117
- end
118
-
119
- def playing?
120
- !paused?
121
- end
122
-
123
- def ended?
124
- video_attribute('ended')
125
- end
126
-
127
- # Video fully loaded and ready for playback
128
- def loaded?
129
- !!@completed
130
- end
131
-
132
- def position
133
- video_attribute('currentTime')
134
- end
135
-
136
- def position=(new_position)
137
- video_attribute_set('currentTime', new_position)
138
- end
139
-
140
- def duration
141
- video_attribute('duration')
142
- end
143
-
144
- def can_handle_observation_request?(observation_request)
145
- result = false
146
- if observation_request.start_with?('on_')
147
- attribute = observation_request.sub(/^on_/, '')
148
- result = OBSERVED_ATTRIBUTE_TO_PROPERTY_MAPPING.keys.include?(attribute)
149
- end
150
- result || super
151
- end
152
-
153
- def handle_observation_request(observation_request, &block)
154
- if observation_request.start_with?('on_')
155
- attribute = observation_request.sub(/^on_/, '')
156
- if attribute == 'loaded' && !@completed
157
- super('on_completed', &block)
158
- elsif OBSERVED_ATTRIBUTE_TO_PROPERTY_MAPPING.keys.include?(attribute)
159
- add_video_observer(block, OBSERVED_ATTRIBUTE_TO_PROPERTY_MAPPING[attribute])
160
- else
161
- super
162
- end
163
- end
164
- end
165
-
166
- private
167
-
168
- class VideoObserverBrowserFunction < BrowserFunction
169
- def initialize(video, observer_proc, attribute)
170
- @observer_proc = observer_proc
171
- @attribute = attribute
172
- name = self.class.generate_name(@attribute)
173
- super(video.swt_widget, name)
174
- end
175
-
176
- def function(arguments)
177
- @observer_proc.call
178
- rescue => e
179
- Glimmer.logger&.error "#{e.message}\n#{e.backtrace.join("\n")}"
180
- ensure
181
- nil
182
- end
183
-
184
- private
185
-
186
- class << self
187
- def generate_name(attribute)
188
- "video#{attribute}#{generate_attribute_id(attribute)}"
189
- end
190
-
191
- def generate_attribute_id(attribute)
192
- attribute_max_ids[attribute] = attribute_max_id(attribute) + 1
193
- end
194
-
195
- def attribute_max_id(attribute)
196
- attribute_max_ids[attribute] ||= 0
197
- end
198
-
199
- def attribute_max_ids
200
- @attribute_max_ids ||= {}
201
- end
202
- end
203
- end
204
-
205
- OBSERVED_ATTRIBUTE_TO_PROPERTY_MAPPING = {
206
- 'playing' => 'play',
207
- 'paused' => 'pause',
208
- 'ended' => 'ended',
209
- 'loaded' => 'canplay',
210
- }
211
-
212
- def set_video_source
213
- run_on_completed do
214
- video_attribute_set('src', source)
215
- end
216
- end
217
-
218
- def video_action(action)
219
- run_on_completed do
220
- swt_widget.execute("document.getElementById('video').#{action}()")
221
- end
222
- end
223
-
224
- def video_attribute(attribute)
225
- swt_widget.evaluate("return document.getElementById('video').#{attribute}") if @completed
226
- end
227
-
228
- def video_attribute_set(attribute, value)
229
- value = "'#{value}'" if value.is_a?(String) || value.is_a?(Symbol)
230
- run_on_completed do
231
- swt_widget.execute("document.getElementById('video').#{attribute} = #{value}")
232
- end
233
- end
234
-
235
- def add_video_observer(observer_proc, attribute)
236
- run_on_completed do
237
- video_observer_browser_function = VideoObserverBrowserFunction.new(self, observer_proc, attribute)
238
- swt_widget.execute("document.getElementById('video').addEventListener('#{attribute}', function() {#{video_observer_browser_function.getName}()})")
239
- end
240
- end
241
-
242
- def run_on_completed(&block)
243
- if @completed
244
- block.call
245
- else
246
- on_completed(&block)
247
- end
248
- end
249
-
250
- def browser_video_autoplay
251
- 'autoplay' if autoplay?
252
- end
253
-
254
- def browser_video_controls
255
- 'controls' if controls?
256
- end
257
-
258
- def browser_video_loop
259
- 'loop' if looped?
260
- end
261
-
262
- def browser_video_width
263
- "100%" if fit_to_width
264
- end
265
-
266
- def browser_video_height
267
- "100%" if fit_to_height
268
- end
269
-
270
- def browser_body_background
271
- color = background
272
- if color.is_a?(Symbol) || color.is_a?(String)
273
- color = SWT::ColorProxy.new(color).swt_color
274
- elsif color.is_a?(SWT::ColorProxy)
275
- color = color.swt_color
276
- end
277
- "rgba(#{color.getRed}, #{color.getGreen}, #{color.getBlue}, #{color.getAlpha})"
278
- end
279
-
280
- def browser_body_offset_x
281
- offset_x
282
- end
283
-
284
- def browser_body_offset_y
285
- offset_y
286
- end
287
- end
288
- end
289
- end