glimmer-dsl-swt 4.18.0.2 → 4.18.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/swt/widget_listener_proxy'
23
+ require 'glimmer/swt/custom/drawable'
23
24
 
24
25
  module Glimmer
25
26
  module SWT
@@ -36,6 +37,8 @@ module Glimmer
36
37
  # Follows the Proxy Design Pattern
37
38
  class DisplayProxy
38
39
  include_package 'org.eclipse.swt.widgets'
40
+
41
+ include Custom::Drawable
39
42
 
40
43
  OBSERVED_MENU_ITEMS = ['about', 'preferences']
41
44
 
@@ -53,6 +56,7 @@ module Glimmer
53
56
  attr_reader :swt_display
54
57
 
55
58
  def initialize(*args)
59
+ Display.app_name ||= 'Glimmer'
56
60
  @swt_display = Display.new(*args)
57
61
  @swt_display.set_data('proxy', self)
58
62
  end
@@ -60,6 +64,18 @@ module Glimmer
60
64
  def content(&block)
61
65
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::DisplayExpression.new, &block)
62
66
  end
67
+
68
+ def async_exec(&block)
69
+ @swt_display.async_exec(&block)
70
+ end
71
+
72
+ def sync_exec(&block)
73
+ @swt_display.sync_exec(&block)
74
+ end
75
+
76
+ def timer_exec(&block)
77
+ @swt_display.timer_exec(&block)
78
+ end
63
79
 
64
80
  def method_missing(method, *args, &block)
65
81
  if can_handle_observation_request?(method)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2007-2021 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
@@ -0,0 +1,49 @@
1
+ # Copyright (c) 2007-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
+ module Glimmer
23
+ module SWT
24
+ module Properties
25
+ def ruby_attribute_setter(attribute_name)
26
+ "#{normalized_attribute(attribute_name)}="
27
+ end
28
+
29
+ def attribute_setter(attribute_name)
30
+ "set#{normalized_attribute(attribute_name).camelcase(:upper)}"
31
+ end
32
+
33
+ def attribute_getter(attribute_name)
34
+ "get#{normalized_attribute(attribute_name).camelcase(:upper)}"
35
+ end
36
+
37
+ def normalized_attribute(attribute_name)
38
+ attribute_name = attribute_name.to_s if attribute_name.is_a?(Symbol)
39
+ attribute_name = attribute_name.underscore unless attribute_name.downcase?
40
+ attribute_name = attribute_name.sub(/^get_/, '') if attribute_name.start_with?('get_')
41
+ attribute_name = attribute_name.sub(/^set_/, '') if attribute_name.start_with?('set_')
42
+ attribute_name = attribute_name.sub(/=$/, '') if attribute_name.end_with?('=')
43
+ attribute_name
44
+ end
45
+ alias ruby_attribute_getter normalized_attribute
46
+
47
+ end
48
+ end
49
+ end
@@ -64,10 +64,11 @@ module Glimmer
64
64
  @swt_widget.setLayout(FillLayout.new)
65
65
  @swt_widget.setMinimumSize(WIDTH_MIN, HEIGHT_MIN)
66
66
  # TODO make this an option not the default
67
+ shell_swt_display = Glimmer::SWT::DisplayProxy.instance.swt_display
67
68
  on_swt_show do
68
69
  Thread.new do
69
70
  sleep(0.25)
70
- async_exec do
71
+ shell_swt_display.async_exec do
71
72
  @swt_widget.setActive unless @swt_widget.isDisposed
72
73
  end
73
74
  end
@@ -26,6 +26,8 @@ require 'glimmer/swt/swt_proxy'
26
26
  require 'glimmer/swt/display_proxy'
27
27
  require 'glimmer/swt/dnd_proxy'
28
28
  require 'glimmer/swt/image_proxy'
29
+ require 'glimmer/swt/properties'
30
+ require 'glimmer/swt/custom/drawable'
29
31
 
30
32
  # TODO refactor to make file smaller and extract sub-widget-proxies out of this
31
33
 
@@ -42,6 +44,8 @@ module Glimmer
42
44
  # Follows the Proxy Design Pattern
43
45
  class WidgetProxy
44
46
  include Packages
47
+ include Properties
48
+ include Custom::Drawable
45
49
 
46
50
  DEFAULT_STYLES = {
47
51
  'arrow' => [:arrow],
@@ -667,28 +671,6 @@ module Glimmer
667
671
  DEFAULT_STYLES[underscored_widget_name] || [:none]
668
672
  end
669
673
 
670
- def ruby_attribute_setter(attribute_name)
671
- "#{normalized_attribute(attribute_name)}="
672
- end
673
-
674
- def attribute_setter(attribute_name)
675
- "set#{normalized_attribute(attribute_name).camelcase(:upper)}"
676
- end
677
-
678
- def attribute_getter(attribute_name)
679
- "get#{normalized_attribute(attribute_name).camelcase(:upper)}"
680
- end
681
-
682
- def normalized_attribute(attribute_name)
683
- attribute_name = attribute_name.to_s if attribute_name.is_a?(Symbol)
684
- attribute_name = attribute_name.underscore unless attribute_name.downcase?
685
- attribute_name = attribute_name.sub(/^get_/, '') if attribute_name.start_with?('get_')
686
- attribute_name = attribute_name.sub(/^set_/, '') if attribute_name.start_with?('set_')
687
- attribute_name = attribute_name.sub(/=$/, '') if attribute_name.end_with?('=')
688
- attribute_name
689
- end
690
- alias ruby_attribute_getter normalized_attribute
691
-
692
674
  # TODO refactor following methods to eliminate duplication
693
675
  # perhaps consider relying on raising an exception to avoid checking first
694
676
  # unless that gives obscure SWT errors
@@ -150,7 +150,7 @@ class MetaSampleApplication
150
150
  end
151
151
 
152
152
  def launch
153
- Display.setAppName('Glimmer Meta-Sample')
153
+ Display.app_name = 'Glimmer Meta-Sample'
154
154
  shell {
155
155
  minimum_size 1280, 768
156
156
  text 'Glimmer Meta-Sample (The Sample of Samples)'
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2007-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
+ include Glimmer
23
+
24
+ shell {
25
+ text 'Hello, Canvas!'
26
+ minimum_size 320, 400
27
+
28
+ canvas {
29
+ background :yellow
30
+ rectangle(0, 0, 220, 400, fill: true) {
31
+ background :red
32
+ }
33
+ rectangle(50, 20, 300, 150, 30, 50, round: true, fill: true) {
34
+ background :magenta
35
+ }
36
+ rectangle(150, 200, 100, 70, true, gradient: true) {
37
+ background :dark_magenta
38
+ foreground :yellow
39
+ }
40
+ rectangle(50, 200, 30, 70, false, gradient: true) {
41
+ background :magenta
42
+ foreground :dark_blue
43
+ }
44
+ rectangle(205, 50, 88, 96) {
45
+ foreground :yellow
46
+ }
47
+ text('Picasso', 60, 80) {
48
+ background :yellow
49
+ foreground :dark_magenta
50
+ font name: 'Courier', height: 30
51
+ }
52
+ oval(110, 310, 100, 100, fill: true) {
53
+ background rgb(128, 138, 248)
54
+ }
55
+ arc(210, 210, 100, 100, 30, -77, fill: true) {
56
+ background :red
57
+ }
58
+ polygon(250, 210, 260, 170, 270, 210, 290, 230, fill: true) {
59
+ background :dark_yellow
60
+ }
61
+ polyline(250, 110, 260, 70, 270, 110, 290, 130, 250, 110)
62
+ }
63
+ }.open
@@ -0,0 +1,66 @@
1
+ # Copyright (c) 2007-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
+ include Glimmer
23
+
24
+ shell {
25
+ text 'Hello, Canvas Animation!'
26
+ minimum_size 800, 420
27
+
28
+ canvas {
29
+ animation {
30
+ every 0.01 # in seconds (one hundredth)
31
+
32
+ frame { |index| # frame block loops indefinitely (unless frame_count is set to an integer)
33
+ background rgb(index%255, 100, 200) # sets canvas background color
34
+
35
+ oval(0, 0, 400, 400) { # x, y, width, height
36
+ foreground :black # sets oval background color
37
+ }
38
+ arc(0, 0, 400, 400, -1.4*index%360, 10, fill: true) { # x, y, width, height, start angle, arc angle
39
+ background rgb(200, 200, 50) # sets arc background color
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ canvas {
46
+ colors = [:yellow, :red]
47
+ animation {
48
+ every 0.25 # in seconds (one quarter)
49
+ cycle colors # cycles array of colors into the second variable of the frame block below
50
+
51
+ frame { |index, color| # frame block loops indefinitely (unless frame_count or cycle_count is set to an integer)
52
+ outside_color = colors[index % 2]
53
+ inside_color = colors[(index + 1) % 2]
54
+
55
+ background outside_color # sets canvas background color
56
+
57
+ rectangle(0, 0, 200, 200, fill: true) {
58
+ background inside_color # sets rectangle background color
59
+ }
60
+ rectangle(200, 200, 200, 200, fill: true) {
61
+ background inside_color # sets rectangle background color
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }.open
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.18.0.2
4
+ version: 4.18.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 1.0.7
18
+ version: 1.0.8
19
19
  name: glimmer
20
20
  type: :runtime
21
21
  prerelease: false
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.7
26
+ version: 1.0.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -330,18 +330,20 @@ dependencies:
330
330
  version: 0.7.0
331
331
  description: Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI
332
332
  cross-platform desktop development library written in JRuby, an OS-threaded faster
333
- version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables
334
- productive and efficient authoring of desktop application user-interfaces while
335
- relying on the robust Eclipse SWT library. Glimmer additionally innovates by having
336
- built-in data-binding support, which greatly facilitates synchronizing the GUI with
337
- domain models, thus achieving true decoupling of object oriented components and
338
- enabling developers to solve business problems (test-first) without worrying about
339
- GUI concerns, or alternatively drive development GUI-first, and then write clean
340
- business models (test-first) afterwards. To get started quickly, Glimmer offers
341
- scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable
342
- packaging support, sorely lacking in other libraries, thus enabling the delivery
343
- of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App
344
- Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.
333
+ JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables
334
+ productive and efficient authoring of desktop application user-interfaces by relying
335
+ on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in
336
+ data-binding support, which greatly facilitates synchronizing the GUI with domain
337
+ models, thus achieving true decoupling of object oriented components and enabling
338
+ developers to solve business problems (test-first) without worrying about GUI concerns,
339
+ or alternatively drive development GUI-first, and then write clean business models
340
+ (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets,
341
+ but it also supports drawing Canvas Graphics like Shapes and Animations. To get
342
+ started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets.
343
+ Glimmer also includes native-executable packaging support, sorely lacking in other
344
+ libraries, thus enabling the delivery of desktop apps written in Ruby as truly native
345
+ DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged
346
+ Shell Scripts on Linux.
345
347
  email: andy.am@gmail.com
346
348
  executables:
347
349
  - glimmer
@@ -373,6 +375,7 @@ files:
373
375
  - lib/glimmer/data_binding/table_items_binding.rb
374
376
  - lib/glimmer/data_binding/tree_items_binding.rb
375
377
  - lib/glimmer/data_binding/widget_binding.rb
378
+ - lib/glimmer/dsl/swt/animation_expression.rb
376
379
  - lib/glimmer/dsl/swt/async_exec_expression.rb
377
380
  - lib/glimmer/dsl/swt/bind_expression.rb
378
381
  - lib/glimmer/dsl/swt/block_property_expression.rb
@@ -404,6 +407,7 @@ files:
404
407
  - lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb
405
408
  - lib/glimmer/dsl/swt/rgb_expression.rb
406
409
  - lib/glimmer/dsl/swt/rgba_expression.rb
410
+ - lib/glimmer/dsl/swt/shape_expression.rb
407
411
  - lib/glimmer/dsl/swt/shell_expression.rb
408
412
  - lib/glimmer/dsl/swt/swt_expression.rb
409
413
  - lib/glimmer/dsl/swt/sync_exec_expression.rb
@@ -420,9 +424,12 @@ files:
420
424
  - lib/glimmer/rake_task/scaffold.rb
421
425
  - lib/glimmer/swt/color_proxy.rb
422
426
  - lib/glimmer/swt/cursor_proxy.rb
427
+ - lib/glimmer/swt/custom/animation.rb
423
428
  - lib/glimmer/swt/custom/checkbox_group.rb
424
429
  - lib/glimmer/swt/custom/code_text.rb
430
+ - lib/glimmer/swt/custom/drawable.rb
425
431
  - lib/glimmer/swt/custom/radio_group.rb
432
+ - lib/glimmer/swt/custom/shape.rb
426
433
  - lib/glimmer/swt/date_time_proxy.rb
427
434
  - lib/glimmer/swt/directory_dialog_proxy.rb
428
435
  - lib/glimmer/swt/display_proxy.rb
@@ -436,6 +443,7 @@ files:
436
443
  - lib/glimmer/swt/menu_proxy.rb
437
444
  - lib/glimmer/swt/message_box_proxy.rb
438
445
  - lib/glimmer/swt/packages.rb
446
+ - lib/glimmer/swt/properties.rb
439
447
  - lib/glimmer/swt/sash_form_proxy.rb
440
448
  - lib/glimmer/swt/scrolled_composite_proxy.rb
441
449
  - lib/glimmer/swt/shell_proxy.rb
@@ -463,6 +471,8 @@ files:
463
471
  - samples/elaborate/user_profile.rb
464
472
  - samples/hello/hello_browser.rb
465
473
  - samples/hello/hello_button.rb
474
+ - samples/hello/hello_canvas.rb
475
+ - samples/hello/hello_canvas_animation.rb
466
476
  - samples/hello/hello_checkbox.rb
467
477
  - samples/hello/hello_checkbox_group.rb
468
478
  - samples/hello/hello_combo.rb