shoes-swt 4.0.0.pre4 → 4.0.0.pre5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +4 -0
  3. data/lib/shoes/swt/app.rb +11 -2
  4. data/lib/shoes/swt/button.rb +2 -4
  5. data/lib/shoes/swt/check_button.rb +2 -4
  6. data/lib/shoes/swt/color_factory.rb +1 -2
  7. data/lib/shoes/swt/common/painter.rb +8 -6
  8. data/lib/shoes/swt/common/resource.rb +14 -0
  9. data/lib/shoes/swt/download.rb +1 -1
  10. data/lib/shoes/swt/generate-backend.rb +1 -1
  11. data/lib/shoes/swt/gradient.rb +3 -2
  12. data/lib/shoes/swt/image.rb +3 -4
  13. data/lib/shoes/swt/input_box.rb +10 -11
  14. data/lib/shoes/swt/key_listener.rb +11 -5
  15. data/lib/shoes/swt/link.rb +2 -0
  16. data/lib/shoes/swt/list_box.rb +4 -9
  17. data/lib/shoes/swt/packager.rb +1 -0
  18. data/lib/shoes/swt/progress.rb +4 -5
  19. data/lib/shoes/swt/radio.rb +3 -3
  20. data/lib/shoes/swt/redrawing_aspect.rb +4 -13
  21. data/lib/shoes/swt/slot.rb +4 -1
  22. data/lib/shoes/swt/sound.rb +1 -1
  23. data/lib/shoes/swt/swt_button.rb +4 -4
  24. data/lib/shoes/swt/text_block/painter.rb +4 -1
  25. data/lib/shoes/swt/text_block/text_segment_collection.rb +14 -3
  26. data/lib/shoes/swt/text_block/text_style_factory.rb +1 -0
  27. data/lib/shoes/swt/text_block.rb +5 -1
  28. data/lib/shoes/swt/version.rb +1 -1
  29. data/lib/shoes/swt.rb +3 -3
  30. data/shoes-swt.gemspec +1 -1
  31. data/spec/shoes/swt/animation_spec.rb +6 -7
  32. data/spec/shoes/swt/app_spec.rb +56 -14
  33. data/spec/shoes/swt/arc_spec.rb +5 -5
  34. data/spec/shoes/swt/background_spec.rb +5 -5
  35. data/spec/shoes/swt/border_spec.rb +3 -3
  36. data/spec/shoes/swt/button_spec.rb +3 -7
  37. data/spec/shoes/swt/check_spec.rb +1 -1
  38. data/spec/shoes/swt/click_listener_spec.rb +2 -2
  39. data/spec/shoes/swt/color_factory_spec.rb +1 -1
  40. data/spec/shoes/swt/color_spec.rb +1 -1
  41. data/spec/shoes/swt/common/painter_spec.rb +13 -3
  42. data/spec/shoes/swt/common/remove_spec.rb +1 -1
  43. data/spec/shoes/swt/configuration_spec.rb +1 -2
  44. data/spec/shoes/swt/dialog_spec.rb +1 -4
  45. data/spec/shoes/swt/flow_spec.rb +4 -4
  46. data/spec/shoes/swt/font_spec.rb +1 -3
  47. data/spec/shoes/swt/gradient_spec.rb +1 -1
  48. data/spec/shoes/swt/image_pattern_spec.rb +1 -1
  49. data/spec/shoes/swt/image_spec.rb +3 -4
  50. data/spec/shoes/swt/input_box_spec.rb +6 -8
  51. data/spec/shoes/swt/integration_spec.rb +1 -1
  52. data/spec/shoes/swt/key_listener_spec.rb +44 -17
  53. data/spec/shoes/swt/line_spec.rb +2 -2
  54. data/spec/shoes/swt/link_segment_spec.rb +2 -3
  55. data/spec/shoes/swt/link_spec.rb +1 -1
  56. data/spec/shoes/swt/list_box_spec.rb +8 -9
  57. data/spec/shoes/swt/mouse_move_listener_spec.rb +6 -6
  58. data/spec/shoes/swt/oval_spec.rb +1 -1
  59. data/spec/shoes/swt/progress_spec.rb +3 -3
  60. data/spec/shoes/swt/radio_group_spec.rb +1 -2
  61. data/spec/shoes/swt/radio_spec.rb +4 -4
  62. data/spec/shoes/swt/rect_painter_spec.rb +6 -6
  63. data/spec/shoes/swt/rect_spec.rb +1 -1
  64. data/spec/shoes/swt/shape_spec.rb +2 -3
  65. data/spec/shoes/swt/shared_examples/button.rb +0 -2
  66. data/spec/shoes/swt/shared_examples/movable.rb +0 -1
  67. data/spec/shoes/swt/shared_examples/painter.rb +2 -3
  68. data/spec/shoes/swt/shared_examples/swt_app_context.rb +11 -9
  69. data/spec/shoes/swt/shell_control_listener_spec.rb +2 -2
  70. data/spec/shoes/swt/shoes_layout_spec.rb +6 -7
  71. data/spec/shoes/swt/slot_spec.rb +10 -4
  72. data/spec/shoes/swt/spec_helper.rb +11 -0
  73. data/spec/shoes/swt/star_spec.rb +4 -4
  74. data/spec/shoes/swt/text_block/centered_text_segment_spec.rb +1 -1
  75. data/spec/shoes/swt/text_block/cursor_painter_spec.rb +7 -7
  76. data/spec/shoes/swt/text_block/fitter_spec.rb +8 -9
  77. data/spec/shoes/swt/text_block/painter_spec.rb +15 -4
  78. data/spec/shoes/swt/text_block/text_font_factory_spec.rb +4 -4
  79. data/spec/shoes/swt/text_block/text_segment_collection_spec.rb +17 -18
  80. data/spec/shoes/swt/text_block/text_segment_spec.rb +5 -5
  81. data/spec/shoes/swt/text_block_spec.rb +13 -11
  82. data/spec/spec_helper.rb +2 -1
  83. metadata +14 -14
  84. data/lib/shoes/swt/common/child.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffaed9c950057b7cfab0d611a0570dec0b604151
4
- data.tar.gz: 2308581f63ff15b868167ce26cbb6d7898face7a
3
+ metadata.gz: ad850293dc338127cb8179643d1687913cb91fbb
4
+ data.tar.gz: e0fc3c0b500802b5f294ca454fc12955a9fc6462
5
5
  SHA512:
6
- metadata.gz: 93191af23b19fa9f015ac6803c2cb00facd3265ad85d84bef0278626f1f408fa441d2bafc5c26b721afe909935801324f10f04994588997db9a2d28d16bf55b6
7
- data.tar.gz: c99eafcac01873724c545367dc5ff5ca21a4ab257bfc68ede4f919991dcb3d6b3561e3b454fde2bc78c5f39d086aa4949c25639bb1ccdba32b6b92071313bde0
6
+ metadata.gz: e0e22591aded485f7bd61cfe8b0db70b92d9c1f50bb3b8f350cf11c42fc5b43b44d030983f82de0755d851a53601a36ae65ae8b208485acffdb1eeb1b4d0dcd0
7
+ data.tar.gz: 3f282218db6550e8dafb20d006f6f7c98aea3d33e0f602ddcbb4199088c903125fb851d77069c40316e47a799f8bf184e2696e85adb6588bffa753747f2afad0
data/Guardfile ADDED
@@ -0,0 +1,4 @@
1
+ guard 'rspec', cmd: 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ end
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
 
@@ -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, parent)
12
- super(dsl, parent, ::Swt::SWT::PUSH) do |button|
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
@@ -1,10 +1,8 @@
1
1
  class Shoes
2
2
  module Swt
3
3
  class CheckButton < SwtButton
4
- include Common::Child
5
-
6
- def initialize(dsl, parent, type)
7
- super(dsl, parent, type)
4
+ def initialize(dsl, app, type)
5
+ super(dsl, app, type)
8
6
  end
9
7
 
10
8
  def checked?
@@ -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
- if obj.needs_rotate?
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
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
@@ -2,7 +2,7 @@ class Shoes
2
2
  module Swt
3
3
  class Download
4
4
  attr_accessor :busy
5
- def initialize(_dsl)
5
+ def initialize(_dsl, _app)
6
6
  @busy = false
7
7
  end
8
8
 
@@ -5,5 +5,5 @@ def generate_backend(path)
5
5
  options = "-J-XstartOnFirstThread"
6
6
  end
7
7
 
8
- "jruby --1.9 #{options} #{path}/shoes-swt"
8
+ "jruby #{options} #{path}/shoes-swt"
9
9
  end
@@ -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
- dsl.element_left, dsl.element_top,
49
- width, height)
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
@@ -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 :parent, :real, :dsl, :painter
13
+ attr_reader :app, :real, :dsl, :painter
15
14
 
16
- def initialize(dsl, parent)
15
+ def initialize(dsl, app)
17
16
  @dsl = dsl
18
- @parent = parent
17
+ @app = app
19
18
  update_image
20
19
  add_paint_listener
21
20
  end
@@ -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, :parent
11
+ attr_reader :real, :dsl, :app
13
12
 
14
- def initialize(dsl, parent, text_options)
15
- @dsl = dsl
16
- @parent = parent
13
+ def initialize(dsl, app, text_options)
14
+ @dsl = dsl
15
+ @app = app
17
16
 
18
- @real = ::Swt::Widgets::Text.new(@parent.real, text_options)
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.enable_widget value
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, parent)
58
+ def initialize(dsl, app)
60
59
  styles = DEFAULT_STYLES
61
60
  styles |= ::Swt::SWT::PASSWORD if dsl.secret?
62
- super(dsl, parent, styles)
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, parent)
69
- super(dsl, parent, DEFAULT_STYLES)
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
- # NOTE: state_mask and key_code error for me so the java version is used
90
- def is_this_modifier_key?(event, key)
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 control?(event)
99
- is_this_modifier_key?(event, ::Swt::SWT::CTRL)
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)
@@ -2,6 +2,8 @@ class Shoes
2
2
  module Swt
3
3
  class Link
4
4
  include Common::Clickable
5
+ include Common::Fill
6
+ include Common::Stroke
5
7
 
6
8
  attr_reader :app, :link_segments, :dsl
7
9
 
@@ -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, :parent
9
+ attr_reader :dsl, :app
11
10
 
12
- # Create a list box
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
- @parent = parent
13
+ @app = app
19
14
  @real = ::Swt::Widgets::Combo.new(
20
- @parent.real,
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
@@ -59,6 +59,7 @@ class Shoes
59
59
  end
60
60
 
61
61
  private
62
+
62
63
  # Copy the master config (including singleton class), since we may be
63
64
  # packaging for more than one backend
64
65
  def create_config(master_config, backend)
@@ -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 :parent, :dsl
10
+ attr_reader :app, :dsl
12
11
 
13
- def initialize(dsl, parent)
12
+ def initialize(dsl, app)
14
13
  @dsl = dsl
15
- @parent = parent
14
+ @app = app
16
15
 
17
- @real = ::Swt::Widgets::ProgressBar.new(@parent.real,
16
+ @real = ::Swt::Widgets::ProgressBar.new(@app.real,
18
17
  ::Swt::SWT::SMOOTH)
19
18
  real.minimum = 0
20
19
  real.maximum = 100
@@ -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] parent The parent element of this button
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, parent)
15
- super(dsl, parent, ::Swt::SWT::RADIO)
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
@@ -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
- if dsl.hidden?
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)
@@ -19,7 +19,7 @@ class Shoes
19
19
 
20
20
  BufferSize = 4096
21
21
 
22
- def initialize(dsl)
22
+ def initialize(dsl, _app)
23
23
  @dsl = dsl
24
24
  end
25
25
 
@@ -6,14 +6,14 @@ class Shoes
6
6
  include Common::UpdatePosition
7
7
  include ::Shoes::BackendDimensionsDelegations
8
8
 
9
- attr_reader :parent, :real, :dsl
9
+ attr_reader :app, :real, :dsl
10
10
 
11
- def initialize(dsl, parent, type)
11
+ def initialize(dsl, app, type)
12
12
  @dsl = dsl
13
- @parent = parent
13
+ @app = app
14
14
 
15
15
  @type = type
16
- @real = ::Swt::Widgets::Button.new(@parent.real, @type)
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
- @dsl.gui.segments.paint_control(paint_event.gc)
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
- :one?, :any?, :empty?
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.line_bounds(0).height
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
@@ -86,6 +86,7 @@ class Shoes
86
86
  end
87
87
 
88
88
  private
89
+
89
90
  def style_present?(style)
90
91
  !style.nil? && !(style == 'none')
91
92
  end
@@ -94,7 +94,11 @@ class Shoes
94
94
  def set_absolutes(starting_left, starting_top)
95
95
  last_segment = segments.last
96
96
 
97
- @dsl.absolute_right = starting_left + last_segment.last_line_width +
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 +
@@ -1,5 +1,5 @@
1
1
  class Shoes
2
2
  module Swt
3
- VERSION = "4.0.0.pre4"
3
+ VERSION = "4.0.0.pre5"
4
4
  end
5
5
  end
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 #{$0} #{ARGV.join(" ")}`
135
- exit $?.exitstatus
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 'shoes/swt/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Shoes::Swt::Animation do
4
4
  include_context 'swt app'
5
- let(:dsl) { double('dsl', :stopped? => false, :removed? => false,
6
- :framerate => 10, :current_frame => nil,
7
- :increment_frame => nil, :blk => block) }
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 :stopped? => true
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 :removed? => true
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