glimmer 0.7.8 → 0.8.0
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.
- checksums.yaml +4 -4
- data/README.md +54 -45
- data/VERSION +1 -1
- data/lib/glimmer/launcher.rb +1 -1
- data/lib/glimmer/scaffold.rb +12 -18
- data/lib/glimmer/swt/display_proxy.rb +14 -0
- data/lib/glimmer/swt/menu_proxy.rb +17 -0
- data/lib/glimmer/swt/shell_proxy.rb +0 -25
- data/lib/glimmer/ui/custom_widget.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d87ba92b94f38539aa2dad56f18f8ec09a358d8ac327008b08ef9be3977e9a
|
4
|
+
data.tar.gz: 74bc0959b428802c4a4e1ef28b3f1365b2f4444a1d0446b6cc85420743a9aa7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b80eeec01d04286de10967801413c72cba05dd06b21f9be75a044cf433827d4598f1bed83576222d71f7455dc868cf4af31ae6db9445a536772f1f6f0f446100
|
7
|
+
data.tar.gz: 0d2ac02fb3c55b4bcf79e150b320b5a0d23749ded30a9324c954b0d79d35543e50c9b786c5a7a258342f72f9144bcffd58b733dd2b4c3bcc66b61e4bfcbf85f8
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Glimmer 0.
|
1
|
+
# Glimmer 0.8.0 Beta (Ruby Desktop Development GUI Library)
|
2
2
|
[](http://badge.fury.io/rb/glimmer)
|
3
3
|
[](https://travis-ci.com/github/AndyObtiva/glimmer)
|
4
4
|
[](https://codeclimate.com/github/AndyObtiva/glimmer/test_coverage)
|
@@ -75,7 +75,7 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
|
|
75
75
|
|
76
76
|
## Table of Contents
|
77
77
|
|
78
|
-
- [Glimmer 0.
|
78
|
+
- [Glimmer 0.8.0 Beta (Ruby Desktop Development GUI Library)](#glimmer-080-beta-desktop-development-library-for-ruby)
|
79
79
|
- [Examples](#examples)
|
80
80
|
- [Hello, World!](#hello-world)
|
81
81
|
- [Tic Tac Toe](#tic-tac-toe)
|
@@ -174,7 +174,7 @@ Please follow these instructions to make the `glimmer` command available on your
|
|
174
174
|
|
175
175
|
Run this command to install directly:
|
176
176
|
```
|
177
|
-
jgem install glimmer -v 0.
|
177
|
+
jgem install glimmer -v 0.8.0
|
178
178
|
```
|
179
179
|
|
180
180
|
`jgem` is JRuby's version of `gem` command.
|
@@ -185,7 +185,7 @@ Otherwise, you may also run `jruby -S gem install ...`
|
|
185
185
|
|
186
186
|
Add the following to `Gemfile`:
|
187
187
|
```
|
188
|
-
gem 'glimmer', '~> 0.
|
188
|
+
gem 'glimmer', '~> 0.8.0'
|
189
189
|
```
|
190
190
|
|
191
191
|
And, then run:
|
@@ -247,7 +247,7 @@ automatically preloading the glimmer Ruby gem and SWT jar dependency.
|
|
247
247
|
Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
|
248
248
|
|
249
249
|
Glimmer options:
|
250
|
-
- "--quiet" : Does not announce file path of Glimmer application being launched
|
250
|
+
- "--quiet" : Does not announce file path of Glimmer application being launched
|
251
251
|
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
|
252
252
|
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
|
253
253
|
|
@@ -632,7 +632,7 @@ Shell widget proxy has extra methods specific to SWT Shell:
|
|
632
632
|
|
633
633
|
Dialog is a variation on Shell. It is basically a shell that is modal (blocks what's behind it) and belongs to another shell. It only has a close button.
|
634
634
|
|
635
|
-
Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT
|
635
|
+
Glimmer facilitates building dialogs by using the `dialog` keyword, which automatically adds the SWT.DIALOG_TRIM and SWT.APPLICATION_MODAL [widget styles](#widget-styles) needed for a dialog.
|
636
636
|
|
637
637
|
#### Menus
|
638
638
|
|
@@ -1324,7 +1324,7 @@ Glimmer supports observing widgets with two main types of events:
|
|
1324
1324
|
|
1325
1325
|
Additionally, there are two more types of events:
|
1326
1326
|
- SWT `display` supports global listeners called filters that run on any widget. They are hooked via `on_event_{swt-event-constant}`
|
1327
|
-
-
|
1327
|
+
- SWT `display` supports Mac application menu item observers (`on_about` and `on_preferences`), which you can read about under [Miscellaneous](#miscellaneous).
|
1328
1328
|
|
1329
1329
|
Number 1 is more commonly used in SWT applications, so make it your starting point. Number 2 covers events not found in number 1, so look into it if you don't find an SWT listener you need in number 1.
|
1330
1330
|
|
@@ -1559,8 +1559,8 @@ Custom Widgets have the following attributes available to call from inside the `
|
|
1559
1559
|
- `#swt_widget`: actual SWT widget for `body_root`
|
1560
1560
|
|
1561
1561
|
Additionally, custom widgets can call the following class methods:
|
1562
|
-
-
|
1563
|
-
-
|
1562
|
+
- `::options(*option_names)`: declares a list of options by taking an option name array (symbols/strings). This generates option attribute accessors (e.g. `options :orientation, :bg_color` generates `#orientation`, `#orientation=(v)`, `#bg_color`, and `#bg_color=(v)` attribute accessors)
|
1563
|
+
- `::option(option_name, default: nil)`: declares a single option taking option name and default value as arguments (also generates attribute accessors just like `::options`)
|
1564
1564
|
|
1565
1565
|
#### Content/Options Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
1566
1566
|
|
@@ -1570,7 +1570,7 @@ class Sandwich
|
|
1570
1570
|
include Glimmer::UI::CustomWidget
|
1571
1571
|
|
1572
1572
|
options :orientation, :bg_color
|
1573
|
-
option :fg_color, :black
|
1573
|
+
option :fg_color, default: :black
|
1574
1574
|
|
1575
1575
|
body {
|
1576
1576
|
composite(swt_style) { # gets custom widget style
|
@@ -1705,52 +1705,61 @@ shell { |app_shell|
|
|
1705
1705
|
|
1706
1706
|
#### Application Menu Items (About/Preferences)
|
1707
1707
|
|
1708
|
-
Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `
|
1708
|
+
Mac applications always have About and Preferences menu items. Glimmer provides widget observer hooks for them on the `display`:
|
1709
1709
|
- `on_about`: executes code when user selects App Name -> About
|
1710
1710
|
- `on_preferences`: executes code when user selects App Name -> Preferences or hits 'CMD+,' on the Mac
|
1711
1711
|
|
1712
1712
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb-command)):
|
1713
1713
|
|
1714
1714
|
```ruby
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
font height: 30
|
1724
|
-
}
|
1725
|
-
on_about {
|
1726
|
-
message_box = MessageBox.new(shell_proxy.swt_widget)
|
1727
|
-
message_box.setText("About")
|
1728
|
-
message_box.setMessage("About Application")
|
1729
|
-
message_box.open
|
1730
|
-
}
|
1731
|
-
on_preferences {
|
1732
|
-
preferences_dialog = shell(:dialog_trim, :application_modal) {
|
1733
|
-
text 'Preferences'
|
1734
|
-
row_layout {
|
1735
|
-
type :vertical
|
1736
|
-
margin_left 15
|
1737
|
-
margin_top 15
|
1738
|
-
margin_right 15
|
1739
|
-
margin_bottom 15
|
1715
|
+
class Example
|
1716
|
+
def initialize
|
1717
|
+
display {
|
1718
|
+
on_about {
|
1719
|
+
message_box = MessageBox.new(@shell_proxy.swt_widget)
|
1720
|
+
message_box.setText("About")
|
1721
|
+
message_box.setMessage("About Application")
|
1722
|
+
message_box.open
|
1740
1723
|
}
|
1741
|
-
|
1742
|
-
|
1724
|
+
on_preferences {
|
1725
|
+
preferences_dialog = dialog {
|
1726
|
+
text 'Preferences'
|
1727
|
+
row_layout {
|
1728
|
+
type :vertical
|
1729
|
+
margin_left 15
|
1730
|
+
margin_top 15
|
1731
|
+
margin_right 15
|
1732
|
+
margin_bottom 15
|
1733
|
+
}
|
1734
|
+
label {
|
1735
|
+
text 'Check one of these options:'
|
1736
|
+
}
|
1737
|
+
button(:radio) {
|
1738
|
+
text 'Option 1'
|
1739
|
+
}
|
1740
|
+
button(:radio) {
|
1741
|
+
text 'Option 2'
|
1742
|
+
}
|
1743
|
+
}
|
1744
|
+
preferences_dialog.open
|
1743
1745
|
}
|
1744
|
-
|
1745
|
-
|
1746
|
+
}
|
1747
|
+
@shell_proxy = shell {
|
1748
|
+
text 'Application Menu Items'
|
1749
|
+
fill_layout {
|
1750
|
+
margin_width 15
|
1751
|
+
margin_height 15
|
1746
1752
|
}
|
1747
|
-
|
1748
|
-
text '
|
1753
|
+
label {
|
1754
|
+
text 'Application Menu Items'
|
1755
|
+
font height: 30
|
1749
1756
|
}
|
1750
1757
|
}
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1758
|
+
@shell_proxy.open
|
1759
|
+
end
|
1760
|
+
end
|
1761
|
+
|
1762
|
+
Example.new
|
1754
1763
|
```
|
1755
1764
|
|
1756
1765
|
#### App Name and Version
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -27,7 +27,7 @@ module Glimmer
|
|
27
27
|
Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
|
28
28
|
|
29
29
|
Glimmer options:
|
30
|
-
- "--quiet" : Does not announce file path of Glimmer application being launched
|
30
|
+
- "--quiet" : Does not announce file path of Glimmer application being launched
|
31
31
|
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
|
32
32
|
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
|
33
33
|
|
data/lib/glimmer/scaffold.rb
CHANGED
@@ -424,9 +424,9 @@ class Scaffold
|
|
424
424
|
## Add options like the following to configure CustomShell by outside consumers
|
425
425
|
#
|
426
426
|
# options :title, :background_color
|
427
|
-
# option :width, 320
|
428
|
-
# option :height, 240
|
429
|
-
option :greeting, 'Hello, World!'
|
427
|
+
# option :width, default: 320
|
428
|
+
# option :height, default: 240
|
429
|
+
option :greeting, default: 'Hello, World!'
|
430
430
|
|
431
431
|
## Use before_body block to pre-initialize variables to use in body
|
432
432
|
#
|
@@ -438,6 +438,14 @@ class Scaffold
|
|
438
438
|
before_body {
|
439
439
|
Display.setAppName('#{shell_type == :gem ? human_name(custom_shell_name) : human_name(namespace)}')
|
440
440
|
Display.setAppVersion(VERSION)
|
441
|
+
@display = display {
|
442
|
+
on_about {
|
443
|
+
display_about_dialog
|
444
|
+
}
|
445
|
+
on_preferences {
|
446
|
+
display_preferences_dialog
|
447
|
+
}
|
448
|
+
}
|
441
449
|
}
|
442
450
|
MULTI_LINE_STRING
|
443
451
|
else
|
@@ -465,20 +473,6 @@ class Scaffold
|
|
465
473
|
minimum_size 320, 240
|
466
474
|
text "#{human_name(namespace)} - #{human_name(custom_shell_name)}"
|
467
475
|
grid_layout
|
468
|
-
MULTI_LINE_STRING
|
469
|
-
|
470
|
-
if %i[gem app].include?(shell_type)
|
471
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
472
|
-
on_about {
|
473
|
-
display_about_dialog
|
474
|
-
}
|
475
|
-
on_preferences {
|
476
|
-
display_preferences_dialog
|
477
|
-
}
|
478
|
-
MULTI_LINE_STRING
|
479
|
-
end
|
480
|
-
|
481
|
-
custom_shell_file_content += <<-MULTI_LINE_STRING
|
482
476
|
label(:center) {
|
483
477
|
text bind(self, :greeting)
|
484
478
|
font height: 40
|
@@ -552,7 +546,7 @@ end
|
|
552
546
|
## Add options like the following to configure CustomWidget by outside consumers
|
553
547
|
#
|
554
548
|
# options :custom_text, :background_color
|
555
|
-
# option :foreground_color, :red
|
549
|
+
# option :foreground_color, default: :red
|
556
550
|
|
557
551
|
## Use before_body block to pre-initialize variables to use in body
|
558
552
|
#
|
@@ -16,6 +16,8 @@ module Glimmer
|
|
16
16
|
class DisplayProxy
|
17
17
|
include_package 'org.eclipse.swt.widgets'
|
18
18
|
|
19
|
+
OBSERVED_MENU_ITEMS = ['about', 'preferences']
|
20
|
+
|
19
21
|
class << self
|
20
22
|
# Returns singleton instance
|
21
23
|
def instance(*args)
|
@@ -52,6 +54,9 @@ module Glimmer
|
|
52
54
|
if observation_request.start_with?('on_event_')
|
53
55
|
constant_name = observation_request.sub(/^on_event_/, '')
|
54
56
|
SWTProxy.has_constant?(constant_name)
|
57
|
+
elsif observation_request.start_with?('on_')
|
58
|
+
event_name = observation_request.sub(/^on_/, '')
|
59
|
+
OBSERVED_MENU_ITEMS.include?(event_name)
|
55
60
|
else
|
56
61
|
false
|
57
62
|
end
|
@@ -61,6 +66,15 @@ module Glimmer
|
|
61
66
|
if observation_request.start_with?('on_event_')
|
62
67
|
constant_name = observation_request.sub(/^on_event_/, '')
|
63
68
|
add_swt_event_listener(constant_name, &block)
|
69
|
+
elsif observation_request.start_with?('on_')
|
70
|
+
event_name = observation_request.sub(/^on_/, '')
|
71
|
+
if OBSERVED_MENU_ITEMS.include?(event_name)
|
72
|
+
if OS.mac?
|
73
|
+
system_menu = swt_display.getSystemMenu
|
74
|
+
menu_item = system_menu.getItems.find {|menu_item| menu_item.getID == SWTProxy["ID_#{event_name.upcase}"]}
|
75
|
+
menu_item.addListener(SWTProxy[:Selection], &block)
|
76
|
+
end
|
77
|
+
end
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|
@@ -79,6 +79,23 @@ module Glimmer
|
|
79
79
|
super(attribute_name)
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
83
|
+
def can_handle_observation_request?(observation_request, super_only: false)
|
84
|
+
super_result = super(observation_request)
|
85
|
+
if observation_request.start_with?('on_') && !super_result && !super_only
|
86
|
+
return menu_item_proxy.can_handle_observation_request?(observation_request)
|
87
|
+
else
|
88
|
+
super_result
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def handle_observation_request(observation_request, &block)
|
93
|
+
if can_handle_observation_request?(observation_request, super_only: true)
|
94
|
+
super
|
95
|
+
else
|
96
|
+
menu_item_proxy.handle_observation_request(observation_request, &block)
|
97
|
+
end
|
98
|
+
end
|
82
99
|
end
|
83
100
|
end
|
84
101
|
end
|
@@ -14,7 +14,6 @@ module Glimmer
|
|
14
14
|
|
15
15
|
WIDTH_MIN = 130
|
16
16
|
HEIGHT_MIN = 0
|
17
|
-
OBSERVED_MENU_ITEMS = ['about', 'preferences']
|
18
17
|
|
19
18
|
attr_reader :opened_before
|
20
19
|
alias opened_before? opened_before
|
@@ -128,30 +127,6 @@ module Glimmer
|
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
131
|
-
def can_handle_observation_request?(observation_request)
|
132
|
-
result = false
|
133
|
-
if observation_request.start_with?('on_')
|
134
|
-
event_name = observation_request.sub(/^on_/, '')
|
135
|
-
result = OBSERVED_MENU_ITEMS.include?(event_name)
|
136
|
-
end
|
137
|
-
result || super
|
138
|
-
end
|
139
|
-
|
140
|
-
def handle_observation_request(observation_request, &block)
|
141
|
-
if observation_request.start_with?('on_')
|
142
|
-
event_name = observation_request.sub(/^on_/, '')
|
143
|
-
if OBSERVED_MENU_ITEMS.include?(event_name)
|
144
|
-
if OS.mac?
|
145
|
-
system_menu = DisplayProxy.instance.swt_display.getSystemMenu
|
146
|
-
menu_item = system_menu.getItems.find {|menu_item| menu_item.getID == SWTProxy["ID_#{event_name.upcase}"]}
|
147
|
-
menu_item.addListener(SWTProxy[:Selection], &block)
|
148
|
-
end
|
149
|
-
else
|
150
|
-
super
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
130
|
def add_observer(observer, property_name)
|
156
131
|
case property_name.to_s
|
157
132
|
when 'visible?' #TODO see if you must handle non-? version and/or move elsewhere
|
@@ -70,7 +70,7 @@ module Glimmer
|
|
70
70
|
@custom_widget_namespaces = Set[Object, Glimmer::UI]
|
71
71
|
end
|
72
72
|
|
73
|
-
# Allows defining convenience option
|
73
|
+
# Allows defining convenience option accessors for an array of option names
|
74
74
|
# Example: `options :color1, :color2` defines `#color1` and `#color2`
|
75
75
|
# where they return the instance values `options[:color1]` and `options[:color2]`
|
76
76
|
# respectively.
|
@@ -87,9 +87,9 @@ module Glimmer
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def option(new_option,
|
90
|
+
def option(new_option, default: nil)
|
91
91
|
new_option = new_option.to_s.to_sym
|
92
|
-
new_options = {new_option =>
|
92
|
+
new_options = {new_option => default}
|
93
93
|
@options = options.merge(new_options)
|
94
94
|
def_option_attr_accessors(new_options)
|
95
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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-
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 0.8.1
|
167
|
-
description: Desktop Development Library
|
167
|
+
description: Ruby Desktop Development GUI Library
|
168
168
|
email: andy.am@gmail.com
|
169
169
|
executables:
|
170
170
|
- glimmer
|
@@ -299,5 +299,5 @@ requirements: []
|
|
299
299
|
rubygems_version: 3.0.6
|
300
300
|
signing_key:
|
301
301
|
specification_version: 4
|
302
|
-
summary: Desktop Development Library
|
302
|
+
summary: Ruby Desktop Development GUI Library
|
303
303
|
test_files: []
|