glimmer 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +52 -14
- data/lib/glimmer.rb +1 -0
- data/lib/glimmer/launcher.rb +2 -2
- data/lib/glimmer/swt/shell_proxy.rb +5 -3
- data/lib/glimmer/swt/swt_proxy.rb +42 -12
- data/lib/glimmer/ui/video.rb +3 -2
- data/samples/gladiator.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07ac7dc0e7c7beab5855763da9b232037f6561b93c0b8240db5a96fc74a3e026
|
4
|
+
data.tar.gz: 934ff722e09b38eec4c4ede3c369f910ead8d070bbb151f42ec59feac7d66328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abd9390fb32d7e5aaa099d8002527371825d7109e69adeb1fc91e2440dd8b92010691839983bcbed177ce27d5b7c469f9294a62a77261b971eba301986e0e3ae
|
7
|
+
data.tar.gz: c75edc6edce8909868465a75d26ba9cd054192ac256d34f2bc8f271e129326e504e91c3ca1f84b7a0be1c0079f609ab05995e21091002a4aa2d29d8f91a38d28
|
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Glimmer 0.5.
|
1
|
+
# Glimmer 0.5.10 Beta (JRuby Desktop UI DSL + Data-Binding)
|
2
2
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer?branch=master)
|
3
3
|
|
4
4
|
Glimmer is a native-UI cross-platform desktop development library written in Ruby. Glimmer's main innovation is a JRuby DSL that enables productive and efficient authoring of desktop application user-interfaces while relying on the robust platform-native Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support to greatly facilitate synchronizing the UI with domain models. As a result, that achieves true decoupling of object oriented components, enabling developers to solve business problems without worrying about UI concerns, or alternatively drive development UI-first, and then write clean business components test-first afterwards.
|
@@ -70,7 +70,7 @@ NOTE: Glimmer is in beta mode. Please help make better by adopting for small or
|
|
70
70
|
## Table of Contents
|
71
71
|
|
72
72
|
<!-- TOC START min:1 max:3 link:true asterisk:false update:true -->
|
73
|
-
- [Glimmer 0.5.
|
73
|
+
- [Glimmer 0.5.10 Beta (JRuby Desktop UI DSL + Data-Binding)](#glimmer-058-beta-jruby-desktop-ui-dsl--data-binding)
|
74
74
|
- [Examples](#examples)
|
75
75
|
- [Hello World](#hello-world)
|
76
76
|
- [Tic Tac Toe](#tic-tac-toe)
|
@@ -163,14 +163,14 @@ Please follow these instructions to make the `glimmer` command available on your
|
|
163
163
|
|
164
164
|
Run this command to install directly:
|
165
165
|
```
|
166
|
-
jgem install glimmer -v 0.5.
|
166
|
+
jgem install glimmer -v 0.5.10
|
167
167
|
```
|
168
168
|
|
169
169
|
### Option 2: Bundler
|
170
170
|
|
171
171
|
Add the following to `Gemfile`:
|
172
172
|
```
|
173
|
-
gem 'glimmer', '~> 0.5.
|
173
|
+
gem 'glimmer', '~> 0.5.10'
|
174
174
|
```
|
175
175
|
|
176
176
|
And, then run:
|
@@ -598,17 +598,37 @@ You may check out all available `SWT` styles here:
|
|
598
598
|
|
599
599
|
https://help.eclipse.org/2019-12/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/SWT.html
|
600
600
|
|
601
|
-
####
|
601
|
+
#### Explicit SWT Style Bit
|
602
602
|
|
603
603
|
When building a widget-related SWT object manually (e.g. `GridData.new(...)`), you are expected to use `SWT::CONSTANT` directly or BIT-OR a few SWT constants together like `SWT::BORDER | SWT::V_SCROLL`.
|
604
604
|
|
605
|
-
Glimmer facilitates that with `
|
605
|
+
Glimmer facilitates that with `swt` keyword by allowing you to pass multiple styles as an argument array of symbols instead of dealing with BIT-OR.
|
606
|
+
Example:
|
606
607
|
|
607
|
-
|
608
|
+
```ruby
|
609
|
+
style = swt(:border, :v_scroll)
|
610
|
+
```
|
611
|
+
|
612
|
+
#### Negative SWT Style Bits
|
608
613
|
|
609
|
-
|
614
|
+
In rare occasions, you might need to apply & with a negative (not) style bit to negate it from another style bit that includes it.
|
615
|
+
Glimmer facilitates that by declaring the negative style bit via postfixing a symbol with `!`.
|
616
|
+
|
617
|
+
Example:
|
618
|
+
|
619
|
+
```ruby
|
620
|
+
style = swt(:shell_trim, :max!) # creates a shell trim style without the maximize button (negated)
|
621
|
+
```
|
622
|
+
|
623
|
+
#### Extra SWT Styles
|
624
|
+
|
625
|
+
##### Non-resizable Window
|
626
|
+
|
627
|
+
SWT Shell widget by default is resizable. To make it non-resizable, one must pass a complicated style bit concoction like `swt(:shell_trim, :resize!, :max!)`.
|
628
|
+
|
629
|
+
Glimmer makes this easier by alternatively offering a `:no_resize` extra SWT style, added for convenience.
|
630
|
+
This makes declaring a non-resizable window as easy as:
|
610
631
|
|
611
|
-
Glimmer makes this easier by alternatively offering `:no_resize` extra SWT style, added for convenience. This makes declaring an non-resizable window as easy as:
|
612
632
|
```ruby
|
613
633
|
shell(:no_resize) {
|
614
634
|
# ...
|
@@ -889,7 +909,7 @@ composite {
|
|
889
909
|
grid_layout 3, false # grid layout with 3 columns not of equal width
|
890
910
|
label {
|
891
911
|
# layout data set explicitly via an object (helps in rare cases that break convention)
|
892
|
-
layout_data GridData.new(
|
912
|
+
layout_data GridData.new(swt(:fill), swt(:end), true, false)
|
893
913
|
}
|
894
914
|
}
|
895
915
|
# ...
|
@@ -1312,6 +1332,8 @@ shell {
|
|
1312
1332
|
|
1313
1333
|
Notice how `Red::Composite` became `red__composite` with double-underscore, which is how Glimmer Custom Widgets signify namespaces by convention. Additionally, `before_body` hook was utilized to set a `@color` variable and use inside the `body`.
|
1314
1334
|
|
1335
|
+
Keep in mind that namespaces are not needed to be specified if the Custom Widget class has a unique name, not clashing with a basic SWT widget or another custom widget name.
|
1336
|
+
|
1315
1337
|
Custom Widgets have the following attributes (attribute readers) available to call from inside the `#body` method:
|
1316
1338
|
- `#parent`: Glimmer object parenting custom widget
|
1317
1339
|
- `#swt_style`: SWT style integer. Can be useful if you want to allow consumers to customize a widget inside the custom widget body
|
@@ -1711,15 +1733,31 @@ glimmer samples/gladiator.rb # demonstrates a text editor with tree/list data-bi
|
|
1711
1733
|
|
1712
1734
|
![Gladiator](images/glimmer-gladiator.png)
|
1713
1735
|
|
1714
|
-
Gladiator (short for Glimmer Editor) is an on-going sample project
|
1715
|
-
|
1716
|
-
|
1736
|
+
Gladiator (short for Glimmer Editor) is an on-going sample project under continuous development. It is used as the main text editor for developing Glimmer.
|
1737
|
+
|
1738
|
+
It currently supports the following text editing features:
|
1739
|
+
- File explorer navigation to open file
|
1740
|
+
- File lookup by name
|
1741
|
+
- Find & Replace
|
1742
|
+
- Show Line Numbers
|
1743
|
+
- Jump to Line
|
1744
|
+
- Remember last opened file, caret position, and top line
|
1745
|
+
- Autosave on focus out/quit/open new file
|
1746
|
+
- Watch open file for external changes to reflect in editor
|
1747
|
+
- Duplicate Line(s)
|
1748
|
+
- Kill Line(s)
|
1749
|
+
- Move up one line
|
1750
|
+
- Move down one line
|
1751
|
+
|
1752
|
+
Gladiator has been made available in [Glimmer's gem](https://rubygems.org/gems/glimmer) via the `gladiator` command should others find useful too.
|
1753
|
+
|
1717
1754
|
If you cloned this project and followed [CONTRIBUTING.md](CONTRIBUTING.md) instructions, you may invoke via `bin/gladiator` instead.
|
1718
1755
|
|
1719
1756
|
## In Production
|
1720
1757
|
|
1721
1758
|
The following production apps have been built with Glimmer:
|
1722
|
-
|
1759
|
+
|
1760
|
+
[<img alt="Math Bowling Logo" src="https://raw.githubusercontent.com/AndyObtiva/MathBowling/master/images/math-bowling-logo.png" width="40" />Math Bowling](https://github.com/AndyObtiva/MathBowling): an educational math game for elementary level kids
|
1723
1761
|
|
1724
1762
|
## SWT Reference
|
1725
1763
|
|
data/lib/glimmer.rb
CHANGED
data/lib/glimmer/launcher.rb
CHANGED
@@ -69,8 +69,8 @@ module Glimmer
|
|
69
69
|
if the_glimmer_lib == GLIMMER_LIB_LOCAL
|
70
70
|
devmode_require = '-r puts_debuggerer '
|
71
71
|
end
|
72
|
-
puts "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} -r #{the_glimmer_lib}
|
73
|
-
system "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} -r #{the_glimmer_lib}
|
72
|
+
puts "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}" if jruby_options_string.to_s.include?('--debug')
|
73
|
+
system "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -130,9 +130,11 @@ module Glimmer
|
|
130
130
|
if observation_request.start_with?('on_')
|
131
131
|
event_name = observation_request.sub(/^on_/, '')
|
132
132
|
if OBSERVED_MENU_ITEMS.include?(event_name)
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
if OS.mac?
|
134
|
+
system_menu = DisplayProxy.instance.swt_display.getSystemMenu
|
135
|
+
menu_item = system_menu.getItems.find {|menu_item| menu_item.getID == SWTProxy["ID_#{event_name.upcase}"]}
|
136
|
+
menu_item.addListener(SWTProxy[:Selection], &block)
|
137
|
+
end
|
136
138
|
else
|
137
139
|
super
|
138
140
|
end
|
@@ -10,19 +10,24 @@ module Glimmer
|
|
10
10
|
java_import 'org.eclipse.swt.SWT'
|
11
11
|
|
12
12
|
ERROR_INVALID_STYLE = " is an invalid SWT style! Please choose a style from org.eclipse.swt.SWT class constants."
|
13
|
+
REGEX_SYMBOL_NEGATIVITY = /^([^!]+)(!)?$/
|
13
14
|
|
14
15
|
# Gets SWT constants as if calling SWT::CONSTANT where constant is
|
15
16
|
# passed in as a lower case symbol
|
16
17
|
def [](*symbols)
|
17
18
|
symbols = symbols.first if symbols.size == 1 && symbols.first.is_a?(Array)
|
18
|
-
symbols.compact.
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
result = symbols.compact.map do |symbol|
|
20
|
+
constant(symbol).tap do |constant_value|
|
21
|
+
raise Error, symbol.to_s + ERROR_INVALID_STYLE unless constant_value.is_a?(Integer)
|
22
|
+
end
|
23
|
+
end.reduce do |output, constant_value|
|
24
|
+
if constant_value < 0
|
25
|
+
output & constant_value
|
22
26
|
else
|
23
|
-
|
27
|
+
output | constant_value
|
24
28
|
end
|
25
29
|
end
|
30
|
+
result.nil? ? SWT::NONE : result
|
26
31
|
end
|
27
32
|
|
28
33
|
# Returns SWT style integer value for passed in symbol or allows
|
@@ -32,18 +37,43 @@ module Glimmer
|
|
32
37
|
# (look into [] operator if you want an error raised on invalid values)
|
33
38
|
def constant(symbol)
|
34
39
|
return symbol unless symbol.is_a?(Symbol) || symbol.is_a?(String)
|
35
|
-
symbol_string = symbol
|
40
|
+
symbol_string, negative = extract_symbol_string_negativity(symbol)
|
36
41
|
swt_constant_symbol = symbol_string.downcase == symbol_string ? symbol_string.upcase.to_sym : symbol_string.to_sym
|
37
|
-
SWT.const_get(swt_constant_symbol)
|
38
|
-
|
42
|
+
bit_value = SWT.const_get(swt_constant_symbol)
|
43
|
+
negative ? ~bit_value : bit_value
|
44
|
+
rescue => e
|
39
45
|
begin
|
46
|
+
# Glimmer.logger&.debug(e.full_message)
|
40
47
|
alternative_swt_constant_symbol = SWT.constants.find {|c| c.to_s.upcase == swt_constant_symbol.to_s.upcase}
|
41
|
-
SWT.const_get(alternative_swt_constant_symbol)
|
42
|
-
|
43
|
-
|
48
|
+
bit_value = SWT.const_get(alternative_swt_constant_symbol)
|
49
|
+
negative ? ~bit_value : bit_value
|
50
|
+
rescue => e
|
51
|
+
# Glimmer.logger&.debug(e.full_message)
|
52
|
+
bit_value = Glimmer::SWT::SWTProxy::EXTRA_STYLES[swt_constant_symbol]
|
53
|
+
if bit_value
|
54
|
+
negative ? ~bit_value : bit_value
|
55
|
+
else
|
56
|
+
symbol
|
57
|
+
end
|
44
58
|
end
|
45
59
|
end
|
46
60
|
|
61
|
+
def extract_symbol_string_negativity(symbol)
|
62
|
+
if symbol.is_a?(Symbol) || symbol.is_a?(String)
|
63
|
+
symbol_negativity_match = symbol.to_s.match(REGEX_SYMBOL_NEGATIVITY)
|
64
|
+
symbol = symbol_negativity_match[1]
|
65
|
+
negative = !!symbol_negativity_match[2]
|
66
|
+
[symbol, negative]
|
67
|
+
else
|
68
|
+
negative = symbol < 0
|
69
|
+
[symbol, negative]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def negative?(symbol)
|
74
|
+
extract_symbol_string_negativity(symbol)[1]
|
75
|
+
end
|
76
|
+
|
47
77
|
def has_constant?(symbol)
|
48
78
|
return false unless symbol.is_a?(Symbol) || symbol.is_a?(String)
|
49
79
|
constant(symbol).is_a?(Integer)
|
@@ -69,7 +99,7 @@ module Glimmer
|
|
69
99
|
end
|
70
100
|
|
71
101
|
EXTRA_STYLES = {
|
72
|
-
NO_RESIZE:
|
102
|
+
NO_RESIZE: self[:shell_trim, :resize!, :max!]
|
73
103
|
}
|
74
104
|
end
|
75
105
|
end
|
data/lib/glimmer/ui/video.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'glimmer/ui/custom_widget'
|
2
2
|
require 'glimmer/swt/color_proxy'
|
3
3
|
|
4
|
-
#TODO display progress wheel while loading video
|
4
|
+
#TODO consider the need to display a progress wheel while loading video as an option
|
5
5
|
|
6
6
|
module Glimmer
|
7
7
|
module UI
|
@@ -26,7 +26,7 @@ module Glimmer
|
|
26
26
|
alias fit_to_height? fit_to_height
|
27
27
|
|
28
28
|
body {
|
29
|
-
browser {
|
29
|
+
browser(:no_scroll) {
|
30
30
|
text <<~HTML
|
31
31
|
<html>
|
32
32
|
<head>
|
@@ -34,6 +34,7 @@ module Glimmer
|
|
34
34
|
body {
|
35
35
|
margin: 0;
|
36
36
|
padding: 0;
|
37
|
+
overflow: hidden;
|
37
38
|
}
|
38
39
|
</style>
|
39
40
|
<style id="style-body-background">
|
data/samples/gladiator.rb
CHANGED
@@ -3,6 +3,7 @@ require 'filewatcher'
|
|
3
3
|
require 'clipboard'
|
4
4
|
|
5
5
|
Clipboard.implementation = Clipboard::Java
|
6
|
+
Clipboard.copy(Clipboard.paste) # pre-initialize library to avoid slowdown during use
|
6
7
|
|
7
8
|
# Gladiator (Glimmer Editor)
|
8
9
|
class Gladiator
|
@@ -370,11 +371,11 @@ class Gladiator
|
|
370
371
|
end
|
371
372
|
|
372
373
|
def line_for_caret_position(caret_position)
|
373
|
-
lines[line_index_for_caret_position(caret_position)]
|
374
|
+
lines[line_index_for_caret_position(caret_position.to_i)]
|
374
375
|
end
|
375
376
|
|
376
377
|
def line_index_for_caret_position(caret_position)
|
377
|
-
dirty_content[0...caret_position].count("\n")
|
378
|
+
dirty_content[0...caret_position.to_i].count("\n")
|
378
379
|
end
|
379
380
|
|
380
381
|
def caret_position_for_line_index(line_index)
|
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.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|