shoes-swt 4.0.0.pre2 → 4.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/shoes/swt/swt_button.rb
CHANGED
@@ -20,7 +20,7 @@ class Shoes
|
|
20
20
|
set_size
|
21
21
|
end
|
22
22
|
|
23
|
-
def eval_block
|
23
|
+
def eval_block(blk)
|
24
24
|
blk.call @dsl
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,7 @@ class Shoes
|
|
28
28
|
@real.set_focus
|
29
29
|
end
|
30
30
|
|
31
|
-
def click
|
31
|
+
def click(blk)
|
32
32
|
remove_listeners
|
33
33
|
@real.addSelectionListener { eval_block blk }
|
34
34
|
end
|
@@ -45,6 +45,7 @@ class Shoes
|
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
|
+
|
48
49
|
def set_size
|
49
50
|
@real.pack
|
50
51
|
@dsl.element_width ||= @real.size.x
|
data/lib/shoes/swt/text_block.rb
CHANGED
@@ -65,10 +65,10 @@ class Shoes
|
|
65
65
|
last_segment = segments.last
|
66
66
|
|
67
67
|
@dsl.absolute_right = starting_left + last_segment.last_line_width +
|
68
|
-
|
68
|
+
margin_right
|
69
69
|
|
70
70
|
@dsl.absolute_bottom = starting_top + last_segment.height +
|
71
|
-
|
71
|
+
margin_top + margin_bottom
|
72
72
|
end
|
73
73
|
|
74
74
|
def bump_absolutes_to_next_line
|
@@ -79,7 +79,7 @@ class Shoes
|
|
79
79
|
def set_calculated_sizes
|
80
80
|
@dsl.calculated_width = segments.last.width
|
81
81
|
@dsl.calculated_height = segments.inject(0) do |total, segment|
|
82
|
-
total
|
82
|
+
total + segment.bounds.height
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -22,7 +22,6 @@ class Shoes
|
|
22
22
|
|
23
23
|
move_if_necessary(segment.element_left + position.x,
|
24
24
|
segment.element_top + position.y)
|
25
|
-
|
26
25
|
end
|
27
26
|
|
28
27
|
# It's important to only move when necessary to avoid constant redraws
|
@@ -33,7 +32,8 @@ class Shoes
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def move_textcursor(x, y)
|
36
|
-
textcursor.
|
35
|
+
height = textcursor.height
|
36
|
+
textcursor.move(x, y, x, y + height)
|
37
37
|
textcursor.show
|
38
38
|
end
|
39
39
|
|
@@ -84,7 +84,6 @@ class Shoes
|
|
84
84
|
|
85
85
|
# Since we regenerate layouts, we must dispose of first try here.
|
86
86
|
layout.dispose
|
87
|
-
layout = nil
|
88
87
|
|
89
88
|
first_layout = generate_layout(width, first_text)
|
90
89
|
|
@@ -185,6 +184,9 @@ class Shoes
|
|
185
184
|
segment
|
186
185
|
end
|
187
186
|
|
187
|
+
# Splits the text into two pieces based on height. Allows one final
|
188
|
+
# line to exceed the requested height, which results in smoother
|
189
|
+
# flowing text between different sized fonts on a line.
|
188
190
|
def split_text(layout, height)
|
189
191
|
ending_offset = 0
|
190
192
|
height_so_far = 0
|
@@ -192,9 +194,9 @@ class Shoes
|
|
192
194
|
offsets = layout.line_offsets
|
193
195
|
offsets[0...-1].each_with_index do |_, i|
|
194
196
|
height_so_far += layout.line_bounds(i).height
|
195
|
-
|
197
|
+
ending_offset = offsets[i + 1]
|
196
198
|
|
197
|
-
|
199
|
+
break if height_so_far > height
|
198
200
|
end
|
199
201
|
[layout.text[0...ending_offset], layout.text[ending_offset..-1]]
|
200
202
|
end
|
@@ -30,15 +30,15 @@ class Shoes
|
|
30
30
|
|
31
31
|
def default_text_styles
|
32
32
|
{
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
fg: @style[:fg],
|
34
|
+
bg: @style[:bg],
|
35
|
+
strikecolor: @style[:strikecolor],
|
36
|
+
undercolor: @style[:undercolor],
|
37
|
+
font_detail: {
|
38
|
+
name: @dsl.font,
|
39
|
+
size: @dsl.size,
|
40
|
+
styles: [::Swt::SWT::NORMAL]
|
41
|
+
}
|
42
42
|
}
|
43
43
|
end
|
44
44
|
end
|
@@ -29,9 +29,9 @@ class Shoes
|
|
29
29
|
@fonts.find do |font|
|
30
30
|
font.font_data.any? do |font_data|
|
31
31
|
font_data.name == name &&
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
# Windows seems to create fonts of height 15.75 when requesting 16
|
33
|
+
font_data.height.round == size.round &&
|
34
|
+
font_data.style == styles
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -18,7 +18,7 @@ class Shoes
|
|
18
18
|
|
19
19
|
extend Forwardable
|
20
20
|
def_delegators :@layout, :text, :text=, :bounds, :width, :spacing,
|
21
|
-
|
21
|
+
:line_bounds, :line_count, :line_offsets
|
22
22
|
|
23
23
|
def initialize(dsl, text, width)
|
24
24
|
@dsl = dsl
|
@@ -43,7 +43,7 @@ class Shoes
|
|
43
43
|
self
|
44
44
|
end
|
45
45
|
|
46
|
-
def get_location(cursor, trailing=false)
|
46
|
+
def get_location(cursor, trailing = false)
|
47
47
|
@layout.get_location(cursor, trailing)
|
48
48
|
end
|
49
49
|
|
@@ -51,15 +51,15 @@ class Shoes
|
|
51
51
|
layout.justify = style[:justify]
|
52
52
|
layout.spacing = (style[:leading] || DEFAULT_SPACING)
|
53
53
|
layout.alignment = case style[:align]
|
54
|
-
when 'center'
|
55
|
-
when 'right'
|
54
|
+
when 'center' then ::Swt::SWT::CENTER
|
55
|
+
when 'right' then ::Swt::SWT::RIGHT
|
56
56
|
else ::Swt::SWT::LEFT
|
57
57
|
end
|
58
58
|
|
59
59
|
set_style(TextStyleFactory.apply_styles(default_text_styles, style))
|
60
60
|
end
|
61
61
|
|
62
|
-
def set_style(styles, range=(0...text.length))
|
62
|
+
def set_style(styles, range = (0...text.length))
|
63
63
|
# If we've been given an empty/nonsense range, just ignore it
|
64
64
|
return unless range.count > 0
|
65
65
|
|
@@ -71,10 +71,10 @@ class Shoes
|
|
71
71
|
def font_styling
|
72
72
|
{
|
73
73
|
font_detail: {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
name: @dsl.font,
|
75
|
+
size: @dsl.size,
|
76
|
+
styles: [::Swt::SWT::NORMAL]
|
77
|
+
}
|
78
78
|
}
|
79
79
|
end
|
80
80
|
|
@@ -83,6 +83,8 @@ class Shoes
|
|
83
83
|
# segments apply, and what the relative ranges within each segment to use.
|
84
84
|
def segment_ranges(text_range)
|
85
85
|
return [] unless @segments.first # TODO WTF #636
|
86
|
+
return [] unless text_range.any?
|
87
|
+
|
86
88
|
first_text = @segments.first.text
|
87
89
|
slice = first_text[text_range]
|
88
90
|
|
@@ -47,12 +47,13 @@ class Shoes
|
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
|
+
|
50
51
|
def set_rise(style)
|
51
52
|
@gui_style.rise = style[:rise]
|
52
53
|
end
|
53
54
|
|
54
55
|
def set_underline(style)
|
55
|
-
@gui_style.underline =
|
56
|
+
@gui_style.underline = style_present? style[:underline]
|
56
57
|
@gui_style.underlineStyle = UNDERLINE_STYLES[style[:underline]]
|
57
58
|
end
|
58
59
|
|
@@ -61,7 +62,7 @@ class Shoes
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def set_strikethrough(style)
|
64
|
-
@gui_style.strikeout =
|
65
|
+
@gui_style.strikeout = style_present? style[:strikethrough]
|
65
66
|
end
|
66
67
|
|
67
68
|
def set_strikecolor(style)
|
@@ -74,7 +75,7 @@ class Shoes
|
|
74
75
|
end
|
75
76
|
|
76
77
|
def color_from_dsl(dsl_color, default = nil)
|
77
|
-
return nil if dsl_color.nil?
|
78
|
+
return nil if dsl_color.nil? && default.nil?
|
78
79
|
return color_from_dsl default if dsl_color.nil?
|
79
80
|
color = ::Swt::Color.new(Shoes.display, dsl_color.red, dsl_color.green, dsl_color.blue)
|
80
81
|
|
@@ -83,6 +84,11 @@ class Shoes
|
|
83
84
|
|
84
85
|
color
|
85
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
def style_present?(style)
|
90
|
+
!style.nil? && !(style == 'none')
|
91
|
+
end
|
86
92
|
end
|
87
93
|
end
|
88
94
|
end
|
data/lib/shoes/swt/timer.rb
CHANGED
data/lib/shoes/swt/version.rb
CHANGED
data/shoes-swt.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require_relative 'manifests/shoes-swt'
|
2
|
+
require File.expand_path('lib/shoes/swt/version')
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "shoes-swt"
|
@@ -13,12 +12,14 @@ Gem::Specification.new do |s|
|
|
13
12
|
s.description = %q{A JRuby and Swt backend for Shoes, the best little GUI toolkit for Ruby. Shoes makes building for Mac, Windows, and Linux super simple.}
|
14
13
|
s.license = 'MIT'
|
15
14
|
|
16
|
-
s.files =
|
17
|
-
s.test_files =
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
17
|
s.require_paths = ["lib"]
|
19
18
|
|
20
19
|
s.add_dependency "swt", "~>4.4"
|
21
20
|
s.add_dependency "after_do", "~>0.3"
|
22
|
-
s.add_dependency "shoes-
|
23
|
-
s.add_dependency "
|
21
|
+
s.add_dependency "shoes-core", Shoes::Swt::VERSION
|
22
|
+
s.add_dependency "shoes-package", Shoes::Swt::VERSION
|
23
|
+
|
24
|
+
s.executables = ['shoes-swt']
|
24
25
|
end
|
data/spec/shoes/cli_spec.rb
CHANGED
@@ -4,12 +4,12 @@ describe Shoes::CLI do
|
|
4
4
|
subject {Shoes::CLI.new}
|
5
5
|
|
6
6
|
before :each do
|
7
|
-
allow(subject).to receive :
|
7
|
+
allow(subject.packager).to receive :run
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'does not raise an error for a normal packaging command #624' do
|
11
11
|
expect do
|
12
|
-
subject.run ['-p', 'swt:app', '
|
12
|
+
subject.run ['-p', 'swt:app', 'samples/simple-sound.rb']
|
13
13
|
end.not_to raise_error
|
14
14
|
end
|
15
15
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "shoes/swt/spec_helper"
|
2
2
|
|
3
3
|
describe Shoes::Swt::App do
|
4
4
|
let(:opts) { {:background => Shoes::COLORS[:salmon], :resizable => true} }
|
@@ -24,10 +24,11 @@ describe Shoes::Swt::App do
|
|
24
24
|
it_behaves_like "clickable backend" do
|
25
25
|
let(:swt_app) { subject }
|
26
26
|
let(:click_block_parameters) { click_block_coordinates }
|
27
|
+
let(:click_listener) { double("listener", add_click_listener: nil, add_release_listener: nil) }
|
27
28
|
|
28
29
|
before do
|
29
30
|
allow(dsl).to receive(:pass_coordinates?) { true }
|
30
|
-
allow(subject).to receive(:
|
31
|
+
allow(subject).to receive(:click_listener) { click_listener }
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -70,7 +71,7 @@ describe Shoes::Swt::App do
|
|
70
71
|
|
71
72
|
context "when attempting to copy text" do
|
72
73
|
it "copies text to clipboard" do
|
73
|
-
|
74
|
+
# In case of failure when running tmux, please see #398
|
74
75
|
text = "test"
|
75
76
|
subject.clipboard = text
|
76
77
|
expect(subject.clipboard).to eq(text)
|
@@ -81,4 +82,36 @@ describe Shoes::Swt::App do
|
|
81
82
|
# which at the time is overkill imo
|
82
83
|
it {is_expected.to respond_to :started?}
|
83
84
|
|
85
|
+
describe 'App dimensions' do
|
86
|
+
let(:client_area) {double 'client_area', width: width, height: height}
|
87
|
+
let(:vertical_bar) {double 'scroll bar', visible?: bar_visible}
|
88
|
+
let(:shell) {double('shell', client_area: client_area,
|
89
|
+
vertical_bar: vertical_bar)}
|
90
|
+
let(:width) {50}
|
91
|
+
let(:height) {80}
|
92
|
+
let(:bar_visible) {false}
|
93
|
+
|
94
|
+
before :each do
|
95
|
+
allow(subject).to receive(:shell).and_return(shell)
|
96
|
+
end
|
97
|
+
|
98
|
+
shared_examples_for 'reports client area dimensions' do
|
99
|
+
it 'always returns the client area width' do
|
100
|
+
expect(subject.width).to eq width
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns the client area height' do
|
104
|
+
expect(subject.height).to eq height
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it_behaves_like 'reports client area dimensions'
|
109
|
+
|
110
|
+
context 'with a scroll bar' do
|
111
|
+
let(:bar_visible) {true}
|
112
|
+
|
113
|
+
it_behaves_like 'reports client area dimensions'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
84
117
|
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'shoes/swt/spec_helper'
|
2
|
+
|
3
|
+
describe Shoes::Swt::ClickListener do
|
4
|
+
include_context 'swt app'
|
5
|
+
|
6
|
+
let(:dsl) { double('dsl', hidden?: false, pass_coordinates?: false) }
|
7
|
+
|
8
|
+
let(:click_block) { double("click block", call: nil) }
|
9
|
+
let(:release_block) { double("release block", call: nil) }
|
10
|
+
|
11
|
+
subject { Shoes::Swt::ClickListener.new(swt_app) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
allow(swt_app).to receive(:add_listener)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "SWT event wireup" do
|
18
|
+
it "registers mouse down and mouse up" do
|
19
|
+
subject
|
20
|
+
expect(swt_app).to have_received(:add_listener).with(::Swt::SWT::MouseDown, subject)
|
21
|
+
expect(swt_app).to have_received(:add_listener).with(::Swt::SWT::MouseUp, subject)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "adding listeners" do
|
26
|
+
it "adds a click listener" do
|
27
|
+
subject.add_click_listener(dsl, click_block)
|
28
|
+
expect(subject.clickable_elements).to eq([dsl])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "adds a release listener" do
|
32
|
+
subject.add_release_listener(dsl, release_block)
|
33
|
+
expect(subject.clickable_elements).to eq([dsl])
|
34
|
+
end
|
35
|
+
|
36
|
+
it "only reports each element once" do
|
37
|
+
subject.add_click_listener(dsl, click_block)
|
38
|
+
subject.add_release_listener(dsl, release_block)
|
39
|
+
expect(subject.clickable_elements).to eq([dsl])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "removing" do
|
44
|
+
it "removes safely when not added" do
|
45
|
+
subject.remove_listeners_for(dsl)
|
46
|
+
expect(subject.clickable_elements).to be_empty
|
47
|
+
end
|
48
|
+
|
49
|
+
it "removes element" do
|
50
|
+
subject.add_click_listener(dsl, click_block)
|
51
|
+
subject.add_release_listener(dsl, release_block)
|
52
|
+
|
53
|
+
subject.remove_listeners_for(dsl)
|
54
|
+
|
55
|
+
expect(subject.clickable_elements).to be_empty
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "event handling" do
|
60
|
+
before do
|
61
|
+
subject.add_click_listener(dsl, click_block)
|
62
|
+
subject.add_release_listener(dsl, release_block)
|
63
|
+
|
64
|
+
allow(dsl).to receive(:in_bounds?) { false }
|
65
|
+
allow(dsl).to receive(:in_bounds?).with(10, 10) { true }
|
66
|
+
end
|
67
|
+
|
68
|
+
shared_examples_for "mouse event" do
|
69
|
+
it "triggers" do
|
70
|
+
event = double(type: event_type, x: 10, y: 10)
|
71
|
+
subject.handle_event(event)
|
72
|
+
|
73
|
+
expect(block).to have_received(:call)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "doesn't trigger other block" do
|
77
|
+
event = double(type: event_type, x: 10, y: 10)
|
78
|
+
subject.handle_event(event)
|
79
|
+
|
80
|
+
expect(other_block).to_not have_received(:call)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "doesn't trigger click out of bounds" do
|
84
|
+
event = double(type: event_type, x: 20, y: 10)
|
85
|
+
subject.handle_event(event)
|
86
|
+
|
87
|
+
expect(block).to_not have_received(:call)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "re-registering an element's click overwrites old one" do
|
91
|
+
another_block = double("another block", call: nil)
|
92
|
+
subject.send(add_method, dsl, another_block)
|
93
|
+
|
94
|
+
event = double(type: event_type, x: 10, y: 10)
|
95
|
+
subject.handle_event(event)
|
96
|
+
|
97
|
+
expect(block).to_not have_received(:call)
|
98
|
+
expect(another_block).to have_received(:call)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "takes the last element to respond" do
|
102
|
+
other_dsl = double("other dsl", in_bounds?: true,
|
103
|
+
hidden?: false, pass_coordinates?: false)
|
104
|
+
other_block = double("other block", call: nil)
|
105
|
+
|
106
|
+
subject.send(add_method, other_dsl, other_block)
|
107
|
+
|
108
|
+
event = double(type: event_type, x: 10, y: 10)
|
109
|
+
subject.handle_event(event)
|
110
|
+
|
111
|
+
expect(block).to_not have_received(:call)
|
112
|
+
expect(other_block).to have_received(:call)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "won't call on hidden elements" do
|
116
|
+
allow(dsl).to receive(:hidden?) { true }
|
117
|
+
|
118
|
+
event = double(type: event_type, x: 10, y: 10)
|
119
|
+
subject.handle_event(event)
|
120
|
+
|
121
|
+
expect(block).to_not have_received(:call)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "passes dsl along by default to event" do
|
125
|
+
event = double(type: event_type, x: 10, y: 10)
|
126
|
+
subject.handle_event(event)
|
127
|
+
|
128
|
+
expect(block).to have_received(:call).with(dsl)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "can pass coordinates if requested" do
|
132
|
+
allow(dsl).to receive(:pass_coordinates?) { true }
|
133
|
+
|
134
|
+
event = double(type: event_type, x: 10, y: 10, button: 1)
|
135
|
+
subject.handle_event(event)
|
136
|
+
|
137
|
+
expect(block).to have_received(:call).with(1, 10, 10)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "ignores incorrect event types" do
|
141
|
+
event = double(type: ::Swt::SWT::KeyDown, x: 10, y: 10)
|
142
|
+
subject.handle_event(event)
|
143
|
+
|
144
|
+
expect(block).to_not have_received(:call)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it_behaves_like "mouse event" do
|
149
|
+
let(:event_type) { ::Swt::SWT::MouseDown }
|
150
|
+
let(:block) { click_block }
|
151
|
+
let(:other_block) { release_block }
|
152
|
+
let(:add_method) { :add_click_listener }
|
153
|
+
end
|
154
|
+
|
155
|
+
it_behaves_like "mouse event" do
|
156
|
+
let(:event_type) { ::Swt::SWT::MouseUp }
|
157
|
+
let(:block) { release_block }
|
158
|
+
let(:other_block) { click_block }
|
159
|
+
let(:add_method) { :add_release_listener }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|