glimmer-dsl-swt 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/glimmer/dsl/swt/cursor_expression.rb +1 -4
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +3 -1
- data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +6 -0
- data/lib/glimmer/swt/image_proxy.rb +16 -23
- data/lib/glimmer/swt/layout_proxy.rb +2 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -11
- data/lib/glimmer/swt/widget_proxy.rb +39 -14
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d54a8793938853e74eb207e159ce6ab3f856ac57f737a3bd28990f5e52a745d
|
4
|
+
data.tar.gz: a28121a29d1a123b056d121642bf70acd12891c428bdda8602caa2cf7157df35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a850f6805c1cc2f129bdc91c09c7a8b336ce81640311af63040c8168d535ab68fb91cb53bf0a8421ec38d1daab94b9a835eec209e2685e1702ca3e91b51af8
|
7
|
+
data.tar.gz: 3044e95046bbda195c0ecd736ff30097ab6dadf660093d317d86d92c46f1bdf16dc669f944a9a62b398fa2f27697572290f4df9caffb8825c6b61a8f0ff2fea1
|
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.6.
|
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.2 (Desktop GUI)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
3
3
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'glimmer/dsl/expression'
|
2
|
-
require 'glimmer/dsl/top_level_expression'
|
3
2
|
require 'glimmer/swt/cursor_proxy'
|
4
3
|
|
5
4
|
module Glimmer
|
@@ -8,11 +7,9 @@ module Glimmer
|
|
8
7
|
# cursor expression
|
9
8
|
# Note: Cannot be a static expression because it clashes with cursor property expression
|
10
9
|
class CursorExpression < Expression
|
11
|
-
include TopLevelExpression
|
12
|
-
|
13
10
|
def can_interpret?(parent, keyword, *args, &block)
|
14
11
|
keyword.to_s == 'cursor' and
|
15
|
-
|
12
|
+
(parent.nil? or !parent.respond_to?('cursor')) and
|
16
13
|
args.size == 1 and
|
17
14
|
(args.first.is_a?(Integer) or textual?(args.first))
|
18
15
|
end
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -12,7 +12,9 @@ module Glimmer
|
|
12
12
|
|
13
13
|
def can_interpret?(parent, keyword, *args, &block)
|
14
14
|
keyword.to_s == 'font' and
|
15
|
-
|
15
|
+
(parent.nil? || !parent.respond_to?('font')) and
|
16
|
+
args.size == 1 and
|
17
|
+
args.first.is_a?(Hash)
|
16
18
|
end
|
17
19
|
|
18
20
|
def interpret(parent, keyword, *args, &block)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/swt/image_proxy'
|
3
|
+
|
4
|
+
module Glimmer
|
5
|
+
module DSL
|
6
|
+
module SWT
|
7
|
+
# image expression
|
8
|
+
# Note: Cannot be a static expression because it clashes with image property expression
|
9
|
+
class ImageExpression < Expression
|
10
|
+
def can_interpret?(parent, keyword, *args, &block)
|
11
|
+
keyword.to_s == 'image' and
|
12
|
+
(parent.nil? or !parent.respond_to?('image'))
|
13
|
+
end
|
14
|
+
|
15
|
+
def interpret(parent, keyword, *args, &block)
|
16
|
+
Glimmer::SWT::ImageProxy.new(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -8,7 +8,7 @@ module Glimmer
|
|
8
8
|
class ImageProxy
|
9
9
|
include_package 'org.eclipse.swt.graphics'
|
10
10
|
|
11
|
-
attr_reader :jar_file_path, :image_data
|
11
|
+
attr_reader :file_path, :jar_file_path, :image_data, :swt_image
|
12
12
|
|
13
13
|
# Initializes a proxy for an SWT Image object
|
14
14
|
#
|
@@ -17,31 +17,24 @@ module Glimmer
|
|
17
17
|
# and returns an image object.
|
18
18
|
def initialize(*args)
|
19
19
|
@args = args
|
20
|
-
@
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if file_path.start_with?('uri:classloader')
|
29
|
-
file_path = file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac
|
30
|
-
object = java.lang.Object.new
|
31
|
-
file_input_stream = object.java_class.resource_as_stream(file_path)
|
32
|
-
buffered_file_input_stream = java.io.BufferedInputStream.new(file_input_stream)
|
33
|
-
end
|
34
|
-
@image_data = ImageData.new(buffered_file_input_stream || file_path)
|
35
|
-
@swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
|
36
|
-
else
|
37
|
-
@swt_image = Image.new(*@args)
|
20
|
+
@file_path = @args.first if @args.first.is_a?(String) && @args.size == 1
|
21
|
+
if @file_path
|
22
|
+
if @file_path.start_with?('uri:classloader')
|
23
|
+
@jar_file_path = @file_path
|
24
|
+
@file_path = @jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac
|
25
|
+
object = java.lang.Object.new
|
26
|
+
file_input_stream = object.java_class.resource_as_stream(file_path)
|
27
|
+
buffered_file_input_stream = java.io.BufferedInputStream.new(file_input_stream)
|
38
28
|
end
|
39
|
-
|
40
|
-
|
29
|
+
@image_data = ImageData.new(buffered_file_input_stream || @file_path)
|
30
|
+
@swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
|
31
|
+
else
|
32
|
+
@swt_image = Image.new(*@args)
|
33
|
+
@image_data = @swt_image.image_data
|
34
|
+
end
|
41
35
|
end
|
42
|
-
|
36
|
+
|
43
37
|
def scale_to(width, height)
|
44
|
-
return @swt_image if image_data.nil?
|
45
38
|
scaled_image_data = image_data.scaledTo(width, height)
|
46
39
|
device = swt_image.device
|
47
40
|
swt_image.dispose
|
@@ -45,6 +45,8 @@ module Glimmer
|
|
45
45
|
@widget_proxy = widget_proxy
|
46
46
|
args = SWTProxy.constantify_args(args)
|
47
47
|
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
48
|
+
@swt_layout.marginWidth = 15 if @swt_layout.respond_to?(:marginWidth)
|
49
|
+
@swt_layout.marginHeight = 15 if @swt_layout.respond_to?(:marginHeight)
|
48
50
|
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
49
51
|
end
|
50
52
|
|
@@ -1,21 +1,16 @@
|
|
1
1
|
require 'glimmer/swt/widget_proxy'
|
2
|
+
require 'glimmer/swt/swt_proxy'
|
2
3
|
|
3
4
|
module Glimmer
|
4
5
|
module SWT
|
5
|
-
class ScrolledCompositeProxy < Glimmer::SWT::WidgetProxy
|
6
|
-
def initialize(underscored_widget_name, parent, args)
|
7
|
-
unless args.first.is_a?(Numeric)
|
8
|
-
args.unshift(:h_scroll)
|
9
|
-
args.unshift(:v_scroll)
|
10
|
-
end
|
11
|
-
super
|
12
|
-
swt_widget.expand_horizontal = true
|
13
|
-
swt_widget.expand_vertical = true
|
14
|
-
end
|
15
|
-
|
6
|
+
class ScrolledCompositeProxy < Glimmer::SWT::WidgetProxy
|
16
7
|
def post_initialize_child(child)
|
17
8
|
swt_widget.content = child.swt_widget
|
18
9
|
end
|
10
|
+
|
11
|
+
def post_add_content
|
12
|
+
swt_widget.set_min_size(swt_widget.computeSize(SWTProxy[:default], SWTProxy[:default]))
|
13
|
+
end
|
19
14
|
end
|
20
15
|
end
|
21
16
|
end
|
@@ -22,21 +22,39 @@ module Glimmer
|
|
22
22
|
include Packages
|
23
23
|
|
24
24
|
DEFAULT_STYLES = {
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"list"
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
25
|
+
"arrow" => [:arrow],
|
26
|
+
"button" => [:push],
|
27
|
+
"checkbox" => [:check],
|
28
|
+
"drag_source" => [:drop_copy],
|
29
|
+
"drop_target" => [:drop_copy],
|
30
|
+
"list" => [:border, :v_scroll],
|
31
|
+
"menu_item" => [:push],
|
32
|
+
"radio" => [:radio],
|
33
|
+
"scrolled_composite" => [:border, :h_scroll, :v_scroll],
|
34
|
+
"spinner" => [:border],
|
35
|
+
"styled_text" => [:border],
|
36
|
+
"table" => [:virtual, :border, :full_selection],
|
37
|
+
"text" => [:border],
|
38
|
+
"toggle" => [:toggle],
|
39
|
+
"tree" => [:virtual, :border, :h_scroll, :v_scroll],
|
35
40
|
}
|
36
41
|
|
37
42
|
DEFAULT_INITIALIZERS = {
|
38
43
|
"composite" => lambda do |composite|
|
39
|
-
|
44
|
+
layout = GridLayout.new
|
45
|
+
layout.marginWidth = 15
|
46
|
+
layout.marginHeight = 15
|
47
|
+
composite.layout = layout
|
48
|
+
end,
|
49
|
+
"scrolled_composite" => lambda do |scrolled_composite|
|
50
|
+
scrolled_composite.expand_horizontal = true
|
51
|
+
scrolled_composite.expand_vertical = true
|
52
|
+
end,
|
53
|
+
"shell" => lambda do |shell|
|
54
|
+
layout = FillLayout.new
|
55
|
+
layout.marginWidth = 15
|
56
|
+
layout.marginHeight = 15
|
57
|
+
shell.layout = layout
|
40
58
|
end,
|
41
59
|
"table" => lambda do |table|
|
42
60
|
table.setHeaderVisible(true)
|
@@ -50,18 +68,19 @@ module Glimmer
|
|
50
68
|
end,
|
51
69
|
}
|
52
70
|
|
53
|
-
attr_reader :swt_widget, :drag_source_proxy, :drop_target_proxy, :drag_source_style, :drag_source_transfer, :drop_target_transfer
|
71
|
+
attr_reader :parent_proxy, :swt_widget, :drag_source_proxy, :drop_target_proxy, :drag_source_style, :drag_source_transfer, :drop_target_transfer
|
54
72
|
|
55
73
|
# Initializes a new SWT Widget
|
56
74
|
#
|
57
75
|
# Styles is a comma separate list of symbols representing SWT styles in lower case
|
58
76
|
def initialize(underscored_widget_name, parent, args)
|
77
|
+
@parent_proxy = parent
|
59
78
|
styles, extra_options = extract_args(underscored_widget_name, args)
|
60
79
|
swt_widget_class = self.class.swt_widget_class_for(underscored_widget_name)
|
61
|
-
@swt_widget = swt_widget_class.new(
|
80
|
+
@swt_widget = swt_widget_class.new(@parent_proxy.swt_widget, style(underscored_widget_name, styles), *extra_options)
|
62
81
|
@swt_widget.set_data('proxy', self)
|
63
82
|
DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@swt_widget)
|
64
|
-
|
83
|
+
@parent_proxy.post_initialize_child(self)
|
65
84
|
end
|
66
85
|
|
67
86
|
# Subclasses may override to perform post initialization work on an added child
|
@@ -69,6 +88,11 @@ module Glimmer
|
|
69
88
|
# No Op by default
|
70
89
|
end
|
71
90
|
|
91
|
+
# Subclasses may override to perform post add_content work
|
92
|
+
def post_add_content
|
93
|
+
# No Op by default
|
94
|
+
end
|
95
|
+
|
72
96
|
def extract_args(underscored_widget_name, args)
|
73
97
|
@arg_extractor_mapping ||= {
|
74
98
|
'menu_item' => lambda do |args|
|
@@ -264,6 +288,7 @@ module Glimmer
|
|
264
288
|
|
265
289
|
# This supports widgets in and out of basic SWT
|
266
290
|
def self.swt_widget_class_for(underscored_widget_name)
|
291
|
+
underscored_widget_name = 'button' if %w[radio checkbox toggle arrow].include?(underscored_widget_name)
|
267
292
|
swt_widget_name = underscored_widget_name.camelcase(:upper)
|
268
293
|
swt_widget_class = eval(swt_widget_name)
|
269
294
|
unless swt_widget_class.ancestors.include?(org.eclipse.swt.widgets.Widget)
|
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.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -333,6 +333,7 @@ files:
|
|
333
333
|
- lib/glimmer/dsl/swt/dsl.rb
|
334
334
|
- lib/glimmer/dsl/swt/exec_expression.rb
|
335
335
|
- lib/glimmer/dsl/swt/font_expression.rb
|
336
|
+
- lib/glimmer/dsl/swt/image_expression.rb
|
336
337
|
- lib/glimmer/dsl/swt/layout_data_expression.rb
|
337
338
|
- lib/glimmer/dsl/swt/layout_expression.rb
|
338
339
|
- lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
|