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/arc.rb
CHANGED
@@ -35,14 +35,14 @@ class Shoes
|
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
|
+
|
38
39
|
def radians_to_degrees(radians)
|
39
40
|
radians * 180 / ::Shoes::PI
|
40
41
|
end
|
41
42
|
|
42
|
-
public
|
43
43
|
class Painter < Common::Painter
|
44
44
|
def fill(graphics_context)
|
45
|
-
if
|
45
|
+
if @obj.wedge?
|
46
46
|
graphics_context.fill_arc(@obj.element_left, @obj.element_top,
|
47
47
|
@obj.element_width, @obj.element_height,
|
48
48
|
@obj.angle1, @obj.angle2 * -1)
|
@@ -57,11 +57,11 @@ class Shoes
|
|
57
57
|
|
58
58
|
def draw(graphics_context)
|
59
59
|
sw = graphics_context.get_line_width
|
60
|
-
if
|
61
|
-
graphics_context.draw_arc(@obj.element_left+sw/2,
|
62
|
-
@obj.element_top+sw/2,
|
63
|
-
@obj.element_width-sw,
|
64
|
-
@obj.element_height-sw,
|
60
|
+
if @obj.element_left && @obj.element_top && @obj.element_width && @obj.element_height
|
61
|
+
graphics_context.draw_arc(@obj.element_left + sw / 2,
|
62
|
+
@obj.element_top + sw / 2,
|
63
|
+
@obj.element_width - sw,
|
64
|
+
@obj.element_height - sw,
|
65
65
|
@obj.angle1, @obj.angle2 * -1)
|
66
66
|
end
|
67
67
|
end
|
data/lib/shoes/swt/background.rb
CHANGED
data/lib/shoes/swt/border.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
# This class is intended as the single click listener held onto by the app.
|
4
|
+
# That lets us control dispatch of events to our DSL objects however we
|
5
|
+
# please, instead of relying on whatever SWT thinks is right. See #882.
|
6
|
+
class ClickListener
|
7
|
+
include ::Swt::Widgets::Listener
|
8
|
+
|
9
|
+
attr_reader :clickable_elements
|
10
|
+
|
11
|
+
def initialize(swt_app)
|
12
|
+
@clickable_elements = []
|
13
|
+
@clicks = {}
|
14
|
+
@releases = {}
|
15
|
+
swt_app.add_listener ::Swt::SWT::MouseDown, self
|
16
|
+
swt_app.add_listener ::Swt::SWT::MouseUp, self
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_click_listener(dsl, block)
|
20
|
+
add_clickable_element(dsl)
|
21
|
+
@clicks[dsl] = block
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_release_listener(dsl, block)
|
25
|
+
add_clickable_element(dsl)
|
26
|
+
@releases[dsl] = block
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_listeners_for(dsl)
|
30
|
+
@clickable_elements.delete(dsl)
|
31
|
+
@clicks.delete(dsl)
|
32
|
+
@releases.delete(dsl)
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_clickable_element(dsl)
|
36
|
+
@clickable_elements << dsl unless @clickable_elements.include?(dsl)
|
37
|
+
end
|
38
|
+
|
39
|
+
def handle_event(event)
|
40
|
+
handlers = case event.type
|
41
|
+
when ::Swt::SWT::MouseDown then @clicks
|
42
|
+
when ::Swt::SWT::MouseUp then @releases
|
43
|
+
else nil
|
44
|
+
end
|
45
|
+
return if handlers.nil? || handlers.empty?
|
46
|
+
|
47
|
+
handlers = handlers.to_a.
|
48
|
+
select { |dsl, _| !dsl.hidden? }.
|
49
|
+
select { |dsl, _| dsl.in_bounds?(event.x, event.y) }
|
50
|
+
|
51
|
+
# Take the last handler as an approximation of the "top-most" element
|
52
|
+
# since we don't have a true z-index. For layouts that aren't too
|
53
|
+
# dynamic this is sufficient to give the behavior we want.
|
54
|
+
dsl, block = handlers.last
|
55
|
+
|
56
|
+
eval_block(event, dsl, block)
|
57
|
+
end
|
58
|
+
|
59
|
+
def eval_block(event, dsl, block)
|
60
|
+
return if block.nil?
|
61
|
+
|
62
|
+
if dsl.pass_coordinates?
|
63
|
+
block.call event.button, event.x, event.y
|
64
|
+
else
|
65
|
+
block.call(dsl)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/shoes/swt/color.rb
CHANGED
@@ -27,13 +27,13 @@ class Shoes
|
|
27
27
|
# @param [Swt::Graphics::GC] gc the graphics context on which to apply fill
|
28
28
|
# @note left, top, width, height, and angle are not used in this method, and only
|
29
29
|
# exist to satisfy the Pattern interface
|
30
|
-
def apply_as_fill(gc,
|
30
|
+
def apply_as_fill(gc, _left = nil, _top = nil, _width = nil, _height = nil, _angle = nil)
|
31
31
|
gc.set_background real
|
32
32
|
gc.set_alpha alpha
|
33
33
|
end
|
34
34
|
|
35
35
|
# @param [Swt::Graphics::GC] gc the graphics context on which to apply stroke
|
36
|
-
def apply_as_stroke(gc,
|
36
|
+
def apply_as_stroke(gc, _left = nil, _top = nil, _width = nil, _height = nil, _angle = nil)
|
37
37
|
gc.set_foreground real
|
38
38
|
gc.set_alpha alpha
|
39
39
|
end
|
@@ -41,9 +41,9 @@ class Shoes
|
|
41
41
|
|
42
42
|
class NullColor
|
43
43
|
attr_reader :alpha, :dsl, :real
|
44
|
-
def apply_as_fill(
|
45
|
-
|
44
|
+
def apply_as_fill(_gc); end
|
45
|
+
|
46
|
+
def apply_as_stroke(_gc); end
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
49
|
-
|
@@ -2,66 +2,15 @@ class Shoes
|
|
2
2
|
module Swt
|
3
3
|
module Common
|
4
4
|
module Clickable
|
5
|
-
|
6
5
|
attr_accessor :click_listener
|
7
6
|
|
8
|
-
# object = self is there for compatibility reasons for now
|
9
|
-
# it's for link (defined in text.rb) and the listener is added in the
|
10
|
-
# swt/text_block.rb ... moving it around would be too hard now
|
11
|
-
def clickable(object = self, block)
|
12
|
-
add_listener_for object, ::Swt::SWT::MouseDown, block
|
13
|
-
end
|
14
|
-
|
15
7
|
def click(block)
|
16
|
-
|
17
|
-
add_listener_for ::Swt::SWT::MouseDown, block
|
8
|
+
app.click_listener.add_click_listener(dsl, block)
|
18
9
|
end
|
19
10
|
|
20
11
|
def release(block)
|
21
|
-
|
22
|
-
add_listener_for ::Swt::SWT::MouseUp, block
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
def add_listener_for(swt_object = self, event, block)
|
27
|
-
# dsl objects take care of in bounds checking etc.
|
28
|
-
dsl_object = swt_object.dsl
|
29
|
-
listener = ClickListener.new(dsl_object, block)
|
30
|
-
swt_object.click_listener = listener
|
31
|
-
app.add_clickable_element dsl_object
|
32
|
-
app.add_listener event, listener
|
33
|
-
end
|
34
|
-
|
35
|
-
def remove_listener_for(swt_object = self, event)
|
36
|
-
dsl_object = swt_object.dsl
|
37
|
-
app.clickable_elements.delete(dsl_object)
|
38
|
-
app.remove_listener event, swt_object.click_listener
|
12
|
+
app.click_listener.add_release_listener(dsl, block)
|
39
13
|
end
|
40
|
-
|
41
|
-
class ClickListener
|
42
|
-
include ::Swt::Widgets::Listener
|
43
|
-
|
44
|
-
def initialize(clickable_object, block)
|
45
|
-
@clickable_object = clickable_object
|
46
|
-
@block = block
|
47
|
-
end
|
48
|
-
|
49
|
-
def handleEvent(mouse_event)
|
50
|
-
return if @clickable_object.respond_to?(:hidden?) && @clickable_object.hidden?
|
51
|
-
if @clickable_object.in_bounds?(mouse_event.x, mouse_event.y)
|
52
|
-
eval_block mouse_event
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def eval_block(mouse_event)
|
57
|
-
if @clickable_object.pass_coordinates?
|
58
|
-
@block.call mouse_event.button, mouse_event.x, mouse_event.y
|
59
|
-
else
|
60
|
-
@block.call @clickable_object
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
14
|
end
|
66
15
|
end
|
67
16
|
end
|
@@ -27,7 +27,7 @@ class Shoes
|
|
27
27
|
|
28
28
|
def apply_fill(context)
|
29
29
|
if fill
|
30
|
-
left, top = self.is_a?(Star) ? [element_left - element_width/2.0, element_top - element_height/2.0] : [element_left, element_top]
|
30
|
+
left, top = self.is_a?(Star) ? [element_left - element_width / 2.0, element_top - element_height / 2.0] : [element_left, element_top]
|
31
31
|
fill.apply_as_fill(context, left, top, element_width, element_height, angle)
|
32
32
|
true
|
33
33
|
end
|
@@ -37,8 +37,8 @@ class Shoes
|
|
37
37
|
case obj
|
38
38
|
when ::Shoes::Oval, ::Shoes::Rect
|
39
39
|
set_rotate graphics_context, obj.rotate,
|
40
|
-
obj.element_left + obj.element_width/2.0,
|
41
|
-
obj.element_top + obj.element_height/2.0 do
|
40
|
+
obj.element_left + obj.element_width / 2.0,
|
41
|
+
obj.element_top + obj.element_height / 2.0 do
|
42
42
|
fill graphics_context if fill_setup(graphics_context)
|
43
43
|
draw graphics_context if draw_setup(graphics_context)
|
44
44
|
end
|
@@ -54,7 +54,7 @@ class Shoes
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# Implement in subclass
|
57
|
-
def fill(
|
57
|
+
def fill(_graphics_context)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Override in subclass and return something falsy if not using draw
|
@@ -63,10 +63,10 @@ class Shoes
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Implement in subclass
|
66
|
-
def draw(
|
66
|
+
def draw(_graphics_context)
|
67
67
|
end
|
68
68
|
|
69
|
-
def set_rotate
|
69
|
+
def set_rotate(graphics_context, angle, left, top)
|
70
70
|
angle, left, top = angle.to_i, left.to_i, top.to_i
|
71
71
|
if block_given?
|
72
72
|
begin
|
@@ -80,10 +80,10 @@ class Shoes
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
def reset_rotate
|
83
|
+
def reset_rotate(transform, graphics_context, angle, left, top)
|
84
84
|
transform.translate left, top
|
85
85
|
transform.rotate angle
|
86
|
-
transform.translate
|
86
|
+
transform.translate(-left, -top)
|
87
87
|
graphics_context.setTransform transform
|
88
88
|
end
|
89
89
|
end
|
@@ -2,11 +2,11 @@ class Shoes
|
|
2
2
|
module Swt
|
3
3
|
module Common
|
4
4
|
module PainterUpdatesPosition
|
5
|
-
# No-op. This object manages its own position with its own painter. The
|
5
|
+
# No-op. This object manages its own position with its own painter. The
|
6
6
|
# painter is triggered automatically in the event loop.
|
7
7
|
def update_position
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
@@ -19,10 +19,9 @@ class Shoes
|
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
|
+
|
22
23
|
def remove_click_listeners
|
23
|
-
app.
|
24
|
-
app.remove_listener ::Swt::SWT::MouseUp, @click_listener
|
25
|
-
app.clickable_elements.delete self.dsl
|
24
|
+
app.click_listener.remove_listeners_for(dsl)
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Swt
|
3
|
-
class SelectionListener
|
4
|
-
|
5
|
-
|
6
|
-
@
|
7
|
-
|
8
|
-
|
9
|
-
def widget_selected
|
10
|
-
@blk.call @radio, event
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
class Shoes
|
2
|
+
module Swt
|
3
|
+
class SelectionListener
|
4
|
+
def initialize(radio, &blk)
|
5
|
+
@radio = radio
|
6
|
+
@blk = blk
|
7
|
+
end
|
8
|
+
|
9
|
+
def widget_selected(event)
|
10
|
+
@blk.call @radio, event
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -27,10 +27,9 @@ class Shoes
|
|
27
27
|
dsl.strokewidth
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
30
|
def apply_stroke(context)
|
32
31
|
if stroke
|
33
|
-
l, t = self.is_a?(Star) ? [element_left - element_width/2.0, element_top - element_height/2.0] : [element_left, element_top]
|
32
|
+
l, t = self.is_a?(Star) ? [element_left - element_width / 2.0, element_top - element_height / 2.0] : [element_left, element_top]
|
34
33
|
stroke.apply_as_stroke(context, l, t, element_width, element_height, angle)
|
35
34
|
context.set_line_width strokewidth
|
36
35
|
true
|
data/lib/shoes/swt/dialog.rb
CHANGED
@@ -15,7 +15,7 @@ class Shoes
|
|
15
15
|
confirmed? answer_id
|
16
16
|
end
|
17
17
|
|
18
|
-
def dialog_chooser
|
18
|
+
def dialog_chooser(title, folder = false)
|
19
19
|
style = ::Swt::SWT::OPEN
|
20
20
|
shell = ::Swt::Widgets::Shell.new Shoes.display
|
21
21
|
fd = folder ? ::Swt::Widgets::DirectoryDialog.new(shell, style) : ::Swt::Widgets::FileDialog.new(shell, style)
|
@@ -23,11 +23,7 @@ class Shoes
|
|
23
23
|
fd.open
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
Swt::AskDialog.new(::Swt::Widgets::Shell.new, msg, args).open
|
28
|
-
end
|
29
|
-
|
30
|
-
def ask_color title
|
26
|
+
def ask_color(title)
|
31
27
|
shell = ::Swt::Widgets::Shell.new Shoes.display
|
32
28
|
cd = ::Swt::Widgets::ColorDialog.new shell
|
33
29
|
cd.setText title
|
@@ -36,6 +32,7 @@ class Shoes
|
|
36
32
|
end
|
37
33
|
|
38
34
|
private
|
35
|
+
|
39
36
|
def open_message_box(style, msg)
|
40
37
|
shell = ::Swt::Widgets::Shell.new ::Swt.display
|
41
38
|
@message_box = ::Swt::Widgets::MessageBox.new shell, style
|
@@ -47,44 +44,5 @@ class Shoes
|
|
47
44
|
answer_id == SWT::YES
|
48
45
|
end
|
49
46
|
end
|
50
|
-
|
51
|
-
class AskDialog < ::Swt::Widgets::Dialog
|
52
|
-
def initialize shell, msg, args
|
53
|
-
@shell, @msg, @args= shell, msg, args
|
54
|
-
super shell
|
55
|
-
end
|
56
|
-
|
57
|
-
def open
|
58
|
-
display = getParent.getDisplay
|
59
|
-
icon = ::Swt::Graphics::Image.new display, ::Shoes::Swt::ICON
|
60
|
-
@shell.setImage icon
|
61
|
-
@shell.setSize 300, 125
|
62
|
-
@shell.setText 'Shoes 4 asks:'
|
63
|
-
label = ::Swt::Widgets::Label.new @shell, ::Swt::SWT::NONE
|
64
|
-
label.setText @msg
|
65
|
-
label.setLocation 10, 10
|
66
|
-
label.pack
|
67
|
-
styles = @args[:secret] ? ::Swt::SWT::BORDER | ::Swt::SWT::SINGLE | ::Swt::SWT::PASSWORD : ::Swt::SWT::BORDER | ::Swt::SWT::SINGLE
|
68
|
-
text = ::Swt::Widgets::Text.new @shell, styles
|
69
|
-
text.setLocation 10, 30
|
70
|
-
text.setSize 270, 20
|
71
|
-
b = ::Swt::Widgets::Button.new @shell, ::Swt::SWT::NULL
|
72
|
-
b.setText 'OK'
|
73
|
-
b.setLocation 180, 55
|
74
|
-
b.pack
|
75
|
-
b.addSelectionListener{|e| @ret = text.getText; @shell.close}
|
76
|
-
b = ::Swt::Widgets::Button.new @shell, ::Swt::SWT::NULL
|
77
|
-
b.setText 'CANCEL'
|
78
|
-
b.setLocation 222, 55
|
79
|
-
b.pack
|
80
|
-
b.addSelectionListener{|e| @ret = nil; @shell.close}
|
81
|
-
@shell.open
|
82
|
-
while !@shell.isDisposed do
|
83
|
-
display.sleep unless display.readAndDispatch
|
84
|
-
end
|
85
|
-
icon.dispose
|
86
|
-
@ret
|
87
|
-
end
|
88
|
-
end
|
89
47
|
end
|
90
48
|
end
|