shoes-swt 4.0.0.pre5 → 4.0.0.pre6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoes/swt/app.rb +2 -1
- data/lib/shoes/swt/button.rb +4 -0
- data/lib/shoes/swt/image.rb +5 -5
- data/lib/shoes/swt/link_segment.rb +1 -1
- data/lib/shoes/swt/text_block/fitter.rb +1 -1
- data/lib/shoes/swt/text_block/text_segment.rb +5 -4
- data/lib/shoes/swt/text_block/text_segment_collection.rb +1 -1
- data/lib/shoes/swt/version.rb +1 -1
- data/shoes-swt.gemspec +2 -2
- data/spec/shoes/swt/app_spec.rb +30 -32
- data/spec/shoes/swt/button_spec.rb +7 -0
- data/spec/shoes/swt/link_segment_spec.rb +1 -1
- data/spec/shoes/swt/link_spec.rb +2 -3
- data/spec/shoes/swt/text_block/fitter_spec.rb +4 -4
- data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +1 -1
- data/spec/shoes/swt/text_block_spec.rb +2 -2
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beac25befd7cf85ba03f9b1cd9826bb9f1e28930
|
4
|
+
data.tar.gz: e82b136fb081ce7f34a0a9c62e1683e42e1f46cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11f22c3d4cf71dc857f7ce0314b1faeac57a8b4438c24b2fa4c32a5b186e1abd9ac804934eade0a1972dca958391c5a32d90eb52b4ac5f85dc9afcd3e36483a5
|
7
|
+
data.tar.gz: e44f05ba4c214ed613aacd03325c24f588e4a68ddf6d3118fac3070efcdd9f25d42144b21f9185c06f8d054d8507cb1d628bce93f5a4a1ba282f6a9da2a1efde
|
data/lib/shoes/swt/app.rb
CHANGED
@@ -199,7 +199,8 @@ class Shoes
|
|
199
199
|
style = ::Swt::SWT::CLOSE | ::Swt::SWT::MIN | ::Swt::SWT::V_SCROLL
|
200
200
|
style |= ::Swt::SWT::RESIZE | ::Swt::SWT::MAX if @dsl.opts[:resizable]
|
201
201
|
style |= ::Swt::SWT::APPLICATION_MODAL if @dsl.opts[:modal]
|
202
|
-
style |= ::Swt::SWT::ON_TOP
|
202
|
+
style |= ::Swt::SWT::ON_TOP if @dsl.opts[:always_on_top]
|
203
|
+
style |= ::Swt::SWT::NO_TRIM unless @dsl.opts.fetch(:border, true)
|
203
204
|
style
|
204
205
|
end
|
205
206
|
|
data/lib/shoes/swt/button.rb
CHANGED
data/lib/shoes/swt/image.rb
CHANGED
@@ -89,11 +89,11 @@ class Shoes
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def display_image(name_or_data)
|
92
|
-
if raw_image_data?(name_or_data)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
92
|
+
data = if raw_image_data?(name_or_data)
|
93
|
+
load_raw_image_data(name_or_data)
|
94
|
+
else
|
95
|
+
name_or_data
|
96
|
+
end
|
97
97
|
create_image(data)
|
98
98
|
end
|
99
99
|
|
@@ -198,7 +198,7 @@ class Shoes
|
|
198
198
|
|
199
199
|
offsets = layout.line_offsets
|
200
200
|
offsets[0...-1].each_with_index do |_, i|
|
201
|
-
height_so_far += layout.
|
201
|
+
height_so_far += layout.get_line_bounds(i).height + TextBlock::NEXT_ELEMENT_OFFSET
|
202
202
|
ending_offset = offsets[i + 1]
|
203
203
|
|
204
204
|
break if height_so_far >= height
|
@@ -12,14 +12,15 @@ class Shoes
|
|
12
12
|
#
|
13
13
|
# These are only expected to be called during contents_alignment
|
14
14
|
class TextSegment
|
15
|
+
extend Forwardable
|
16
|
+
|
15
17
|
DEFAULT_SPACING = 4
|
16
18
|
|
17
19
|
attr_reader :layout, :element_left, :element_top
|
18
20
|
attr_accessor :fill_background
|
19
21
|
|
20
|
-
extend Forwardable
|
21
22
|
def_delegators :@layout, :text, :text=, :bounds, :width, :spacing,
|
22
|
-
:
|
23
|
+
:get_line_bounds, :line_count, :line_offsets
|
23
24
|
|
24
25
|
def initialize(dsl, text, width)
|
25
26
|
@dsl = dsl
|
@@ -88,11 +89,11 @@ class Shoes
|
|
88
89
|
end
|
89
90
|
|
90
91
|
def last_line_height
|
91
|
-
layout.
|
92
|
+
layout.get_line_bounds(layout.line_count - 1).height
|
92
93
|
end
|
93
94
|
|
94
95
|
def last_line_width
|
95
|
-
layout.
|
96
|
+
layout.get_line_bounds(layout.line_count - 1).width
|
96
97
|
end
|
97
98
|
|
98
99
|
def draw(graphics_context)
|
data/lib/shoes/swt/version.rb
CHANGED
data/shoes-swt.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_dependency "swt", "~>4.4"
|
20
|
-
s.add_dependency "after_do", "~>0.
|
19
|
+
s.add_dependency "swt", "~>4.4.0"
|
20
|
+
s.add_dependency "after_do", "~>0.4.0"
|
21
21
|
s.add_dependency "shoes-core", Shoes::Swt::VERSION
|
22
22
|
s.add_dependency "shoes-package", Shoes::Swt::VERSION
|
23
23
|
|
data/spec/shoes/swt/app_spec.rb
CHANGED
@@ -2,34 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shoes::Swt::App do
|
4
4
|
let(:opts) { {background: Shoes::COLORS[:salmon], resizable: true} }
|
5
|
-
let(:app) { double('app') }
|
6
|
-
let(:dsl) { double('dsl', app: app,
|
7
|
-
opts: opts,
|
8
|
-
width: width,
|
9
|
-
height: 0,
|
10
|
-
app_title: 'double') }
|
11
|
-
|
12
|
-
let(:opts_unresizable) { { background: Shoes::COLORS[:salmon],
|
13
|
-
resizable: false } }
|
14
|
-
let(:app_unresizable) { double('app', opts: opts_unresizable,
|
15
|
-
width: 0,
|
16
|
-
height: 0,
|
17
|
-
app_title: 'double') }
|
18
|
-
let(:opts_always_on_top) { {background: Shoes::COLORS[:salmon],
|
19
|
-
always_on_top: true} }
|
20
|
-
let(:app_always_on_top) { double('app', opts: opts_always_on_top,
|
21
|
-
width: 0,
|
22
|
-
height: 0,
|
23
|
-
app_title: 'double') }
|
24
|
-
let(:plain_app) { double('app', opts: {},
|
25
|
-
width: 2,
|
26
|
-
height: 2,
|
27
|
-
app_title: 'double') }
|
28
5
|
let(:width) {0}
|
6
|
+
let(:dsl) { dsl_app_with_opts(opts) }
|
7
|
+
let(:app) {double 'app' }
|
29
8
|
|
30
|
-
|
31
|
-
|
32
|
-
subject { Shoes::Swt::App.new(dsl) }
|
9
|
+
subject { described_class.new dsl }
|
33
10
|
|
34
11
|
it { is_expected.to respond_to :clipboard }
|
35
12
|
it { is_expected.to respond_to :clipboard= }
|
@@ -85,14 +62,19 @@ describe Shoes::Swt::App do
|
|
85
62
|
end
|
86
63
|
|
87
64
|
it "should return a bitmask that represents not being resizable" do
|
88
|
-
not_resizable =
|
65
|
+
not_resizable = app_with_opts resizable: false
|
89
66
|
expect(not_resizable.send(:main_window_style)).to eq(BASE_BITMASK)
|
90
67
|
end
|
91
68
|
|
92
69
|
it "should return a bitmask that represents always being on top" do
|
93
|
-
always_on_top =
|
70
|
+
always_on_top = app_with_opts always_on_top: true, resizable: false
|
94
71
|
expect(always_on_top.send(:main_window_style)).to eq(BASE_BITMASK | Swt::SWT::ON_TOP)
|
95
72
|
end
|
73
|
+
|
74
|
+
it "should return an bitmask that indicates no trim" do
|
75
|
+
no_border = app_with_opts(border: false, resizable: false)
|
76
|
+
expect(no_border.send(:main_window_style)).to eq(BASE_BITMASK | Swt::SWT::NO_TRIM)
|
77
|
+
end
|
96
78
|
end
|
97
79
|
|
98
80
|
context "when attempting to copy text" do
|
@@ -142,12 +124,12 @@ describe Shoes::Swt::App do
|
|
142
124
|
|
143
125
|
describe 'App Background color' do
|
144
126
|
it 'has the given background when specified' do
|
145
|
-
|
146
|
-
|
147
|
-
|
127
|
+
color = Shoes::COLORS[:salmon]
|
128
|
+
colored = app_with_opts background: color
|
129
|
+
background = colored.shell.background
|
130
|
+
expect(background).to eq Shoes::Swt::Color.new(color).real
|
148
131
|
end
|
149
132
|
|
150
|
-
|
151
133
|
it 'has the default system background when unspecified' do
|
152
134
|
default_background = ::Swt.display.getSystemColor(::Swt::SWT::COLOR_WIDGET_BACKGROUND)
|
153
135
|
app = Shoes::Swt::App.new(Shoes::InternalApp.new(Shoes::App.new, {}))
|
@@ -165,4 +147,20 @@ describe Shoes::Swt::App do
|
|
165
147
|
subject.class.setup_system_colors
|
166
148
|
end
|
167
149
|
end
|
150
|
+
|
151
|
+
def app_with_opts(opts)
|
152
|
+
dsl_app_double = dsl_app_with_opts(opts)
|
153
|
+
|
154
|
+
Shoes::Swt::App.new dsl_app_double
|
155
|
+
end
|
156
|
+
|
157
|
+
def dsl_app_with_opts(opts)
|
158
|
+
double('app',
|
159
|
+
app: app,
|
160
|
+
opts: Shoes::InternalApp::DEFAULT_OPTIONS.merge(opts),
|
161
|
+
width: 0,
|
162
|
+
height: 0,
|
163
|
+
app_title: 'double')
|
164
|
+
end
|
165
|
+
|
168
166
|
end
|
@@ -108,7 +108,7 @@ describe Shoes::Swt::LinkSegment do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def stub_line_bounds(index)
|
111
|
-
allow(layout).to receive(:
|
111
|
+
allow(layout).to receive(:get_line_bounds).with(index) {
|
112
112
|
double("line #{index}",
|
113
113
|
x: 0,
|
114
114
|
y: index * line_height,
|
data/spec/shoes/swt/link_spec.rb
CHANGED
@@ -12,10 +12,9 @@ describe Shoes::Swt::Link do
|
|
12
12
|
it_behaves_like "clickable backend"
|
13
13
|
|
14
14
|
context "creating link segments" do
|
15
|
-
let(:bounds) { double("bounds", height: 0) }
|
15
|
+
let(:bounds) { double("bounds", x: 0, y: 0, height: 0) }
|
16
16
|
let(:inner_layout) { double("inner layout",
|
17
|
-
get_line_bounds: bounds, line_count: 1
|
18
|
-
line_bounds: double(x: 0, y: 0, height: 0)) }
|
17
|
+
get_line_bounds: bounds, line_count: 1) }
|
19
18
|
let(:layout) { double("layout",
|
20
19
|
get_location: double("position", x: 0, y: 0),
|
21
20
|
element_left: 0, element_top: 0,
|
@@ -76,15 +76,15 @@ describe Shoes::Swt::TextBlock::Fitter do
|
|
76
76
|
describe "finding what didn't fit" do
|
77
77
|
it "splits when one line past requested height" do
|
78
78
|
segment = double('segment', line_offsets: [0, 5, 10], text: "Text Split")
|
79
|
-
allow(segment).to receive(:
|
79
|
+
allow(segment).to receive(:get_line_bounds) { double('line_bounds', height: 25)}
|
80
80
|
|
81
81
|
expect(subject.split_text(segment, 24)).to eq(["Text ", "Split"])
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should be able to split text when too small" do
|
85
85
|
segment = double('segment', line_offsets: [0, 10], text: "Text Split")
|
86
|
-
allow(segment).to receive(:
|
87
|
-
allow(segment).to receive(:
|
86
|
+
allow(segment).to receive(:get_line_bounds).with(0) { double('line_bounds', height: 21)}
|
87
|
+
allow(segment).to receive(:get_line_bounds).with(1) { raise "Boom" }
|
88
88
|
|
89
89
|
expect(subject.split_text(segment, 33)).to eq(["Text Split", ""])
|
90
90
|
end
|
@@ -118,7 +118,7 @@ describe Shoes::Swt::TextBlock::Fitter do
|
|
118
118
|
|
119
119
|
context "to two segments" do
|
120
120
|
before(:each) do
|
121
|
-
allow(segment).to receive_messages(line_count: 2,
|
121
|
+
allow(segment).to receive_messages(line_count: 2, get_line_bounds: double(height: 15))
|
122
122
|
allow(bounds).to receive_messages(width: 50)
|
123
123
|
allow(dsl).to receive_messages(containing_width: :unused)
|
124
124
|
end
|
@@ -238,7 +238,7 @@ describe Shoes::Swt::TextBlock::TextSegmentCollection do
|
|
238
238
|
bounds = double("bounds", x: 0, y: 0, height: 0)
|
239
239
|
layout = double(name, text: text,
|
240
240
|
:justify= => nil, :spacing= => nil, :alignment= => nil,
|
241
|
-
|
241
|
+
get_line_bounds: bounds, line_count: 1)
|
242
242
|
|
243
243
|
allow_any_instance_of(Shoes::Swt::TextFontFactory).to receive(:create_font)
|
244
244
|
|
@@ -196,11 +196,11 @@ describe Shoes::Swt::TextBlock do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def create_segment(name = "segment", width = layout_width,
|
199
|
-
height = layout_height,
|
199
|
+
height = layout_height, last_line_height = line_height)
|
200
200
|
bounds = double("bounds", width: width, height: height)
|
201
201
|
double(name, disposed?: false, style_from: nil,
|
202
202
|
width: width, height: height,
|
203
|
-
last_line_width: width, last_line_height:
|
203
|
+
last_line_width: width, last_line_height: last_line_height,
|
204
204
|
bounds: bounds)
|
205
205
|
end
|
206
206
|
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoes-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.pre6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Shoes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 4.4.0
|
19
19
|
name: swt
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,13 +23,13 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 0.4.0
|
33
33
|
name: after_do
|
34
34
|
prerelease: false
|
35
35
|
type: :runtime
|
@@ -37,13 +37,13 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - '='
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 4.0.0.
|
46
|
+
version: 4.0.0.pre6
|
47
47
|
name: shoes-core
|
48
48
|
prerelease: false
|
49
49
|
type: :runtime
|
@@ -51,13 +51,13 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.0.0.
|
54
|
+
version: 4.0.0.pre6
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - '='
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 4.0.0.
|
60
|
+
version: 4.0.0.pre6
|
61
61
|
name: shoes-package
|
62
62
|
prerelease: false
|
63
63
|
type: :runtime
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 4.0.0.
|
68
|
+
version: 4.0.0.pre6
|
69
69
|
description: A JRuby and Swt backend for Shoes, the best little GUI toolkit for Ruby. Shoes makes building for Mac, Windows, and Linux super simple.
|
70
70
|
email:
|
71
71
|
- shoes@librelist.com
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: 1.3.1
|
232
232
|
requirements: []
|
233
233
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
234
|
+
rubygems_version: 2.6.6
|
235
235
|
signing_key:
|
236
236
|
specification_version: 4
|
237
237
|
summary: A JRuby and Swt backend for Shoes, the best little GUI toolkit for Ruby.
|
@@ -296,4 +296,3 @@ test_files:
|
|
296
296
|
- spec/shoes/swt/text_block/text_segment_spec.rb
|
297
297
|
- spec/shoes/swt/text_block_spec.rb
|
298
298
|
- spec/spec_helper.rb
|
299
|
-
has_rdoc:
|