shoes-swt 4.0.0.pre4 → 4.0.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +4 -0
- data/lib/shoes/swt/app.rb +11 -2
- data/lib/shoes/swt/button.rb +2 -4
- data/lib/shoes/swt/check_button.rb +2 -4
- data/lib/shoes/swt/color_factory.rb +1 -2
- data/lib/shoes/swt/common/painter.rb +8 -6
- data/lib/shoes/swt/common/resource.rb +14 -0
- data/lib/shoes/swt/download.rb +1 -1
- data/lib/shoes/swt/generate-backend.rb +1 -1
- data/lib/shoes/swt/gradient.rb +3 -2
- data/lib/shoes/swt/image.rb +3 -4
- data/lib/shoes/swt/input_box.rb +10 -11
- data/lib/shoes/swt/key_listener.rb +11 -5
- data/lib/shoes/swt/link.rb +2 -0
- data/lib/shoes/swt/list_box.rb +4 -9
- data/lib/shoes/swt/packager.rb +1 -0
- data/lib/shoes/swt/progress.rb +4 -5
- data/lib/shoes/swt/radio.rb +3 -3
- data/lib/shoes/swt/redrawing_aspect.rb +4 -13
- data/lib/shoes/swt/slot.rb +4 -1
- data/lib/shoes/swt/sound.rb +1 -1
- data/lib/shoes/swt/swt_button.rb +4 -4
- data/lib/shoes/swt/text_block/painter.rb +4 -1
- data/lib/shoes/swt/text_block/text_segment_collection.rb +14 -3
- data/lib/shoes/swt/text_block/text_style_factory.rb +1 -0
- data/lib/shoes/swt/text_block.rb +5 -1
- data/lib/shoes/swt/version.rb +1 -1
- data/lib/shoes/swt.rb +3 -3
- data/shoes-swt.gemspec +1 -1
- data/spec/shoes/swt/animation_spec.rb +6 -7
- data/spec/shoes/swt/app_spec.rb +56 -14
- data/spec/shoes/swt/arc_spec.rb +5 -5
- data/spec/shoes/swt/background_spec.rb +5 -5
- data/spec/shoes/swt/border_spec.rb +3 -3
- data/spec/shoes/swt/button_spec.rb +3 -7
- data/spec/shoes/swt/check_spec.rb +1 -1
- data/spec/shoes/swt/click_listener_spec.rb +2 -2
- data/spec/shoes/swt/color_factory_spec.rb +1 -1
- data/spec/shoes/swt/color_spec.rb +1 -1
- data/spec/shoes/swt/common/painter_spec.rb +13 -3
- data/spec/shoes/swt/common/remove_spec.rb +1 -1
- data/spec/shoes/swt/configuration_spec.rb +1 -2
- data/spec/shoes/swt/dialog_spec.rb +1 -4
- data/spec/shoes/swt/flow_spec.rb +4 -4
- data/spec/shoes/swt/font_spec.rb +1 -3
- data/spec/shoes/swt/gradient_spec.rb +1 -1
- data/spec/shoes/swt/image_pattern_spec.rb +1 -1
- data/spec/shoes/swt/image_spec.rb +3 -4
- data/spec/shoes/swt/input_box_spec.rb +6 -8
- data/spec/shoes/swt/integration_spec.rb +1 -1
- data/spec/shoes/swt/key_listener_spec.rb +44 -17
- data/spec/shoes/swt/line_spec.rb +2 -2
- data/spec/shoes/swt/link_segment_spec.rb +2 -3
- data/spec/shoes/swt/link_spec.rb +1 -1
- data/spec/shoes/swt/list_box_spec.rb +8 -9
- data/spec/shoes/swt/mouse_move_listener_spec.rb +6 -6
- data/spec/shoes/swt/oval_spec.rb +1 -1
- data/spec/shoes/swt/progress_spec.rb +3 -3
- data/spec/shoes/swt/radio_group_spec.rb +1 -2
- data/spec/shoes/swt/radio_spec.rb +4 -4
- data/spec/shoes/swt/rect_painter_spec.rb +6 -6
- data/spec/shoes/swt/rect_spec.rb +1 -1
- data/spec/shoes/swt/shape_spec.rb +2 -3
- data/spec/shoes/swt/shared_examples/button.rb +0 -2
- data/spec/shoes/swt/shared_examples/movable.rb +0 -1
- data/spec/shoes/swt/shared_examples/painter.rb +2 -3
- data/spec/shoes/swt/shared_examples/swt_app_context.rb +11 -9
- data/spec/shoes/swt/shell_control_listener_spec.rb +2 -2
- data/spec/shoes/swt/shoes_layout_spec.rb +6 -7
- data/spec/shoes/swt/slot_spec.rb +10 -4
- data/spec/shoes/swt/spec_helper.rb +11 -0
- data/spec/shoes/swt/star_spec.rb +4 -4
- data/spec/shoes/swt/text_block/centered_text_segment_spec.rb +1 -1
- data/spec/shoes/swt/text_block/cursor_painter_spec.rb +7 -7
- data/spec/shoes/swt/text_block/fitter_spec.rb +8 -9
- data/spec/shoes/swt/text_block/painter_spec.rb +15 -4
- data/spec/shoes/swt/text_block/text_font_factory_spec.rb +4 -4
- data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +17 -18
- data/spec/shoes/swt/text_block/text_segment_spec.rb +5 -5
- data/spec/shoes/swt/text_block_spec.rb +13 -11
- data/spec/spec_helper.rb +2 -1
- metadata +14 -14
- data/lib/shoes/swt/common/child.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad850293dc338127cb8179643d1687913cb91fbb
|
4
|
+
data.tar.gz: e0fc3c0b500802b5f294ca454fc12955a9fc6462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0e22591aded485f7bd61cfe8b0db70b92d9c1f50bb3b8f350cf11c42fc5b43b44d030983f82de0755d851a53601a36ae65ae8b208485acffdb1eeb1b4d0dcd0
|
7
|
+
data.tar.gz: 3f282218db6550e8dafb20d006f6f7c98aea3d33e0f602ddcbb4199088c903125fb851d77069c40316e47a799f8bf184e2696e85adb6588bffa753747f2afad0
|
data/Guardfile
ADDED
data/lib/shoes/swt/app.rb
CHANGED
@@ -24,7 +24,8 @@ class Shoes
|
|
24
24
|
def initialize(dsl)
|
25
25
|
@dsl = dsl
|
26
26
|
::Swt::Widgets::Display.app_name = @dsl.app_title
|
27
|
-
@background = Color.new(@dsl.opts[:background]
|
27
|
+
@background = Color.new(@dsl.opts[:background] ||
|
28
|
+
::Shoes::COLORS.fetch(:system_background))
|
28
29
|
@started = false
|
29
30
|
initialize_shell
|
30
31
|
initialize_real
|
@@ -42,7 +43,6 @@ class Shoes
|
|
42
43
|
@shell.pack
|
43
44
|
force_shell_size
|
44
45
|
@shell.open
|
45
|
-
@dsl.top_slot.contents_alignment
|
46
46
|
@started = true
|
47
47
|
self.fullscreen = true if dsl.start_as_fullscreen?
|
48
48
|
flush
|
@@ -153,6 +153,14 @@ class Shoes
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
def self.setup_system_colors
|
157
|
+
# just one color for now
|
158
|
+
background_color = Shoes.display.getSystemColor(::Swt::SWT::COLOR_WIDGET_BACKGROUND)
|
159
|
+
::Shoes::DSL.define_shoes_color(:system_background, background_color.red,
|
160
|
+
background_color.green,
|
161
|
+
background_color.blue)
|
162
|
+
end
|
163
|
+
|
156
164
|
private
|
157
165
|
|
158
166
|
def initialize_scroll_bar
|
@@ -191,6 +199,7 @@ class Shoes
|
|
191
199
|
style = ::Swt::SWT::CLOSE | ::Swt::SWT::MIN | ::Swt::SWT::V_SCROLL
|
192
200
|
style |= ::Swt::SWT::RESIZE | ::Swt::SWT::MAX if @dsl.opts[:resizable]
|
193
201
|
style |= ::Swt::SWT::APPLICATION_MODAL if @dsl.opts[:modal]
|
202
|
+
style |= ::Swt::SWT::ON_TOP if @dsl.opts[:always_on_top]
|
194
203
|
style
|
195
204
|
end
|
196
205
|
|
data/lib/shoes/swt/button.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
class Shoes
|
2
2
|
module Swt
|
3
3
|
class Button < SwtButton
|
4
|
-
include Common::Child
|
5
|
-
|
6
4
|
# Create a button
|
7
5
|
#
|
8
6
|
# @param [Shoes::Button] dsl The Shoes DSL button this represents
|
9
7
|
# @param [::Swt::Widgets::Composite] parent The parent element of this button
|
10
8
|
# @param [Proc] blk The block of code to call when this button is activated
|
11
|
-
def initialize(dsl,
|
12
|
-
super(dsl,
|
9
|
+
def initialize(dsl, app)
|
10
|
+
super(dsl, app, ::Swt::SWT::PUSH) do |button|
|
13
11
|
button.set_text @dsl.text
|
14
12
|
end
|
15
13
|
end
|
@@ -22,8 +22,7 @@ class Shoes
|
|
22
22
|
def create(element)
|
23
23
|
return nil if element.nil?
|
24
24
|
return @swt_elements[element] if @swt_elements.include?(element)
|
25
|
-
|
26
|
-
swt_element = ::Shoes.configuration.backend_for(element)
|
25
|
+
swt_element = ::Shoes.backend_for(element)
|
27
26
|
@swt_elements[element] = swt_element
|
28
27
|
swt_element
|
29
28
|
end
|
@@ -35,14 +35,16 @@ class Shoes
|
|
35
35
|
graphics_context.set_transform(@obj.transform)
|
36
36
|
|
37
37
|
obj = @obj.dsl
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
clip_context_to(graphics_context, obj.parent, obj.parent.fixed_height?) do
|
39
|
+
if obj.needs_rotate?
|
40
|
+
set_rotate graphics_context, obj.rotate,
|
41
|
+
obj.element_left + obj.element_width / 2.0,
|
42
|
+
obj.element_top + obj.element_height / 2.0 do
|
43
|
+
fill_and_draw(graphics_context)
|
44
|
+
end
|
45
|
+
else
|
42
46
|
fill_and_draw(graphics_context)
|
43
47
|
end
|
44
|
-
else
|
45
|
-
fill_and_draw(graphics_context)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -23,6 +23,20 @@ class Shoes
|
|
23
23
|
def track_graphics_context(graphics_context)
|
24
24
|
@graphic_contexts << graphics_context
|
25
25
|
end
|
26
|
+
|
27
|
+
def clip_context_to(graphics_context, element, use_element_height = true)
|
28
|
+
clipping = graphics_context.clipping
|
29
|
+
height = use_element_height ? element.height : element.app.height
|
30
|
+
|
31
|
+
graphics_context.set_clipping(element.absolute_left, element.absolute_top,
|
32
|
+
element.width, height)
|
33
|
+
yield graphics_context
|
34
|
+
ensure
|
35
|
+
if clipping
|
36
|
+
graphics_context.set_clipping(clipping.x, clipping.y,
|
37
|
+
clipping.width, clipping.height)
|
38
|
+
end
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
28
42
|
end
|
data/lib/shoes/swt/download.rb
CHANGED
data/lib/shoes/swt/gradient.rb
CHANGED
@@ -40,13 +40,14 @@ class Shoes
|
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
43
|
+
|
43
44
|
def create_pattern(dsl)
|
44
45
|
width = dsl.element_width * 0.5
|
45
46
|
height = dsl.element_height * 0.5
|
46
47
|
angle = normalize_angle(-dsl.angle)
|
47
48
|
left, top, width, height = determine_args_based_on_angle(angle,
|
48
|
-
|
49
|
-
|
49
|
+
dsl.element_left, dsl.element_top,
|
50
|
+
width, height)
|
50
51
|
|
51
52
|
pattern = ::Swt::Pattern.new Shoes.display, left, top, width, height,
|
52
53
|
color1.real, color2.real
|
data/lib/shoes/swt/image.rb
CHANGED
@@ -3,7 +3,6 @@ class Shoes
|
|
3
3
|
class Image
|
4
4
|
import java.io.ByteArrayInputStream
|
5
5
|
|
6
|
-
include Common::Child
|
7
6
|
include Common::Resource
|
8
7
|
include Common::Clickable
|
9
8
|
include Common::PainterUpdatesPosition
|
@@ -11,11 +10,11 @@ class Shoes
|
|
11
10
|
include Common::Remove
|
12
11
|
include ::Shoes::BackendDimensionsDelegations
|
13
12
|
|
14
|
-
attr_reader :
|
13
|
+
attr_reader :app, :real, :dsl, :painter
|
15
14
|
|
16
|
-
def initialize(dsl,
|
15
|
+
def initialize(dsl, app)
|
17
16
|
@dsl = dsl
|
18
|
-
@
|
17
|
+
@app = app
|
19
18
|
update_image
|
20
19
|
add_paint_listener
|
21
20
|
end
|
data/lib/shoes/swt/input_box.rb
CHANGED
@@ -2,20 +2,19 @@ class Shoes
|
|
2
2
|
module Swt
|
3
3
|
# Class is used by edit_box and edit_line
|
4
4
|
class InputBox
|
5
|
-
include Common::Child
|
6
5
|
include Common::Remove
|
7
6
|
include Common::PainterUpdatesPosition
|
8
7
|
include Common::Visibility
|
9
8
|
include Common::UpdatePosition
|
10
9
|
include ::Shoes::BackendDimensionsDelegations
|
11
10
|
|
12
|
-
attr_reader :real, :dsl, :
|
11
|
+
attr_reader :real, :dsl, :app
|
13
12
|
|
14
|
-
def initialize(dsl,
|
15
|
-
@dsl
|
16
|
-
@
|
13
|
+
def initialize(dsl, app, text_options)
|
14
|
+
@dsl = dsl
|
15
|
+
@app = app
|
17
16
|
|
18
|
-
@real = ::Swt::Widgets::Text.new(@
|
17
|
+
@real = ::Swt::Widgets::Text.new(@app.real, text_options)
|
19
18
|
@real.set_size dsl.element_width, dsl.element_height
|
20
19
|
@real.set_text dsl.style[:text]
|
21
20
|
@real.add_modify_listener do |event|
|
@@ -33,7 +32,7 @@ class Shoes
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def enabled(value)
|
36
|
-
@real.
|
35
|
+
@real.enabled = value
|
37
36
|
end
|
38
37
|
|
39
38
|
def highlight_text(start_index, final_index)
|
@@ -56,17 +55,17 @@ class Shoes
|
|
56
55
|
|
57
56
|
class EditLine < InputBox
|
58
57
|
DEFAULT_STYLES = ::Swt::SWT::SINGLE | ::Swt::SWT::BORDER
|
59
|
-
def initialize(dsl,
|
58
|
+
def initialize(dsl, app)
|
60
59
|
styles = DEFAULT_STYLES
|
61
60
|
styles |= ::Swt::SWT::PASSWORD if dsl.secret?
|
62
|
-
super(dsl,
|
61
|
+
super(dsl, app, styles)
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
class EditBox < InputBox
|
67
66
|
DEFAULT_STYLES = ::Swt::SWT::MULTI | ::Swt::SWT::BORDER | ::Swt::SWT::WRAP | ::Swt::SWT::V_SCROLL
|
68
|
-
def initialize(dsl,
|
69
|
-
super(dsl,
|
67
|
+
def initialize(dsl, app)
|
68
|
+
super(dsl, app, DEFAULT_STYLES)
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
@@ -79,6 +79,7 @@ class Shoes
|
|
79
79
|
modifier_keys += 'control_' if control?(event)
|
80
80
|
modifier_keys += 'shift_' if shift?(event) && special_key?(event)
|
81
81
|
modifier_keys += 'alt_' if alt?(event)
|
82
|
+
modifier_keys += 'super_' if super?(event)
|
82
83
|
modifier_keys
|
83
84
|
end
|
84
85
|
|
@@ -86,19 +87,24 @@ class Shoes
|
|
86
87
|
is_this_modifier_key?(event, ::Swt::SWT::ALT)
|
87
88
|
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
(event.stateMask & key) == key
|
90
|
+
def control?(event)
|
91
|
+
is_this_modifier_key?(event, ::Swt::SWT::CTRL)
|
92
92
|
end
|
93
93
|
|
94
94
|
def shift?(event)
|
95
95
|
is_this_modifier_key?(event, ::Swt::SWT::SHIFT)
|
96
96
|
end
|
97
97
|
|
98
|
-
def
|
99
|
-
is_this_modifier_key?(event, ::Swt::SWT::
|
98
|
+
def super?(event)
|
99
|
+
is_this_modifier_key?(event, ::Swt::SWT::COMMAND)
|
100
100
|
end
|
101
101
|
|
102
|
+
# NOTE: state_mask and key_code error for me so the java version is used
|
103
|
+
def is_this_modifier_key?(event, key)
|
104
|
+
(event.stateMask & key) == key
|
105
|
+
end
|
106
|
+
|
107
|
+
|
102
108
|
def character_key(event)
|
103
109
|
return '' if current_key_is_modifier?(event)
|
104
110
|
if special_key?(event)
|
data/lib/shoes/swt/link.rb
CHANGED
data/lib/shoes/swt/list_box.rb
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
class Shoes
|
2
2
|
module Swt
|
3
3
|
class ListBox
|
4
|
-
include Common::Child
|
5
4
|
include Common::Remove
|
6
5
|
include Common::Visibility
|
7
6
|
include Common::UpdatePosition
|
8
7
|
include ::Shoes::BackendDimensionsDelegations
|
9
8
|
|
10
|
-
attr_reader :dsl, :
|
9
|
+
attr_reader :dsl, :app
|
11
10
|
|
12
|
-
|
13
|
-
#
|
14
|
-
# @param dsl [Shoes::List_box] The Shoes DSL list box this represents
|
15
|
-
# @param parent [::Swt::Widgets::Composite] The parent element of this button
|
16
|
-
def initialize(dsl, parent)
|
11
|
+
def initialize(dsl, app)
|
17
12
|
@dsl = dsl
|
18
|
-
@
|
13
|
+
@app = app
|
19
14
|
@real = ::Swt::Widgets::Combo.new(
|
20
|
-
@
|
15
|
+
@app.real,
|
21
16
|
::Swt::SWT::DROP_DOWN | ::Swt::SWT::READ_ONLY
|
22
17
|
)
|
23
18
|
@real.set_size dsl.element_width, dsl.element_height
|
data/lib/shoes/swt/packager.rb
CHANGED
data/lib/shoes/swt/progress.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
class Shoes
|
2
2
|
module Swt
|
3
3
|
class Progress
|
4
|
-
include Common::Child
|
5
4
|
include Common::Remove
|
6
5
|
include Common::Visibility
|
7
6
|
include Common::UpdatePosition
|
8
7
|
include DisposedProtection
|
9
8
|
include ::Shoes::BackendDimensionsDelegations
|
10
9
|
|
11
|
-
attr_reader :
|
10
|
+
attr_reader :app, :dsl
|
12
11
|
|
13
|
-
def initialize(dsl,
|
12
|
+
def initialize(dsl, app)
|
14
13
|
@dsl = dsl
|
15
|
-
@
|
14
|
+
@app = app
|
16
15
|
|
17
|
-
@real = ::Swt::Widgets::ProgressBar.new(@
|
16
|
+
@real = ::Swt::Widgets::ProgressBar.new(@app.real,
|
18
17
|
::Swt::SWT::SMOOTH)
|
19
18
|
real.minimum = 0
|
20
19
|
real.maximum = 100
|
data/lib/shoes/swt/radio.rb
CHANGED
@@ -9,10 +9,10 @@ class Shoes
|
|
9
9
|
# Create a radio button
|
10
10
|
#
|
11
11
|
# @param [Shoes::Radio] dsl The Shoes DSL radio this represents
|
12
|
-
# @param [::Swt::Widgets::Composite]
|
12
|
+
# @param [::Swt::Widgets::Composite] app The app element of this button
|
13
13
|
# @param [Proc] blk The block of code to call when this button is activated
|
14
|
-
def initialize(dsl,
|
15
|
-
super(dsl,
|
14
|
+
def initialize(dsl, app)
|
15
|
+
super(dsl, app, ::Swt::SWT::RADIO)
|
16
16
|
self.group = dsl.group
|
17
17
|
end
|
18
18
|
|
@@ -20,27 +20,22 @@ class Shoes
|
|
20
20
|
TextBlock::CursorPainter => [:move_textcursor],
|
21
21
|
Timer => [:eval_block],
|
22
22
|
::Shoes::Common::Changeable => [:call_change_listeners] }
|
23
|
+
|
23
24
|
# only the main thread may draw
|
24
25
|
NEED_TO_ASYNC_UPDATE_GUI = { ::Shoes::Download => [:eval_block] }
|
25
26
|
|
26
27
|
# These need to trigger a redraw
|
27
28
|
SAME_POSITION = { Common::Visibility => [:update_visibility],
|
28
29
|
Image => [:create_image],
|
30
|
+
::Shoes::Common::Hover => [:eval_hover_block],
|
29
31
|
::Shoes::Common::Style => [:update_style],
|
30
32
|
::Shoes::Common::Remove => [:remove],
|
31
33
|
::Shoes::Slot => [:mouse_hovered,
|
32
34
|
:mouse_left],
|
33
35
|
::Shoes::TextBlock => [:replace] }
|
34
36
|
|
35
|
-
CHANGED_POSITION = { ::Shoes::Common::Positioning => [:_position]
|
36
|
-
|
37
|
-
# These methods trigger SWT painting listeners, so we need to be sure
|
38
|
-
# that positioning has run properly before allowing them to continue.
|
39
|
-
NEED_CONTENTS_ALIGNMENT = {
|
40
|
-
::Shoes::Swt::Dialog => [:ask_color,
|
41
|
-
:dialog_chooser,
|
42
|
-
:open_message_box]
|
43
|
-
}
|
37
|
+
CHANGED_POSITION = { ::Shoes::Common::Positioning => [:_position],
|
38
|
+
::Shoes::Common::Hover => [:eval_hover_block] }
|
44
39
|
|
45
40
|
attr_reader :app
|
46
41
|
|
@@ -64,7 +59,6 @@ class Shoes
|
|
64
59
|
def affected_classes
|
65
60
|
classes = NEED_TO_UPDATE.keys +
|
66
61
|
NEED_TO_ASYNC_UPDATE_GUI.keys +
|
67
|
-
NEED_CONTENTS_ALIGNMENT.keys +
|
68
62
|
SAME_POSITION.keys +
|
69
63
|
CHANGED_POSITION.keys
|
70
64
|
classes.uniq
|
@@ -83,9 +77,6 @@ class Shoes
|
|
83
77
|
before_and_after_every CHANGED_POSITION do |*_args, element|
|
84
78
|
redraw_element element
|
85
79
|
end
|
86
|
-
before_every NEED_CONTENTS_ALIGNMENT do |*_args|
|
87
|
-
app.dsl.top_slot.contents_alignment
|
88
|
-
end
|
89
80
|
end
|
90
81
|
|
91
82
|
def update_gui
|
data/lib/shoes/swt/slot.rb
CHANGED
@@ -25,7 +25,10 @@ class Shoes
|
|
25
25
|
# responsibility, although this is more DSL code
|
26
26
|
# #904 #905
|
27
27
|
def update_visibility
|
28
|
-
|
28
|
+
# Only alter contents on a visibility change
|
29
|
+
return if @last_hidden_state == dsl.hidden?
|
30
|
+
|
31
|
+
if @last_hidden_state = dsl.hidden?
|
29
32
|
dsl.contents.each(&:hide)
|
30
33
|
else
|
31
34
|
dsl.contents.each(&:show)
|
data/lib/shoes/swt/sound.rb
CHANGED
data/lib/shoes/swt/swt_button.rb
CHANGED
@@ -6,14 +6,14 @@ class Shoes
|
|
6
6
|
include Common::UpdatePosition
|
7
7
|
include ::Shoes::BackendDimensionsDelegations
|
8
8
|
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :app, :real, :dsl
|
10
10
|
|
11
|
-
def initialize(dsl,
|
11
|
+
def initialize(dsl, app, type)
|
12
12
|
@dsl = dsl
|
13
|
-
@
|
13
|
+
@app = app
|
14
14
|
|
15
15
|
@type = type
|
16
|
-
@real = ::Swt::Widgets::Button.new(@
|
16
|
+
@real = ::Swt::Widgets::Button.new(@app.real, @type)
|
17
17
|
|
18
18
|
yield(@real) if block_given?
|
19
19
|
|
@@ -20,7 +20,10 @@ class Shoes
|
|
20
20
|
@dsl.gui.segments.empty?
|
21
21
|
|
22
22
|
reset_graphics_context(paint_event.gc)
|
23
|
-
|
23
|
+
|
24
|
+
clip_context_to(paint_event.gc, @dsl.parent) do |gc|
|
25
|
+
@dsl.gui.segments.paint_control(gc)
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -4,7 +4,7 @@ class Shoes
|
|
4
4
|
class TextSegmentCollection
|
5
5
|
extend Forwardable
|
6
6
|
def_delegators :@segments, :length, :last, :inject,
|
7
|
-
|
7
|
+
:one?, :any?, :empty?
|
8
8
|
|
9
9
|
attr_reader :dsl, :default_text_styles
|
10
10
|
|
@@ -164,9 +164,20 @@ class Shoes
|
|
164
164
|
end
|
165
165
|
|
166
166
|
# This could be smarter, basing height on the actual line the cursor's
|
167
|
-
# in. For now, just use the first line's height.
|
167
|
+
# in. For now, just use the first line's (purported) height.
|
168
168
|
def cursor_height
|
169
|
-
@segments.first.
|
169
|
+
if @segments.first.text.empty?
|
170
|
+
# Heights are off for empty text layouts. Fake it to make it (it
|
171
|
+
# being a real height).
|
172
|
+
new_segment = TextSegment.new(@dsl, "Hi", 100)
|
173
|
+
height_from_segment(new_segment)
|
174
|
+
else
|
175
|
+
height_from_segment(@segments.first)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def height_from_segment(segment)
|
180
|
+
segment.line_bounds(0).height
|
170
181
|
end
|
171
182
|
end
|
172
183
|
end
|
data/lib/shoes/swt/text_block.rb
CHANGED
@@ -94,7 +94,11 @@ class Shoes
|
|
94
94
|
def set_absolutes(starting_left, starting_top)
|
95
95
|
last_segment = segments.last
|
96
96
|
|
97
|
-
|
97
|
+
# If we have an explicit width, use that.
|
98
|
+
# If not, take our trailing line's width.
|
99
|
+
width_to_offset = @dsl.element_width || last_segment.last_line_width
|
100
|
+
|
101
|
+
@dsl.absolute_right = starting_left + width_to_offset +
|
98
102
|
margin_right - NEXT_ELEMENT_OFFSET
|
99
103
|
|
100
104
|
@dsl.absolute_bottom = starting_top + last_segment.height +
|
data/lib/shoes/swt/version.rb
CHANGED
data/lib/shoes/swt.rb
CHANGED
@@ -56,7 +56,6 @@ class Shoes
|
|
56
56
|
require 'shoes/swt/click_listener'
|
57
57
|
require 'shoes/swt/color'
|
58
58
|
require 'shoes/swt/color_factory'
|
59
|
-
require 'shoes/swt/common/child'
|
60
59
|
require 'shoes/swt/common/remove'
|
61
60
|
require 'shoes/swt/common/clickable'
|
62
61
|
require 'shoes/swt/common/container'
|
@@ -122,6 +121,7 @@ class Shoes
|
|
122
121
|
# redrawing aspect needs to know all the classes
|
123
122
|
require 'shoes/swt/redrawing_aspect'
|
124
123
|
|
124
|
+
::Shoes::Swt::App.setup_system_colors
|
125
125
|
@initialized = true
|
126
126
|
rescue Java::OrgEclipseSwt::SWTException => e
|
127
127
|
if e.message == "Invalid thread access"
|
@@ -131,8 +131,8 @@ class Shoes
|
|
131
131
|
puts " * Use the shoes executable to start your app"
|
132
132
|
puts " * Add JRUBY_OPTS='-J-XstartOnFirstThread' to your environment before starting."
|
133
133
|
|
134
|
-
`JRUBY_OPTS=-J-XstartOnFirstThread #{$
|
135
|
-
exit
|
134
|
+
`JRUBY_OPTS=-J-XstartOnFirstThread #{$PROGRAM_NAME} #{ARGV.join(" ")}`
|
135
|
+
exit $CHILD_STATUS.exitstatus
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
data/shoes-swt.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = 'A JRuby and Swt backend for Shoes, the best little GUI toolkit for Ruby. Shoes makes building for Mac, Windows, and Linux super simple.'
|
13
13
|
s.license = 'MIT'
|
14
14
|
|
15
|
-
s.files = `git ls-files`.split(
|
15
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Swt::Animation do
|
4
4
|
include_context 'swt app'
|
5
|
-
let(:dsl) { double('dsl',
|
6
|
-
|
7
|
-
|
5
|
+
let(:dsl) { double('dsl', stopped?: false, removed?: false,
|
6
|
+
framerate: 10, current_frame: nil,
|
7
|
+
increment_frame: nil, blk: block) }
|
8
8
|
let(:block) { double 'block', call: nil }
|
9
9
|
let(:display) { ::Swt.display }
|
10
10
|
subject { Shoes::Swt::Animation.new dsl, swt_app }
|
@@ -51,7 +51,7 @@ describe Shoes::Swt::Animation do
|
|
51
51
|
describe 'disabled' do
|
52
52
|
describe 'stopped?' do
|
53
53
|
before :each do
|
54
|
-
allow(dsl).to receive_messages
|
54
|
+
allow(dsl).to receive_messages stopped?: true
|
55
55
|
task.call
|
56
56
|
end
|
57
57
|
|
@@ -67,7 +67,7 @@ describe Shoes::Swt::Animation do
|
|
67
67
|
|
68
68
|
describe 'removed?' do
|
69
69
|
before :each do
|
70
|
-
allow(dsl).to receive_messages
|
70
|
+
allow(dsl).to receive_messages removed?: true
|
71
71
|
task.call
|
72
72
|
end
|
73
73
|
|
@@ -81,6 +81,5 @@ describe Shoes::Swt::Animation do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
85
84
|
end
|
86
85
|
end
|