shoes-swt 4.0.0.pre12 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/shoes-swt +1 -0
- data/lib/shoes/swt.rb +3 -1
- data/lib/shoes/swt/animation.rb +1 -0
- data/lib/shoes/swt/app.rb +12 -11
- data/lib/shoes/swt/arc.rb +1 -0
- data/lib/shoes/swt/arc_painter.rb +4 -3
- data/lib/shoes/swt/arrow.rb +1 -0
- data/lib/shoes/swt/arrow_painter.rb +10 -5
- data/lib/shoes/swt/background.rb +1 -0
- data/lib/shoes/swt/border.rb +1 -0
- data/lib/shoes/swt/button.rb +1 -0
- data/lib/shoes/swt/check.rb +1 -0
- data/lib/shoes/swt/check_button.rb +1 -0
- data/lib/shoes/swt/click_listener.rb +1 -0
- data/lib/shoes/swt/color.rb +1 -0
- data/lib/shoes/swt/color_factory.rb +1 -0
- data/lib/shoes/swt/common/clickable.rb +1 -0
- data/lib/shoes/swt/common/container.rb +1 -0
- data/lib/shoes/swt/common/fill.rb +2 -1
- data/lib/shoes/swt/common/focus.rb +5 -0
- data/lib/shoes/swt/common/image_handling.rb +11 -5
- data/lib/shoes/swt/common/painter.rb +21 -1
- data/lib/shoes/swt/common/painter_updates_position.rb +1 -0
- data/lib/shoes/swt/common/remove.rb +16 -3
- data/lib/shoes/swt/common/resource.rb +1 -0
- data/lib/shoes/swt/common/selection_listener.rb +1 -0
- data/lib/shoes/swt/common/stroke.rb +1 -0
- data/lib/shoes/swt/common/translate.rb +1 -0
- data/lib/shoes/swt/common/update_position.rb +1 -0
- data/lib/shoes/swt/common/visibility.rb +7 -2
- data/lib/shoes/swt/dialog.rb +1 -0
- data/lib/shoes/swt/disposed_protection.rb +1 -0
- data/lib/shoes/swt/download.rb +1 -0
- data/lib/shoes/swt/font.rb +1 -0
- data/lib/shoes/swt/generate_backend.rb +10 -10
- data/lib/shoes/swt/gradient.rb +24 -6
- data/lib/shoes/swt/image.rb +6 -10
- data/lib/shoes/swt/image_painter.rb +26 -0
- data/lib/shoes/swt/image_pattern.rb +1 -0
- data/lib/shoes/swt/input_box.rb +1 -0
- data/lib/shoes/swt/key_listener.rb +6 -5
- data/lib/shoes/swt/line.rb +1 -0
- data/lib/shoes/swt/line_painter.rb +3 -2
- data/lib/shoes/swt/link.rb +1 -0
- data/lib/shoes/swt/link_segment.rb +1 -0
- data/lib/shoes/swt/list_box.rb +1 -0
- data/lib/shoes/swt/mouse_move_listener.rb +1 -0
- data/lib/shoes/swt/oval.rb +1 -0
- data/lib/shoes/swt/oval_painter.rb +4 -3
- data/lib/shoes/swt/packager.rb +1 -0
- data/lib/shoes/swt/progress.rb +1 -0
- data/lib/shoes/swt/radio.rb +4 -3
- data/lib/shoes/swt/radio_group.rb +1 -0
- data/lib/shoes/swt/rect.rb +1 -2
- data/lib/shoes/swt/rect_painter.rb +3 -2
- data/lib/shoes/swt/redrawing_aspect.rb +16 -12
- data/lib/shoes/swt/shape.rb +5 -3
- data/lib/shoes/swt/shape_painter.rb +12 -0
- data/lib/shoes/swt/shoes_layout.rb +1 -0
- data/lib/shoes/swt/slot.rb +24 -13
- data/lib/shoes/swt/sound.rb +1 -1
- data/lib/shoes/swt/star.rb +1 -0
- data/lib/shoes/swt/star_painter.rb +2 -1
- data/lib/shoes/swt/swt_button.rb +1 -0
- data/lib/shoes/swt/text_block.rb +1 -0
- data/lib/shoes/swt/text_block/centered_text_segment.rb +1 -0
- data/lib/shoes/swt/text_block/cursor_painter.rb +1 -0
- data/lib/shoes/swt/text_block/fitter.rb +1 -0
- data/lib/shoes/swt/text_block/painter.rb +1 -0
- data/lib/shoes/swt/text_block/text_font_factory.rb +2 -0
- data/lib/shoes/swt/text_block/text_segment.rb +1 -0
- data/lib/shoes/swt/text_block/text_segment_collection.rb +1 -0
- data/lib/shoes/swt/text_block/text_style_factory.rb +1 -0
- data/lib/shoes/swt/timer.rb +1 -0
- data/lib/shoes/swt/tooling/leak_hunter.rb +1 -0
- data/lib/shoes/swt/version.rb +1 -1
- metadata +7 -6
@@ -1,11 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
module Common
|
5
6
|
module Visibility
|
6
7
|
def update_visibility
|
7
|
-
if @real && @real.respond_to?(:set_visible)
|
8
|
-
|
8
|
+
if defined?(@real) && @real.respond_to?(:set_visible)
|
9
|
+
# hidden_from_view? handles all visiblity conditions, including
|
10
|
+
# being outside a slot. SWT as backend doesn't get that for free
|
11
|
+
# because we can't use Composites as they lack transparency...
|
12
|
+
visible = !@dsl.hidden_from_view?
|
13
|
+
@real.set_visible(visible)
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
data/lib/shoes/swt/dialog.rb
CHANGED
data/lib/shoes/swt/download.rb
CHANGED
data/lib/shoes/swt/font.rb
CHANGED
@@ -7,21 +7,21 @@ class Shoes
|
|
7
7
|
class << self
|
8
8
|
def validate
|
9
9
|
if RUBY_ENGINE != "jruby"
|
10
|
-
puts
|
10
|
+
puts <<~EOS
|
11
11
|
|
12
|
-
*******************************************************************************
|
13
|
-
The shoes-swt backend requires a 9.X version of JRuby.
|
12
|
+
*******************************************************************************
|
13
|
+
The shoes-swt backend requires a 9.X version of JRuby.
|
14
14
|
|
15
|
-
You are running the following Ruby instead:
|
15
|
+
You are running the following Ruby instead:
|
16
16
|
|
17
|
-
|
17
|
+
#{RUBY_DESCRIPTION}
|
18
18
|
|
19
|
-
Please download JRuby from http://jruby.org (or your favorite Ruby version
|
20
|
-
manager), then check our https://github.com/shoes/shoes4#installing-shoes-4 to
|
21
|
-
get Shoes installed.
|
19
|
+
Please download JRuby from http://jruby.org (or your favorite Ruby version
|
20
|
+
manager), then check our https://github.com/shoes/shoes4#installing-shoes-4 to
|
21
|
+
get Shoes installed.
|
22
22
|
|
23
|
-
Sorry for the inconvenience!
|
24
|
-
*******************************************************************************
|
23
|
+
Sorry for the inconvenience!
|
24
|
+
*******************************************************************************
|
25
25
|
|
26
26
|
EOS
|
27
27
|
exit 1
|
data/lib/shoes/swt/gradient.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Gradients are a little confusing, but don't let all the math below scare you.
|
4
|
+
# Here's the (relatively) simple explanation of what's going on.
|
5
|
+
#
|
6
|
+
# ::SWT::Pattern, the underlying class we use, defines a gradient by a starting
|
7
|
+
# and ending point. We account the angle into it by changing these points.
|
8
|
+
#
|
9
|
+
# To look right, the start/end points must be outside our shape! If not, then
|
10
|
+
# we get a hard line where the color resets without fading, which looks bad.
|
11
|
+
# Given that, we must keep those points outside our bounds of the element,
|
12
|
+
# which are reported via the redraw_left, redraw_top, etc. methods.
|
13
|
+
|
2
14
|
class Shoes
|
3
15
|
module Swt
|
4
16
|
class Gradient
|
@@ -7,6 +19,8 @@ class Shoes
|
|
7
19
|
def initialize(dsl)
|
8
20
|
@dsl = dsl
|
9
21
|
@patterns = []
|
22
|
+
@color1 = nil
|
23
|
+
@color2 = nil
|
10
24
|
end
|
11
25
|
|
12
26
|
def dispose
|
@@ -42,12 +56,16 @@ class Shoes
|
|
42
56
|
|
43
57
|
private
|
44
58
|
|
45
|
-
def create_pattern(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
59
|
+
def create_pattern(gui)
|
60
|
+
dsl = gui.dsl
|
61
|
+
width = dsl.redraw_width * 0.5
|
62
|
+
height = dsl.redraw_height * 0.5
|
63
|
+
angle = normalize_angle(-(dsl.angle || 0))
|
64
|
+
left, top, width, height = determine_args_based_on_angle(angle,
|
65
|
+
dsl.redraw_left,
|
66
|
+
dsl.redraw_top,
|
67
|
+
width,
|
68
|
+
height)
|
51
69
|
|
52
70
|
pattern = ::Swt::Pattern.new Shoes.display, left, top, width, height,
|
53
71
|
color1.real, color2.real
|
data/lib/shoes/swt/image.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'fileutils'
|
3
4
|
|
4
5
|
class Shoes
|
@@ -14,13 +15,16 @@ class Shoes
|
|
14
15
|
include Common::ImageHandling
|
15
16
|
include ::Shoes::BackendDimensionsDelegations
|
16
17
|
|
17
|
-
attr_reader :app, :real, :dsl, :painter
|
18
|
+
attr_reader :app, :real, :dsl, :painter, :full_width, :full_height
|
18
19
|
|
19
20
|
def initialize(dsl, app)
|
20
21
|
@dsl = dsl
|
21
22
|
@app = app
|
23
|
+
@tmpname_or_data = nil
|
22
24
|
update_image
|
23
|
-
|
25
|
+
|
26
|
+
@painter = ImagePainter.new(self)
|
27
|
+
app.add_paint_listener(@painter)
|
24
28
|
end
|
25
29
|
|
26
30
|
def update_image
|
@@ -116,14 +120,6 @@ class Shoes
|
|
116
120
|
end
|
117
121
|
data
|
118
122
|
end
|
119
|
-
|
120
|
-
def add_paint_listener
|
121
|
-
@painter = lambda do |event|
|
122
|
-
graphics_context = event.gc
|
123
|
-
graphics_context.drawImage @real, 0, 0, @full_width, @full_height, dsl.element_left, dsl.element_top, dsl.element_width, dsl.element_height unless @dsl.hidden
|
124
|
-
end
|
125
|
-
app.add_paint_listener(@painter)
|
126
|
-
end
|
127
123
|
end
|
128
124
|
end
|
129
125
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
module Swt
|
5
|
+
class ImagePainter
|
6
|
+
include Common::Resource
|
7
|
+
|
8
|
+
def initialize(image)
|
9
|
+
@image = image
|
10
|
+
@dsl = image.dsl
|
11
|
+
end
|
12
|
+
|
13
|
+
def paint_control(event)
|
14
|
+
return if @dsl.hidden
|
15
|
+
|
16
|
+
graphics_context = event.gc
|
17
|
+
clip_context_to(graphics_context, @dsl.parent) do
|
18
|
+
graphics_context.drawImage(@image.real, 0, 0,
|
19
|
+
@image.full_width, @image.full_height,
|
20
|
+
@dsl.element_left, @dsl.element_top,
|
21
|
+
@dsl.element_width, @dsl.element_height)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/shoes/swt/input_box.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
class KeyListener
|
@@ -9,13 +10,13 @@ class Shoes
|
|
9
10
|
end
|
10
11
|
|
11
12
|
SPECIAL_KEY_NAMES = Hash[
|
12
|
-
%w
|
13
|
-
F13 F14 F15
|
13
|
+
%w[TAB PAGE_UP PAGE_DOWN HOME END F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12
|
14
|
+
F13 F14 F15].map do |key|
|
14
15
|
[get_swt_constant(key), key.downcase]
|
15
16
|
end
|
16
17
|
]
|
17
18
|
|
18
|
-
%w
|
19
|
+
%w[UP DOWN LEFT RIGHT].each do |key|
|
19
20
|
SPECIAL_KEY_NAMES[get_swt_constant "ARROW_#{key}"] = key.downcase
|
20
21
|
end
|
21
22
|
|
@@ -26,7 +27,7 @@ class Shoes
|
|
26
27
|
|
27
28
|
SPECIAL_KEY_NAMES.freeze
|
28
29
|
|
29
|
-
MODIFIER_KEYS = %w
|
30
|
+
MODIFIER_KEYS = %w[CTRL SHIFT ALT CAPS_LOCK COMMAND].map do |key|
|
30
31
|
get_swt_constant key
|
31
32
|
end
|
32
33
|
|
@@ -49,7 +50,7 @@ class Shoes
|
|
49
50
|
end
|
50
51
|
|
51
52
|
BUTTON_EXCLUDES = ["\n", " "].freeze
|
52
|
-
COMBO_EXCLUDES = %w
|
53
|
+
COMBO_EXCLUDES = %w[up down] + BUTTON_EXCLUDES
|
53
54
|
|
54
55
|
# For a variety of SWT controls, certain characters should not be passed
|
55
56
|
# to Shoes key listeners, since they're already handled by the controls.
|
data/lib/shoes/swt/line.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
class LinePainter < Common::Painter
|
5
6
|
def draw(gc)
|
6
7
|
gc.draw_line(@obj.translate_left + @obj.element_left,
|
7
|
-
@obj.translate_top +
|
8
|
+
@obj.translate_top + drawing_top,
|
8
9
|
@obj.translate_left + @obj.element_right + 1,
|
9
|
-
@obj.translate_top +
|
10
|
+
@obj.translate_top + drawing_bottom + 1)
|
10
11
|
end
|
11
12
|
|
12
13
|
# Don't do fill setup
|
data/lib/shoes/swt/link.rb
CHANGED
data/lib/shoes/swt/list_box.rb
CHANGED
data/lib/shoes/swt/oval.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
class OvalPainter < Common::Painter
|
5
6
|
def clipping
|
6
7
|
clipping = ::Swt::Path.new(Shoes.display)
|
7
|
-
clipping.add_arc(@obj.element_left,
|
8
|
+
clipping.add_arc(@obj.element_left, drawing_top,
|
8
9
|
@obj.element_width, @obj.element_height, 0, 360)
|
9
10
|
clipping
|
10
11
|
end
|
11
12
|
|
12
13
|
def fill(graphics_context)
|
13
14
|
graphics_context.fill_oval(@obj.translate_left + @obj.element_left,
|
14
|
-
@obj.translate_top +
|
15
|
+
@obj.translate_top + drawing_top,
|
15
16
|
@obj.element_width,
|
16
17
|
@obj.element_height)
|
17
18
|
end
|
@@ -19,7 +20,7 @@ class Shoes
|
|
19
20
|
def draw(graphics_context)
|
20
21
|
sw = graphics_context.get_line_width
|
21
22
|
graphics_context.draw_oval(@obj.translate_left + @obj.element_left + sw / 2,
|
22
|
-
@obj.translate_top +
|
23
|
+
@obj.translate_top + drawing_top + sw / 2,
|
23
24
|
@obj.element_width - sw,
|
24
25
|
@obj.element_height - sw)
|
25
26
|
end
|
data/lib/shoes/swt/packager.rb
CHANGED
data/lib/shoes/swt/progress.rb
CHANGED
data/lib/shoes/swt/radio.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
# In Swt a radio button is actually just a
|
5
6
|
# button, so a lot of these methods are
|
6
7
|
# borrowed from button.rb
|
7
8
|
class Radio < CheckButton
|
8
|
-
|
9
|
+
attr_reader :group
|
9
10
|
|
10
11
|
# Create a radio button
|
11
12
|
#
|
@@ -19,9 +20,9 @@ class Shoes
|
|
19
20
|
|
20
21
|
def group=(value)
|
21
22
|
group_lookup = RadioGroup.group_lookup
|
22
|
-
group_lookup[
|
23
|
+
group_lookup[group].remove(self) unless group.nil?
|
23
24
|
@group = value || RadioGroup::DEFAULT_RADIO_GROUP
|
24
|
-
group_lookup[
|
25
|
+
group_lookup[group].add self
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
data/lib/shoes/swt/rect.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
class Rect
|
@@ -12,8 +13,6 @@ class Shoes
|
|
12
13
|
include Common::Translate
|
13
14
|
include ::Shoes::BackendDimensionsDelegations
|
14
15
|
|
15
|
-
def_delegators :dsl, :angle
|
16
|
-
|
17
16
|
attr_reader :dsl, :app, :transform, :painter
|
18
17
|
|
19
18
|
def initialize(dsl, app)
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
class Shoes
|
3
4
|
module Swt
|
4
5
|
class RectPainter < Common::Painter
|
5
6
|
def fill(gc)
|
6
7
|
gc.fill_round_rectangle(@obj.translate_left + @obj.element_left + inset,
|
7
|
-
@obj.translate_top +
|
8
|
+
@obj.translate_top + drawing_top + inset,
|
8
9
|
@obj.element_width - inset * 2,
|
9
10
|
@obj.element_height - inset * 2,
|
10
11
|
@obj.corners * 2,
|
@@ -14,7 +15,7 @@ class Shoes
|
|
14
15
|
def draw(gc)
|
15
16
|
stroke_width = gc.get_line_width
|
16
17
|
gc.draw_round_rectangle(@obj.translate_left + @obj.element_left + stroke_width / 2,
|
17
|
-
@obj.translate_top +
|
18
|
+
@obj.translate_top + drawing_top + stroke_width / 2,
|
18
19
|
@obj.element_width - stroke_width,
|
19
20
|
@obj.element_height - stroke_width,
|
20
21
|
@obj.corners * 2, @obj.corners * 2)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# This file uses the after_do gem, which you probably haven't heard of (yet)
|
3
4
|
# It basically works like Class.after :method do ... end
|
4
5
|
# So for every instance of Class, after method is executed the block you
|
@@ -22,18 +23,21 @@ class Shoes
|
|
22
23
|
MouseMoveListener => [:eval_move_block],
|
23
24
|
TextBlock::CursorPainter => [:move_textcursor],
|
24
25
|
Timer => [:eval_block],
|
25
|
-
|
26
|
+
Slot => [:update_scroll],
|
27
|
+
::Shoes::Common::Changeable => [:call_change_listeners],
|
26
28
|
}.freeze
|
27
29
|
|
28
30
|
# These need to trigger a redraw
|
29
|
-
SAME_POSITION
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
SAME_POSITION =
|
32
|
+
{
|
33
|
+
Common::Visibility => [:update_visibility],
|
34
|
+
Image => [:create_image],
|
35
|
+
::Shoes::Common::Hover => [:eval_hover_block],
|
36
|
+
::Shoes::Common::Style => [:update_style],
|
37
|
+
::Shoes::Common::Remove => [:remove],
|
38
|
+
::Shoes::Slot => [:mouse_hovered, :mouse_left],
|
39
|
+
::Shoes::TextBlock => [:replace],
|
40
|
+
}.freeze
|
37
41
|
|
38
42
|
CHANGED_POSITION = { ::Shoes::DimensionsDelegations => [:adjust_current_position],
|
39
43
|
::Shoes::Common::Positioning => [:_position, :displace],
|
@@ -85,8 +89,8 @@ class Shoes
|
|
85
89
|
|
86
90
|
def redraw_element(element, include_children = true)
|
87
91
|
target = redraw_target(element)
|
88
|
-
redraw_area target.
|
89
|
-
target.
|
92
|
+
redraw_area target.redraw_left, target.redraw_top,
|
93
|
+
target.redraw_width, target.redraw_height,
|
90
94
|
include_children
|
91
95
|
end
|
92
96
|
|
@@ -98,7 +102,7 @@ class Shoes
|
|
98
102
|
|
99
103
|
def redraw_target(element)
|
100
104
|
# During DSL initialization element.gui is nil, so if a SWT backend
|
101
|
-
# object causes a redraw in its
|
105
|
+
# object causes a redraw in its initialize (like Shoes::Swt::Image),
|
102
106
|
# we won't have gui set yet. Annoying, but fine.
|
103
107
|
if element.gui
|
104
108
|
element.gui.redraw_target
|