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/download.rb
CHANGED
data/lib/shoes/swt/font.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class Shoes
|
2
|
-
|
3
2
|
module Swt
|
4
3
|
module Font
|
5
4
|
class << self
|
@@ -10,11 +9,12 @@ class Shoes
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def initial_fonts
|
13
|
-
load_shoes_fonts #system fonts are loaded automatically by SWT
|
12
|
+
load_shoes_fonts # system fonts are loaded automatically by SWT
|
14
13
|
::Swt.display.get_font_list(nil, true).map(&:name)
|
15
14
|
end
|
16
15
|
|
17
16
|
private
|
17
|
+
|
18
18
|
def load_font(path)
|
19
19
|
::Swt.display.load_font path
|
20
20
|
end
|
@@ -28,5 +28,5 @@ class Shoes
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
::Shoes::Font.initial_fonts.each {|font| Shoes::FONTS << font}
|
32
|
-
end
|
31
|
+
::Shoes::Font.initial_fonts.each { |font| Shoes::FONTS << font }
|
32
|
+
end
|
data/lib/shoes/swt/gradient.rb
CHANGED
@@ -40,7 +40,8 @@ class Shoes
|
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
43
|
-
|
43
|
+
|
44
|
+
def create_pattern(left, top, width, height, angle)
|
44
45
|
width = width * 0.5
|
45
46
|
height = height * 0.5
|
46
47
|
angle = normalize_angle(angle)
|
@@ -52,20 +53,20 @@ class Shoes
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def normalize_angle(angle)
|
55
|
-
angle = Math::PI * (angle/180.0)
|
56
|
-
angle % (Math::PI*2.0)
|
56
|
+
angle = Math::PI * (angle / 180.0)
|
57
|
+
angle % (Math::PI * 2.0)
|
57
58
|
end
|
58
59
|
|
59
60
|
def determine_args_based_on_angle(angle, left, top, width, height)
|
60
61
|
x, y = calculate_x_and_y(angle, height, width)
|
61
|
-
if 0 <= angle
|
62
|
-
args = [left+width+x, top+height-y, left+width-x, top+height+y]
|
63
|
-
elsif Math::PI*0.5 <= angle
|
64
|
-
args = [left+width+y, top+height+x, left+width-y, top+height-x]
|
65
|
-
elsif Math::PI <= angle
|
66
|
-
args = [left+width-x, top+height+y, left+width+x, top+height-y]
|
67
|
-
elsif Math::PI*1.5 <= angle
|
68
|
-
args = [left+width-y, top+height-x, left+width+y, top+height+x]
|
62
|
+
if 0 <= angle && angle < Math::PI * 0.5
|
63
|
+
args = [left + width + x, top + height - y, left + width - x, top + height + y]
|
64
|
+
elsif Math::PI * 0.5 <= angle && angle < Math::PI
|
65
|
+
args = [left + width + y, top + height + x, left + width - y, top + height - x]
|
66
|
+
elsif Math::PI <= angle && angle < Math::PI * 1.5
|
67
|
+
args = [left + width - x, top + height + y, left + width + x, top + height - y]
|
68
|
+
elsif Math::PI * 1.5 <= angle && angle < Math::PI * 2.0
|
69
|
+
args = [left + width - y, top + height - x, left + width + y, top + height + x]
|
69
70
|
end
|
70
71
|
args
|
71
72
|
end
|
@@ -80,12 +81,12 @@ class Shoes
|
|
80
81
|
end
|
81
82
|
my_angle = angle % (Math::PI * 0.5)
|
82
83
|
length = Math.sqrt(my_width**2 + my_height**2)
|
83
|
-
b = (my_height==0
|
84
|
-
c = Math::PI*0.5 - my_angle - b
|
84
|
+
b = (my_height == 0 && my_width == 0) ? 0 : Math.atan(my_height / my_width)
|
85
|
+
c = Math::PI * 0.5 - my_angle - b
|
85
86
|
r = length * Math.cos(c.abs)
|
86
|
-
x = r * Math.cos(b+c)
|
87
|
-
y = r * Math.sin(b+c)
|
88
|
-
|
87
|
+
x = r * Math.cos(b + c)
|
88
|
+
y = r * Math.sin(b + c)
|
89
|
+
[x, y]
|
89
90
|
end
|
90
91
|
end
|
91
92
|
end
|
data/lib/shoes/swt/image.rb
CHANGED
@@ -11,8 +11,6 @@ class Shoes
|
|
11
11
|
include Common::Remove
|
12
12
|
include ::Shoes::BackendDimensionsDelegations
|
13
13
|
|
14
|
-
BINARY_ENCODING = Encoding.find('binary')
|
15
|
-
|
16
14
|
attr_reader :parent, :real, :dsl, :painter
|
17
15
|
|
18
16
|
def initialize(dsl, parent)
|
@@ -29,6 +27,7 @@ class Shoes
|
|
29
27
|
end
|
30
28
|
|
31
29
|
private
|
30
|
+
|
32
31
|
def load_image(name_or_data)
|
33
32
|
if url?(name_or_data)
|
34
33
|
save_width_and_height
|
@@ -40,7 +39,7 @@ class Shoes
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def url?(name_or_data)
|
43
|
-
name_or_data
|
42
|
+
@dsl.url?(name_or_data)
|
44
43
|
end
|
45
44
|
|
46
45
|
def save_width_and_height
|
@@ -102,7 +101,7 @@ class Shoes
|
|
102
101
|
end
|
103
102
|
|
104
103
|
def raw_image_data?(name_or_data)
|
105
|
-
name_or_data
|
104
|
+
@dsl.raw_image_data?(name_or_data)
|
106
105
|
end
|
107
106
|
|
108
107
|
def load_raw_image_data(name_or_data)
|
@@ -122,7 +121,6 @@ class Shoes
|
|
122
121
|
end
|
123
122
|
app.add_paint_listener(@painter)
|
124
123
|
end
|
125
|
-
|
126
124
|
end
|
127
125
|
end
|
128
126
|
end
|
@@ -19,11 +19,11 @@ class Shoes
|
|
19
19
|
@pattern ||= ::Swt::Pattern.new(Shoes.display, @image)
|
20
20
|
end
|
21
21
|
|
22
|
-
def apply_as_fill(gc,
|
22
|
+
def apply_as_fill(gc, _left, _top, _width, _height, _angle = 0)
|
23
23
|
gc.set_background_pattern pattern
|
24
24
|
end
|
25
25
|
|
26
|
-
def apply_as_stroke(gc,
|
26
|
+
def apply_as_stroke(gc, _left, _top, _width, _height, _angle = 0)
|
27
27
|
gc.set_foreground_pattern pattern
|
28
28
|
end
|
29
29
|
end
|
data/lib/shoes/swt/input_box.rb
CHANGED
@@ -45,11 +45,12 @@ class Shoes
|
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
|
+
|
48
49
|
def nothing_changed?(event)
|
49
50
|
source = event.source
|
50
51
|
event.instance_of?(Java::OrgEclipseSwtEvents::ModifyEvent) &&
|
51
|
-
|
52
|
-
|
52
|
+
source.instance_of?(Java::OrgEclipseSwtWidgets::Text) &&
|
53
|
+
source.text == @last_text
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
@@ -68,6 +69,5 @@ class Shoes
|
|
68
69
|
super(dsl, parent, DEFAULT_STYLES)
|
69
70
|
end
|
70
71
|
end
|
71
|
-
|
72
72
|
end
|
73
73
|
end
|
@@ -9,11 +9,11 @@ class Shoes
|
|
9
9
|
|
10
10
|
SPECIAL_KEY_NAMES = {}
|
11
11
|
|
12
|
-
%w
|
13
|
-
F13 F14 F15
|
12
|
+
%w(TAB PAGE_UP PAGE_DOWN HOME END F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
|
13
|
+
F13 F14 F15).each do|key|
|
14
14
|
SPECIAL_KEY_NAMES[get_swt_constant key] = key.downcase
|
15
15
|
end
|
16
|
-
%w
|
16
|
+
%w(UP DOWN LEFT RIGHT).each do |key|
|
17
17
|
SPECIAL_KEY_NAMES[get_swt_constant "ARROW_#{key}"] = key.downcase
|
18
18
|
end
|
19
19
|
|
@@ -22,11 +22,11 @@ class Shoes
|
|
22
22
|
SPECIAL_KEY_NAMES[::Swt::SWT::ESC] = "escape"
|
23
23
|
SPECIAL_KEY_NAMES[::Swt::SWT::CR] = "\n"
|
24
24
|
|
25
|
-
MODIFIER_KEYS = %w
|
25
|
+
MODIFIER_KEYS = %w(CTRL SHIFT ALT CAPS_LOCK COMMAND).map do |key|
|
26
26
|
get_swt_constant key
|
27
27
|
end
|
28
28
|
|
29
|
-
def initialize(
|
29
|
+
def initialize(_dsl, app, &blk)
|
30
30
|
@block = blk
|
31
31
|
@app = app
|
32
32
|
@app.add_key_listener(self)
|
@@ -45,7 +45,7 @@ class Shoes
|
|
45
45
|
end
|
46
46
|
|
47
47
|
BUTTON_EXCLUDES = ["\n", " "]
|
48
|
-
COMBO_EXCLUDES = %w
|
48
|
+
COMBO_EXCLUDES = %w(up down) + BUTTON_EXCLUDES
|
49
49
|
|
50
50
|
# For a variety of SWT controls, certain characters should not be passed
|
51
51
|
# to Shoes key listeners, since they're already handled by the controls.
|
data/lib/shoes/swt/line.rb
CHANGED
@@ -9,50 +9,30 @@ class Shoes
|
|
9
9
|
include ::Shoes::BackendDimensionsDelegations
|
10
10
|
|
11
11
|
attr_reader :dsl, :app
|
12
|
-
attr_reader :translated_point_a, :translated_point_b
|
13
12
|
attr_reader :transform
|
14
13
|
|
15
|
-
# @param [Shoes::Line] dsl The {Shoes::Line} implemented by this object
|
16
|
-
# @param [Shoes::Swt::App] app The {Swt::App} this object belongs to
|
17
|
-
# @param [Shoes::Point] point_a One endpoint of the line
|
18
|
-
# @param [Shoes::Point] point_b The other endpoint of the line
|
19
14
|
def initialize(dsl, app)
|
20
15
|
@dsl, @app = dsl, app
|
21
|
-
translate_according_to_enclosing_box
|
22
16
|
@painter = Painter.new(self)
|
23
17
|
@app.add_paint_listener(@painter)
|
24
|
-
end
|
25
18
|
|
26
|
-
|
27
|
-
@transform.dispose unless @transform.disposed?
|
19
|
+
@transform = nil # Not necessary for this shape
|
28
20
|
end
|
29
21
|
|
30
22
|
def angle
|
31
23
|
@dsl.angle
|
32
24
|
end
|
33
25
|
|
34
|
-
def update_position
|
35
|
-
translate_according_to_enclosing_box
|
36
|
-
end
|
37
|
-
|
38
26
|
private
|
39
|
-
def translate_according_to_enclosing_box
|
40
|
-
@translated_point_a = @dsl.point_a.to(-left, -top)
|
41
|
-
@translated_point_b = @dsl.point_b.to(-left, -top)
|
42
|
-
@transform = ::Swt::Transform.new(::Swt.display)
|
43
|
-
@transform_elements = Java::float[6].new
|
44
|
-
@transform.get_elements @transform_elements
|
45
|
-
@transform.set_elements @transform_elements[0], @transform_elements[1], @transform_elements[2], @transform_elements[3], dsl.element_left, dsl.element_top
|
46
|
-
end
|
47
27
|
|
48
28
|
class Painter < Common::Painter
|
49
29
|
def draw(gc)
|
50
|
-
|
51
|
-
|
30
|
+
gc.draw_line(@obj.element_left, @obj.element_top,
|
31
|
+
@obj.element_right + 1, @obj.element_bottom + 1)
|
52
32
|
end
|
53
33
|
|
54
34
|
# Don't do fill setup
|
55
|
-
def fill_setup(
|
35
|
+
def fill_setup(_gc)
|
56
36
|
end
|
57
37
|
end
|
58
38
|
end
|
data/lib/shoes/swt/link.rb
CHANGED
@@ -13,7 +13,7 @@ class Shoes
|
|
13
13
|
|
14
14
|
def remove
|
15
15
|
@link_segments.clear
|
16
|
-
|
16
|
+
app.click_listener.remove_listeners_for(self)
|
17
17
|
end
|
18
18
|
|
19
19
|
def create_links_in(text_segment_ranges)
|
@@ -24,7 +24,7 @@ class Shoes
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def in_bounds?(x, y)
|
27
|
-
@link_segments.any? {|segment| segment.in_bounds?(x, y)}
|
27
|
+
@link_segments.any? { |segment| segment.in_bounds?(x, y) }
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -32,7 +32,7 @@ class Shoes
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def line_bounds
|
35
|
-
(0..layout.line_count-1).map do |index|
|
35
|
+
(0..layout.line_count - 1).map do |index|
|
36
36
|
layout.line_bounds(index)
|
37
37
|
end
|
38
38
|
end
|
@@ -71,7 +71,7 @@ class Shoes
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def in_bounds?(x, y)
|
74
|
-
@regions.any? {|region| region.in_bounds?(x, y)}
|
74
|
+
@regions.any? { |region| region.in_bounds?(x, y) }
|
75
75
|
end
|
76
76
|
|
77
77
|
def start_position
|
@@ -103,7 +103,7 @@ class Shoes
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def in_bounds?(x, y)
|
106
|
-
(@start_x..@end_x).include?(x)
|
106
|
+
(@start_x..@end_x).include?(x) && (@start_y..@end_y).include?(y)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
data/lib/shoes/swt/list_box.rb
CHANGED
@@ -21,14 +21,14 @@ class Shoes
|
|
21
21
|
::Swt::SWT::DROP_DOWN | ::Swt::SWT::READ_ONLY
|
22
22
|
)
|
23
23
|
@real.set_size dsl.element_width, dsl.element_height
|
24
|
-
@real.add_selection_listener do |
|
24
|
+
@real.add_selection_listener do |_event|
|
25
25
|
@dsl.call_change_listeners
|
26
26
|
end
|
27
|
-
update_items
|
27
|
+
update_items
|
28
28
|
end
|
29
29
|
|
30
|
-
def update_items
|
31
|
-
@real.items =
|
30
|
+
def update_items
|
31
|
+
@real.items = @dsl.items.map(&:to_s)
|
32
32
|
end
|
33
33
|
|
34
34
|
def text
|
@@ -3,19 +3,20 @@ class Shoes
|
|
3
3
|
class MouseMoveListener
|
4
4
|
include ::Swt::Events::MouseMoveListener
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize(app)
|
7
7
|
@app = app
|
8
8
|
end
|
9
9
|
|
10
10
|
def mouse_move(mouse_event)
|
11
11
|
@app.dsl.mouse_pos = [mouse_event.x, mouse_event.y]
|
12
|
-
@app.dsl.mouse_motion.each{|blk| eval_move_block blk, mouse_event}
|
12
|
+
@app.dsl.mouse_motion.each { |blk| eval_move_block blk, mouse_event }
|
13
13
|
mouse_shape_control mouse_event
|
14
14
|
mouse_leave_control mouse_event
|
15
15
|
mouse_hover_control mouse_event
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
|
+
|
19
20
|
def eval_move_block(blk, event)
|
20
21
|
blk.call event.x, event.y
|
21
22
|
end
|
@@ -26,12 +27,12 @@ class Shoes
|
|
26
27
|
else
|
27
28
|
::Swt::SWT::CURSOR_ARROW
|
28
29
|
end
|
29
|
-
@app.shell.setCursor
|
30
|
+
@app.shell.setCursor Shoes.display.getSystemCursor(cursor)
|
30
31
|
end
|
31
32
|
|
32
33
|
def mouse_leave_control(mouse_event)
|
33
34
|
@app.dsl.mouse_hover_controls.each do |element|
|
34
|
-
if !mouse_on?(element, mouse_event)
|
35
|
+
if !mouse_on?(element, mouse_event) && element.hovered?
|
35
36
|
element.mouse_left
|
36
37
|
end
|
37
38
|
end
|
@@ -39,7 +40,7 @@ class Shoes
|
|
39
40
|
|
40
41
|
def mouse_hover_control(mouse_event)
|
41
42
|
@app.dsl.mouse_hover_controls.each do |element|
|
42
|
-
if mouse_on?(element, mouse_event)
|
43
|
+
if mouse_on?(element, mouse_event) && !element.hovered?
|
43
44
|
element.mouse_hovered
|
44
45
|
end
|
45
46
|
end
|
data/lib/shoes/swt/oval.rb
CHANGED
@@ -11,7 +11,6 @@ class Shoes
|
|
11
11
|
|
12
12
|
attr_reader :dsl, :app, :transform, :painter, :container
|
13
13
|
|
14
|
-
|
15
14
|
# @param [Shoes::Oval] dsl the dsl object to provide gui for
|
16
15
|
# @param [Shoes::Swt::App] app the app
|
17
16
|
# @param [Hash] opts options
|
@@ -43,8 +42,8 @@ class Shoes
|
|
43
42
|
|
44
43
|
def draw(graphics_context)
|
45
44
|
sw = graphics_context.get_line_width
|
46
|
-
graphics_context.draw_oval(@obj.element_left+sw/2, @obj.element_top+sw/2,
|
47
|
-
@obj.element_width-sw, @obj.element_height-sw)
|
45
|
+
graphics_context.draw_oval(@obj.element_left + sw / 2, @obj.element_top + sw / 2,
|
46
|
+
@obj.element_width - sw, @obj.element_height - sw)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
class Packager
|
4
|
+
def initialize(dsl)
|
5
|
+
@dsl = dsl
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_package(program_name, package)
|
9
|
+
unless package =~ /^(swt):(app|jar)$/
|
10
|
+
abort("#{program_name}: Can't package as '#{package}'. See '#{program_name} --help'")
|
11
|
+
end
|
12
|
+
package.split(':')
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(path)
|
16
|
+
begin
|
17
|
+
require 'shoes/package/configuration'
|
18
|
+
require 'shoes/package/jar'
|
19
|
+
require 'shoes/package/jar_app'
|
20
|
+
master_config = ::Shoes::Package::Configuration.load(path)
|
21
|
+
rescue Errno::ENOENT => e
|
22
|
+
abort "shoes: #{e.message}"
|
23
|
+
end
|
24
|
+
|
25
|
+
@dsl.packages.each do |backend, wrapper|
|
26
|
+
puts "Packaging #{backend}:#{wrapper}..."
|
27
|
+
config = create_config(master_config, backend)
|
28
|
+
packager = create_packager(config, wrapper)
|
29
|
+
packager.package
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def help(program_name)
|
34
|
+
<<-EOS
|
35
|
+
|
36
|
+
Package types:
|
37
|
+
#{package_types}
|
38
|
+
Examples:
|
39
|
+
#{examples(program_name)}
|
40
|
+
EOS
|
41
|
+
end
|
42
|
+
|
43
|
+
def package_types()
|
44
|
+
<<-EOS
|
45
|
+
swt:app A standalone OS X executable with the Swt backend
|
46
|
+
swt:jar An executable JAR with the Swt backend
|
47
|
+
EOS
|
48
|
+
end
|
49
|
+
|
50
|
+
def examples(program_name)
|
51
|
+
<<-EOS
|
52
|
+
To run a Shoes app:
|
53
|
+
#{program_name} path/to/shoes-app.rb
|
54
|
+
|
55
|
+
Two ways to package a Shoes app as an APP and a JAR, using the Swt backend:
|
56
|
+
#{program_name} -p swt:app -p swt:jar path/to/app.yaml
|
57
|
+
#{program_name} -p swt:app -p swt:jar path/to/shoes-app.rb
|
58
|
+
EOS
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
# Copy the master config (including singleton class), since we may be
|
63
|
+
# packaging for more than one backend
|
64
|
+
def create_config(master_config, backend)
|
65
|
+
config = master_config.clone
|
66
|
+
config.gems << "shoes-#{backend}"
|
67
|
+
config
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_packager(config, wrapper)
|
71
|
+
case wrapper
|
72
|
+
when 'jar'
|
73
|
+
::Furoshiki::Jar.new(config)
|
74
|
+
when 'app'
|
75
|
+
::Furoshiki::JarApp.new(config)
|
76
|
+
else
|
77
|
+
abort "shoes: Don't know how to make #{backend}:#{wrapper} packages"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|