shoes-swt 4.0.0.pre2 → 4.0.0.pre3
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 +5 -200
- data/Rakefile +1 -0
- data/bin/shoes-swt +11 -0
- data/lib/shoes/swt.rb +5 -2
- data/lib/shoes/swt/animation.rb +2 -2
- data/lib/shoes/swt/app.rb +45 -50
- data/lib/shoes/swt/arc.rb +7 -7
- data/lib/shoes/swt/background.rb +1 -1
- data/lib/shoes/swt/border.rb +1 -2
- data/lib/shoes/swt/click_listener.rb +70 -0
- data/lib/shoes/swt/color.rb +5 -5
- data/lib/shoes/swt/common/clickable.rb +2 -53
- data/lib/shoes/swt/common/fill.rb +1 -1
- data/lib/shoes/swt/common/painter.rb +7 -7
- data/lib/shoes/swt/common/painter_updates_position.rb +2 -2
- data/lib/shoes/swt/common/remove.rb +2 -3
- data/lib/shoes/swt/common/resource.rb +1 -1
- data/lib/shoes/swt/common/selection_listener.rb +14 -14
- data/lib/shoes/swt/common/stroke.rb +1 -2
- data/lib/shoes/swt/common/update_position.rb +1 -1
- data/lib/shoes/swt/dialog.rb +3 -45
- data/lib/shoes/swt/disposed_protection.rb +1 -1
- data/lib/shoes/swt/download.rb +0 -1
- data/lib/shoes/swt/font.rb +4 -4
- data/lib/shoes/swt/generate-backend.rb +9 -0
- data/lib/shoes/swt/gradient.rb +17 -16
- data/lib/shoes/swt/image.rb +3 -5
- data/lib/shoes/swt/image_pattern.rb +2 -2
- data/lib/shoes/swt/input_box.rb +3 -3
- data/lib/shoes/swt/key_listener.rb +6 -6
- data/lib/shoes/swt/line.rb +4 -24
- data/lib/shoes/swt/link.rb +2 -2
- data/lib/shoes/swt/link_segment.rb +3 -3
- data/lib/shoes/swt/list_box.rb +4 -4
- data/lib/shoes/swt/mouse_move_listener.rb +6 -5
- data/lib/shoes/swt/oval.rb +2 -3
- data/lib/shoes/swt/packager.rb +82 -0
- data/lib/shoes/swt/progress.rb +2 -2
- data/lib/shoes/swt/radio.rb +0 -2
- data/lib/shoes/swt/radio_group.rb +54 -54
- data/lib/shoes/swt/rect_painter.rb +7 -7
- data/lib/shoes/swt/redrawing_aspect.rb +32 -34
- data/lib/shoes/swt/shape.rb +1 -1
- data/lib/shoes/swt/shoes_layout.rb +5 -2
- data/lib/shoes/swt/slot.rb +2 -3
- data/lib/shoes/swt/sound.rb +17 -22
- data/lib/shoes/swt/star.rb +30 -8
- data/lib/shoes/swt/swt_button.rb +3 -2
- data/lib/shoes/swt/text_block.rb +3 -3
- data/lib/shoes/swt/text_block/cursor_painter.rb +2 -2
- data/lib/shoes/swt/text_block/fitter.rb +5 -3
- data/lib/shoes/swt/text_block/painter.rb +9 -9
- data/lib/shoes/swt/text_block/text_font_factory.rb +3 -3
- data/lib/shoes/swt/text_block/text_segment.rb +9 -9
- data/lib/shoes/swt/text_block/text_segment_collection.rb +2 -0
- data/lib/shoes/swt/text_block/text_style_factory.rb +9 -3
- data/lib/shoes/swt/timer.rb +1 -1
- data/lib/shoes/swt/version.rb +1 -1
- data/shoes-swt.gemspec +7 -6
- data/spec/shoes/cli_spec.rb +2 -2
- data/spec/{swt_shoes → shoes/swt}/animation_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/app_spec.rb +36 -3
- data/spec/{swt_shoes → shoes/swt}/arc_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/background_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/border_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/button_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/check_spec.rb +1 -1
- data/spec/shoes/swt/click_listener_spec.rb +162 -0
- data/spec/{swt_shoes → shoes/swt}/color_factory_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/color_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/common/painter_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/common/remove_spec.rb +4 -11
- data/spec/{swt_shoes → shoes/swt}/configuration_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/dialog_spec.rb +1 -7
- data/spec/{swt_shoes → shoes/swt}/disposed_protection_spec.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/flow_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/font_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/gradient_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/image_pattern_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/image_spec.rb +4 -3
- data/spec/{swt_shoes → shoes/swt}/input_box_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/integration_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/key_listener_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/line_spec.rb +4 -8
- data/spec/{swt_shoes → shoes/swt}/link_segment_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/link_spec.rb +3 -10
- data/spec/{swt_shoes → shoes/swt}/list_box_spec.rb +5 -3
- data/spec/{swt_shoes → shoes/swt}/minimal.png +0 -0
- data/spec/{swt_shoes → shoes/swt}/mouse_move_listener_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/oval_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/progress_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/radio_group_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/radio_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/rect_painter_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/rect_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/shape_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/shared_examples/button.rb +0 -0
- data/spec/shoes/swt/shared_examples/clickable.rb +13 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/movable.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/paintable.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/painter.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/pattern.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/removable.rb +1 -3
- data/spec/{swt_shoes → shoes/swt}/shared_examples/swt_app_context.rb +11 -3
- data/spec/{swt_shoes → shoes/swt}/shared_examples/visibility.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shell_control_listener_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/slot_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/spec_helper.rb +0 -1
- data/spec/{swt_shoes → shoes/swt}/star_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/centered_text_segment_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/cursor_painter_spec.rb +8 -4
- data/spec/{swt_shoes → shoes/swt}/text_block/fitter_spec.rb +5 -5
- data/spec/{swt_shoes → shoes/swt}/text_block/painter_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/text_font_factory_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_collection_spec.rb +7 -2
- data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block_spec.rb +2 -5
- data/spec/spec_helper.rb +7 -3
- metadata +132 -331
- data/CHANGELOG +0 -84
- data/Gemfile +0 -24
- data/Guardfile +0 -11
- data/manifests/common.rb +0 -34
- data/manifests/shoes-swt.rb +0 -29
- data/spec/code_coverage.rb +0 -14
- data/spec/shoes/animation_spec.rb +0 -65
- data/spec/shoes/app_spec.rb +0 -484
- data/spec/shoes/arc_spec.rb +0 -51
- data/spec/shoes/background_spec.rb +0 -53
- data/spec/shoes/border_spec.rb +0 -47
- data/spec/shoes/builtin_methods_spec.rb +0 -110
- data/spec/shoes/button_spec.rb +0 -44
- data/spec/shoes/check_spec.rb +0 -35
- data/spec/shoes/color_spec.rb +0 -408
- data/spec/shoes/common/inspect_spec.rb +0 -26
- data/spec/shoes/common/remove_spec.rb +0 -38
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -147
- data/spec/shoes/configuration_spec.rb +0 -36
- data/spec/shoes/constants_spec.rb +0 -38
- data/spec/shoes/dialog_spec.rb +0 -163
- data/spec/shoes/dimension_spec.rb +0 -407
- data/spec/shoes/dimensions_spec.rb +0 -837
- data/spec/shoes/download_spec.rb +0 -142
- data/spec/shoes/flow_spec.rb +0 -133
- data/spec/shoes/font_spec.rb +0 -37
- data/spec/shoes/framework_learning_spec.rb +0 -30
- data/spec/shoes/gradient_spec.rb +0 -32
- data/spec/shoes/helpers/fake_element.rb +0 -17
- data/spec/shoes/helpers/inspect_helpers.rb +0 -5
- data/spec/shoes/helpers/sample17_helper.rb +0 -66
- data/spec/shoes/image_spec.rb +0 -49
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -80
- data/spec/shoes/integration_spec.rb +0 -20
- data/spec/shoes/internal_app_spec.rb +0 -141
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -12
- data/spec/shoes/line_spec.rb +0 -49
- data/spec/shoes/link_spec.rb +0 -105
- data/spec/shoes/list_box_spec.rb +0 -74
- data/spec/shoes/logger/ruby_spec.rb +0 -8
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -24
- data/spec/shoes/point_spec.rb +0 -71
- data/spec/shoes/progress_spec.rb +0 -54
- data/spec/shoes/radio_spec.rb +0 -32
- data/spec/shoes/rect_spec.rb +0 -39
- data/spec/shoes/renamed_delegate_spec.rb +0 -70
- data/spec/shoes/shape_spec.rb +0 -95
- data/spec/shoes/shared_examples/button.rb +0 -6
- data/spec/shoes/shared_examples/changeable.rb +0 -26
- data/spec/shoes/shared_examples/clickable.rb +0 -5
- data/spec/shoes/shared_examples/common_methods.rb +0 -35
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -44
- data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
- data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
- data/spec/shoes/shared_examples/dsl/background.rb +0 -26
- data/spec/shoes/shared_examples/dsl/border.rb +0 -10
- data/spec/shoes/shared_examples/dsl/button.rb +0 -5
- data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
- data/spec/shoes/shared_examples/dsl/check.rb +0 -11
- data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
- data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
- data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
- data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
- data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
- data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
- data/spec/shoes/shared_examples/dsl/image.rb +0 -21
- data/spec/shoes/shared_examples/dsl/line.rb +0 -9
- data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
- data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
- data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
- data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
- data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
- data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
- data/spec/shoes/shared_examples/dsl/rgb.rb +0 -26
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -21
- data/spec/shoes/shared_examples/dsl/star.rb +0 -48
- data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
- data/spec/shoes/shared_examples/dsl/style.rb +0 -32
- data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -81
- data/spec/shoes/shared_examples/dsl/video.rb +0 -5
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -8
- data/spec/shoes/shared_examples/hover_leave.rb +0 -11
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/scroll.rb +0 -41
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
- data/spec/shoes/shared_examples/slot.rb +0 -331
- data/spec/shoes/shared_examples/state.rb +0 -19
- data/spec/shoes/shared_examples/style.rb +0 -82
- data/spec/shoes/slot_spec.rb +0 -130
- data/spec/shoes/sound_spec.rb +0 -15
- data/spec/shoes/span_spec.rb +0 -112
- data/spec/shoes/spec_helper.rb +0 -24
- data/spec/shoes/stack_spec.rb +0 -79
- data/spec/shoes/star_spec.rb +0 -31
- data/spec/shoes/text_block_dimensions_spec.rb +0 -75
- data/spec/shoes/text_block_spec.rb +0 -270
- data/spec/shoes/url_spec.rb +0 -68
- data/spec/shoes/widget_spec.rb +0 -70
- data/spec/shoes_spec.rb +0 -44
- data/spec/swt_shoes/shared_examples/clickable.rb +0 -85
- data/spec/swt_shoes/sound.rb +0 -10
@@ -1,81 +0,0 @@
|
|
1
|
-
shared_examples_for "text element DSL methods" do
|
2
|
-
it "should set banner font size to 48" do
|
3
|
-
text_block = dsl.banner("hello!")
|
4
|
-
expect(text_block.size).to eql 48
|
5
|
-
end
|
6
|
-
|
7
|
-
it "should set title font size to 34" do
|
8
|
-
text_block = dsl.title("hello!")
|
9
|
-
expect(text_block.size).to eql 34
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should set subtitle font size to 26" do
|
13
|
-
text_block = dsl.subtitle("hello!")
|
14
|
-
expect(text_block.size).to eql 26
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should set tagline font size to 18" do
|
18
|
-
text_block = dsl.tagline("hello!")
|
19
|
-
expect(text_block.size).to eql 18
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should set caption font size to 14" do
|
23
|
-
text_block = dsl.caption("hello!")
|
24
|
-
expect(text_block.size).to eql 14
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should set para font size to 12" do
|
28
|
-
text_block = dsl.para("hello!")
|
29
|
-
expect(text_block.size).to eql 12
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should set inscription font size to 10" do
|
33
|
-
text_block = dsl.inscription("hello!")
|
34
|
-
expect(text_block.size).to eql 10
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'span' do
|
38
|
-
it 'should parse the color' do
|
39
|
-
span = dsl.span 'Hello', stroke: '#ccc'
|
40
|
-
expect(span.style[:stroke]).to eq Shoes::Color.new 204, 204, 204
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should handle a splatted array of links' do
|
44
|
-
expect{dsl.span *[dsl.link('foo'), dsl.link('foo')]}.not_to raise_error
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should handle a splatted array of links and parse the color' do
|
48
|
-
span = dsl.span *[dsl.link('foo'), dsl.link('foo')], stroke: '#ccc'
|
49
|
-
expect(span.style[:stroke]).to eq Shoes::Color.new 204, 204, 204
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should handle a splatted array of links with a block' do
|
53
|
-
link = dsl.link('foo') { "Bar" }
|
54
|
-
expect{dsl.span *[link, link]}.not_to raise_error
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe 'link' do
|
59
|
-
it 'handles multiple texts' do
|
60
|
-
link = dsl.link('one', 'two')
|
61
|
-
expect(link.to_s).to eql('onetwo')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'handles trailing options' do
|
65
|
-
link = dsl.link('one', 'two', stroke: '#ccc')
|
66
|
-
expect(link.to_s).to eql('onetwo')
|
67
|
-
expect(link.style[:stroke]).to eq Shoes::Color.new 204, 204, 204
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'para' do
|
72
|
-
context "with nested text fragments with parameters" do
|
73
|
-
Shoes::DSL::TEXT_STYLES.keys.each do |style|
|
74
|
-
it "handles opts properly for #{style}" do
|
75
|
-
para = dsl.para(dsl.send(style, style, stroke: '#ccc'))
|
76
|
-
expect(para.text).to eq(style.to_s)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
shared_context "dsl app" do
|
2
|
-
let(:input_block) { Proc.new {} }
|
3
|
-
let(:input_opts) { Hash.new }
|
4
|
-
let(:user_facing_app) { Shoes::App.new input_opts, &input_block }
|
5
|
-
let(:app) { user_facing_app.instance_variable_get(:@__app__) }
|
6
|
-
let(:parent) { Shoes::Flow.new app, app }
|
7
|
-
end
|
8
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
shared_examples "hover and leave events" do
|
2
|
-
let(:proc) {Proc.new do end}
|
3
|
-
|
4
|
-
it 'can execute hover without raising an error' do
|
5
|
-
expect{subject.hover proc}.not_to raise_error
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'can execute leave without raising an error' do
|
9
|
-
expect{subject.leave proc}.not_to raise_error
|
10
|
-
end
|
11
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
shared_examples_for "scrollable slot" do
|
2
|
-
its(:scroll) { should be_truthy }
|
3
|
-
it "initializes scroll_top to 0" do
|
4
|
-
expect(subject.scroll_top).to eq(0)
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
shared_examples_for "scrollable slot with overflowing content" do
|
9
|
-
it "retains the same height" do
|
10
|
-
expect(subject.height).to eq(height)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "has scroll_height larger than height" do
|
14
|
-
expect(subject.scroll_height).to be > height
|
15
|
-
end
|
16
|
-
|
17
|
-
it "has scroll_max = (scroll_height - height)" do
|
18
|
-
expect(subject.scroll_max).to eq(subject.scroll_height - subject.height)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'adjusts scroll_top' do
|
22
|
-
expect(subject.scroll_top).to eq(new_position)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
shared_context "scroll" do
|
27
|
-
let(:height) { 200 }
|
28
|
-
let(:input_opts) { {left: 40, top: 20, width: 400, height: height} }
|
29
|
-
let(:opts) { input_opts.merge(scroll: scroll) }
|
30
|
-
end
|
31
|
-
|
32
|
-
shared_context "overflowing content" do
|
33
|
-
let(:new_position) { 300 }
|
34
|
-
|
35
|
-
before :each do
|
36
|
-
200.times do
|
37
|
-
Shoes::TextBlock.new(app, subject, "Fourteen fat chimichangas", size: 18)
|
38
|
-
end
|
39
|
-
subject.scroll_top = new_position
|
40
|
-
end
|
41
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'shoes/color'
|
2
|
-
|
3
|
-
shared_examples_for "object with stroke" do
|
4
|
-
let(:color) { Shoes::COLORS.fetch :tomato }
|
5
|
-
let(:color2) { Shoes::COLORS.fetch :forestgreen }
|
6
|
-
let(:gradient) { Shoes::Gradient.new(color, color2) }
|
7
|
-
|
8
|
-
specify "returns a color" do
|
9
|
-
c = subject.stroke = color
|
10
|
-
expect(c.class).to eq(Shoes::Color)
|
11
|
-
end
|
12
|
-
|
13
|
-
specify "sets on receiver" do
|
14
|
-
subject.stroke = color
|
15
|
-
expect(subject.stroke).to eq(color)
|
16
|
-
expect(subject.style[:stroke]).to eq(color)
|
17
|
-
end
|
18
|
-
|
19
|
-
specify "sets with a gradient" do
|
20
|
-
subject.stroke = gradient
|
21
|
-
expect(subject.stroke).to eq(gradient)
|
22
|
-
expect(subject.style[:stroke]).to eq(gradient)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Be sure the subject does *not* have the stroke set previously
|
26
|
-
specify "defaults to black" do
|
27
|
-
expect(subject.stroke).to eq(Shoes::COLORS.fetch :black)
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "strokewidth" do
|
31
|
-
specify "defaults to 1" do
|
32
|
-
expect(subject.strokewidth).to eq(1)
|
33
|
-
end
|
34
|
-
|
35
|
-
specify "sets" do
|
36
|
-
subject.strokewidth = 2
|
37
|
-
expect(subject.strokewidth).to eq(2)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
shared_examples_for "object with fill" do
|
43
|
-
let(:color) { Shoes::COLORS.fetch :honeydew }
|
44
|
-
|
45
|
-
specify "returns a color" do
|
46
|
-
c = subject.fill = color
|
47
|
-
expect(c.class).to eq(Shoes::Color)
|
48
|
-
end
|
49
|
-
|
50
|
-
specify "sets on receiver" do
|
51
|
-
subject.fill = color
|
52
|
-
expect(subject.fill).to eq(color)
|
53
|
-
expect(subject.style[:fill]).to eq(color)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Be sure the subject does *not* have the stroke set previously
|
57
|
-
specify "defaults to black" do
|
58
|
-
expect(subject.fill).to eq(Shoes::COLORS.fetch :black)
|
59
|
-
end
|
60
|
-
end
|
@@ -1,331 +0,0 @@
|
|
1
|
-
shared_examples_for "Slot" do
|
2
|
-
it "should be able to append" do
|
3
|
-
expect(subject.contents).to be_empty
|
4
|
-
our_subject = subject
|
5
|
-
app.execute_block Proc.new { our_subject.append {para "foo"} }
|
6
|
-
expect(subject.contents.size).to eq(1)
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'has a height of 0 as it is empty although it has a top' do
|
10
|
-
subject.absolute_top = 100
|
11
|
-
subject.contents_alignment
|
12
|
-
expect(subject.height).to eq 0
|
13
|
-
end
|
14
|
-
|
15
|
-
it_behaves_like 'prepending'
|
16
|
-
it_behaves_like 'clearing'
|
17
|
-
it_behaves_like 'element one positioned with bottom and right'
|
18
|
-
it_behaves_like 'growing although relatively positioned elements'
|
19
|
-
end
|
20
|
-
|
21
|
-
shared_context 'one slot child' do
|
22
|
-
let(:ele_opts) {Hash.new}
|
23
|
-
let(:element) {Shoes::FakeElement.new(nil, {height: 100,width: 50}.merge(ele_opts))}
|
24
|
-
|
25
|
-
before :each do
|
26
|
-
subject.add_child element
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
shared_context 'two slot children' do
|
31
|
-
include_context 'one slot child'
|
32
|
-
let(:element2) {Shoes::FakeElement.new nil, height: 200, width: 70}
|
33
|
-
|
34
|
-
before :each do
|
35
|
-
subject.add_child element2
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
shared_context 'hidden child' do
|
40
|
-
let(:hidden_element) {Shoes::FakeElement.new nil, height: 200, width: 70}
|
41
|
-
|
42
|
-
before :each do
|
43
|
-
subject.add_child hidden_element
|
44
|
-
hidden_element.gui = double("hidden gui", update_visibility: nil)
|
45
|
-
hidden_element.hide
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
shared_context 'three slot children' do
|
50
|
-
include_context 'two slot children'
|
51
|
-
let(:element3) {Shoes::FakeElement.new(nil, height: 50, width: 20)}
|
52
|
-
|
53
|
-
before :each do
|
54
|
-
subject.add_child element3
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
shared_context 'contents_alignment' do
|
59
|
-
before :each do
|
60
|
-
subject.contents_alignment
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
shared_context 'element one with top and left' do
|
65
|
-
let(:ele_top) {22}
|
66
|
-
let(:ele_left) {47}
|
67
|
-
let(:ele_opts) {{left: ele_left, top: ele_top}}
|
68
|
-
end
|
69
|
-
|
70
|
-
shared_context 'slot with set height and width' do
|
71
|
-
let(:input_opts) {{width: 250, height: 300}}
|
72
|
-
end
|
73
|
-
|
74
|
-
shared_context 'element one with bottom and right' do
|
75
|
-
let(:ele_bottom) {24}
|
76
|
-
let(:ele_right) {49}
|
77
|
-
let(:ele_opts) {{right: ele_right, bottom: ele_bottom}}
|
78
|
-
end
|
79
|
-
|
80
|
-
shared_examples_for 'positioning through :_position' do
|
81
|
-
|
82
|
-
let(:element) {Shoes::FakeElement.new nil, height: 100, width: 50}
|
83
|
-
|
84
|
-
def add_child_and_align
|
85
|
-
subject.add_child element
|
86
|
-
subject.contents_alignment
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'sends the child the :_position method to position it' do
|
90
|
-
expect(element).to receive(:_position).and_call_original
|
91
|
-
add_child_and_align
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'does not send _position again if the position did not change' do
|
95
|
-
add_child_and_align
|
96
|
-
expect(element).not_to receive(:_position)
|
97
|
-
subject.contents_alignment
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'does not position an element if it does not need positioning' do
|
101
|
-
my_element = element
|
102
|
-
allow(my_element).to receive_messages needs_to_be_positioned?: false
|
103
|
-
expect(my_element).not_to receive :_position
|
104
|
-
subject.add_child my_element
|
105
|
-
subject.contents_alignment
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
shared_examples_for 'element one positioned with top and left' do
|
110
|
-
it 'positions the element at its left value' do
|
111
|
-
expect(element.absolute_left).to eq subject.absolute_left + ele_left
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'positions the element at its top value' do
|
115
|
-
expect(element.absolute_top).to eq subject.absolute_top + ele_top
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
shared_examples_for 'element one positioned with bottom and right' do
|
120
|
-
include_context 'one slot child'
|
121
|
-
include_context 'contents_alignment'
|
122
|
-
include_context 'element one with bottom and right'
|
123
|
-
include_context 'slot with set height and width'
|
124
|
-
|
125
|
-
it 'positions the element from its right' do
|
126
|
-
expect(element.absolute_right).to eq (subject.absolute_right - ele_right - 1)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'positions the element from its bottom' do
|
130
|
-
expect(element.absolute_bottom).to eq (subject.absolute_bottom - ele_bottom - 1)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
shared_examples_for 'positions the first element in the top left' do
|
135
|
-
include_context 'one slot child'
|
136
|
-
include_context 'contents_alignment'
|
137
|
-
it 'positions a single object at the same top as self' do
|
138
|
-
expect(element.absolute_top).to eq subject.element_top
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'positions a single object at the same left as self' do
|
142
|
-
expect(element.absolute_left).to eq subject.element_left
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'has a slot height of the element height' do
|
146
|
-
expect(subject.height).to eq element.height
|
147
|
-
end
|
148
|
-
|
149
|
-
describe 'top and left' do
|
150
|
-
include_context 'element one with top and left'
|
151
|
-
it_behaves_like 'element one positioned with top and left'
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
shared_examples_for 'arranges elements underneath each other' do
|
156
|
-
include_context 'two slot children'
|
157
|
-
include_context 'contents_alignment'
|
158
|
-
|
159
|
-
it 'positions an element beneath a previous element' do
|
160
|
-
expect(element2.absolute_top).to eq element.absolute_bottom + 1
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'still positions it at the start of the line (e.g. self.left)' do
|
164
|
-
expect(element2.absolute_left).to eq subject.absolute_left
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'has a stack height according to its contents' do
|
168
|
-
expect(subject.height).to eq (element.height + element2.height)
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'has an absolute_bottom of top + height' do
|
172
|
-
expect(subject.absolute_bottom).to eq (subject.absolute_top + subject.height - 1)
|
173
|
-
end
|
174
|
-
|
175
|
-
describe 'element one with top and left' do
|
176
|
-
include_context 'element one with top and left'
|
177
|
-
it_behaves_like 'element one positioned with top and left'
|
178
|
-
|
179
|
-
describe 'positions element2 disregarding element1' do
|
180
|
-
it 'has the same absolute left as the slot' do
|
181
|
-
expect(element2.absolute_left).to eq subject.absolute_left
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'has the same absolute top as the slot' do
|
185
|
-
expect(element2.absolute_top).to eq subject.absolute_top
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
shared_examples_for 'set height and contents alignment' do
|
192
|
-
include_context 'two slot children'
|
193
|
-
|
194
|
-
it 'contents_alignment returns the height of the content' do
|
195
|
-
expect(subject.contents_alignment).to eq (element.height + element2.height)
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'still has the same height though' do
|
199
|
-
old_height = subject.height
|
200
|
-
subject.contents_alignment
|
201
|
-
expect(subject.height).to eq old_height
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
shared_examples_for 'taking care of margin' do
|
206
|
-
include_context 'two slot children'
|
207
|
-
include_context 'contents_alignment'
|
208
|
-
|
209
|
-
it 'respects the left margin for the first element' do
|
210
|
-
expect(element.absolute_left).to eq input_opts[:margin]
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'respects the left margin for the second element' do
|
214
|
-
expect(element2.absolute_left).to eq input_opts[:margin]
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'respects the top margin for the first element' do
|
218
|
-
expect(element.absolute_top).to eq input_opts[:margin]
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
shared_examples_for 'growing although relatively positioned elements' do
|
223
|
-
include_context 'one slot child'
|
224
|
-
include_context 'contents_alignment'
|
225
|
-
|
226
|
-
describe 'positioned at the very beginning' do
|
227
|
-
let(:ele_opts) {{top: 0}}
|
228
|
-
|
229
|
-
it 'grows the slot height' do
|
230
|
-
expect(subject.height).to eq element.height
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe 'positioned with a good offset' do
|
235
|
-
let(:ele_opts) {{top: 70}}
|
236
|
-
|
237
|
-
it 'grows the height even further' do
|
238
|
-
expect(subject.height).to eq element.height + 70
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
describe 'positioning with hidden elements' do
|
243
|
-
include_context 'hidden child'
|
244
|
-
|
245
|
-
it 'grows only to height of first child' do
|
246
|
-
subject.contents_alignment
|
247
|
-
expect(subject.height).to eq element.height
|
248
|
-
end
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
shared_examples_for 'prepending' do
|
253
|
-
include_context 'two slot children'
|
254
|
-
let(:prepend1) {double 'prepend1'}
|
255
|
-
let(:prepend2) {double 'prepend2'}
|
256
|
-
|
257
|
-
describe 'one element' do
|
258
|
-
before :each do
|
259
|
-
subject.prepend do
|
260
|
-
subject.add_child prepend1
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
it 'as the first' do
|
265
|
-
expect(subject.contents.first).to eq prepend1
|
266
|
-
end
|
267
|
-
|
268
|
-
it 'has a total of 3 elements then' do
|
269
|
-
expect(subject.contents.size).to eq(3)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
describe 'two elements' do
|
274
|
-
before :each do
|
275
|
-
subject.prepend do
|
276
|
-
subject.add_child prepend1
|
277
|
-
subject.add_child prepend2
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
it 'has prepend1 as the first child' do
|
282
|
-
expect(subject.contents.first).to eq prepend1
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'has prepend2 as the second child' do
|
286
|
-
expect(subject.contents[1]).to eq prepend2
|
287
|
-
end
|
288
|
-
|
289
|
-
it 'has a total of 4 children' do
|
290
|
-
expect(subject.contents.size).to eq(4)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
describe 'two times' do
|
295
|
-
before :each do
|
296
|
-
subject.prepend { subject.add_child prepend1 }
|
297
|
-
subject.prepend {subject.add_child prepend2 }
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'has the last prepended element as the first' do
|
301
|
-
expect(subject.contents.first).to eq prepend2
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'has the first prepended element as the second' do
|
305
|
-
expect(subject.contents[1]).to eq prepend1
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'has a total of 4 children' do
|
309
|
-
expect(subject.contents.size).to eq(4)
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
shared_examples_for 'clearing' do
|
315
|
-
include_context 'two slot children'
|
316
|
-
|
317
|
-
describe '#clear' do
|
318
|
-
it 'removes all contents' do
|
319
|
-
subject.clear
|
320
|
-
expect(subject.contents).to be_empty
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
describe 'Element#remove' do
|
325
|
-
it 'removees the element' do
|
326
|
-
element.parent = subject
|
327
|
-
element.remove
|
328
|
-
expect(subject.contents).not_to include element
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|