glimmer-dsl-swt 4.17.2.1 → 4.17.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,166 @@
1
+ class Sample
2
+ attr_accessor :sample_directory, :file, :selected
3
+
4
+ def initialize(file, sample_directory: )
5
+ self.file = file
6
+ self.sample_directory = sample_directory
7
+ end
8
+
9
+ def name
10
+ if @name.nil?
11
+ @name = File.basename(file, '.rb').split('_').map(&:capitalize).join(' ')
12
+ if @name.start_with?('Hello')
13
+ name_parts = @name.split
14
+ name_parts[0] = name_parts.first + ','
15
+ name_parts[-1] = name_parts.last + '!'
16
+ @name = name_parts.join(' ')
17
+ end
18
+ end
19
+ @name
20
+ end
21
+
22
+ def content
23
+ @content ||= File.read(file)
24
+ end
25
+
26
+ def launch
27
+ load file
28
+ end
29
+ end
30
+
31
+ class SampleDirectory
32
+ class << self
33
+ attr_accessor :selected_sample
34
+
35
+ def sample_directories
36
+ if @sample_directories.nil?
37
+ @sample_directories = Dir.glob(File.join(File.expand_path('..', __FILE__), '*')).
38
+ select { |file| File.directory?(file) }.
39
+ map { |file| SampleDirectory.new(file) }
40
+ glimmer_gems = Gem.find_latest_files("glimmer-*-*")
41
+ sample_directories = glimmer_gems.map do |lib|
42
+ File.dirname(File.dirname(lib))
43
+ end.select do |gem|
44
+ Dir.exist?(File.join(gem, 'samples'))
45
+ end.map do |gem|
46
+ Dir.glob(File.join(gem, 'samples', '*')).select {|file_or_dir| Dir.exist?(file_or_dir)}
47
+ end.flatten.uniq.reverse
48
+ if Dir.exist?('samples')
49
+ Dir.glob(File.join('samples', '*')).to_a.reverse.each do |dir|
50
+ sample_directories << dir if Dir.exist?(dir)
51
+ end
52
+ end
53
+ sample_directories = sample_directories.uniq {|dir| File.basename(dir)}
54
+ @sample_directories = sample_directories.map { |file| SampleDirectory.new(file) }
55
+ end
56
+ @sample_directories
57
+ end
58
+
59
+ def all_samples
60
+ @all_samples ||= sample_directories.map(&:samples).reduce(:+)
61
+ end
62
+ end
63
+
64
+ include Glimmer # used for observe syntax
65
+
66
+ attr_accessor :file
67
+
68
+ def initialize(file)
69
+ self.file = file
70
+ end
71
+
72
+ def name
73
+ File.basename(file).split('_').map(&:capitalize).join(' ')
74
+ end
75
+
76
+ def samples
77
+ if @samples.nil?
78
+ @samples = Dir.glob(File.join(file, '*')).
79
+ select { |file| File.file?(file) }.
80
+ map { |sample_file| Sample.new(sample_file, sample_directory: self) }.
81
+ sort_by(&:name)
82
+
83
+ @samples.each do |sample|
84
+ observe(sample, :selected) do |new_selected_value|
85
+ if new_selected_value
86
+ self.class.all_samples.reject {|a_sample| a_sample.name == sample.name}.each do |other_sample|
87
+ other_sample.selected = false
88
+ end
89
+ self.class.selected_sample = sample
90
+ end
91
+ end
92
+ end
93
+ end
94
+ @samples
95
+ end
96
+ end
97
+
98
+ class MetaSampleApplication
99
+ include Glimmer
100
+
101
+ def launch
102
+ shell {
103
+ text 'Glimmer Meta-Sample (The Sample of Samples)'
104
+
105
+ on_swt_show {
106
+ SampleDirectory.selected_sample = SampleDirectory.all_samples.first
107
+ }
108
+
109
+ sash_form {
110
+ composite {
111
+ grid_layout 1, false
112
+
113
+ scrolled_composite {
114
+ layout_data(:fill, :fill, true, true)
115
+
116
+ composite {
117
+ SampleDirectory.sample_directories.each { |sample_directory|
118
+ group {
119
+ layout_data(:fill, :fill, true, true)
120
+ grid_layout 2, false
121
+ text sample_directory.name
122
+ font height: 30
123
+
124
+ sample_directory.samples.each { |sample|
125
+ label_radio = radio {
126
+ selection bind(sample, :selected)
127
+ }
128
+ label {
129
+ text sample.name
130
+ font height: 30
131
+
132
+ on_mouse_up {
133
+ sample.selected = true
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ button {
143
+ layout_data(:center, :center, false, false) {
144
+ height_hint 150
145
+ }
146
+ text 'Launch Sample'
147
+ font height: 45
148
+ on_widget_selected {
149
+ SampleDirectory.selected_sample.launch
150
+ }
151
+ }
152
+ }
153
+
154
+ code_text {
155
+ text bind(SampleDirectory, 'selected_sample.content')
156
+ editable false
157
+ caret nil
158
+ }
159
+
160
+ weights 1, 2
161
+ }
162
+ }.open
163
+ end
164
+ end
165
+
166
+ MetaSampleApplication.new.launch
@@ -23,30 +23,34 @@ class Person
23
23
  attr_accessor :country, :country_options
24
24
 
25
25
  def initialize
26
- self.country_options=["", "Canada", "US", "Mexico"]
27
- self.country = "Canada"
26
+ self.country_options = ['', 'Canada', 'US', 'Mexico']
27
+ reset_country
28
28
  end
29
29
 
30
30
  def reset_country
31
- self.country = "Canada"
31
+ self.country = 'Canada'
32
32
  end
33
33
  end
34
34
 
35
35
  class HelloCombo
36
36
  include Glimmer
37
+
37
38
  def launch
38
39
  person = Person.new
39
40
 
40
41
  shell {
41
- fill_layout :vertical
42
- text 'Hello, Combo!'
42
+ row_layout(:vertical) {
43
+ pack false
44
+ }
45
+
46
+ text 'Hello, Combo!'
43
47
 
44
48
  combo(:read_only) {
45
49
  selection bind(person, :country)
46
50
  }
47
51
 
48
52
  button {
49
- text "Reset Selection"
53
+ text 'Reset Selection'
50
54
 
51
55
  on_widget_selected do
52
56
  person.reset_country
@@ -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 'date'
2
23
 
3
24
  # This class declares an `email_shell` custom shell, aka custom window (by convention)
@@ -53,7 +74,7 @@ class EmailShell
53
74
  label {
54
75
  layout_data(:fill, :fill, true, true) {
55
76
  horizontal_span 2
56
- verticalIndent 10
77
+ vertical_indent 10
57
78
  }
58
79
 
59
80
  background :white
@@ -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
  # This class declares a `greeting_label` custom widget (by convention)
2
23
  class GreetingLabel
3
24
  include Glimmer::UI::CustomWidget
@@ -0,0 +1,137 @@
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
+
22
+ class SashFormPresenter
23
+ include Glimmer
24
+
25
+ attr_accessor :sash_width, :orientation, :orientation_style
26
+
27
+ def initialize
28
+ @sash_width = 10
29
+ self.orientation = 'horizontal'
30
+ end
31
+
32
+ def orientation_options
33
+ ['horizontal', 'vertical']
34
+ end
35
+
36
+ def orientation=(value)
37
+ @orientation = value
38
+ self.orientation_style = swt(@orientation)
39
+ end
40
+ end
41
+
42
+ @presenter = SashFormPresenter.new
43
+
44
+ include Glimmer
45
+
46
+ shell {
47
+ grid_layout 1, false
48
+ minimum_size 740, 0
49
+ text 'Hello, Sash Form!'
50
+
51
+ @sash_form = sash_form {
52
+ layout_data(:fill, :fill, true, true) {
53
+ height_hint 200
54
+ }
55
+ sash_width bind(@presenter, :sash_width)
56
+ orientation bind(@presenter, :orientation_style)
57
+ weights 1, 2
58
+
59
+ @green_label = label {
60
+ text 'Hello, (resize >>)'
61
+ background :dark_green
62
+ foreground :white
63
+ font height: 30
64
+ }
65
+
66
+ @red_label = label {
67
+ text '(<< resize) Sash Form!'
68
+ background :red
69
+ foreground :white
70
+ font height: 30
71
+ }
72
+ }
73
+
74
+ composite {
75
+ layout_data(:fill, :fill, true, true)
76
+ grid_layout 2, true
77
+
78
+ label {
79
+ layout_data(:right, :center, true, false)
80
+ text 'Sash Width:'
81
+ font height: 16
82
+ }
83
+ spinner {
84
+ layout_data(:fill, :center, true, false) {
85
+ width_hint 100
86
+ }
87
+ selection bind(@presenter, :sash_width)
88
+ font height: 16
89
+ }
90
+
91
+ label {
92
+ layout_data(:right, :center, true, false)
93
+ text 'Orientation:'
94
+ font height: 16
95
+ }
96
+ combo(:read_only, :border) {
97
+ layout_data(:fill, :center, true, false) {
98
+ width_hint 100
99
+ }
100
+ selection bind(@presenter, :orientation)
101
+ font height: 16
102
+ }
103
+
104
+ button {
105
+ layout_data(:fill, :center, true, false)
106
+ text 'Maximize Green Label'
107
+ foreground :dark_green
108
+ font height: 16
109
+
110
+ on_widget_selected {
111
+ @sash_form.maximized_control = @green_label.swt_widget
112
+ }
113
+ }
114
+ button {
115
+ layout_data(:fill, :center, true, false)
116
+ text 'Maximize Red Label'
117
+ foreground :red
118
+ font height: 16
119
+
120
+ on_widget_selected {
121
+ @sash_form.maximized_control = @red_label.swt_widget
122
+ }
123
+ }
124
+
125
+ button {
126
+ layout_data(:fill, :center, true, false) {
127
+ horizontal_span 2
128
+ }
129
+ text 'Maximize None'
130
+ font height: 16
131
+
132
+ on_widget_selected {
133
+ @sash_form.maximized_control = nil
134
+ }
135
+ }
136
+ }
137
+ }.open
@@ -21,20 +21,25 @@
21
21
 
22
22
  class HelloTab
23
23
  include Glimmer
24
+
24
25
  def launch
25
26
  shell {
26
- text "Hello, Tab!"
27
+ text 'Hello, Tab!'
28
+
27
29
  tab_folder {
28
30
  tab_item {
29
- text "English"
31
+ text 'English'
32
+
30
33
  label {
31
- text "Hello, World!"
34
+ text 'Hello, World!'
32
35
  }
33
36
  }
37
+
34
38
  tab_item {
35
- text "French"
39
+ text 'French'
40
+
36
41
  label {
37
- text "Bonjour, Univers!"
42
+ text 'Bonjour, Univers!'
38
43
  }
39
44
  }
40
45
  }
@@ -22,8 +22,8 @@
22
22
  include Glimmer
23
23
 
24
24
  shell {
25
- text "Glimmer"
25
+ text 'Glimmer'
26
26
  label {
27
- text "Hello, World!"
27
+ text 'Hello, World!'
28
28
  }
29
29
  }.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.17.2.1
4
+ version: 4.17.4.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-10-02 00:00:00.000000000 Z
11
+ date: 2020-10-21 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.0
18
+ version: 1.0.1
19
19
  name: glimmer
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.10.1
60
+ version: 0.10.2
61
61
  name: puts_debuggerer
62
62
  prerelease: false
63
63
  type: :runtime
@@ -65,7 +65,7 @@ dependencies:
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.10.1
68
+ version: 0.10.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
@@ -185,21 +185,21 @@ dependencies:
185
185
  requirements:
186
186
  - - ">="
187
187
  - !ruby/object:Gem::Version
188
- version: 0.6.0
188
+ version: 3.23.0
189
189
  - - "<"
190
190
  - !ruby/object:Gem::Version
191
- version: 2.0.0
192
- name: tty-markdown
191
+ version: 4.0.0
192
+ name: rouge
193
193
  prerelease: false
194
194
  type: :runtime
195
195
  version_requirements: !ruby/object:Gem::Requirement
196
196
  requirements:
197
197
  - - ">="
198
198
  - !ruby/object:Gem::Version
199
- version: 0.6.0
199
+ version: 3.23.0
200
200
  - - "<"
201
201
  - !ruby/object:Gem::Version
202
- version: 2.0.0
202
+ version: 4.0.0
203
203
  - !ruby/object:Gem::Dependency
204
204
  requirement: !ruby/object:Gem::Requirement
205
205
  requirements:
@@ -381,10 +381,10 @@ files:
381
381
  - lib/glimmer/rake_task.rb
382
382
  - lib/glimmer/rake_task/list.rb
383
383
  - lib/glimmer/rake_task/package.rb
384
- - lib/glimmer/rake_task/sample.rb
385
384
  - lib/glimmer/rake_task/scaffold.rb
386
385
  - lib/glimmer/swt/color_proxy.rb
387
386
  - lib/glimmer/swt/cursor_proxy.rb
387
+ - lib/glimmer/swt/custom/code_text.rb
388
388
  - lib/glimmer/swt/display_proxy.rb
389
389
  - lib/glimmer/swt/dnd_proxy.rb
390
390
  - lib/glimmer/swt/font_proxy.rb
@@ -394,6 +394,7 @@ files:
394
394
  - lib/glimmer/swt/menu_proxy.rb
395
395
  - lib/glimmer/swt/message_box_proxy.rb
396
396
  - lib/glimmer/swt/packages.rb
397
+ - lib/glimmer/swt/sash_form_proxy.rb
397
398
  - lib/glimmer/swt/scrolled_composite_proxy.rb
398
399
  - lib/glimmer/swt/shell_proxy.rb
399
400
  - lib/glimmer/swt/style_constantizable.rb
@@ -412,6 +413,7 @@ files:
412
413
  - samples/elaborate/contact_manager/contact_manager_presenter.rb
413
414
  - samples/elaborate/contact_manager/contact_repository.rb
414
415
  - samples/elaborate/login.rb
416
+ - samples/elaborate/meta_sample.rb
415
417
  - samples/elaborate/tic_tac_toe.rb
416
418
  - samples/elaborate/tic_tac_toe/board.rb
417
419
  - samples/elaborate/tic_tac_toe/cell.rb
@@ -428,6 +430,7 @@ files:
428
430
  - samples/hello/hello_menu_bar.rb
429
431
  - samples/hello/hello_message_box.rb
430
432
  - samples/hello/hello_pop_up_context_menu.rb
433
+ - samples/hello/hello_sash_form.rb
431
434
  - samples/hello/hello_tab.rb
432
435
  - samples/hello/hello_world.rb
433
436
  - vendor/swt/linux/swt.jar