shoes 4.0.0.pre1 → 4.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +84 -32
- data/Gemfile +22 -1
- data/README.md +28 -13
- data/Rakefile +7 -210
- data/bin/ruby-shoes +2 -2
- data/ext/install/shoes.bat +4 -1
- data/lib/shoes.rb +1 -121
- data/lib/shoes/{cli.rb → ui/cli.rb} +7 -1
- data/lib/shoes/{help.rb → ui/help.rb} +2 -2
- data/lib/shoes/{manual.rb → ui/manual.rb} +1 -1
- data/lib/shoes/version.rb +1 -1
- data/manifests/common.rb +34 -0
- data/manifests/shoes.rb +44 -0
- data/samples/Gemfile +3 -0
- data/samples/Gemfile.lock +35 -0
- data/samples/README +16 -5
- data/samples/boom.rb +239 -0
- data/samples/clicky.rb +24 -0
- data/samples/flow.rb +63 -0
- data/samples/gray.rb +11 -0
- data/samples/nks_booklist.rb +24 -0
- data/samples/nks_breadsticks.rb +7 -0
- data/samples/nks_dancing_circle.rb +13 -0
- data/samples/nks_dictionary.rb +23 -0
- data/samples/nks_edit_box.rb +4 -0
- data/samples/nks_edit_line.rb +6 -0
- data/samples/nks_notes.rb +16 -0
- data/samples/nks_self.rb +6 -0
- data/samples/nks_text_sizes.rb +10 -0
- data/samples/nks_trurl.rb +5 -0
- data/samples/packaging/package_me.rb +6 -0
- data/samples/present.rb +27 -0
- data/samples/progress.rb +10 -0
- data/samples/sample31.rb +1 -1
- data/samples/simple-calc.rb +1 -1
- data/samples/simple-tictactoe.rb +238 -0
- data/samples/simple-visibility.rb +11 -0
- data/samples/simple-widget.rb +9 -0
- data/samples/swt-raw.rb +20 -0
- data/samples/troll.rb +22 -0
- data/shoes.gemspec +10 -22
- data/snapshots/sample56.png +0 -0
- data/static/manual-en.txt +16 -7
- data/tasks/changelog.rb +92 -0
- data/tasks/gem.rb +38 -0
- data/tasks/rspec.rb +106 -0
- data/tasks/sample.rb +66 -0
- data/tasks/yard.rb +13 -0
- metadata +55 -488
- data/.gitignore +0 -53
- data/.rspec +0 -3
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -31
- data/bin/shoes +0 -59
- data/bin/shoes.bat +0 -6
- data/fonts/Coolvetica.ttf +0 -0
- data/fonts/Lacuna.ttf +0 -0
- data/lib/ext/highlighter.rb +0 -2
- data/lib/ext/highlighter/common.rb +0 -197
- data/lib/ext/highlighter/lang/ruby.rb +0 -316
- data/lib/ext/highlighter/markup.rb +0 -222
- data/lib/rubygems_plugin.rb +0 -19
- data/lib/shoes/animation.rb +0 -55
- data/lib/shoes/app.rb +0 -320
- data/lib/shoes/arc.rb +0 -35
- data/lib/shoes/background.rb +0 -30
- data/lib/shoes/border.rb +0 -33
- data/lib/shoes/builtin_methods.rb +0 -73
- data/lib/shoes/button.rb +0 -32
- data/lib/shoes/check_button.rb +0 -43
- data/lib/shoes/color.rb +0 -375
- data/lib/shoes/common/background_element.rb +0 -9
- data/lib/shoes/common/changeable.rb +0 -34
- data/lib/shoes/common/clickable.rb +0 -17
- data/lib/shoes/common/common_methods.rb +0 -70
- data/lib/shoes/common/fill.rb +0 -21
- data/lib/shoes/common/registration.rb +0 -33
- data/lib/shoes/common/state.rb +0 -18
- data/lib/shoes/common/stroke.rb +0 -28
- data/lib/shoes/common/style.rb +0 -34
- data/lib/shoes/common/style_normalizer.rb +0 -16
- data/lib/shoes/configuration.rb +0 -96
- data/lib/shoes/dialog.rb +0 -27
- data/lib/shoes/dimension.rb +0 -237
- data/lib/shoes/dimensions.rb +0 -194
- data/lib/shoes/download.rb +0 -117
- data/lib/shoes/dsl.rb +0 -478
- data/lib/shoes/font.rb +0 -49
- data/lib/shoes/gradient.rb +0 -18
- data/lib/shoes/image.rb +0 -33
- data/lib/shoes/image_pattern.rb +0 -10
- data/lib/shoes/input_box.rb +0 -68
- data/lib/shoes/key_event.rb +0 -17
- data/lib/shoes/line.rb +0 -38
- data/lib/shoes/link.rb +0 -49
- data/lib/shoes/link_hover.rb +0 -5
- data/lib/shoes/list_box.rb +0 -44
- data/lib/shoes/logger.rb +0 -66
- data/lib/shoes/logger/ruby.rb +0 -18
- data/lib/shoes/mock.rb +0 -30
- data/lib/shoes/mock/animation.rb +0 -8
- data/lib/shoes/mock/app.rb +0 -44
- data/lib/shoes/mock/arc.rb +0 -8
- data/lib/shoes/mock/background.rb +0 -10
- data/lib/shoes/mock/border.rb +0 -7
- data/lib/shoes/mock/button.rb +0 -10
- data/lib/shoes/mock/check.rb +0 -24
- data/lib/shoes/mock/common_methods.rb +0 -11
- data/lib/shoes/mock/dialog.rb +0 -13
- data/lib/shoes/mock/download.rb +0 -18
- data/lib/shoes/mock/font.rb +0 -17
- data/lib/shoes/mock/image.rb +0 -12
- data/lib/shoes/mock/image_pattern.rb +0 -9
- data/lib/shoes/mock/input_box.rb +0 -23
- data/lib/shoes/mock/keypress.rb +0 -8
- data/lib/shoes/mock/keyrelease.rb +0 -8
- data/lib/shoes/mock/line.rb +0 -14
- data/lib/shoes/mock/link.rb +0 -11
- data/lib/shoes/mock/list_box.rb +0 -16
- data/lib/shoes/mock/oval.rb +0 -11
- data/lib/shoes/mock/progress.rb +0 -10
- data/lib/shoes/mock/radio.rb +0 -26
- data/lib/shoes/mock/rect.rb +0 -13
- data/lib/shoes/mock/shape.rb +0 -19
- data/lib/shoes/mock/slot.rb +0 -14
- data/lib/shoes/mock/sound.rb +0 -8
- data/lib/shoes/mock/star.rb +0 -13
- data/lib/shoes/mock/text_block.rb +0 -29
- data/lib/shoes/mock/timer.rb +0 -8
- data/lib/shoes/oval.rb +0 -28
- data/lib/shoes/point.rb +0 -43
- data/lib/shoes/progress.rb +0 -26
- data/lib/shoes/radio.rb +0 -15
- data/lib/shoes/rect.rb +0 -28
- data/lib/shoes/renamed_delegate.rb +0 -15
- data/lib/shoes/shape.rb +0 -175
- data/lib/shoes/slot.rb +0 -232
- data/lib/shoes/slot_contents.rb +0 -56
- data/lib/shoes/sound.rb +0 -16
- data/lib/shoes/span.rb +0 -16
- data/lib/shoes/star.rb +0 -49
- data/lib/shoes/swt.rb +0 -114
- data/lib/shoes/swt/animation.rb +0 -46
- data/lib/shoes/swt/app.rb +0 -300
- data/lib/shoes/swt/arc.rb +0 -70
- data/lib/shoes/swt/background.rb +0 -31
- data/lib/shoes/swt/border.rb +0 -37
- data/lib/shoes/swt/button.rb +0 -18
- data/lib/shoes/swt/check.rb +0 -14
- data/lib/shoes/swt/check_button.rb +0 -19
- data/lib/shoes/swt/color.rb +0 -45
- data/lib/shoes/swt/common/child.rb +0 -16
- data/lib/shoes/swt/common/clear.rb +0 -24
- data/lib/shoes/swt/common/clickable.rb +0 -62
- data/lib/shoes/swt/common/container.rb +0 -28
- data/lib/shoes/swt/common/fill.rb +0 -37
- data/lib/shoes/swt/common/painter.rb +0 -83
- data/lib/shoes/swt/common/painter_updates_position.rb +0 -12
- data/lib/shoes/swt/common/resource.rb +0 -14
- data/lib/shoes/swt/common/selection_listener.rb +0 -14
- data/lib/shoes/swt/common/stroke.rb +0 -41
- data/lib/shoes/swt/common/toggle.rb +0 -13
- data/lib/shoes/swt/common/update_position.rb +0 -15
- data/lib/shoes/swt/dialog.rb +0 -89
- data/lib/shoes/swt/disposed_protection.rb +0 -23
- data/lib/shoes/swt/download.rb +0 -24
- data/lib/shoes/swt/fitted_text_layout.rb +0 -94
- data/lib/shoes/swt/fitted_text_layout_collection.rb +0 -108
- data/lib/shoes/swt/font.rb +0 -32
- data/lib/shoes/swt/gradient.rb +0 -77
- data/lib/shoes/swt/image.rb +0 -130
- data/lib/shoes/swt/image_pattern.rb +0 -19
- data/lib/shoes/swt/input_box.rb +0 -73
- data/lib/shoes/swt/key_listener.rb +0 -145
- data/lib/shoes/swt/line.rb +0 -57
- data/lib/shoes/swt/link.rb +0 -37
- data/lib/shoes/swt/link_segment.rb +0 -108
- data/lib/shoes/swt/list_box.rb +0 -49
- data/lib/shoes/swt/mouse_move_listener.rb +0 -61
- data/lib/shoes/swt/oval.rb +0 -53
- data/lib/shoes/swt/progress.rb +0 -35
- data/lib/shoes/swt/radio.rb +0 -29
- data/lib/shoes/swt/radio_group.rb +0 -54
- data/lib/shoes/swt/rect.rb +0 -31
- data/lib/shoes/swt/rect_painter.rb +0 -23
- data/lib/shoes/swt/redrawing_aspect.rb +0 -122
- data/lib/shoes/swt/shape.rb +0 -101
- data/lib/shoes/swt/shoes_layout.rb +0 -43
- data/lib/shoes/swt/slot.rb +0 -25
- data/lib/shoes/swt/sound.rb +0 -119
- data/lib/shoes/swt/star.rb +0 -51
- data/lib/shoes/swt/swt_button.rb +0 -49
- data/lib/shoes/swt/text_block.rb +0 -133
- data/lib/shoes/swt/text_block_cursor_painter.rb +0 -112
- data/lib/shoes/swt/text_block_fitter.rb +0 -180
- data/lib/shoes/swt/text_block_painter.rb +0 -49
- data/lib/shoes/swt/text_font_factory.rb +0 -27
- data/lib/shoes/swt/text_style_factory.rb +0 -88
- data/lib/shoes/swt/timer.rb +0 -19
- data/lib/shoes/swt/tooling/leak_hunter.rb +0 -84
- data/lib/shoes/text.rb +0 -14
- data/lib/shoes/text_block.rb +0 -162
- data/lib/shoes/timer.rb +0 -10
- data/lib/shoes/url.rb +0 -47
- data/lib/shoes/widget.rb +0 -73
- data/lib/support/jl1.0.1.jar +0 -0
- data/lib/support/jogg-0.0.7.jar +0 -0
- data/lib/support/jorbis-0.0.15.jar +0 -0
- data/lib/support/log4j-1.2.16.jar +0 -0
- data/lib/support/mp3spi1.9.5.jar +0 -0
- data/lib/support/tritonus_share.jar +0 -0
- data/lib/support/vorbisspi1.0.3.jar +0 -0
- data/samples/good-clock-adjusted.rb +0 -49
- data/spec/async_helper.rb +0 -21
- data/spec/code_coverage.rb +0 -11
- data/spec/shoes/animation_spec.rb +0 -65
- data/spec/shoes/app_spec.rb +0 -411
- data/spec/shoes/arc_spec.rb +0 -53
- data/spec/shoes/background_spec.rb +0 -48
- data/spec/shoes/border_spec.rb +0 -43
- data/spec/shoes/builtin_methods_spec.rb +0 -84
- data/spec/shoes/button_spec.rb +0 -41
- data/spec/shoes/check_spec.rb +0 -31
- data/spec/shoes/cli_spec.rb +0 -16
- data/spec/shoes/color_spec.rb +0 -396
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -58
- data/spec/shoes/configuration_spec.rb +0 -37
- data/spec/shoes/constants_spec.rb +0 -38
- data/spec/shoes/dialog_spec.rb +0 -163
- data/spec/shoes/dimension_spec.rb +0 -381
- data/spec/shoes/dimensions_spec.rb +0 -831
- data/spec/shoes/download_spec.rb +0 -133
- data/spec/shoes/flow_spec.rb +0 -92
- data/spec/shoes/font_spec.rb +0 -38
- data/spec/shoes/framework_learning_spec.rb +0 -30
- data/spec/shoes/helpers/fake_element.rb +0 -11
- data/spec/shoes/helpers/sample17_helper.rb +0 -66
- data/spec/shoes/image_spec.rb +0 -45
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -44
- data/spec/shoes/integration_spec.rb +0 -20
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -12
- data/spec/shoes/line_spec.rb +0 -47
- data/spec/shoes/link_spec.rb +0 -89
- data/spec/shoes/list_box_spec.rb +0 -63
- data/spec/shoes/logger/ruby_spec.rb +0 -9
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -20
- data/spec/shoes/point_spec.rb +0 -51
- data/spec/shoes/progress_spec.rb +0 -40
- data/spec/shoes/radio_spec.rb +0 -28
- data/spec/shoes/rect_spec.rb +0 -38
- data/spec/shoes/renamed_delegate_spec.rb +0 -70
- data/spec/shoes/shape_spec.rb +0 -54
- 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 -42
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -42
- 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/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 -52
- 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 -60
- 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_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/shared_element_method.rb +0 -52
- data/spec/shoes/shared_examples/slot.rb +0 -272
- data/spec/shoes/shared_examples/state.rb +0 -19
- data/spec/shoes/shared_examples/style.rb +0 -24
- data/spec/shoes/slot_spec.rb +0 -60
- data/spec/shoes/sound_spec.rb +0 -15
- data/spec/shoes/span_spec.rb +0 -94
- data/spec/shoes/spec_helper.rb +0 -1
- data/spec/shoes/stack_spec.rb +0 -53
- data/spec/shoes/star_spec.rb +0 -30
- data/spec/shoes/text_block_spec.rb +0 -242
- data/spec/shoes/url_spec.rb +0 -66
- data/spec/shoes/widget_spec.rb +0 -34
- data/spec/shoes_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -16
- data/spec/swt_shoes/animation_spec.rb +0 -86
- data/spec/swt_shoes/app_spec.rb +0 -75
- data/spec/swt_shoes/arc_spec.rb +0 -101
- data/spec/swt_shoes/background_spec.rb +0 -56
- data/spec/swt_shoes/border_spec.rb +0 -51
- data/spec/swt_shoes/button_spec.rb +0 -101
- data/spec/swt_shoes/check_spec.rb +0 -28
- data/spec/swt_shoes/color_spec.rb +0 -67
- data/spec/swt_shoes/common/painter_spec.rb +0 -29
- data/spec/swt_shoes/configuration_spec.rb +0 -12
- data/spec/swt_shoes/dialog_spec.rb +0 -106
- data/spec/swt_shoes/disposed_protection_spec.rb +0 -49
- data/spec/swt_shoes/fitted_text_layout_collection_spec.rb +0 -174
- data/spec/swt_shoes/fitted_text_layout_spec.rb +0 -130
- data/spec/swt_shoes/flow_spec.rb +0 -26
- data/spec/swt_shoes/font_spec.rb +0 -33
- data/spec/swt_shoes/gradient_spec.rb +0 -20
- data/spec/swt_shoes/image_pattern_spec.rb +0 -19
- data/spec/swt_shoes/image_spec.rb +0 -100
- data/spec/swt_shoes/input_box_spec.rb +0 -110
- data/spec/swt_shoes/integration_spec.rb +0 -18
- data/spec/swt_shoes/key_listener_spec.rb +0 -320
- data/spec/swt_shoes/line_spec.rb +0 -43
- data/spec/swt_shoes/link_segment_spec.rb +0 -103
- data/spec/swt_shoes/link_spec.rb +0 -59
- data/spec/swt_shoes/list_box_spec.rb +0 -51
- data/spec/swt_shoes/minimal.png +0 -0
- data/spec/swt_shoes/mouse_move_listener_spec.rb +0 -129
- data/spec/swt_shoes/oval_spec.rb +0 -51
- data/spec/swt_shoes/progress_spec.rb +0 -44
- data/spec/swt_shoes/radio_group_spec.rb +0 -73
- data/spec/swt_shoes/radio_spec.rb +0 -56
- data/spec/swt_shoes/rect_painter_spec.rb +0 -45
- data/spec/swt_shoes/rect_spec.rb +0 -19
- data/spec/swt_shoes/shape_spec.rb +0 -81
- data/spec/swt_shoes/shared_examples/button.rb +0 -24
- data/spec/swt_shoes/shared_examples/clearable.rb +0 -32
- data/spec/swt_shoes/shared_examples/clickable.rb +0 -60
- data/spec/swt_shoes/shared_examples/movable.rb +0 -36
- data/spec/swt_shoes/shared_examples/paintable_spec.rb +0 -7
- data/spec/swt_shoes/shared_examples/painter.rb +0 -83
- data/spec/swt_shoes/shared_examples/pattern.rb +0 -32
- data/spec/swt_shoes/shared_examples/swt_app_context.rb +0 -17
- data/spec/swt_shoes/shared_examples/togglable.rb +0 -15
- data/spec/swt_shoes/shell_control_listener_spec.rb +0 -23
- data/spec/swt_shoes/sound.rb +0 -10
- data/spec/swt_shoes/spec_helper.rb +0 -31
- data/spec/swt_shoes/star_spec.rb +0 -47
- data/spec/swt_shoes/text_block_cursor_painter_spec.rb +0 -202
- data/spec/swt_shoes/text_block_fitter_spec.rb +0 -181
- data/spec/swt_shoes/text_block_painter_spec.rb +0 -221
- data/spec/swt_shoes/text_block_spec.rb +0 -183
@@ -1,174 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::FittedTextLayoutCollection do
|
4
|
-
include_context "swt app"
|
5
|
-
|
6
|
-
let(:first_layout) { create_layout("first", "first") }
|
7
|
-
let(:second_layout) { create_layout("second", "rest") }
|
8
|
-
|
9
|
-
let(:gc) { double("gc") }
|
10
|
-
let(:default_text_styles) {
|
11
|
-
{
|
12
|
-
:fg => :fg,
|
13
|
-
:bg => :bg,
|
14
|
-
:strikecolor => :strikecolor,
|
15
|
-
:undercolor => :undercolor,
|
16
|
-
:font_detail => {
|
17
|
-
:name => "font name",
|
18
|
-
:size => 12,
|
19
|
-
:styles => [::Swt::SWT::NORMAL]
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
context "with one layout" do
|
25
|
-
subject { Shoes::Swt::FittedTextLayoutCollection.new([first_layout], default_text_styles) }
|
26
|
-
|
27
|
-
it "should have length" do
|
28
|
-
expect(subject.length).to eq(1)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "delegates drawing" do
|
32
|
-
subject.draw(gc)
|
33
|
-
expect(first_layout).to have_received(:draw)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "applies segment styling" do
|
37
|
-
styles = [[0..1, [double("segment", opts:{stroke: :blue})]]]
|
38
|
-
subject.style_segment_ranges(styles)
|
39
|
-
|
40
|
-
expected_style = style_with(stroke: :blue, fg: :blue)
|
41
|
-
expect(first_layout).to have_received(:set_style).with(expected_style, 0..1)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "only gets default styling if segment is missing opts" do
|
45
|
-
styles = [[0..1, [double("segment")]]]
|
46
|
-
subject.style_segment_ranges(styles)
|
47
|
-
expect(first_layout).to have_received(:set_style).with(default_text_styles, 0..1)
|
48
|
-
end
|
49
|
-
|
50
|
-
context "links" do
|
51
|
-
it "styles links" do
|
52
|
-
styles = [[0..1, [create_link("linky")]]]
|
53
|
-
subject.style_segment_ranges(styles)
|
54
|
-
|
55
|
-
expected_style = style_with(underline: true, stroke: ::Shoes::COLORS[:blue])
|
56
|
-
expect(first_layout).to have_received(:set_style).with(expected_style, 0..1)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "creates a link segment" do
|
60
|
-
link = create_link("f")
|
61
|
-
styles = [[0..1, [link]]]
|
62
|
-
subject.create_links(styles)
|
63
|
-
|
64
|
-
expect(link.gui.link_segments).to have(1).item
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "layout ranges" do
|
69
|
-
it "picks within the first range" do
|
70
|
-
result = subject.layout_ranges(0..2)
|
71
|
-
expect(result).to eql([[first_layout, 0..2]])
|
72
|
-
end
|
73
|
-
|
74
|
-
it "picks the full first range if too large value requested" do
|
75
|
-
result = subject.layout_ranges(0..first_layout.text.length + 10)
|
76
|
-
expect(result).to eql([[first_layout, 0..first_layout.text.length]])
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with two layouts" do
|
82
|
-
subject { Shoes::Swt::FittedTextLayoutCollection.new([first_layout, second_layout], default_text_styles) }
|
83
|
-
|
84
|
-
it "should have length" do
|
85
|
-
expect(subject.length).to eq(2)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "picks range in first layout" do
|
89
|
-
result = subject.layout_ranges(0..2)
|
90
|
-
expect(result).to eql([[first_layout, 0..2]])
|
91
|
-
end
|
92
|
-
|
93
|
-
it "picks range in second layout" do
|
94
|
-
result = subject.layout_ranges(5..7)
|
95
|
-
expect(result).to eql([[second_layout, 0..2]])
|
96
|
-
end
|
97
|
-
|
98
|
-
it "spans both layouts" do
|
99
|
-
result = subject.layout_ranges(2..7)
|
100
|
-
expect(result).to eql([[first_layout, 2..5],
|
101
|
-
[second_layout, 0..2]])
|
102
|
-
end
|
103
|
-
|
104
|
-
it "applies segment styling in first layout" do
|
105
|
-
styles = [[0..2, [double("segment", opts:{stroke: :blue})]]]
|
106
|
-
subject.style_segment_ranges(styles)
|
107
|
-
|
108
|
-
expected_style = style_with(stroke: :blue, fg: :blue)
|
109
|
-
expect(first_layout).to have_received(:set_style).with(expected_style, 0..2)
|
110
|
-
expect(second_layout).to_not have_received(:set_style)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "applies segment styling in second layout" do
|
114
|
-
styles = [[5..7, [double("segment", opts:{stroke: :blue})]]]
|
115
|
-
subject.style_segment_ranges(styles)
|
116
|
-
|
117
|
-
expected_style = style_with(stroke: :blue, fg: :blue)
|
118
|
-
expect(first_layout).to_not have_received(:set_style)
|
119
|
-
expect(second_layout).to have_received(:set_style).with(expected_style, 0..2)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "applies segment styling in both layouts" do
|
123
|
-
styles = [[2..7, [double("segment", opts:{stroke: :blue})]]]
|
124
|
-
subject.style_segment_ranges(styles)
|
125
|
-
|
126
|
-
expected_style = style_with(stroke: :blue, fg: :blue)
|
127
|
-
expect(first_layout).to have_received(:set_style).with(expected_style, 2..5)
|
128
|
-
expect(second_layout).to have_received(:set_style).with(expected_style, 0..2)
|
129
|
-
end
|
130
|
-
|
131
|
-
context "links" do
|
132
|
-
let(:link) { create_link("rstres") }
|
133
|
-
|
134
|
-
it "creates link segments in both layouts" do
|
135
|
-
styles = [[2..7, [link]]]
|
136
|
-
subject.create_links(styles)
|
137
|
-
|
138
|
-
expect(link.gui.link_segments).to have(2).items
|
139
|
-
end
|
140
|
-
|
141
|
-
it "clears links before re-creating them" do
|
142
|
-
styles = [[2..7, [link]]]
|
143
|
-
|
144
|
-
subject.create_links(styles)
|
145
|
-
subject.create_links(styles)
|
146
|
-
|
147
|
-
expect(link.gui.link_segments).to have(2).items
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def create_layout(name, text)
|
153
|
-
bounds = double("bounds", x: 0, y: 0, height: 0)
|
154
|
-
inner_layout = double(name, text: text,
|
155
|
-
line_bounds: bounds, line_count: 1)
|
156
|
-
|
157
|
-
dsl = double("dsl", font: "", font_size: 16, opts:{})
|
158
|
-
layout = Shoes::Swt::FittedTextLayout.new(dsl, text, 1)
|
159
|
-
layout.position_at(0, 0)
|
160
|
-
layout.stub(:draw)
|
161
|
-
layout.stub(:set_style)
|
162
|
-
layout.stub(:get_location).and_return(double("position", x: 0, y: 0))
|
163
|
-
layout.stub(:layout).and_return(inner_layout)
|
164
|
-
layout
|
165
|
-
end
|
166
|
-
|
167
|
-
def create_link(text)
|
168
|
-
Shoes::Link.new(shoes_app, parent, [text])
|
169
|
-
end
|
170
|
-
|
171
|
-
def style_with(opts={})
|
172
|
-
default_text_styles.merge(opts)
|
173
|
-
end
|
174
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::FittedTextLayout do
|
4
|
-
let(:layout) { double("layout", text: "the text",
|
5
|
-
:alignment= => nil, :justify= => nil, :spacing= => nil,
|
6
|
-
:text= => nil, setWidth: nil,
|
7
|
-
disposed?: false, dispose: nil,
|
8
|
-
set_style: nil, bounds: bounds) }
|
9
|
-
let(:bounds) { Java::OrgEclipseSwtGraphics::Rectangle.new(0, 0, 0, 0) }
|
10
|
-
let(:element_left) { 0 }
|
11
|
-
let(:element_top) { 0 }
|
12
|
-
let(:layout_width) { 10 }
|
13
|
-
let(:layout_height) { 10 }
|
14
|
-
let(:left_offset) { 5 }
|
15
|
-
let(:top_offset) { 5 }
|
16
|
-
|
17
|
-
let(:font_factory) { double("font factory", create_font: font, dispose: nil) }
|
18
|
-
let(:style_factory) { double("style factory", create_style: style, dispose: nil) }
|
19
|
-
let(:font) { double("font") }
|
20
|
-
let(:style) { double("style") }
|
21
|
-
|
22
|
-
let(:style_hash) {
|
23
|
-
{
|
24
|
-
bg: double("bg"),
|
25
|
-
fg: double("fg"),
|
26
|
-
font_detail: {
|
27
|
-
name: "Comic Sans",
|
28
|
-
size: 18,
|
29
|
-
styles: nil
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
let(:dsl) { double("dsl", font: "", font_size: 16, opts:{}) }
|
35
|
-
|
36
|
-
before(:each) do
|
37
|
-
::Swt::TextLayout.stub(:new) { layout }
|
38
|
-
Shoes::Swt::TextFontFactory.stub(:new) { font_factory }
|
39
|
-
Shoes::Swt::TextStyleFactory.stub(:new) { style_factory }
|
40
|
-
end
|
41
|
-
|
42
|
-
subject do
|
43
|
-
fitted = Shoes::Swt::FittedTextLayout.new(dsl, "text", layout_width)
|
44
|
-
fitted.position_at(element_left, element_top)
|
45
|
-
end
|
46
|
-
|
47
|
-
context "disposal" do
|
48
|
-
it "disposes of underlying layout" do
|
49
|
-
layout.stub(:disposed?) { false }
|
50
|
-
expect(layout).to receive(:dispose)
|
51
|
-
subject.dispose
|
52
|
-
end
|
53
|
-
|
54
|
-
it "doesn't overdispose" do
|
55
|
-
layout.stub(:disposed?) { true }
|
56
|
-
expect(layout).to_not receive(:dispose)
|
57
|
-
subject.dispose
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "setting style" do
|
62
|
-
it "on full range" do
|
63
|
-
subject.set_style(style_hash)
|
64
|
-
expect(layout).to have_received(:set_style).
|
65
|
-
with(style, 0, layout.text.length - 1).
|
66
|
-
at_least(1).times
|
67
|
-
end
|
68
|
-
|
69
|
-
it "with a range" do
|
70
|
-
subject.set_style(style_hash, 1..2)
|
71
|
-
expect(layout).to have_received(:set_style).with(style, 1, 2)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "shrinking on initialization" do
|
76
|
-
it "should not shrink when enough containing width" do
|
77
|
-
expect(subject.layout).to_not have_received(:setWidth)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "shrinks when too long for container" do
|
81
|
-
bounds.width = layout_width + 10
|
82
|
-
expect(subject.layout).to have_received(:setWidth).with(layout_width)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "bounds checking" do
|
87
|
-
before(:each) do
|
88
|
-
set_bounds(0, 0, layout_width, layout_height)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "checks boundaries" do
|
92
|
-
expect(subject.in_bounds?(1,1)).to be_true
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "offsets left" do
|
96
|
-
let(:element_left) { left_offset }
|
97
|
-
|
98
|
-
it "checks boundaries" do
|
99
|
-
expect(subject.in_bounds?(layout_width + left_offset - 1, 0)).to be_true
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe "offsets top" do
|
104
|
-
let(:element_top) { top_offset }
|
105
|
-
|
106
|
-
it "checks boundaries" do
|
107
|
-
expect(subject.in_bounds?(0, layout_height + top_offset - 1)).to be_true
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def set_bounds(x, y, width, height)
|
112
|
-
bounds.x = x
|
113
|
-
bounds.y = y
|
114
|
-
bounds.width = width
|
115
|
-
bounds.height = height
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "dispose" do
|
120
|
-
it "should dispose its Swt fonts" do
|
121
|
-
subject.dispose
|
122
|
-
expect(font_factory).to have_received(:dispose)
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should dispose its Swt colors" do
|
126
|
-
subject.dispose
|
127
|
-
expect(style_factory).to have_received(:dispose)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
data/spec/swt_shoes/flow_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::Flow do
|
4
|
-
include_context "swt app"
|
5
|
-
|
6
|
-
let(:dsl) { double('dsl', app: shoes_app).as_null_object }
|
7
|
-
let(:real) { double('real', disposed?: false) }
|
8
|
-
let(:parent_real) { double('parent_real', :get_layout => "ok") }
|
9
|
-
|
10
|
-
subject { Shoes::Swt::Flow.new(dsl, parent) }
|
11
|
-
|
12
|
-
it_behaves_like "togglable"
|
13
|
-
|
14
|
-
describe "#initialize" do
|
15
|
-
before do
|
16
|
-
parent.stub(:real) { parent_real }
|
17
|
-
parent_real.stub(:get_layout){double(top_slot: true)}
|
18
|
-
end
|
19
|
-
|
20
|
-
it "sets readers" do
|
21
|
-
expect(subject.parent).to eq parent
|
22
|
-
expect(subject.dsl).to eq dsl
|
23
|
-
expect(subject.real).to eq parent_real
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/swt_shoes/font_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::Font do
|
4
|
-
|
5
|
-
subject {Shoes::Swt::Font}
|
6
|
-
|
7
|
-
describe 'Shoes::FONTS' do
|
8
|
-
it 'has the FONTS array initially populared' do
|
9
|
-
Shoes::FONTS.should_not be_empty
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'loads the 2 shoes specific fonts' do
|
13
|
-
Shoes::FONTS.should include("Coolvetica", "Lacuna")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.add_font' do
|
18
|
-
it 'returns nil if no font was found' do
|
19
|
-
subject.add_font('/non/existent/font.ttf').should be_nil
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns the font name when the font file is present' do
|
23
|
-
subject.add_font(Shoes::FONT_DIR + 'Coolvetica.ttf').should eq 'Coolvetica'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'calls the Display#load_font method' do
|
27
|
-
font_path = Shoes::FONT_DIR + 'Coolvetica.ttf'
|
28
|
-
::Swt.display.should_receive(:load_font).with(font_path)
|
29
|
-
subject.add_font font_path
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::Gradient do
|
4
|
-
let(:color1) { Shoes::Color.create(Shoes::COLORS[:honeydew]) }
|
5
|
-
let(:color2) { Shoes::Color.create(Shoes::COLORS[:salmon]) }
|
6
|
-
let(:dsl) { Shoes::Gradient.new(color1, color2) }
|
7
|
-
|
8
|
-
subject { Shoes::Swt::Gradient.new(dsl) }
|
9
|
-
|
10
|
-
it_behaves_like "an swt pattern"
|
11
|
-
|
12
|
-
describe "#apply_as_fill" do
|
13
|
-
let(:gc) { double("gc") }
|
14
|
-
|
15
|
-
it "sets background" do
|
16
|
-
gc.should_receive(:set_background_pattern)
|
17
|
-
subject.apply_as_fill(gc, 10, 20, 100, 200)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::ImagePattern do
|
4
|
-
let(:path) { File.join Shoes::DIR, 'static/shoes-icon.png' }
|
5
|
-
let(:dsl) { Shoes::ImagePattern.new(path) }
|
6
|
-
|
7
|
-
subject { Shoes::Swt::ImagePattern.new(dsl) }
|
8
|
-
|
9
|
-
it_behaves_like "an swt pattern"
|
10
|
-
|
11
|
-
describe "#apply_as_fill" do
|
12
|
-
let(:gc) { double("gc") }
|
13
|
-
|
14
|
-
it "sets background" do
|
15
|
-
gc.should_receive(:set_background_pattern)
|
16
|
-
subject.apply_as_fill(gc, 10, 20, 100, 200)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'swt_shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Swt::Image do
|
4
|
-
include_context "swt app"
|
5
|
-
|
6
|
-
IMAGE_WIDTH = 3
|
7
|
-
IMAGE_HEIGHT = 1
|
8
|
-
|
9
|
-
let(:blk) { double("block") }
|
10
|
-
let(:dsl) { Shoes::Image.new shoes_app, parent_dsl, image, opts}
|
11
|
-
let(:opts) {{left: left, top: top, width: width, height: height}}
|
12
|
-
let(:left) { 100 }
|
13
|
-
let(:top) { 200 }
|
14
|
-
let(:height) { nil }
|
15
|
-
let(:width) {nil}
|
16
|
-
let(:image) { "spec/swt_shoes/minimal.png" }
|
17
|
-
|
18
|
-
subject {
|
19
|
-
dsl.stub(:file_path) { image }
|
20
|
-
Shoes::Swt::Image.new(dsl, parent, blk)
|
21
|
-
}
|
22
|
-
|
23
|
-
it_behaves_like "paintable"
|
24
|
-
it_behaves_like "clearable"
|
25
|
-
it_behaves_like "clickable backend"
|
26
|
-
it_behaves_like "togglable"
|
27
|
-
|
28
|
-
describe "paint callback" do
|
29
|
-
let(:event) { double("event", gc: gc) }
|
30
|
-
let(:gc) { double("gc", drawImage: true) }
|
31
|
-
|
32
|
-
before :each do
|
33
|
-
swt_app.should_receive(:add_paint_listener)
|
34
|
-
end
|
35
|
-
|
36
|
-
specify "draws image" do
|
37
|
-
dsl.stub element_left: left, element_top: top
|
38
|
-
gc.should_receive(:drawImage).with(subject.real, 0, 0, 3, 1, left, top, 3, 1)
|
39
|
-
subject.painter.call(event)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "painting raw images" do
|
44
|
-
let(:image) { File.read("spec/swt_shoes/minimal.png", :mode => "rb") }
|
45
|
-
|
46
|
-
specify "loads image from raw data" do
|
47
|
-
subject.real.image_data.width = 3
|
48
|
-
subject.real.image_data.height = 1
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# note the image used is 3x1 pixel big
|
53
|
-
describe 'dimensions' do
|
54
|
-
|
55
|
-
it 'has the given width' do
|
56
|
-
subject.width.should == IMAGE_WIDTH
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'has the given height' do
|
60
|
-
subject.height.should == IMAGE_HEIGHT
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'can change its width' do
|
64
|
-
subject.width = 7
|
65
|
-
subject.width.should == 7
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'can change its height' do
|
69
|
-
subject.height = 7
|
70
|
-
subject.height.should == 7
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'with a given width' do
|
74
|
-
let(:width) {(IMAGE_WIDTH * 5.8).to_i}
|
75
|
-
it 'scales the height' do
|
76
|
-
subject.height.should == (IMAGE_HEIGHT * 5.8).to_i
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'with a given height' do
|
81
|
-
let(:height) {IMAGE_HEIGHT * 4}
|
82
|
-
|
83
|
-
it 'scales the width' do
|
84
|
-
subject.width.should == IMAGE_WIDTH * 4
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe 'with a given width and height' do
|
89
|
-
let(:width) {1}
|
90
|
-
let(:height) {2}
|
91
|
-
it 'sets the given width' do
|
92
|
-
subject.width.should == 1
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'sets the given height' do
|
96
|
-
subject.height.should == 2
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|