shoes-core 4.0.0.pre5 → 4.0.0.pre6
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/bin/shoes +1 -0
- data/ext/install/Rakefile +5 -5
- data/lib/shoes/app.rb +1 -1
- data/lib/shoes/button.rb +5 -0
- data/lib/shoes/color/hex_converter.rb +2 -2
- data/lib/shoes/common/initialization.rb +0 -1
- data/lib/shoes/common/state.rb +1 -0
- data/lib/shoes/core.rb +1 -0
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/dimension.rb +1 -1
- data/lib/shoes/dimensions.rb +1 -1
- data/lib/shoes/dsl.rb +2 -2
- data/lib/shoes/input_box.rb +0 -1
- data/lib/shoes/internal_app.rb +16 -15
- data/lib/shoes/link.rb +6 -6
- data/lib/shoes/logger/ruby.rb +0 -1
- data/lib/shoes/slot.rb +6 -6
- data/lib/shoes/slot_contents.rb +2 -2
- data/lib/shoes/text_block.rb +10 -6
- data/lib/shoes/text_block_dimensions.rb +7 -7
- data/lib/shoes/ui/picker.rb +2 -2
- data/lib/shoes/version.rb +1 -1
- data/spec/shoes/button_spec.rb +9 -0
- data/spec/shoes/color_spec.rb +12 -12
- data/spec/shoes/dimension_spec.rb +1 -1
- data/spec/shoes/gradient_spec.rb +8 -8
- data/spec/shoes/text_block_spec.rb +16 -0
- metadata +3 -4
- data/bin/shoes +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a1616fc9ee94998821bae34f5e523b6bb435e8c
|
4
|
+
data.tar.gz: 80be512d070e25a15b46fc9744dd005922bfc1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40702d6e8e3ec2dbb2e7e34c98bdcfd37a741010f34d5a5b0c939c0da3c9ec251b7fe38971094cdbc5288cbde912e30fb04273030b752e0c1ceb149f1ee3dff7
|
7
|
+
data.tar.gz: 0dbc92f9dd5a7bd178d998a12456cdca348f8a7b28df320ee6adec3d9fb1d803d157b93302a6c528bbec4a4b14f80c0e4a010300ea2d7e86a6972f3beb1c2092
|
data/bin/shoes
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bin/shoes-stub
|
data/ext/install/Rakefile
CHANGED
@@ -20,11 +20,11 @@ task default: ['install_script']
|
|
20
20
|
task :install_script do
|
21
21
|
# If we're run via jruby-complete.jar, bindir is within the jar itself so
|
22
22
|
# look for bin based on user directory. Otherwise, prefer Gem.bindir.
|
23
|
-
if Gem.bindir.start_with?("uri:classloader")
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
dest_dir = if Gem.bindir.start_with?("uri:classloader")
|
24
|
+
Gem.bindir(Gem.user_dir)
|
25
|
+
else
|
26
|
+
Gem.bindir
|
27
|
+
end
|
28
28
|
|
29
29
|
if Gem.win_platform?
|
30
30
|
source_path = File.join(Dir.pwd, "shoes.bat")
|
data/lib/shoes/app.rb
CHANGED
data/lib/shoes/button.rb
CHANGED
@@ -3,13 +3,13 @@ class Shoes
|
|
3
3
|
class HexConverter
|
4
4
|
def initialize(hex)
|
5
5
|
@hex = validate(hex) || fail(ArgumentError, "Bad hex color: #{hex}")
|
6
|
-
@red, @green, @blue = hex_to_rgb(pad_if_necessary
|
6
|
+
@red, @green, @blue = hex_to_rgb(pad_if_necessary(@hex))
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_rgb
|
10
10
|
[@red, @green, @blue]
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
private
|
14
14
|
|
15
15
|
def hex_to_rgb(hex)
|
data/lib/shoes/common/state.rb
CHANGED
data/lib/shoes/core.rb
CHANGED
data/lib/shoes/core/version.rb
CHANGED
data/lib/shoes/dimension.rb
CHANGED
data/lib/shoes/dimensions.rb
CHANGED
@@ -88,7 +88,7 @@ class Shoes
|
|
88
88
|
def margin=(margin)
|
89
89
|
margin = [margin, margin, margin, margin] unless margin.is_a? Array
|
90
90
|
self.margin_left, self.margin_top,
|
91
|
-
self.margin_right, self.margin_bottom =
|
91
|
+
self.margin_right, self.margin_bottom = margin
|
92
92
|
end
|
93
93
|
|
94
94
|
def needs_positioning?
|
data/lib/shoes/dsl.rb
CHANGED
data/lib/shoes/input_box.rb
CHANGED
data/lib/shoes/internal_app.rb
CHANGED
@@ -13,10 +13,13 @@ class Shoes
|
|
13
13
|
|
14
14
|
extend Forwardable
|
15
15
|
|
16
|
-
DEFAULT_OPTIONS = {
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
DEFAULT_OPTIONS = {
|
17
|
+
width: 600,
|
18
|
+
height: 500,
|
19
|
+
title: "Shoes 4",
|
20
|
+
resizable: true,
|
21
|
+
border: true
|
22
|
+
}.freeze
|
20
23
|
|
21
24
|
def initialize(app, opts, &blk)
|
22
25
|
@app = app
|
@@ -161,17 +164,15 @@ class Shoes
|
|
161
164
|
end
|
162
165
|
|
163
166
|
def create_execution_block(blk)
|
164
|
-
if blk
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
execution_blk = nil
|
174
|
-
end
|
167
|
+
execution_blk = if blk
|
168
|
+
proc do
|
169
|
+
execute_block blk
|
170
|
+
end
|
171
|
+
elsif Shoes::URL.urls.keys.any? { |page| page.match '/' }
|
172
|
+
proc do
|
173
|
+
app.visit '/'
|
174
|
+
end
|
175
|
+
end
|
175
176
|
execution_blk
|
176
177
|
end
|
177
178
|
|
data/lib/shoes/link.rb
CHANGED
@@ -26,12 +26,12 @@ class Shoes
|
|
26
26
|
# Doesn't use Common::Clickable because of URL flavor option clicks
|
27
27
|
def setup_click(blk)
|
28
28
|
if blk.nil?
|
29
|
-
if @style[:click].respond_to? :call
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
blk = if @style[:click].respond_to? :call
|
30
|
+
@style[:click]
|
31
|
+
else
|
32
|
+
# Slightly awkward, but we need App, not InternalApp, to call visit
|
33
|
+
proc { app.app.visit @style[:click] }
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
37
|
click(&blk)
|
data/lib/shoes/logger/ruby.rb
CHANGED
data/lib/shoes/slot.rb
CHANGED
@@ -166,8 +166,8 @@ class Shoes
|
|
166
166
|
|
167
167
|
def position_contents
|
168
168
|
@current_position = CurrentPosition.new element_left,
|
169
|
-
|
170
|
-
|
169
|
+
element_top,
|
170
|
+
element_top
|
171
171
|
|
172
172
|
contents.each do |element|
|
173
173
|
next if element.hidden?
|
@@ -285,10 +285,10 @@ class Shoes
|
|
285
285
|
|
286
286
|
def compute_content_height
|
287
287
|
max_bottom = contents.
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
288
|
+
select(&:takes_up_space?).
|
289
|
+
reject(&:hidden?).
|
290
|
+
map(&:absolute_bottom).
|
291
|
+
max
|
292
292
|
|
293
293
|
if max_bottom
|
294
294
|
max_bottom - self.element_top + NEXT_ELEMENT_OFFSET
|
data/lib/shoes/slot_contents.rb
CHANGED
data/lib/shoes/text_block.rb
CHANGED
@@ -33,6 +33,10 @@ class Shoes
|
|
33
33
|
@gui.in_bounds?(*args)
|
34
34
|
end
|
35
35
|
|
36
|
+
def takes_up_space?
|
37
|
+
@style[:align] != "right"
|
38
|
+
end
|
39
|
+
|
36
40
|
def remove
|
37
41
|
super
|
38
42
|
links.each do |link|
|
@@ -101,11 +105,11 @@ class Shoes
|
|
101
105
|
|
102
106
|
# If our endpoint is before our start, it's an empty string. We treat
|
103
107
|
# those specially with the (0...0) range that has an empty count.
|
104
|
-
if end_point < start_point
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
range = if end_point < start_point
|
109
|
+
(0...0)
|
110
|
+
else
|
111
|
+
start_point..end_point
|
112
|
+
end
|
109
113
|
|
110
114
|
styles[range] ||= []
|
111
115
|
styles[range] << text
|
@@ -125,7 +129,7 @@ class Shoes
|
|
125
129
|
style_regex = /none|bold|normal|oblique|italic/i # TODO: add more
|
126
130
|
|
127
131
|
font_family = type.gsub(style_regex, '').gsub(size_regex, '')
|
128
|
-
|
132
|
+
.split(',').map { |x| x.strip.gsub(/["]/, '') }
|
129
133
|
|
130
134
|
@style[:font] = font_family.first unless (font_family.size == 1 &&
|
131
135
|
font_family[0] == "") || font_family.size == 0
|
@@ -35,13 +35,13 @@ class Shoes
|
|
35
35
|
# If we've gotten an explicit width, use that but check that we fit still
|
36
36
|
# Last but certainly not least, consult what's remaining in our parent.
|
37
37
|
def desired_width(containing = nil)
|
38
|
-
if containing
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
desired = if containing
|
39
|
+
parent.absolute_left + containing - absolute_left
|
40
|
+
elsif element_width
|
41
|
+
[element_width, remaining_in_parent].min
|
42
|
+
else
|
43
|
+
remaining_in_parent
|
44
|
+
end
|
45
45
|
|
46
46
|
desired - margin_left - margin_right
|
47
47
|
end
|
data/lib/shoes/ui/picker.rb
CHANGED
@@ -74,8 +74,8 @@ class Shoes
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def name_for_candidate(candidate)
|
77
|
-
/.*lib\/shoes\/(.*)\/generate-backend.rb
|
78
|
-
return "shoes-#{$1.
|
77
|
+
/.*lib\/shoes\/(.*)\/generate-backend.rb/ =~ candidate
|
78
|
+
return "shoes-#{$1.tr('/', '-')}"
|
79
79
|
end
|
80
80
|
|
81
81
|
def write_backend(generator_file, bin_dir)
|
data/lib/shoes/version.rb
CHANGED
data/spec/shoes/button_spec.rb
CHANGED
@@ -23,6 +23,7 @@ describe Shoes::Button do
|
|
23
23
|
|
24
24
|
it { is_expected.to respond_to :click }
|
25
25
|
it { is_expected.to respond_to :focus }
|
26
|
+
it { is_expected.to respond_to :text= }
|
26
27
|
|
27
28
|
describe "initialize" do
|
28
29
|
its(:parent) { should eq(parent) }
|
@@ -32,6 +33,14 @@ describe Shoes::Button do
|
|
32
33
|
its(:state) { should eq("disabled") }
|
33
34
|
end
|
34
35
|
|
36
|
+
describe ".text=" do
|
37
|
+
it "changes the text" do
|
38
|
+
expect(subject.gui).to receive(:text=).with("something else")
|
39
|
+
subject.text = "something else"
|
40
|
+
expect(subject.text).to eq "something else"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
describe "relative dimensions" do
|
36
45
|
subject { Shoes::Button.new(app, parent, "text", relative_opts, input_block) }
|
37
46
|
it_behaves_like "object with relative dimensions"
|
data/spec/shoes/color_spec.rb
CHANGED
@@ -211,23 +211,23 @@ describe Shoes::Color do
|
|
211
211
|
end
|
212
212
|
|
213
213
|
describe "comparable" do
|
214
|
-
let(:
|
214
|
+
let(:color1) { Shoes::Color.new(255, 69, 0) }
|
215
215
|
let(:red) {Shoes::Color.new 255, 0, 0}
|
216
216
|
let(:green) {Shoes::Color.new 0, 255, 0}
|
217
217
|
|
218
218
|
it "is equal when values are equal" do
|
219
|
-
|
220
|
-
expect(
|
219
|
+
color2 = Shoes::Color.new(255, 69, 0)
|
220
|
+
expect(color1).to eq(color2)
|
221
221
|
end
|
222
222
|
|
223
223
|
it "is less than when darker" do
|
224
|
-
|
225
|
-
expect(
|
224
|
+
color2 = Shoes::Color.new(255, 70, 0)
|
225
|
+
expect(color1).to be < color2
|
226
226
|
end
|
227
227
|
|
228
228
|
it "is greater than when lighter" do
|
229
|
-
|
230
|
-
expect(
|
229
|
+
color2 = Shoes::Color.new(255, 68, 0)
|
230
|
+
expect(color1).to be > color2
|
231
231
|
end
|
232
232
|
|
233
233
|
it 'does not claim for full red and full green to be equal' do
|
@@ -250,13 +250,13 @@ describe Shoes::Color do
|
|
250
250
|
end
|
251
251
|
|
252
252
|
context "same rgb values" do
|
253
|
-
let(:
|
253
|
+
let(:color2) { Shoes::Color.new(255, 69, 0, 254) }
|
254
254
|
it "is less than when less opaque" do
|
255
|
-
expect(
|
255
|
+
expect(color2).to be < color1
|
256
256
|
end
|
257
257
|
|
258
258
|
it "is greater than when more opaque" do
|
259
|
-
expect(
|
259
|
+
expect(color1).to be > color2
|
260
260
|
end
|
261
261
|
end
|
262
262
|
end
|
@@ -309,8 +309,8 @@ describe "Shoes built in gray" do
|
|
309
309
|
end
|
310
310
|
|
311
311
|
it 'hangles 0.93 right as well' do
|
312
|
-
|
313
|
-
expect(app.gray(0.93)).to eq(Shoes::Color.new(
|
312
|
+
result93 = (0.93 * 255).to_i
|
313
|
+
expect(app.gray(0.93)).to eq(Shoes::Color.new(result93, result93, result93))
|
314
314
|
end
|
315
315
|
|
316
316
|
it 'also has a grey alias for our BE friends' do
|
@@ -288,7 +288,7 @@ describe Shoes::Dimension do
|
|
288
288
|
describe '#in_bounds?' do
|
289
289
|
let(:absolute_start) {20}
|
290
290
|
let(:extent) {100}
|
291
|
-
let(:absolute_end) {20 + 100 -ONE_PIXEL} # -1 due to pixel counting adjustment
|
291
|
+
let(:absolute_end) {20 + 100 - ONE_PIXEL} # -1 due to pixel counting adjustment
|
292
292
|
|
293
293
|
before :each do
|
294
294
|
subject.absolute_start = absolute_start
|
data/spec/shoes/gradient_spec.rb
CHANGED
@@ -9,23 +9,23 @@ describe Shoes::Gradient do
|
|
9
9
|
let(:new_color) { Shoes::COLORS[:limegreen] }
|
10
10
|
|
11
11
|
it "is equal when values are equal" do
|
12
|
-
|
13
|
-
expect(subject).to eq(
|
12
|
+
gradient2 = Shoes::Gradient.new(color1, color2)
|
13
|
+
expect(subject).to eq(gradient2)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "is not equal when color 1 is different" do
|
17
|
-
|
18
|
-
expect(subject).not_to eq(
|
17
|
+
gradient2 = Shoes::Gradient.new(new_color, color2)
|
18
|
+
expect(subject).not_to eq(gradient2)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "is not equal when color 2 is different" do
|
22
|
-
|
23
|
-
expect(subject).not_to eq(
|
22
|
+
gradient2 = Shoes::Gradient.new(new_color, color2)
|
23
|
+
expect(subject).not_to eq(gradient2)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "is not equal to just a color" do
|
27
|
-
|
28
|
-
expect(subject).not_to eq(
|
27
|
+
gradient2 = Shoes::Gradient.new(color1, new_color)
|
28
|
+
expect(subject).not_to eq(gradient2)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -47,6 +47,22 @@ describe Shoes::TextBlock do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
describe "#takes_up_space?" do
|
51
|
+
it "does with default alignment" do
|
52
|
+
expect(text_block.takes_up_space?).to eq(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "does when left aligned" do
|
56
|
+
text_block.align = "left"
|
57
|
+
expect(text_block.takes_up_space?).to eq(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "doesn't when right aligned" do
|
61
|
+
text_block.align = "right"
|
62
|
+
expect(text_block.takes_up_space?).to eq(false)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
describe "#to_s" do
|
51
67
|
it "is the same as #text" do
|
52
68
|
text = text_block.text
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoes-core
|
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
|
description: Shoes is the best little GUI toolkit for Ruby. Shoes makes building for Mac, Windows, and Linux super simple. This is the DSL for writing your app. You'll need a backend to run it.
|
14
14
|
email:
|
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
267
|
version: 1.3.1
|
268
268
|
requirements: []
|
269
269
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
270
|
+
rubygems_version: 2.6.6
|
271
271
|
signing_key:
|
272
272
|
specification_version: 4
|
273
273
|
summary: The best little DSL for the best little GUI toolkit for Ruby.
|
@@ -376,4 +376,3 @@ test_files:
|
|
376
376
|
- spec/shoes/widget_spec.rb
|
377
377
|
- spec/shoes_spec.rb
|
378
378
|
- spec/spec_helper.rb
|
379
|
-
has_rdoc:
|
data/bin/shoes
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/env sh
|
2
|
-
|
3
|
-
# This script is symlinked to be present as both bin/shoes and bin/shoes-stub
|
4
|
-
# See ext/install/Rakefile for the full explanation of why we do that.
|
5
|
-
|
6
|
-
# Don't try to cd on an empty $NEXT_DIR (link in same directory)
|
7
|
-
mac_move_to_link_dir () {
|
8
|
-
# Skip if already in link directory
|
9
|
-
NEXT_DIR=$(dirname $1)
|
10
|
-
if [[ -n "$NEXT_DIR" ]]; then
|
11
|
-
cd $NEXT_DIR
|
12
|
-
fi
|
13
|
-
}
|
14
|
-
|
15
|
-
mac_readlink_f () {
|
16
|
-
# based on http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
|
17
|
-
|
18
|
-
# A relative or absolute path to a file, potentially a symlink
|
19
|
-
LINK=$1
|
20
|
-
|
21
|
-
if [ ! -L "$LINK" ] ; then
|
22
|
-
# Not a link, all good
|
23
|
-
echo $LINK
|
24
|
-
return
|
25
|
-
fi
|
26
|
-
|
27
|
-
# http://bosker.wordpress.com/2012/02/12/bash-scripters-beware-of-the-cdpath/
|
28
|
-
unset CDPATH
|
29
|
-
|
30
|
-
# Look up links until we find something that is not a symlink
|
31
|
-
while [ -L "$LINK" ] ; do
|
32
|
-
mac_move_to_link_dir $LINK
|
33
|
-
RELATIVE_LINK=$(basename $LINK)
|
34
|
-
LINK=$(readlink $RELATIVE_LINK)
|
35
|
-
done
|
36
|
-
|
37
|
-
# Now PATH is an unqualified file name, but we're in its directory, so turn
|
38
|
-
# it into an absolute path by prefixing with the current working directory.
|
39
|
-
|
40
|
-
PHYS_DIR=`pwd -P`
|
41
|
-
RESULT=$PHYS_DIR/$LINK
|
42
|
-
echo $RESULT
|
43
|
-
}
|
44
|
-
|
45
|
-
case "${MACHTYPE:-}${OSTYPE:-}" in
|
46
|
-
(*darwin*)
|
47
|
-
SCRIPT=$(mac_readlink_f $0);;
|
48
|
-
(*)
|
49
|
-
# see http://stackoverflow.com/a/1638397/1810896
|
50
|
-
SCRIPT=$(readlink -f "$0");;
|
51
|
-
esac
|
52
|
-
|
53
|
-
SCRIPTPATH=$(dirname "$SCRIPT")
|
54
|
-
|
55
|
-
BACKEND_FILE="$SCRIPTPATH/shoes-backend"
|
56
|
-
if [ ! -e "$BACKEND_FILE" ]
|
57
|
-
then
|
58
|
-
$SCRIPTPATH/shoes-picker $SCRIPTPATH
|
59
|
-
fi
|
60
|
-
|
61
|
-
BACKEND_COMMAND=$(cat $BACKEND_FILE)
|
62
|
-
SHOES_BIN_DIR=$SCRIPTPATH $BACKEND_COMMAND $@
|