glimmer-dsl-swt 4.18.7.5 → 4.19.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/README.md +29 -11
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/bin/girb +10 -9
- data/bin/girb_runner.rb +8 -3
- data/bin/glimmer +10 -1
- data/bin/glimmer-setup +58 -0
- data/bin/glimmer_runner.rb +4 -0
- data/docs/reference/GLIMMER_COMMAND.md +21 -31
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +6 -2
- data/docs/reference/GLIMMER_PACKAGING_AND_DISTRIBUTION.md +7 -1
- data/docs/reference/GLIMMER_SAMPLES.md +27 -0
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +8 -0
- data/lib/glimmer/data_binding/widget_binding.rb +1 -1
- data/lib/glimmer/dsl/swt/c_tab_item_expression.rb +58 -0
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +2 -1
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +7 -3
- data/lib/glimmer/dsl/swt/widget_expression.rb +1 -1
- data/lib/glimmer/launcher.rb +27 -51
- data/lib/glimmer/rake_task.rb +1 -1
- data/lib/glimmer/rake_task/package.rb +7 -2
- data/lib/glimmer/rake_task/scaffold.rb +227 -254
- data/lib/glimmer/swt/c_tab_item_proxy.rb +53 -0
- data/lib/glimmer/swt/custom/code_text.rb +19 -3
- data/lib/glimmer/swt/custom/shape.rb +15 -1
- data/lib/glimmer/swt/sash_form_proxy.rb +6 -0
- data/lib/glimmer/swt/shell_proxy.rb +3 -1
- data/lib/glimmer/swt/tab_folder_proxy.rb +1 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +17 -18
- data/lib/glimmer/swt/widget_proxy.rb +9 -0
- data/samples/elaborate/mandelbrot_fractal.rb +11 -6
- data/samples/elaborate/meta_sample.rb +4 -2
- data/samples/elaborate/metronome.rb +1 -1
- data/samples/elaborate/stock_ticker.rb +2 -2
- data/samples/hello/hello_c_combo.rb +68 -0
- data/samples/hello/hello_c_tab.rb +173 -0
- data/samples/hello/hello_c_tab/denmark.png +0 -0
- data/samples/hello/hello_c_tab/finland.png +0 -0
- data/samples/hello/hello_c_tab/france.png +0 -0
- data/samples/hello/hello_c_tab/germany.png +0 -0
- data/samples/hello/hello_c_tab/italy.png +0 -0
- data/samples/hello/hello_c_tab/mexico.png +0 -0
- data/samples/hello/hello_c_tab/netherlands.png +0 -0
- data/samples/hello/hello_c_tab/norway.png +0 -0
- data/samples/hello/hello_c_tab/usa.png +0 -0
- data/samples/hello/hello_code_text.rb +141 -73
- data/samples/hello/hello_shape.rb +1 -0
- data/samples/hello/hello_tab.rb +2 -0
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +75 -34
@@ -368,7 +368,7 @@ These proxy objects have an API and provide some convenience methods, some of wh
|
|
368
368
|
|
369
369
|
Glimmer SWT proxies come with the instance method `#swt_widget`, which returns the actual SWT `Widget` object wrapped by the Glimmer widget proxy. It is useful in cases you'd like to do some custom SWT programming outside of Glimmer.
|
370
370
|
|
371
|
-
##### Shell
|
371
|
+
##### Shell Widget Proxy Methods
|
372
372
|
|
373
373
|
Shell widget proxy has extra methods specific to SWT Shell:
|
374
374
|
- `#open`: Opens the shell, making it visible and active, and starting the SWT Event Loop (you may learn more about it here: https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html). If shell was already open, but hidden, it makes the shell visible.
|
@@ -1040,6 +1040,10 @@ shell(:no_resize) {
|
|
1040
1040
|
}
|
1041
1041
|
```
|
1042
1042
|
|
1043
|
+
##### Fill Screen Window
|
1044
|
+
|
1045
|
+
SWT Shell can open and fill the screen with this style `swt(:fill_screen)`. This makes it have the size of the display, thus filling the screen. Keep in mind that this is different from being maximized (which is a special window state, not just filling the screen).
|
1046
|
+
|
1043
1047
|
### Widget Properties
|
1044
1048
|
|
1045
1049
|
Widget properties such as text value, enablement, visibility, and layout details are set within the widget block using methods matching SWT widget property names in lower snakecase. You may refer to SWT widget guide for details on available widget properties:
|
@@ -3471,7 +3475,7 @@ shell { |app_shell|
|
|
3471
3475
|
}.open
|
3472
3476
|
```
|
3473
3477
|
|
3474
|
-
If you use a Custom Shell as the top-level app shell, you may invoke the class method
|
3478
|
+
If you use a Custom Shell as the top-level app shell, you may invoke the class method `.launch` instead to avoid building an app class yourself or including Glimmer into the top-level namespace (e.g. `Tetris.launch` instead of `include Glimmer; tetris.open`)
|
3475
3479
|
|
3476
3480
|
You may check out [Hello, Custom Shell!](GLIMMER_SAMPLES.md#hello-custom-shell) for another example.
|
3477
3481
|
|
@@ -20,6 +20,12 @@ You may choose to generate a specific type of packaging instead by addionally pa
|
|
20
20
|
glimmer package[msi]
|
21
21
|
```
|
22
22
|
|
23
|
+
Make sure to surround with double-quotes when running from ZShell (zsh):
|
24
|
+
|
25
|
+
```
|
26
|
+
glimmer "package[msi]"
|
27
|
+
```
|
28
|
+
|
23
29
|
- Available Mac packaging types are `dmg`, `pkg`, and `image` (image means a pure Mac `app` without a setup program). Keep in mind that the packages you produce are compatible with the same MacOS you are on or older.
|
24
30
|
- Available Windows packaging types are `msi`, `exe`, and `image` (image means a Windows application directory without a setup program). Learn more about Windows packaging are [over here](#windows-application-packaging).
|
25
31
|
|
@@ -190,7 +196,7 @@ Currently, `Glimmer::RakeTask::Package.javapackager_extra_args` is only honored
|
|
190
196
|
You can get around that in zsh by running glimmer package commands with `bash -c` prefix:
|
191
197
|
|
192
198
|
```
|
193
|
-
bash -c 'glimmer package'
|
199
|
+
bash -c 'source ~/.glimmer_source; glimmer package'
|
194
200
|
```
|
195
201
|
|
196
202
|
4. Java on Windows System PATH
|
@@ -2,7 +2,9 @@
|
|
2
2
|
- [Hello Samples](#hello-samples)
|
3
3
|
- [Hello, World!](#hello-world)
|
4
4
|
- [Hello, Tab!](#hello-tab)
|
5
|
+
- [Hello, C Tab!](#hello-c-tab)
|
5
6
|
- [Hello, Combo!](#hello-combo)
|
7
|
+
- [Hello, C Combo!](#hello-c-combo)
|
6
8
|
- [Hello, List Single Selection!](#hello-list-single-selection)
|
7
9
|
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
8
10
|
- [Hello, Computed!](#hello-computed)
|
@@ -101,6 +103,20 @@ Code:
|
|
101
103
|
![Hello Tab English](/images/glimmer-hello-tab-english.png)
|
102
104
|
![Hello Tab French](/images/glimmer-hello-tab-french.png)
|
103
105
|
|
106
|
+
#### Hello, C Tab!
|
107
|
+
|
108
|
+
This sample demonstrates custom tab widget usage via the `c_tab_folder` and `c_tab_item` variations of `tab_folder` and `tab_item`, which can customize fonts/background/foreground colors for tabs and display additional tabs that do not fit in the window via a drop down.
|
109
|
+
|
110
|
+
Code:
|
111
|
+
|
112
|
+
[samples/hello/hello_c_tab.rb](/samples/hello/hello_c_tab.rb)
|
113
|
+
|
114
|
+
![Hello C Tab](/images/glimmer-hello-c-tab.png)
|
115
|
+
![Hello C Tab Extra Tabs](/images/glimmer-hello-c-tab-extra-tabs.png)
|
116
|
+
![Hello C Tab Other Tab](/images/glimmer-hello-c-tab-other-tab.png)
|
117
|
+
|
118
|
+
Country flag images were made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](http://www.flaticon.com)
|
119
|
+
|
104
120
|
#### Hello, Combo!
|
105
121
|
|
106
122
|
This sample demonstrates combo data-binding.
|
@@ -112,6 +128,17 @@ Code:
|
|
112
128
|
![Hello Combo](/images/glimmer-hello-combo.png)
|
113
129
|
![Hello Combo Expanded](/images/glimmer-hello-combo-expanded.png)
|
114
130
|
|
131
|
+
#### Hello, C Combo!
|
132
|
+
|
133
|
+
This sample demonstrates the custom combo variation on combo, which allows the adjustment of the combo height based on font height or layout data.
|
134
|
+
|
135
|
+
Code:
|
136
|
+
|
137
|
+
[samples/hello/hello_c_combo.rb](/samples/hello/hello_c_combo.rb)
|
138
|
+
|
139
|
+
![Hello Combo](/images/glimmer-hello-c-combo.png)
|
140
|
+
![Hello Combo Expanded](/images/glimmer-hello-c-combo-expanded.png)
|
141
|
+
|
115
142
|
#### Hello, List Single Selection!
|
116
143
|
|
117
144
|
This sample demonstrates list single-selection data-binding.
|
data/glimmer-dsl-swt.gemspec
CHANGED
Binary file
|
data/lib/glimmer-dsl-swt.rb
CHANGED
@@ -53,7 +53,7 @@ module Glimmer
|
|
53
53
|
return
|
54
54
|
end
|
55
55
|
# need the rescue false for a scenario with tree items not being equal to model objects raising an exception
|
56
|
-
|
56
|
+
if @async_exec || !((value == evaluate_property) rescue false) # need the rescue false for a scenario with tree items not being equal to model objects raising an exception
|
57
57
|
@widget.set_attribute(@property, value)
|
58
58
|
end
|
59
59
|
end
|
@@ -0,0 +1,58 @@
|
|
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'
|
23
|
+
require 'glimmer/dsl/static_expression'
|
24
|
+
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/widget_proxy'
|
26
|
+
require 'glimmer/swt/c_tab_item_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module SWT
|
31
|
+
class CTabItemExpression < StaticExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
include_package 'org.eclipse.swt.custom'
|
35
|
+
|
36
|
+
def can_interpret?(parent, keyword, *args, &block)
|
37
|
+
initial_condition = (keyword == 'c_tab_item') and parent.respond_to?(:swt_widget)
|
38
|
+
if initial_condition
|
39
|
+
if parent.swt_widget.is_a?(CTabFolder)
|
40
|
+
return true
|
41
|
+
else
|
42
|
+
Glimmer::Config.logger.error {"c_tab_item widget may only be used directly under a c_tab_folder widget!"}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
def interpret(parent, keyword, *args, &block)
|
49
|
+
Glimmer::SWT::CTabItemProxy.new(parent, args)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -29,12 +29,13 @@ module Glimmer
|
|
29
29
|
module SWT
|
30
30
|
class ComboSelectionDataBindingExpression < Expression
|
31
31
|
include_package 'org.eclipse.swt.widgets'
|
32
|
+
include_package 'org.eclipse.swt.custom'
|
32
33
|
|
33
34
|
def can_interpret?(parent, keyword, *args, &block)
|
34
35
|
keyword == 'selection' and
|
35
36
|
block.nil? and
|
36
37
|
parent.respond_to?(:swt_widget) and
|
37
|
-
parent.swt_widget.is_a?(Combo) and
|
38
|
+
(parent.swt_widget.is_a?(Combo) || parent.swt_widget.is_a?(CCombo)) and
|
38
39
|
args.size == 1 and
|
39
40
|
args[0].is_a?(DataBinding::ModelBinding) and
|
40
41
|
args[0].evaluate_options_property.is_a?(Array)
|
@@ -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
|
@@ -48,7 +48,11 @@ module Glimmer
|
|
48
48
|
def interpret(parent, keyword, *args, &block)
|
49
49
|
Glimmer::SWT::TabItemProxy.new(parent, args)
|
50
50
|
end
|
51
|
+
|
51
52
|
end
|
53
|
+
|
52
54
|
end
|
55
|
+
|
53
56
|
end
|
57
|
+
|
54
58
|
end
|
@@ -30,7 +30,7 @@ module Glimmer
|
|
30
30
|
class WidgetExpression < Expression
|
31
31
|
include ParentExpression
|
32
32
|
|
33
|
-
EXCLUDED_KEYWORDS = %w[shell display tab_item] + Glimmer::SWT::Custom::Shape.keywords - ['text']
|
33
|
+
EXCLUDED_KEYWORDS = %w[shell display tab_item c_tab_item] + Glimmer::SWT::Custom::Shape.keywords - ['text']
|
34
34
|
|
35
35
|
def can_interpret?(parent, keyword, *args, &block)
|
36
36
|
!EXCLUDED_KEYWORDS.include?(keyword) and
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -35,7 +35,7 @@ module Glimmer
|
|
35
35
|
|
36
36
|
TEXT_USAGE = <<~MULTI_LINE_STRING
|
37
37
|
Glimmer (JRuby Desktop Development GUI Framework) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
|
38
|
-
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args])
|
38
|
+
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args])
|
39
39
|
|
40
40
|
Runs Glimmer applications and tasks.
|
41
41
|
|
@@ -67,8 +67,6 @@ module Glimmer
|
|
67
67
|
}
|
68
68
|
REGEX_RAKE_TASK_WITH_ARGS = /^([^\[]+)\[?([^\]]*)\]?$/
|
69
69
|
|
70
|
-
@@mutex = Mutex.new
|
71
|
-
|
72
70
|
class << self
|
73
71
|
def platform_os
|
74
72
|
OPERATING_SYSTEMS_SUPPORTED.detect {|os| OS.send("#{os}?")}
|
@@ -83,14 +81,12 @@ module Glimmer
|
|
83
81
|
end
|
84
82
|
|
85
83
|
def glimmer_lib
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
|
93
|
-
end
|
84
|
+
unless @glimmer_lib
|
85
|
+
@glimmer_lib = GLIMMER_LIB_GEM
|
86
|
+
glimmer_gem_listing = `jgem list #{GLIMMER_LIB_GEM}`.split("\n").map {|l| l.split.first}
|
87
|
+
if !glimmer_gem_listing.include?(GLIMMER_LIB_GEM) && File.exists?(GLIMMER_LIB_LOCAL)
|
88
|
+
@glimmer_lib = GLIMMER_LIB_LOCAL
|
89
|
+
puts "[DEVELOPMENT MODE] (detected #{@glimmer_lib})"
|
94
90
|
end
|
95
91
|
end
|
96
92
|
@glimmer_lib
|
@@ -115,17 +111,12 @@ module Glimmer
|
|
115
111
|
def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
|
116
112
|
jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
|
117
113
|
env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
else
|
122
|
-
"export #{k}=#{v} && "
|
123
|
-
end
|
124
|
-
end.join
|
114
|
+
env_vars.each do |k,v|
|
115
|
+
ENV[k] = v
|
116
|
+
end
|
125
117
|
the_glimmer_lib = glimmer_lib
|
126
|
-
devmode_require = nil
|
127
118
|
if the_glimmer_lib == GLIMMER_LIB_LOCAL
|
128
|
-
|
119
|
+
require 'puts_debuggerer'
|
129
120
|
end
|
130
121
|
require_relative 'rake_task'
|
131
122
|
rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
|
@@ -142,20 +133,9 @@ module Glimmer
|
|
142
133
|
puts "Running Glimmer rake task: #{rake_task}" if jruby_options_string.to_s.include?('--debug')
|
143
134
|
Rake::Task[rake_task].invoke(*rake_task_args)
|
144
135
|
else
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
|
149
|
-
if !env_vars_string.empty? && OS.windows?
|
150
|
-
command = "bash -c \"#{command}\"" if ENV['SHELL'] # do in Windows Git Bash only
|
151
|
-
command = "cmd /C \"#{command}\"" if ENV['PROMPT'] # do in Windows Command Prompt only (or Powershell)
|
152
|
-
end
|
153
|
-
puts command if jruby_options_string.to_s.include?('--debug')
|
154
|
-
if command.include?(' irb ')
|
155
|
-
exec command
|
156
|
-
else
|
157
|
-
system command
|
158
|
-
end
|
136
|
+
puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
|
137
|
+
require the_glimmer_lib
|
138
|
+
load File.expand_path(application)
|
159
139
|
end
|
160
140
|
end
|
161
141
|
end
|
@@ -168,14 +148,14 @@ module Glimmer
|
|
168
148
|
def initialize(raw_options)
|
169
149
|
raw_options << '--quiet' if !caller.join("\n").include?('/bin/glimmer:') && !raw_options.join.include?('--quiet=')
|
170
150
|
raw_options << '--log-level=DEBUG' if raw_options.join.include?('--debug') && !raw_options.join.include?('--log-level=')
|
171
|
-
@
|
151
|
+
@application_path = extract_application_path(raw_options)
|
172
152
|
@env_vars = extract_env_vars(raw_options)
|
173
153
|
@glimmer_options = extract_glimmer_options(raw_options)
|
174
154
|
@jruby_options = raw_options
|
175
155
|
end
|
176
156
|
|
177
157
|
def launch
|
178
|
-
if @
|
158
|
+
if @application_path.nil?
|
179
159
|
display_usage
|
180
160
|
else
|
181
161
|
launch_application
|
@@ -185,18 +165,13 @@ module Glimmer
|
|
185
165
|
private
|
186
166
|
|
187
167
|
def launch_application
|
188
|
-
load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
glimmer_options: @glimmer_options
|
196
|
-
)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
threads.each(&:join)
|
168
|
+
load File.expand_path('./Rakefile') if File.exist?(File.expand_path('./Rakefile')) && caller.join("\n").include?('/bin/glimmer_runner.rb:')
|
169
|
+
self.class.launch(
|
170
|
+
@application_path,
|
171
|
+
jruby_options: @jruby_options,
|
172
|
+
env_vars: @env_vars,
|
173
|
+
glimmer_options: @glimmer_options
|
174
|
+
)
|
200
175
|
end
|
201
176
|
|
202
177
|
def display_usage
|
@@ -232,10 +207,11 @@ module Glimmer
|
|
232
207
|
end
|
233
208
|
end
|
234
209
|
|
235
|
-
|
236
|
-
|
210
|
+
# Extract application path (which can also be a rake task, basically a non-arg)
|
211
|
+
def extract_application_path(options)
|
212
|
+
application_path = options.detect do |option|
|
237
213
|
!option.start_with?('-') && !option.include?('=')
|
238
|
-
end.
|
214
|
+
end.tap do
|
239
215
|
options.delete(application_path)
|
240
216
|
end
|
241
217
|
end
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -100,7 +100,7 @@ namespace :glimmer do
|
|
100
100
|
|
101
101
|
desc 'Generate Native files. type can be dmg/pkg on the Mac, msi/exe on Windows, and rpm/deb on Linux (type is optional)'
|
102
102
|
task :native, [:type] do |t, args|
|
103
|
-
extra_args = ARGV.partition {|arg| arg.
|
103
|
+
extra_args = ARGV.partition {|arg| arg.start_with?('package')}.last.to_a.join(' ')
|
104
104
|
Glimmer::RakeTask::Package.native(args[:type], extra_args)
|
105
105
|
end
|
106
106
|
end
|
@@ -90,8 +90,12 @@ module Glimmer
|
|
90
90
|
|
91
91
|
def native(native_type=nil, native_extra_args)
|
92
92
|
puts "Generating native executable with javapackager/jpackage..."
|
93
|
-
java_version = `
|
94
|
-
|
93
|
+
java_version = `jruby -v`
|
94
|
+
if java_version.include?('1.8.0_241')
|
95
|
+
puts "Java Version 1.8.0_241 Detected!"
|
96
|
+
else
|
97
|
+
puts "WARNING! Glimmer Packaging Pre-Requisite Java Version 1.8.0_241 Is Not Found!"
|
98
|
+
end
|
95
99
|
require 'facets/string/titlecase'
|
96
100
|
require 'facets/string/underscore'
|
97
101
|
require 'facets/string/camelcase'
|
@@ -121,6 +125,7 @@ module Glimmer
|
|
121
125
|
puts "Neither javapackager nor jpackage exist in your Java installation. Please ensure javapackager or jpackage is available in PATH environment variable."
|
122
126
|
return
|
123
127
|
end
|
128
|
+
Rake.application.load_rakefile # make sure to load potential javapackager_extra_args config in app Rakefile
|
124
129
|
command += " #{javapackager_extra_args} " if javapackager_extra_args
|
125
130
|
command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
|
126
131
|
command += " #{native_extra_args} " if native_extra_args
|
@@ -149,8 +149,8 @@ module Glimmer
|
|
149
149
|
write 'Rakefile', gem_rakefile(app_name, nil, gem_name)
|
150
150
|
mkdir 'app'
|
151
151
|
write "app/#{file_name(app_name)}.rb", app_main_file(app_name)
|
152
|
-
|
153
|
-
|
152
|
+
mkdir_p "app/#{file_name(app_name)}/model"
|
153
|
+
mkdir_p "app/#{file_name(app_name)}/view"
|
154
154
|
if shell_type == :desktopify
|
155
155
|
custom_shell('AppView', current_dir_name, shell_type, shell_options)
|
156
156
|
else
|
@@ -185,7 +185,7 @@ module Glimmer
|
|
185
185
|
end
|
186
186
|
write 'spec/spec_helper.rb', spec_helper_file
|
187
187
|
if OS.windows?
|
188
|
-
system "glimmer package[image]"
|
188
|
+
system "glimmer \"package[image]\"" # TODO handle Windows with batch file
|
189
189
|
system "\"packages/bundles/#{human_name(app_name)}/#{human_name(app_name)}.exe\""
|
190
190
|
else
|
191
191
|
system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
|
@@ -200,7 +200,7 @@ module Glimmer
|
|
200
200
|
def custom_shell(custom_shell_name, namespace, shell_type = nil, shell_options = {})
|
201
201
|
namespace ||= current_dir_name
|
202
202
|
root_dir = File.exists?('app') ? 'app' : 'lib'
|
203
|
-
parent_dir = "#{root_dir}
|
203
|
+
parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
|
204
204
|
return puts("The file '#{parent_dir}/#{file_name(custom_shell_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shell_name)}.rb")
|
205
205
|
mkdir_p parent_dir unless File.exists?(parent_dir)
|
206
206
|
write "#{parent_dir}/#{file_name(custom_shell_name)}.rb", custom_shell_file(custom_shell_name, namespace, shell_type, shell_options)
|
@@ -209,7 +209,7 @@ module Glimmer
|
|
209
209
|
def custom_widget(custom_widget_name, namespace)
|
210
210
|
namespace ||= current_dir_name
|
211
211
|
root_dir = File.exists?('app') ? 'app' : 'lib'
|
212
|
-
parent_dir = "#{root_dir}
|
212
|
+
parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
|
213
213
|
return puts("The file '#{parent_dir}/#{file_name(custom_widget_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_widget_name)}.rb")
|
214
214
|
mkdir_p parent_dir unless File.exists?(parent_dir)
|
215
215
|
write "#{parent_dir}/#{file_name(custom_widget_name)}.rb", custom_widget_file(custom_widget_name, namespace)
|
@@ -218,7 +218,7 @@ module Glimmer
|
|
218
218
|
def custom_shape(custom_shape_name, namespace)
|
219
219
|
namespace ||= current_dir_name
|
220
220
|
root_dir = File.exists?('app') ? 'app' : 'lib'
|
221
|
-
parent_dir = "#{root_dir}
|
221
|
+
parent_dir = "#{root_dir}/#{file_name(namespace)}/view"
|
222
222
|
return puts("The file '#{parent_dir}/#{file_name(custom_shape_name)}.rb' already exists. Please either remove or pick a different name.") if File.exist?("#{parent_dir}/#{file_name(custom_shape_name)}.rb")
|
223
223
|
mkdir_p parent_dir unless File.exists?(parent_dir)
|
224
224
|
write "#{parent_dir}/#{file_name(custom_shape_name)}.rb", custom_shape_file(custom_shape_name, namespace)
|
@@ -253,15 +253,12 @@ module Glimmer
|
|
253
253
|
write 'Gemfile', GEMFILE
|
254
254
|
write 'Rakefile', gem_rakefile(custom_shell_name, namespace, gem_name)
|
255
255
|
append "lib/#{gem_name}.rb", gem_main_file(custom_shell_name, namespace)
|
256
|
-
mkdir 'lib/views'
|
257
256
|
custom_shell(custom_shell_name, namespace, :gem)
|
258
257
|
|
259
|
-
mkdir_p "lib/#{
|
260
|
-
write "lib/#{
|
258
|
+
mkdir_p "lib/#{gem_name}"
|
259
|
+
write "lib/#{gem_name}/launch.rb", gem_launch_file(gem_name, custom_shell_name, namespace)
|
261
260
|
mkdir_p 'bin'
|
262
|
-
write "bin/#{
|
263
|
-
FileUtils.chmod 0755, "bin/#{gem_name}"
|
264
|
-
write "bin/#{file_name(custom_shell_name)}", gem_bin_command_file(gem_name, custom_shell_name, namespace)
|
261
|
+
write "bin/#{file_name(custom_shell_name)}", app_bin_command_file(gem_name, custom_shell_name, namespace)
|
265
262
|
FileUtils.chmod 0755, "bin/#{file_name(custom_shell_name)}"
|
266
263
|
if OS.windows?
|
267
264
|
system "bundle"
|
@@ -287,12 +284,12 @@ module Glimmer
|
|
287
284
|
puts "Created #{current_dir_name}/#{icon_file}"
|
288
285
|
|
289
286
|
if OS.windows?
|
290
|
-
system "glimmer package[image]"
|
287
|
+
system "glimmer package[image]" # TODO handle windows properly with batch file
|
291
288
|
system "\"packages/bundles/#{human_name(custom_shell_name)}/#{human_name(custom_shell_name)}.exe\""
|
292
289
|
else
|
293
290
|
system "bash -c '#{RVM_FUNCTION}\n cd .\n glimmer package\n'"
|
294
291
|
if OS.mac?
|
295
|
-
system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app"
|
292
|
+
system "open packages/bundles/#{human_name(custom_shell_name).gsub(' ', '\ ')}.app"
|
296
293
|
else
|
297
294
|
system "glimmer run"
|
298
295
|
end
|
@@ -327,7 +324,6 @@ module Glimmer
|
|
327
324
|
write 'Gemfile', GEMFILE
|
328
325
|
write 'Rakefile', gem_rakefile
|
329
326
|
append "lib/#{gem_name}.rb", gem_main_file(custom_widget_name, namespace)
|
330
|
-
mkdir 'lib/views'
|
331
327
|
custom_widget(custom_widget_name, namespace)
|
332
328
|
if OS.windows?
|
333
329
|
system "bundle"
|
@@ -366,7 +362,6 @@ module Glimmer
|
|
366
362
|
write 'Gemfile', GEMFILE
|
367
363
|
write 'Rakefile', gem_rakefile
|
368
364
|
append "lib/#{gem_name}.rb", gem_main_file(custom_shape_name, namespace)
|
369
|
-
mkdir 'lib/views'
|
370
365
|
custom_shape(custom_shape_name, namespace)
|
371
366
|
if OS.windows?
|
372
367
|
system "bundle"
|
@@ -443,7 +438,7 @@ module Glimmer
|
|
443
438
|
|
444
439
|
require 'bundler/setup'
|
445
440
|
Bundler.require(:default)
|
446
|
-
require '
|
441
|
+
require '#{file_name(app_name)}/view/app_view'
|
447
442
|
|
448
443
|
class #{class_name(app_name)}
|
449
444
|
include Glimmer
|
@@ -451,17 +446,14 @@ module Glimmer
|
|
451
446
|
APP_ROOT = File.expand_path('../..', __FILE__)
|
452
447
|
VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
|
453
448
|
LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
|
454
|
-
|
455
|
-
def open
|
456
|
-
app_view.open
|
457
|
-
end
|
458
449
|
end
|
459
450
|
MULTI_LINE_STRING
|
460
451
|
end
|
461
452
|
|
462
453
|
def gem_main_file(custom_widget_name, namespace = nil)
|
463
|
-
custom_widget_file_path =
|
464
|
-
custom_widget_file_path += "
|
454
|
+
custom_widget_file_path = ''
|
455
|
+
custom_widget_file_path += "#{file_name(namespace)}/" if namespace
|
456
|
+
custom_widget_file_path += "view"
|
465
457
|
custom_widget_file_path += "/#{file_name(custom_widget_name)}"
|
466
458
|
|
467
459
|
<<~MULTI_LINE_STRING
|
@@ -476,15 +468,20 @@ module Glimmer
|
|
476
468
|
<<~MULTI_LINE_STRING
|
477
469
|
require_relative '../#{file_name(app_name)}'
|
478
470
|
|
479
|
-
#{class_name(app_name)}.
|
471
|
+
#{class_name(app_name)}::View::AppView.launch
|
480
472
|
MULTI_LINE_STRING
|
481
473
|
end
|
482
474
|
|
483
|
-
def app_bin_command_file(
|
475
|
+
def app_bin_command_file(app_name_or_gem_name, custom_shell_name=nil, namespace=nil)
|
476
|
+
if custom_shell_name.nil?
|
477
|
+
runner = "File.expand_path('../../app/#{file_name(app_name_or_gem_name)}/launch.rb', __FILE__)"
|
478
|
+
else
|
479
|
+
runner = "File.expand_path('../../lib/#{app_name_or_gem_name}/launch.rb', __FILE__)"
|
480
|
+
end
|
484
481
|
<<~MULTI_LINE_STRING
|
485
482
|
#!/usr/bin/env jruby
|
486
483
|
|
487
|
-
runner =
|
484
|
+
runner = #{runner}
|
488
485
|
|
489
486
|
# Detect if inside a JAR file or not
|
490
487
|
if runner.include?('uri:classloader')
|
@@ -501,39 +498,9 @@ module Glimmer
|
|
501
498
|
def gem_launch_file(gem_name, custom_shell_name, namespace)
|
502
499
|
# TODO change this so that it does not mix Glimmer unto the main object
|
503
500
|
<<~MULTI_LINE_STRING
|
504
|
-
require_relative '
|
505
|
-
|
506
|
-
module #{class_name(namespace)}
|
507
|
-
class #{class_name(custom_shell_name)}
|
508
|
-
class App
|
509
|
-
include Glimmer
|
510
|
-
|
511
|
-
def open
|
512
|
-
#{dsl_widget_name(custom_shell_name)}.open
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
#{class_name(namespace)}::#{class_name(custom_shell_name)}::App.new.open
|
519
|
-
MULTI_LINE_STRING
|
520
|
-
end
|
521
|
-
|
522
|
-
def gem_bin_command_file(gem_name, custom_shell_name, namespace)
|
523
|
-
<<~MULTI_LINE_STRING
|
524
|
-
#!/usr/bin/env jruby
|
525
|
-
|
526
|
-
runner = File.expand_path("../../lib/#{file_name(namespace)}/#{file_name(custom_shell_name)}/launch.rb", __FILE__)
|
501
|
+
require_relative '../#{gem_name}'
|
527
502
|
|
528
|
-
#
|
529
|
-
if runner.include?('uri:classloader')
|
530
|
-
require runner
|
531
|
-
else
|
532
|
-
require 'glimmer/launcher'
|
533
|
-
|
534
|
-
launcher = Glimmer::Launcher.new([runner] + ARGV)
|
535
|
-
launcher.launch
|
536
|
-
end
|
503
|
+
#{class_name(namespace)}::View::#{class_name(custom_shell_name)}.launch
|
537
504
|
MULTI_LINE_STRING
|
538
505
|
end
|
539
506
|
|
@@ -546,8 +513,8 @@ module Glimmer
|
|
546
513
|
if custom_shell_name
|
547
514
|
lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'app/**/*', 'bin/**/*', 'config/**/*', 'db/**/*', 'docs/**/*', 'fonts/**/*', 'icons/**/*', 'images/**/*', 'lib/**/*', 'package/**/*', 'script/**/*', 'sounds/**/*', 'vendor/**/*', 'videos/**/*']")
|
548
515
|
# the second executable is needed for warbler as it matches the gem name, which is the default expected file (alternatively in the future, we could do away with it and configure warbler to use the other file)
|
549
|
-
lines.insert(gem_files_line_index+1, " gem.
|
550
|
-
lines.insert(gem_files_line_index+2, " gem.
|
516
|
+
lines.insert(gem_files_line_index+1, " gem.require_paths = ['vendor', 'lib', 'app']")
|
517
|
+
lines.insert(gem_files_line_index+2, " gem.executables = ['#{file_name(custom_shell_name)}']") if custom_shell_name
|
551
518
|
else
|
552
519
|
lines.insert(gem_files_line_index, " gem.files = Dir['VERSION', 'LICENSE.txt', 'lib/**/*']")
|
553
520
|
end
|
@@ -595,270 +562,276 @@ module Glimmer
|
|
595
562
|
namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
|
596
563
|
|
597
564
|
custom_shell_file_content = <<-MULTI_LINE_STRING
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
565
|
+
#{namespace_type} #{class_name(namespace)}
|
566
|
+
module View
|
567
|
+
class #{class_name(custom_shell_name)}
|
568
|
+
include Glimmer::UI::CustomShell
|
569
|
+
|
602
570
|
MULTI_LINE_STRING
|
603
571
|
|
604
572
|
if shell_type == :gem
|
605
573
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
574
|
+
APP_ROOT = File.expand_path('../../../..', __FILE__)
|
575
|
+
VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
|
576
|
+
LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
|
577
|
+
|
610
578
|
MULTI_LINE_STRING
|
611
579
|
end
|
612
580
|
|
613
581
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
582
|
+
## Add options like the following to configure CustomShell by outside consumers
|
583
|
+
#
|
584
|
+
# options :title, :background_color
|
585
|
+
# option :width, default: 320
|
586
|
+
# option :height, default: 240
|
587
|
+
#{'# ' if shell_type == :desktopify}option :greeting, default: 'Hello, World!'
|
588
|
+
|
589
|
+
## Use before_body block to pre-initialize variables to use in body
|
590
|
+
#
|
591
|
+
#
|
624
592
|
MULTI_LINE_STRING
|
625
593
|
|
626
594
|
if %i[gem app desktopify].include?(shell_type)
|
627
595
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
}
|
596
|
+
before_body {
|
597
|
+
Display.app_name = '#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}'
|
598
|
+
Display.app_version = VERSION
|
599
|
+
@display = display {
|
600
|
+
on_about {
|
601
|
+
display_about_dialog
|
602
|
+
}
|
603
|
+
on_preferences {
|
604
|
+
#{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
|
638
605
|
}
|
639
606
|
}
|
607
|
+
}
|
640
608
|
MULTI_LINE_STRING
|
641
609
|
else
|
642
610
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
643
|
-
|
644
|
-
|
645
|
-
|
611
|
+
# before_body {
|
612
|
+
#
|
613
|
+
# }
|
646
614
|
MULTI_LINE_STRING
|
647
615
|
end
|
648
616
|
|
649
617
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
618
|
+
|
619
|
+
## Use after_body block to setup observers for widgets in body
|
620
|
+
#
|
621
|
+
# after_body {
|
622
|
+
#
|
623
|
+
# }
|
624
|
+
|
625
|
+
## Add widget content inside custom shell body
|
626
|
+
## Top-most widget must be a shell or another custom shell
|
627
|
+
#
|
628
|
+
body {
|
629
|
+
shell(#{':fill_screen' if shell_type == :desktopify}) {
|
630
|
+
# Replace example content below with custom shell content
|
631
|
+
minimum_size #{shell_type == :desktopify ? '768, 432' : '420, 240'}
|
632
|
+
image File.join(APP_ROOT, 'package', 'windows', "#{human_name(shell_type == :gem ? custom_shell_name : current_dir_name)}.ico") if OS.windows?
|
633
|
+
text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
|
634
|
+
|
667
635
|
MULTI_LINE_STRING
|
668
636
|
|
669
637
|
if shell_type == :desktopify
|
670
638
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
671
|
-
|
672
|
-
|
673
|
-
|
639
|
+
browser {
|
640
|
+
url "#{shell_options[:website]}"
|
641
|
+
}
|
674
642
|
MULTI_LINE_STRING
|
675
643
|
else
|
676
644
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
645
|
+
grid_layout
|
646
|
+
label(:center) {
|
647
|
+
text bind(self, :greeting)
|
648
|
+
font height: 40
|
649
|
+
layout_data :fill, :center, true, true
|
650
|
+
}
|
683
651
|
MULTI_LINE_STRING
|
684
652
|
end
|
685
653
|
|
686
654
|
if %i[gem app desktopify].include?(shell_type)
|
687
655
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
}
|
656
|
+
|
657
|
+
menu_bar {
|
658
|
+
menu {
|
659
|
+
text '&File'
|
660
|
+
menu_item {
|
661
|
+
text '&About...'
|
662
|
+
on_widget_selected {
|
663
|
+
display_about_dialog
|
697
664
|
}
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
}
|
665
|
+
}
|
666
|
+
menu_item {
|
667
|
+
text '&Preferences...'
|
668
|
+
on_widget_selected {
|
669
|
+
#{shell_type == :desktopify ? 'display_about_dialog' : 'display_preferences_dialog'}
|
703
670
|
}
|
704
671
|
}
|
705
672
|
}
|
673
|
+
}
|
706
674
|
MULTI_LINE_STRING
|
707
675
|
end
|
708
676
|
|
709
677
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
710
|
-
}
|
711
678
|
}
|
679
|
+
}
|
712
680
|
MULTI_LINE_STRING
|
713
681
|
|
714
682
|
if %i[gem app desktopify].include?(shell_type)
|
715
683
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
684
|
+
|
685
|
+
def display_about_dialog
|
686
|
+
message_box(body_root) {
|
687
|
+
text 'About'
|
688
|
+
message "#{human_name(namespace)}#{" - #{human_name(custom_shell_name)}" if shell_type == :gem} \#{VERSION}\\n\\n\#{LICENSE}"
|
689
|
+
}.open
|
690
|
+
end
|
691
|
+
|
724
692
|
MULTI_LINE_STRING
|
725
693
|
end
|
726
694
|
|
727
695
|
if %i[gem app].include?(shell_type)
|
728
696
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
697
|
+
def display_preferences_dialog
|
698
|
+
dialog(swt_widget) {
|
699
|
+
text 'Preferences'
|
700
|
+
grid_layout {
|
701
|
+
margin_height 5
|
702
|
+
margin_width 5
|
703
|
+
}
|
704
|
+
group {
|
705
|
+
row_layout {
|
706
|
+
type :vertical
|
707
|
+
spacing 10
|
735
708
|
}
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
button(:radio) {
|
748
|
-
text greeting_text
|
749
|
-
selection bind(self, :greeting) { |g| g == greeting_text }
|
750
|
-
layout_data {
|
751
|
-
width 160
|
752
|
-
}
|
753
|
-
on_widget_selected { |event|
|
754
|
-
self.greeting = event.widget.getText
|
755
|
-
}
|
709
|
+
text 'Greeting'
|
710
|
+
font style: :bold
|
711
|
+
[
|
712
|
+
'Hello, World!',
|
713
|
+
'Howdy, Partner!'
|
714
|
+
].each do |greeting_text|
|
715
|
+
button(:radio) {
|
716
|
+
text greeting_text
|
717
|
+
selection bind(self, :greeting) { |g| g == greeting_text }
|
718
|
+
layout_data {
|
719
|
+
width 160
|
756
720
|
}
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
721
|
+
on_widget_selected { |event|
|
722
|
+
self.greeting = event.widget.getText
|
723
|
+
}
|
724
|
+
}
|
725
|
+
end
|
726
|
+
}
|
727
|
+
}.open
|
728
|
+
end
|
761
729
|
MULTI_LINE_STRING
|
762
730
|
end
|
763
731
|
|
764
732
|
custom_shell_file_content += <<-MULTI_LINE_STRING
|
765
|
-
end
|
766
733
|
end
|
734
|
+
end
|
735
|
+
end
|
767
736
|
MULTI_LINE_STRING
|
768
737
|
end
|
769
738
|
|
770
739
|
def custom_widget_file(custom_widget_name, namespace)
|
771
740
|
namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
|
772
741
|
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
742
|
+
<<-MULTI_LINE_STRING
|
743
|
+
#{namespace_type} #{class_name(namespace)}
|
744
|
+
module View
|
745
|
+
class #{class_name(custom_widget_name)}
|
746
|
+
include Glimmer::UI::CustomWidget
|
747
|
+
|
748
|
+
## Add options like the following to configure CustomWidget by outside consumers
|
749
|
+
#
|
750
|
+
# options :custom_text, :background_color
|
751
|
+
# option :foreground_color, default: :red
|
752
|
+
|
753
|
+
## Use before_body block to pre-initialize variables to use in body
|
754
|
+
#
|
755
|
+
#
|
756
|
+
# before_body {
|
757
|
+
#
|
758
|
+
# }
|
759
|
+
|
760
|
+
## Use after_body block to setup observers for widgets in body
|
761
|
+
#
|
762
|
+
# after_body {
|
763
|
+
#
|
764
|
+
# }
|
765
|
+
|
766
|
+
## Add widget content under custom widget body
|
767
|
+
##
|
768
|
+
## If you want to add a shell as the top-most widget,
|
769
|
+
## consider creating a custom shell instead
|
770
|
+
## (Glimmer::UI::CustomShell offers shell convenience methods, like show and hide)
|
771
|
+
#
|
772
|
+
body {
|
773
|
+
# Replace example content below with custom widget content
|
774
|
+
label {
|
775
|
+
background :red
|
776
|
+
}
|
777
|
+
}
|
778
|
+
|
779
|
+
end
|
780
|
+
end
|
781
|
+
end
|
811
782
|
MULTI_LINE_STRING
|
812
783
|
end
|
813
784
|
|
814
785
|
def custom_shape_file(custom_shape_name, namespace)
|
815
786
|
namespace_type = class_name(namespace) == class_name(current_dir_name) ? 'class' : 'module'
|
816
787
|
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
788
|
+
<<-MULTI_LINE_STRING
|
789
|
+
#{namespace_type} #{class_name(namespace)}
|
790
|
+
module View
|
791
|
+
class #{class_name(custom_shape_name)}
|
792
|
+
include Glimmer::UI::CustomShape
|
793
|
+
|
794
|
+
## Add options like the following to configure CustomShape by outside consumers
|
795
|
+
#
|
796
|
+
# options :option1, option2, option3
|
797
|
+
option :background_color, default: :red
|
798
|
+
option :size_width, default: 100
|
799
|
+
option :size_height, default: 100
|
800
|
+
option :location_x, default: 0
|
801
|
+
option :location_y, default: 0
|
802
|
+
|
803
|
+
## Use before_body block to pre-initialize variables to use in body
|
804
|
+
#
|
805
|
+
#
|
806
|
+
# before_body {
|
807
|
+
#
|
808
|
+
# }
|
809
|
+
|
810
|
+
## Use after_body block to setup observers for shapes in body
|
811
|
+
#
|
812
|
+
# after_body {
|
813
|
+
#
|
814
|
+
# }
|
815
|
+
|
816
|
+
## Add shape content under custom shape body
|
817
|
+
#
|
818
|
+
body {
|
819
|
+
# Replace example content below with custom shape content
|
820
|
+
shape(location_x, location_y) {
|
821
|
+
path {
|
822
|
+
background background_color
|
823
|
+
cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*0.65 - size_width*0.66, 0 - size_height*0.33, size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
|
824
|
+
}
|
825
|
+
path {
|
826
|
+
background background_color
|
827
|
+
cubic size_width - size_width*0.66, size_height/2 - size_height*0.33, size_width*1.35 - size_width*0.66, 0 - size_height*0.33, size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33, size_width - size_width*0.66, size_height - size_height*0.33
|
828
|
+
}
|
829
|
+
}
|
830
|
+
}
|
831
|
+
|
832
|
+
end
|
833
|
+
end
|
834
|
+
end
|
862
835
|
MULTI_LINE_STRING
|
863
836
|
end
|
864
837
|
|