glimmer-dsl-swt 4.19.0.1 → 4.20.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +26 -27
  4. data/RUBY_VERSION +1 -1
  5. data/VERSION +1 -1
  6. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +44 -15
  7. data/docs/reference/GLIMMER_SAMPLES.md +136 -17
  8. data/glimmer-dsl-swt.gemspec +0 -0
  9. data/lib/glimmer/data_binding/shine.rb +41 -26
  10. data/lib/glimmer/dsl/swt/dsl.rb +2 -1
  11. data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +49 -0
  12. data/lib/glimmer/dsl/swt/widget_expression.rb +2 -0
  13. data/lib/glimmer/launcher.rb +6 -0
  14. data/lib/glimmer/rake_task/scaffold.rb +0 -2
  15. data/lib/glimmer/swt/combo_proxy.rb +48 -0
  16. data/lib/glimmer/swt/custom/code_text.rb +13 -9
  17. data/lib/glimmer/swt/tool_bar_proxy.rb +51 -0
  18. data/lib/glimmer/swt/widget_proxy.rb +6 -0
  19. data/samples/elaborate/contact_manager.rb +7 -5
  20. data/samples/elaborate/login.rb +7 -7
  21. data/samples/elaborate/mandelbrot_fractal.rb +12 -7
  22. data/samples/elaborate/meta_sample.rb +4 -2
  23. data/samples/elaborate/metronome.rb +4 -4
  24. data/samples/elaborate/tetris/model/game.rb +0 -3
  25. data/samples/elaborate/tic_tac_toe.rb +2 -2
  26. data/samples/hello/hello_button.rb +1 -1
  27. data/samples/hello/hello_c_combo.rb +2 -1
  28. data/samples/hello/hello_c_tab.rb +1 -0
  29. data/samples/hello/hello_canvas.rb +5 -5
  30. data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
  31. data/samples/hello/hello_canvas_data_binding.rb +16 -16
  32. data/samples/hello/hello_checkbox.rb +4 -4
  33. data/samples/hello/hello_code_text.rb +3 -57
  34. data/samples/hello/hello_color_dialog.rb +1 -1
  35. data/samples/hello/hello_combo.rb +1 -1
  36. data/samples/hello/hello_composite.rb +71 -0
  37. data/samples/hello/hello_computed.rb +5 -5
  38. data/samples/hello/hello_cool_bar.rb +147 -0
  39. data/samples/hello/hello_custom_widget.rb +1 -1
  40. data/samples/hello/hello_date_time.rb +4 -4
  41. data/samples/hello/hello_dialog.rb +3 -2
  42. data/samples/hello/hello_drag_and_drop.rb +1 -1
  43. data/samples/hello/hello_file_dialog.rb +1 -1
  44. data/samples/hello/hello_font_dialog.rb +3 -3
  45. data/samples/hello/hello_group.rb +6 -6
  46. data/samples/hello/hello_layout.rb +243 -0
  47. data/samples/hello/hello_link.rb +56 -50
  48. data/samples/hello/hello_list_multi_selection.rb +1 -1
  49. data/samples/hello/hello_list_single_selection.rb +1 -1
  50. data/samples/hello/hello_progress_bar.rb +10 -10
  51. data/samples/hello/hello_radio.rb +6 -6
  52. data/samples/hello/hello_sash_form.rb +4 -4
  53. data/samples/hello/hello_shape.rb +1 -0
  54. data/samples/hello/hello_shell.rb +205 -0
  55. data/samples/hello/hello_spinner.rb +6 -2
  56. data/samples/hello/hello_styled_text.rb +11 -11
  57. data/samples/hello/hello_tool_bar.rb +143 -0
  58. data/vendor/swt/linux/swt.jar +0 -0
  59. data/vendor/swt/linux_aarch64/swt.jar +0 -0
  60. data/vendor/swt/mac/swt.jar +0 -0
  61. data/vendor/swt/mac_aarch64/swt.jar +0 -0
  62. data/vendor/swt/windows/swt.jar +0 -0
  63. metadata +15 -3
@@ -47,6 +47,9 @@ class HelloSpinner
47
47
  grid_layout 3, false
48
48
 
49
49
  label {
50
+ layout_data {
51
+ width_hint 240
52
+ }
50
53
  text 'Amount:'
51
54
  font style: :bold
52
55
  }
@@ -61,11 +64,12 @@ class HelloSpinner
61
64
  maximum 15000 # maximum value (including digits after the decimal point)
62
65
  increment 500 # increment on up and down (including digits after the decimal point)
63
66
  page_increment 5000 # page increment on page up and page down (including digits after the decimal point)
64
- selection bind(@person, :donation) # selection must be set last if other properties are configured to ensure value is within bounds
67
+ selection <=> [@person, :donation] # selection must be set last if other properties are configured to ensure value is within bounds
65
68
  }
66
69
 
67
70
  label {
68
- text bind(@person, :donation) {|value| "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}
71
+ layout_data(:fill, :center, true, false)
72
+ text <=> [@person, :donation, on_read: ->(value) { "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}]
69
73
  }
70
74
 
71
75
  }
@@ -49,7 +49,7 @@ end
49
49
  include Glimmer
50
50
 
51
51
  @presenter = StyledTextPresenter.new
52
- @presenter.text = verbiage*8
52
+ @presenter.text = verbiage*4
53
53
  @presenter.caret_offset = 0
54
54
  @presenter.selection_count = 0
55
55
  @presenter.selection = Point.new(0, 0)
@@ -61,19 +61,19 @@ shell {
61
61
  composite {
62
62
  @styled_text = styled_text {
63
63
  layout_data :fill, :fill, true, true
64
- text bind(@presenter, :text)
64
+ text <=> [@presenter, :text]
65
65
  left_margin 5
66
66
  top_margin 5
67
67
  right_margin 5
68
68
  bottom_margin 5
69
69
  # caret offset scrolls text to view when out of page
70
- caret_offset bind(@presenter, :caret_offset)
70
+ caret_offset <=> [@presenter, :caret_offset]
71
71
  # selection_count is not needed if selection is used
72
- selection_count bind(@presenter, :selection_count)
72
+ selection_count <=> [@presenter, :selection_count]
73
73
  # selection contains both caret_offset and selection_count, but setting it does not scroll text into view if out of page
74
- selection bind(@presenter, :selection)
74
+ selection <=> [@presenter, :selection]
75
75
  # top_pixel indicates vertically what pixel scrolling is at in a long multi-page text document
76
- top_pixel bind(@presenter, :top_pixel)
76
+ top_pixel <=> [@presenter, :top_pixel]
77
77
 
78
78
  # This demonstrates how to set styles via a listener
79
79
  on_line_get_style { |line_style_event|
@@ -109,31 +109,31 @@ shell {
109
109
  text 'Caret Offset:'
110
110
  }
111
111
  text {
112
- text bind(@presenter, :caret_offset, on_read: ->(o) {"%04d" % [o] })
112
+ text <=> [@presenter, :caret_offset, on_read: ->(o) {"%04d" % [o] }]
113
113
  }
114
114
  label {
115
115
  text 'Selection Count:'
116
116
  }
117
117
  text {
118
- text bind(@presenter, :selection_count, on_read: ->(o) {"%04d" % [o] })
118
+ text <=> [@presenter, :selection_count, on_read: ->(o) {"%04d" % [o] }]
119
119
  }
120
120
  label {
121
121
  text 'Selection Start:'
122
122
  }
123
123
  text {
124
- text bind(@presenter, 'selection.x', on_read: ->(o) {"%04d" % [o] })
124
+ text <=> [@presenter, 'selection.x', on_read: ->(o) {"%04d" % [o] }]
125
125
  }
126
126
  label {
127
127
  text 'Selection End:'
128
128
  }
129
129
  text {
130
- text bind(@presenter, 'selection.y', on_read: ->(o) {"%04d" % [o] })
130
+ text <=> [@presenter, 'selection.y', on_read: ->(o) {"%04d" % [o] }]
131
131
  }
132
132
  label {
133
133
  text 'Top Pixel:'
134
134
  }
135
135
  text {
136
- text bind(@presenter, :top_pixel, on_read: ->(o) {"%04d" % [o] })
136
+ text <=> [@presenter, :top_pixel, on_read: ->(o) {"%04d" % [o] }]
137
137
  }
138
138
  }
139
139
  }
@@ -0,0 +1,143 @@
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
+ require 'glimmer-dsl-swt'
23
+
24
+ class HelloToolBar
25
+ include Glimmer::UI::CustomShell
26
+
27
+ attr_accessor :operation, :font_size
28
+
29
+ def font_size_options
30
+ (10..30).to_a.map(&:to_s)
31
+ end
32
+
33
+ before_body {
34
+ self.font_size = '10'
35
+ }
36
+
37
+ body {
38
+ shell {
39
+ fill_layout(:vertical) {
40
+ margin_width 0
41
+ margin_height 0
42
+ }
43
+
44
+ text 'Hello, Tool Bar!'
45
+
46
+ tool_bar { # optionally takes a :flat style, :wrap style if you need wrapping upon shrinking window, and :vertical style if you need vertical layout
47
+ tool_item {
48
+ image cut_image # alternatively you can pass an image file path
49
+
50
+ on_widget_selected do
51
+ self.operation = 'Cut'
52
+ end
53
+ }
54
+ tool_item {
55
+ image copy_image # alternatively you can pass an image file path
56
+
57
+ on_widget_selected do
58
+ self.operation = 'Copy'
59
+ end
60
+ }
61
+ tool_item {
62
+ image paste_image # alternatively you can pass an image file path
63
+
64
+ on_widget_selected do
65
+ self.operation = 'Paste'
66
+ end
67
+ }
68
+ tool_item(:separator)
69
+ tool_item {
70
+ text 'Font Size'
71
+ }
72
+ # a combo can be nested in a tool_bar (it auto-generates a tool_item for itself behind the scenes)
73
+ combo {
74
+ selection bind(self, :font_size)
75
+ }
76
+ }
77
+
78
+ label {
79
+ font height: 30
80
+ text bind(self, :operation)
81
+ text bind(self, :font_size)
82
+ }
83
+ }
84
+ }
85
+
86
+ def cut_image
87
+ # building image on the fly with Canvas Shape DSL
88
+ image(25, 25) {
89
+ rectangle(0, 0, 25, 25) {
90
+ background_pattern 0, 0, 0, 25, :white, :gray
91
+ line(20, 2, 9, 15) {
92
+ line_width 2
93
+ }
94
+ line(5, 2, 16, 15) {
95
+ line_width 2
96
+ }
97
+ oval(2, 15, 8, 8) {
98
+ line_width 2
99
+ }
100
+ oval(16, 15, 8, 8) {
101
+ line_width 2
102
+ }
103
+ }
104
+ }
105
+ end
106
+
107
+ def copy_image
108
+ # building image on the fly with Canvas Shape DSL
109
+ image(25, 25) {
110
+ rectangle(0, 0, 25, 25) {
111
+ background_pattern 0, 0, 0, 25, :white, :gray
112
+ rectangle([:default, 2], [:default, -2], 14, 14, 5, 5) {
113
+ line_width 2
114
+ }
115
+ rectangle([:default, -2], [:default, 2], 14, 14, 5, 5) {
116
+ line_width 2
117
+ }
118
+ }
119
+ }
120
+ end
121
+
122
+ def paste_image
123
+ image(25, 25) {
124
+ rectangle(0, 0, 25, 25) {
125
+ background_pattern 0, 0, 0, 25, :white, :gray
126
+ rectangle(:default, [:default, 1], 15, 20, 5, 5) {
127
+ line_width 2
128
+ }
129
+ line(7, 8, 18, 8) {
130
+ line_width 2
131
+ }
132
+ line(7, 13, 18, 13) {
133
+ line_width 2
134
+ }
135
+ line(7, 18, 18, 18) {
136
+ line_width 2
137
+ }
138
+ }
139
+ }
140
+ end
141
+ end
142
+
143
+ HelloToolBar.launch
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.19.0.1
4
+ version: 4.20.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-30 00:00:00.000000000 Z
11
+ date: 2021-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -343,7 +343,9 @@ description: Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a
343
343
  Glimmer also includes native-executable packaging support, sorely lacking in other
344
344
  libraries, thus enabling the delivery of desktop apps written in Ruby as truly native
345
345
  DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged
346
- Shell Scripts on Linux.
346
+ Shell Scripts on Linux. Glimmer was the first Ruby gem to bring SWT (Standard Widget
347
+ Toolkit) to Ruby, thanks to creator Andy Maleh, EclipseCon/EclipseWorld/RubyConf
348
+ speaker and expert.
347
349
  email: andy.am@gmail.com
348
350
  executables:
349
351
  - glimmer
@@ -429,6 +431,7 @@ files:
429
431
  - lib/glimmer/dsl/swt/rgba_expression.rb
430
432
  - lib/glimmer/dsl/swt/shape_expression.rb
431
433
  - lib/glimmer/dsl/swt/shell_expression.rb
434
+ - lib/glimmer/dsl/swt/shine_data_binding_expression.rb
432
435
  - lib/glimmer/dsl/swt/swt_expression.rb
433
436
  - lib/glimmer/dsl/swt/sync_exec_expression.rb
434
437
  - lib/glimmer/dsl/swt/tab_item_expression.rb
@@ -446,6 +449,7 @@ files:
446
449
  - lib/glimmer/rake_task/scaffold.rb
447
450
  - lib/glimmer/swt/c_tab_item_proxy.rb
448
451
  - lib/glimmer/swt/color_proxy.rb
452
+ - lib/glimmer/swt/combo_proxy.rb
449
453
  - lib/glimmer/swt/cursor_proxy.rb
450
454
  - lib/glimmer/swt/custom/animation.rb
451
455
  - lib/glimmer/swt/custom/checkbox_group.rb
@@ -491,6 +495,7 @@ files:
491
495
  - lib/glimmer/swt/tab_item_proxy.rb
492
496
  - lib/glimmer/swt/table_column_proxy.rb
493
497
  - lib/glimmer/swt/table_proxy.rb
498
+ - lib/glimmer/swt/tool_bar_proxy.rb
494
499
  - lib/glimmer/swt/transform_proxy.rb
495
500
  - lib/glimmer/swt/tree_proxy.rb
496
501
  - lib/glimmer/swt/widget_listener_proxy.rb
@@ -548,8 +553,10 @@ files:
548
553
  - samples/hello/hello_code_text.rb
549
554
  - samples/hello/hello_color_dialog.rb
550
555
  - samples/hello/hello_combo.rb
556
+ - samples/hello/hello_composite.rb
551
557
  - samples/hello/hello_computed.rb
552
558
  - samples/hello/hello_computed/contact.rb
559
+ - samples/hello/hello_cool_bar.rb
553
560
  - samples/hello/hello_cursor.rb
554
561
  - samples/hello/hello_custom_shape.rb
555
562
  - samples/hello/hello_custom_shell.rb
@@ -562,6 +569,7 @@ files:
562
569
  - samples/hello/hello_file_dialog.rb
563
570
  - samples/hello/hello_font_dialog.rb
564
571
  - samples/hello/hello_group.rb
572
+ - samples/hello/hello_layout.rb
565
573
  - samples/hello/hello_link.rb
566
574
  - samples/hello/hello_list_multi_selection.rb
567
575
  - samples/hello/hello_list_single_selection.rb
@@ -573,17 +581,21 @@ files:
573
581
  - samples/hello/hello_radio_group.rb
574
582
  - samples/hello/hello_sash_form.rb
575
583
  - samples/hello/hello_shape.rb
584
+ - samples/hello/hello_shell.rb
576
585
  - samples/hello/hello_spinner.rb
577
586
  - samples/hello/hello_styled_text.rb
578
587
  - samples/hello/hello_tab.rb
579
588
  - samples/hello/hello_table.rb
580
589
  - samples/hello/hello_table/baseball_park.png
590
+ - samples/hello/hello_tool_bar.rb
581
591
  - samples/hello/hello_tree.rb
582
592
  - samples/hello/hello_world.rb
583
593
  - sounds/metronome-down.wav
584
594
  - sounds/metronome-up.wav
585
595
  - vendor/swt/linux/swt.jar
596
+ - vendor/swt/linux_aarch64/swt.jar
586
597
  - vendor/swt/mac/swt.jar
598
+ - vendor/swt/mac_aarch64/swt.jar
587
599
  - vendor/swt/windows/swt.jar
588
600
  homepage: http://github.com/AndyObtiva/glimmer-dsl-swt
589
601
  licenses: