glimmer-dsl-swt 4.18.5.0 → 4.18.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,87 +19,150 @@
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
- include Glimmer
23
-
24
- image_object = image(File.expand_path('../../icons/scaffold_app.png', __dir__), width: 50)
25
-
26
- shell {
27
- text 'Hello, Canvas!'
28
- minimum_size 320, 400
29
-
30
- @canvas = canvas {
31
- background :yellow
32
- rectangle(0, 0, 220, 400) {
33
- transform {
34
- }
35
- background :red
36
- }
37
- rectangle(50, 20, 300, 150, 30, 50) {
38
- background :magenta
39
- }
40
- rectangle(150, 200, 100, 70, true) {
41
- background :dark_magenta
42
- foreground :yellow
43
- }
44
- rectangle(50, 200, 30, 70, false) {
45
- background :magenta
46
- foreground :dark_blue
47
- }
48
- rectangle(205, 50, 88, 96) {
49
- foreground :yellow
50
- }
51
- text('Picasso', 60, 80) {
52
- background :yellow
53
- foreground :dark_magenta
54
- font name: 'Courier', height: 30
55
- }
56
- oval(110, 310, 100, 100) {
57
- # patterns provide a differnet way to make gradients
58
- background_pattern 0, 0, 105, 0, :yellow, rgb(128, 138, 248)
59
- }
60
- arc(210, 210, 100, 100, 30, -77) {
61
- background :red
62
- }
63
- polygon(250, 210, 260, 170, 270, 210, 290, 230) {
64
- background :dark_yellow
65
- }
66
- polyline(250, 110, 260, 70, 270, 110, 290, 130, 250, 110)
67
- 3.times { |n|
68
- line(250, 120 + n*10, 270 + n*10, 80 + n*10) {
69
- foreground :yellow
70
- }
71
- }
72
- 10.times {|n|
73
- point(220 + n*5, 100 + n*5) {
74
- foreground :yellow
75
- }
76
- }
77
- image(image_object, 205, 55)
22
+ class HelloCanvas
23
+ include Glimmer::UI::CustomShell
78
24
 
79
- on_mouse_down { |mouse_event|
80
- @drag_detected = false
81
- @canvas.cursor = :hand
82
- @shape_to_move = @canvas.shape_at_location(mouse_event.x, mouse_event.y)
83
- }
84
-
85
- on_drag_detected { |drag_detect_event|
86
- @drag_detected = true
87
- @drag_current_x = drag_detect_event.x
88
- @drag_current_y = drag_detect_event.y
89
- }
90
-
91
- on_mouse_move { |mouse_event|
92
- if @drag_detected
93
- @shape_to_move&.move_by(mouse_event.x - @drag_current_x, mouse_event.y - @drag_current_y)
94
- @drag_current_x = mouse_event.x
95
- @drag_current_y = mouse_event.y
96
- end
97
- }
25
+ attr_accessor :selected_shape
26
+
27
+ before_body {
28
+ @image_object = image(File.expand_path('../../icons/scaffold_app.png', __dir__), width: 50)
29
+ }
30
+
31
+ body {
32
+ shell {
33
+ text 'Hello, Canvas!'
34
+ minimum_size 320, 400
98
35
 
99
- on_mouse_up { |mouse_event|
100
- @canvas.cursor = :arrow
101
- @drag_detected = false
102
- @shape_to_move = nil
36
+ @canvas = canvas {
37
+ background :yellow
38
+ rectangle(0, 0, 220, 400) {
39
+ transform {
40
+ }
41
+ background :red
42
+ }
43
+ rectangle(50, 20, 300, 150, 30, 50) {
44
+ background :magenta
45
+ }
46
+ rectangle(150, 200, 100, 70, true) {
47
+ background :dark_magenta
48
+ foreground :yellow
49
+ }
50
+ rectangle(50, 200, 30, 70, false) {
51
+ background :magenta
52
+ foreground :dark_blue
53
+ }
54
+ rectangle(205, 50, 88, 96) {
55
+ foreground :yellow
56
+ }
57
+ text('Picasso', 60, 80) {
58
+ background :yellow
59
+ foreground :dark_magenta
60
+ font name: 'Courier', height: 30
61
+ }
62
+ oval(110, 310, 100, 100) {
63
+ # patterns provide a differnet way to make gradients
64
+ background_pattern 0, 0, 105, 0, :yellow, rgb(128, 138, 248)
65
+ }
66
+ arc(210, 210, 100, 100, 30, -77) {
67
+ background :red
68
+ }
69
+ polygon(250, 210, 260, 170, 270, 210, 290, 230) {
70
+ background :dark_yellow
71
+ }
72
+ polyline(250, 110, 260, 70, 270, 110, 290, 130, 250, 110)
73
+ 3.times { |n|
74
+ line(250, 120 + n*10, 270 + n*10, 80 + n*10) {
75
+ foreground :yellow
76
+ }
77
+ }
78
+ 10.times {|n|
79
+ point(220 + n*5, 100 + n*5) {
80
+ foreground :yellow
81
+ }
82
+ }
83
+ image(@image_object, 205, 55)
84
+
85
+ menu {
86
+ menu_item {
87
+ text 'Change Background Color...'
88
+ enabled bind(self, :selected_shape) {|shape| shape.respond_to?(:background) && shape.background }
89
+ on_widget_selected {
90
+ @selected_shape&.background = color_dialog.open
91
+ self.selected_shape = nil
92
+ }
93
+ }
94
+ menu_item {
95
+ text 'Change Background Pattern Color 1...'
96
+ enabled bind(self, :selected_shape) {|shape| shape.respond_to?(:background_pattern) && shape.background_pattern }
97
+ on_widget_selected {
98
+ if @selected_shape
99
+ background_pattern_args = @selected_shape.background_pattern_args
100
+ background_pattern_args[5] = color_dialog.open
101
+ @selected_shape.background_pattern = background_pattern_args
102
+ self.selected_shape = nil
103
+ end
104
+ }
105
+ }
106
+ menu_item {
107
+ text 'Change Background Pattern Color 2...'
108
+ enabled bind(self, :selected_shape) {|shape| shape.respond_to?(:background_pattern) && shape.background_pattern }
109
+ on_widget_selected {
110
+ if @selected_shape
111
+ background_pattern_args = @selected_shape.background_pattern_args
112
+ background_pattern_args[6] = color_dialog.open
113
+ @selected_shape.background_pattern = background_pattern_args
114
+ self.selected_shape = nil
115
+ end
116
+ }
117
+ }
118
+ menu_item(:separator)
119
+ menu_item {
120
+ text 'Change Foreground Color...'
121
+ enabled bind(self, :selected_shape) {|shape| shape.respond_to?(:foreground) && shape.foreground }
122
+ on_widget_selected {
123
+ @selected_shape&.foreground = color_dialog.open
124
+ self.selected_shape = nil
125
+ }
126
+ }
127
+ }
128
+
129
+ on_mouse_down { |mouse_event|
130
+ @drag_detected = false
131
+ @canvas.cursor = :hand
132
+ self.selected_shape = @canvas.shape_at_location(mouse_event.x, mouse_event.y)
133
+ }
134
+
135
+ on_drag_detected { |drag_detect_event|
136
+ @drag_detected = true
137
+ @drag_current_x = drag_detect_event.x
138
+ @drag_current_y = drag_detect_event.y
139
+ }
140
+
141
+ on_mouse_move { |mouse_event|
142
+ if @drag_detected
143
+ @selected_shape&.move_by(mouse_event.x - @drag_current_x, mouse_event.y - @drag_current_y)
144
+ @drag_current_x = mouse_event.x
145
+ @drag_current_y = mouse_event.y
146
+ end
147
+ }
148
+
149
+ on_menu_detected { |menu_detect_event|
150
+ @menu_detected = true
151
+ }
152
+
153
+ on_mouse_up { |mouse_event|
154
+ @canvas.cursor = :arrow
155
+ @drag_detected = false
156
+ if @menu_detected
157
+ @menu_detected = nil
158
+ else
159
+ self.selected_shape = nil
160
+ end
161
+ }
162
+ }
103
163
  }
104
164
  }
105
- }.open
165
+ end
166
+
167
+ HelloCanvas.launch
168
+
@@ -19,30 +19,48 @@
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/static_expression'
23
- require 'glimmer/dsl/parent_expression'
24
- require 'glimmer/dsl/top_level_expression'
25
- require 'glimmer/swt/directory_dialog_proxy'
26
-
27
- module Glimmer
28
- module DSL
29
- module SWT
30
- class DirectoryDialogExpression < StaticExpression
31
- include TopLevelExpression
32
- include ParentExpression
33
-
34
- include_package 'org.eclipse.swt.widgets'
35
-
36
- def can_interpret?(parent, keyword, *args, &block)
37
- keyword == 'directory_dialog' and
38
- (parent.nil? or parent.is_a?(Shell) or parent.is_a?(Glimmer::SWT::ShellProxy))
39
- end
22
+ class HelloColorDialog
23
+ include Glimmer::UI::CustomShell
24
+
25
+ attr_accessor :selected_color
40
26
 
41
- def interpret(parent, keyword, *args, &block)
42
- args = [parent] + args unless parent.nil?
43
- Glimmer::SWT::DirectoryDialogProxy.send(:new, *args)
44
- end
45
- end
46
- end
47
- end
27
+ before_body {
28
+ self.selected_color = :black
29
+ }
30
+
31
+ body {
32
+ shell {
33
+ minimum_size 220, 0
34
+ grid_layout
35
+
36
+ text 'Hello, Color Dialog!'
37
+
38
+ label {
39
+ layout_data :center, :center, true, false
40
+ text 'Selected Color:'
41
+ font height: 14, style: :bold
42
+ }
43
+
44
+ canvas(:border) {
45
+ layout_data :center, :center, true, false
46
+ background bind(self, :selected_color)
47
+
48
+ on_mouse_up {
49
+ self.selected_color = color_dialog.open
50
+ }
51
+ }
52
+
53
+ button {
54
+ layout_data :center, :center, true, false
55
+ text "Choose Color..."
56
+
57
+ on_widget_selected {
58
+ self.selected_color = color_dialog.open
59
+ }
60
+ }
61
+
62
+ }
63
+ }
48
64
  end
65
+
66
+ HelloColorDialog.launch
@@ -0,0 +1,82 @@
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
+ class HelloFontDialog
23
+ include Glimmer::UI::CustomShell
24
+
25
+ attr_accessor :selected_font_data
26
+
27
+ before_body {
28
+ @selected_font_data = FontData.new('Times New Roman', 40, swt(:bold))
29
+ }
30
+
31
+ body {
32
+ shell {
33
+ grid_layout {
34
+ margin_width 15
35
+ margin_width 15
36
+ }
37
+ minimum_size 400, 0
38
+
39
+ text 'Hello, Font Dialog!'
40
+
41
+ label {
42
+ text 'Selected Font:'
43
+ font height: 14, style: :bold
44
+ }
45
+
46
+ label(:center) {
47
+ layout_data(:fill, :center, true, true) {
48
+ vertical_indent 15
49
+ height_hint 200
50
+ }
51
+ background :white
52
+ font bind(self, 'selected_font_data')
53
+ text bind(self, 'selected_font_data') {|font_data|
54
+ style = case font_data.style
55
+ when swt(:normal)
56
+ 'Normal'
57
+ when swt(:italic)
58
+ 'Italic'
59
+ when swt(:bold)
60
+ 'Bold'
61
+ when swt(:bold, :italic)
62
+ 'Bold Italic'
63
+ end
64
+ "#{font_data.name}\n#{font_data.height}\n#{style}"
65
+ }
66
+ }
67
+
68
+ button {
69
+ text "Choose Font..."
70
+
71
+ on_widget_selected {
72
+ self.selected_font_data = font_dialog {
73
+ font_list [@selected_font_data]
74
+ }.open
75
+ }
76
+ }
77
+
78
+ }
79
+ }
80
+ end
81
+
82
+ HelloFontDialog.launch
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.18.5.0
4
+ version: 4.18.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -388,13 +388,11 @@ files:
388
388
  - lib/glimmer/dsl/swt/custom_widget_expression.rb
389
389
  - lib/glimmer/dsl/swt/data_binding_expression.rb
390
390
  - lib/glimmer/dsl/swt/dialog_expression.rb
391
- - lib/glimmer/dsl/swt/directory_dialog_expression.rb
392
391
  - lib/glimmer/dsl/swt/display_expression.rb
393
392
  - lib/glimmer/dsl/swt/dnd_expression.rb
394
393
  - lib/glimmer/dsl/swt/dsl.rb
395
394
  - lib/glimmer/dsl/swt/exec_expression.rb
396
395
  - lib/glimmer/dsl/swt/expand_item_expression.rb
397
- - lib/glimmer/dsl/swt/file_dialog_expression.rb
398
396
  - lib/glimmer/dsl/swt/font_expression.rb
399
397
  - lib/glimmer/dsl/swt/image_expression.rb
400
398
  - lib/glimmer/dsl/swt/layout_data_expression.rb
@@ -446,11 +444,10 @@ files:
446
444
  - lib/glimmer/swt/custom/shape/rectangle.rb
447
445
  - lib/glimmer/swt/custom/shape/text.rb
448
446
  - lib/glimmer/swt/date_time_proxy.rb
449
- - lib/glimmer/swt/directory_dialog_proxy.rb
447
+ - lib/glimmer/swt/dialog_proxy.rb
450
448
  - lib/glimmer/swt/display_proxy.rb
451
449
  - lib/glimmer/swt/dnd_proxy.rb
452
450
  - lib/glimmer/swt/expand_item_proxy.rb
453
- - lib/glimmer/swt/file_dialog_proxy.rb
454
451
  - lib/glimmer/swt/font_proxy.rb
455
452
  - lib/glimmer/swt/image_proxy.rb
456
453
  - lib/glimmer/swt/layout_data_proxy.rb
@@ -459,6 +456,7 @@ files:
459
456
  - lib/glimmer/swt/message_box_proxy.rb
460
457
  - lib/glimmer/swt/packages.rb
461
458
  - lib/glimmer/swt/properties.rb
459
+ - lib/glimmer/swt/proxy_properties.rb
462
460
  - lib/glimmer/swt/sash_form_proxy.rb
463
461
  - lib/glimmer/swt/scrolled_composite_proxy.rb
464
462
  - lib/glimmer/swt/shell_proxy.rb
@@ -505,6 +503,7 @@ files:
505
503
  - samples/hello/hello_checkbox.rb
506
504
  - samples/hello/hello_checkbox_group.rb
507
505
  - samples/hello/hello_code_text.rb
506
+ - samples/hello/hello_color_dialog.rb
508
507
  - samples/hello/hello_combo.rb
509
508
  - samples/hello/hello_computed.rb
510
509
  - samples/hello/hello_computed/contact.rb
@@ -517,6 +516,7 @@ files:
517
516
  - samples/hello/hello_drag_and_drop.rb
518
517
  - samples/hello/hello_expand_bar.rb
519
518
  - samples/hello/hello_file_dialog.rb
519
+ - samples/hello/hello_font_dialog.rb
520
520
  - samples/hello/hello_group.rb
521
521
  - samples/hello/hello_link.rb
522
522
  - samples/hello/hello_list_multi_selection.rb