glimmer-dsl-swt 0.5.6 → 0.6.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 +1 -1
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/glimmer/dsl/swt/cursor_expression.rb +26 -0
- data/lib/glimmer/dsl/swt/dsl.rb +2 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +24 -0
- data/lib/glimmer/swt/cursor_proxy.rb +45 -0
- data/lib/glimmer/swt/font_proxy.rb +7 -7
- data/lib/glimmer/swt/style_constantizable.rb +11 -1
- data/lib/glimmer/swt/widget_proxy.rb +9 -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 +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c023dda45b9c92e69ef9a44ef07fde1f45f5161284cf1b46b70d15a661b3ccc
|
4
|
+
data.tar.gz: 77be63700930812f4da66669003df863d77a1644495e2d37b776e97a5e5f145b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce300717322a9a905a67c589bf1a9398adcd09abf33421283c5d3265ed68b8ce4dbdf25ac33a37812de355c00ba027d7fe33ce284a9c2eb2932817087130a281
|
7
|
+
data.tar.gz: 353b5a6f43cf7d070ae9a2f775ea2430a4eda54bf346210a8ca5e1ee899a35c44f639fbca3e2cd5338aa73c3f1c9b97209c84ea669c436f36f4ce31a0bf9b1b8
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.6.0 (Desktop GUI)
|
2
2
|
[](http://badge.fury.io/rb/glimmer-dsl-swt)
|
3
3
|
[](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
4
4
|
[](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
|
data/RUBY_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-9.2.
|
1
|
+
jruby-9.2.13.0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/dsl/top_level_expression'
|
3
|
+
require 'glimmer/swt/cursor_proxy'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
module DSL
|
7
|
+
module SWT
|
8
|
+
# cursor expression
|
9
|
+
# Note: Cannot be a static expression because it clashes with cursor property expression
|
10
|
+
class CursorExpression < Expression
|
11
|
+
include TopLevelExpression
|
12
|
+
|
13
|
+
def can_interpret?(parent, keyword, *args, &block)
|
14
|
+
keyword.to_s == 'cursor' and
|
15
|
+
(parent.nil? or !parent.respond_to?('cursor')) and
|
16
|
+
args.size == 1 and
|
17
|
+
(args.first.is_a?(Integer) or textual?(args.first))
|
18
|
+
end
|
19
|
+
|
20
|
+
def interpret(parent, keyword, *args, &block)
|
21
|
+
Glimmer::SWT::CursorProxy.new(*args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/dsl/top_level_expression'
|
3
|
+
require 'glimmer/swt/font_proxy'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
module DSL
|
7
|
+
module SWT
|
8
|
+
# font expression
|
9
|
+
# Note: Cannot be a static expression because it clashes with font property expression
|
10
|
+
class FontExpression < Expression
|
11
|
+
include TopLevelExpression
|
12
|
+
|
13
|
+
def can_interpret?(parent, keyword, *args, &block)
|
14
|
+
keyword.to_s == 'font' and
|
15
|
+
(parent.nil? || !parent.respond_to?('font')) && args.size == 1 && args.first.is_a?(Hash)
|
16
|
+
end
|
17
|
+
|
18
|
+
def interpret(parent, keyword, *args, &block)
|
19
|
+
Glimmer::SWT::FontProxy.new(*args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'glimmer/error'
|
2
|
+
require 'glimmer/swt/swt_proxy'
|
3
|
+
require 'glimmer/swt/display_proxy'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
module SWT
|
7
|
+
# Proxy for org.eclipse.swt.graphics.Cursor
|
8
|
+
#
|
9
|
+
# Invoking `#swt_cursor` returns the SWT Cursor object wrapped by this proxy
|
10
|
+
#
|
11
|
+
# Follows the Proxy Design Pattern
|
12
|
+
class CursorProxy
|
13
|
+
CURSOR_STYLES = org.eclipse.swt.SWT.constants.select {|c| c.to_s.downcase.start_with?('cursor_')}.map {|c| c.to_s.downcase.sub('cursor_', '').to_sym}
|
14
|
+
ERROR_INVALID_CURSOR_STYLE = " is an invalid cursor style! Valid values are #{CURSOR_STYLES.map(&:to_s).join(", ")}"
|
15
|
+
|
16
|
+
include_package 'org.eclipse.swt.graphics'
|
17
|
+
|
18
|
+
attr_reader :swt_cursor, :cursor_style
|
19
|
+
|
20
|
+
# Builds a new CursorProxy from passed in cursor SWT style (e.g. :appstarting, :hand, or :help)
|
21
|
+
#
|
22
|
+
# Cursor SWT styles are those that begin with "CURSOR_" prefix
|
23
|
+
#
|
24
|
+
# They are expected to be passed in in short form without the prefix (but would work with the prefix too)
|
25
|
+
def initialize(cursor_style)
|
26
|
+
@cursor_style = cursor_style
|
27
|
+
@cursor_style = SWTProxy.reverse_lookup(@cursor_style).detect { |symbol| symbol.to_s.downcase.start_with?('cursor_') } if cursor_style.is_a?(Integer)
|
28
|
+
@cursor_style = @cursor_style.to_s.downcase
|
29
|
+
@cursor_style = @cursor_style.sub(/^cursor\_/, '') if @cursor_style.start_with?('cursor_')
|
30
|
+
detect_invalid_cursor_style
|
31
|
+
@swt_cursor = DisplayProxy.instance.swt_display.get_system_cursor(SWTProxy[swt_style])
|
32
|
+
end
|
33
|
+
|
34
|
+
def swt_style
|
35
|
+
@swt_style ||= @cursor_style.upcase.start_with?('CURSOR_') ? @cursor_style : "CURSOR_#{@cursor_style}"
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def detect_invalid_cursor_style
|
41
|
+
raise Error, cursor_style.to_s + ERROR_INVALID_CURSOR_STYLE unless CURSOR_STYLES.include?(cursor_style.to_s.downcase.to_sym)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -6,11 +6,10 @@ module Glimmer
|
|
6
6
|
module SWT
|
7
7
|
# Proxy for org.eclipse.swt.graphics.Font
|
8
8
|
#
|
9
|
-
# This class
|
10
|
-
# an SWT widget font
|
9
|
+
# This class can be optionally used with WidgetProxy to manipulate
|
10
|
+
# an SWT widget font (reusing its FontData but building a new Font)
|
11
11
|
#
|
12
|
-
#
|
13
|
-
# a widget proxy.
|
12
|
+
# Otherwise, if no WidgetProxy is passed to constructor, it builds new FontData
|
14
13
|
#
|
15
14
|
# Invoking `#swt_font` returns the SWT Font object wrapped by this proxy
|
16
15
|
#
|
@@ -21,7 +20,7 @@ module Glimmer
|
|
21
20
|
|
22
21
|
include_package 'org.eclipse.swt.graphics'
|
23
22
|
|
24
|
-
attr_reader :widget_proxy, :swt_font
|
23
|
+
attr_reader :widget_proxy, :swt_font, :font_properties
|
25
24
|
|
26
25
|
# Builds a new font proxy from passed in widget_proxy and font_properties hash,
|
27
26
|
#
|
@@ -31,8 +30,9 @@ module Glimmer
|
|
31
30
|
#
|
32
31
|
# Style (:style value) can only be one of FontProxy::FONT_STYLES values:
|
33
32
|
# that is :normal, :bold, or :italic
|
34
|
-
def initialize(widget_proxy, font_properties)
|
33
|
+
def initialize(widget_proxy = nil, font_properties)
|
35
34
|
@widget_proxy = widget_proxy
|
35
|
+
@font_properties = font_properties
|
36
36
|
detect_invalid_font_property(font_properties)
|
37
37
|
font_properties[:style] = SWTProxy[*font_properties[:style]]
|
38
38
|
font_data_args = [:name, :height, :style].map do |font_property_name|
|
@@ -57,7 +57,7 @@ module Glimmer
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def font_datum
|
60
|
-
@font_datum ||= @widget_proxy.swt_widget.getFont.getFontData[0]
|
60
|
+
@font_datum ||= @widget_proxy ? @widget_proxy.swt_widget.getFont.getFontData[0] : FontData.new
|
61
61
|
end
|
62
62
|
|
63
63
|
def detect_invalid_font_property(font_properties)
|
@@ -106,7 +106,17 @@ module Glimmer
|
|
106
106
|
def deconstruct(integer)
|
107
107
|
constant_source_class.constants.reduce([]) do |found, c|
|
108
108
|
constant_value = constant_source_class.const_get(c) rescue -1
|
109
|
-
is_found = constant_value.is_a?(Integer) && (
|
109
|
+
is_found = constant_value.is_a?(Integer) && (integer & constant_value) == integer
|
110
|
+
is_found ? found += [c] : found
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Reverse engineer a style integer into a symbol
|
115
|
+
# Useful for debugging
|
116
|
+
def reverse_lookup(integer)
|
117
|
+
constant_source_class.constants.reduce([]) do |found, c|
|
118
|
+
constant_value = constant_source_class.const_get(c) rescue -1
|
119
|
+
is_found = constant_value.is_a?(Integer) && integer == constant_value
|
110
120
|
is_found ? found += [c] : found
|
111
121
|
end
|
112
122
|
end
|
@@ -607,6 +607,15 @@ module Glimmer
|
|
607
607
|
value
|
608
608
|
end
|
609
609
|
end,
|
610
|
+
:cursor => lambda do |value|
|
611
|
+
cursor_proxy = nil
|
612
|
+
if value.is_a?(CursorProxy)
|
613
|
+
cursor_proxy = value
|
614
|
+
elsif value.is_a?(Symbol) || value.is_a?(String) || value.is_a?(Integer)
|
615
|
+
cursor_proxy = CursorProxy.new(value)
|
616
|
+
end
|
617
|
+
cursor_proxy ? cursor_proxy.swt_cursor : value
|
618
|
+
end,
|
610
619
|
:foreground => color_converter,
|
611
620
|
:font => lambda do |value|
|
612
621
|
if value.is_a?(Hash)
|
data/vendor/swt/linux/swt.jar
CHANGED
Binary file
|
data/vendor/swt/mac/swt.jar
CHANGED
Binary file
|
data/vendor/swt/windows/swt.jar
CHANGED
Binary file
|
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: 0.
|
4
|
+
version: 0.6.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-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -309,6 +309,7 @@ files:
|
|
309
309
|
- lib/glimmer/dsl/swt/color_expression.rb
|
310
310
|
- lib/glimmer/dsl/swt/column_properties_expression.rb
|
311
311
|
- lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb
|
312
|
+
- lib/glimmer/dsl/swt/cursor_expression.rb
|
312
313
|
- lib/glimmer/dsl/swt/custom_widget_expression.rb
|
313
314
|
- lib/glimmer/dsl/swt/data_binding_expression.rb
|
314
315
|
- lib/glimmer/dsl/swt/dialog_expression.rb
|
@@ -316,6 +317,7 @@ files:
|
|
316
317
|
- lib/glimmer/dsl/swt/dnd_expression.rb
|
317
318
|
- lib/glimmer/dsl/swt/dsl.rb
|
318
319
|
- lib/glimmer/dsl/swt/exec_expression.rb
|
320
|
+
- lib/glimmer/dsl/swt/font_expression.rb
|
319
321
|
- lib/glimmer/dsl/swt/layout_data_expression.rb
|
320
322
|
- lib/glimmer/dsl/swt/layout_expression.rb
|
321
323
|
- lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
|
@@ -341,6 +343,7 @@ files:
|
|
341
343
|
- lib/glimmer/rake_task/list.rb
|
342
344
|
- lib/glimmer/scaffold.rb
|
343
345
|
- lib/glimmer/swt/color_proxy.rb
|
346
|
+
- lib/glimmer/swt/cursor_proxy.rb
|
344
347
|
- lib/glimmer/swt/display_proxy.rb
|
345
348
|
- lib/glimmer/swt/dnd_proxy.rb
|
346
349
|
- lib/glimmer/swt/font_proxy.rb
|