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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/bin/shoes-swt +1 -0
  3. data/lib/shoes/swt.rb +3 -1
  4. data/lib/shoes/swt/animation.rb +1 -0
  5. data/lib/shoes/swt/app.rb +12 -11
  6. data/lib/shoes/swt/arc.rb +1 -0
  7. data/lib/shoes/swt/arc_painter.rb +4 -3
  8. data/lib/shoes/swt/arrow.rb +1 -0
  9. data/lib/shoes/swt/arrow_painter.rb +10 -5
  10. data/lib/shoes/swt/background.rb +1 -0
  11. data/lib/shoes/swt/border.rb +1 -0
  12. data/lib/shoes/swt/button.rb +1 -0
  13. data/lib/shoes/swt/check.rb +1 -0
  14. data/lib/shoes/swt/check_button.rb +1 -0
  15. data/lib/shoes/swt/click_listener.rb +1 -0
  16. data/lib/shoes/swt/color.rb +1 -0
  17. data/lib/shoes/swt/color_factory.rb +1 -0
  18. data/lib/shoes/swt/common/clickable.rb +1 -0
  19. data/lib/shoes/swt/common/container.rb +1 -0
  20. data/lib/shoes/swt/common/fill.rb +2 -1
  21. data/lib/shoes/swt/common/focus.rb +5 -0
  22. data/lib/shoes/swt/common/image_handling.rb +11 -5
  23. data/lib/shoes/swt/common/painter.rb +21 -1
  24. data/lib/shoes/swt/common/painter_updates_position.rb +1 -0
  25. data/lib/shoes/swt/common/remove.rb +16 -3
  26. data/lib/shoes/swt/common/resource.rb +1 -0
  27. data/lib/shoes/swt/common/selection_listener.rb +1 -0
  28. data/lib/shoes/swt/common/stroke.rb +1 -0
  29. data/lib/shoes/swt/common/translate.rb +1 -0
  30. data/lib/shoes/swt/common/update_position.rb +1 -0
  31. data/lib/shoes/swt/common/visibility.rb +7 -2
  32. data/lib/shoes/swt/dialog.rb +1 -0
  33. data/lib/shoes/swt/disposed_protection.rb +1 -0
  34. data/lib/shoes/swt/download.rb +1 -0
  35. data/lib/shoes/swt/font.rb +1 -0
  36. data/lib/shoes/swt/generate_backend.rb +10 -10
  37. data/lib/shoes/swt/gradient.rb +24 -6
  38. data/lib/shoes/swt/image.rb +6 -10
  39. data/lib/shoes/swt/image_painter.rb +26 -0
  40. data/lib/shoes/swt/image_pattern.rb +1 -0
  41. data/lib/shoes/swt/input_box.rb +1 -0
  42. data/lib/shoes/swt/key_listener.rb +6 -5
  43. data/lib/shoes/swt/line.rb +1 -0
  44. data/lib/shoes/swt/line_painter.rb +3 -2
  45. data/lib/shoes/swt/link.rb +1 -0
  46. data/lib/shoes/swt/link_segment.rb +1 -0
  47. data/lib/shoes/swt/list_box.rb +1 -0
  48. data/lib/shoes/swt/mouse_move_listener.rb +1 -0
  49. data/lib/shoes/swt/oval.rb +1 -0
  50. data/lib/shoes/swt/oval_painter.rb +4 -3
  51. data/lib/shoes/swt/packager.rb +1 -0
  52. data/lib/shoes/swt/progress.rb +1 -0
  53. data/lib/shoes/swt/radio.rb +4 -3
  54. data/lib/shoes/swt/radio_group.rb +1 -0
  55. data/lib/shoes/swt/rect.rb +1 -2
  56. data/lib/shoes/swt/rect_painter.rb +3 -2
  57. data/lib/shoes/swt/redrawing_aspect.rb +16 -12
  58. data/lib/shoes/swt/shape.rb +5 -3
  59. data/lib/shoes/swt/shape_painter.rb +12 -0
  60. data/lib/shoes/swt/shoes_layout.rb +1 -0
  61. data/lib/shoes/swt/slot.rb +24 -13
  62. data/lib/shoes/swt/sound.rb +1 -1
  63. data/lib/shoes/swt/star.rb +1 -0
  64. data/lib/shoes/swt/star_painter.rb +2 -1
  65. data/lib/shoes/swt/swt_button.rb +1 -0
  66. data/lib/shoes/swt/text_block.rb +1 -0
  67. data/lib/shoes/swt/text_block/centered_text_segment.rb +1 -0
  68. data/lib/shoes/swt/text_block/cursor_painter.rb +1 -0
  69. data/lib/shoes/swt/text_block/fitter.rb +1 -0
  70. data/lib/shoes/swt/text_block/painter.rb +1 -0
  71. data/lib/shoes/swt/text_block/text_font_factory.rb +2 -0
  72. data/lib/shoes/swt/text_block/text_segment.rb +1 -0
  73. data/lib/shoes/swt/text_block/text_segment_collection.rb +1 -0
  74. data/lib/shoes/swt/text_block/text_style_factory.rb +1 -0
  75. data/lib/shoes/swt/timer.rb +1 -0
  76. data/lib/shoes/swt/tooling/leak_hunter.rb +1 -0
  77. data/lib/shoes/swt/version.rb +1 -1
  78. metadata +7 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24d59ab2c243194cd08ec8910dc1ac800cf8d4557c7126338e71bed355cecfe6
4
- data.tar.gz: 35019496beedf4815a237efb971a9ea0dc128b3155f8378bf6f3680735cdb8d7
3
+ metadata.gz: 7a0f5dce653d4fa2b8da0cc28e07058dfaeba20463a5aa2849a456f6088564af
4
+ data.tar.gz: df51d16aa4e78f78e5818e79cd99fb77d230140c7184d7055aa01ab3bcc61690
5
5
  SHA512:
6
- metadata.gz: 86ee6a318228b84e51eea1ad73e5c0dbcc40e938f4c42e002a32f5c2e2fc2ae3699fa11226b92069bfdd9dc8d5e5182d60203a9801a39f3a3646b5439ee10032
7
- data.tar.gz: a41f3c499268d5d8d35ad26a60cd3bdf3f419c082ca1724302e1a9e42701a93ae03a1505a249a5ad8b110de8f47b5a94d23c846b33cb2e10e0490cb5fffdf370
6
+ metadata.gz: 8f90a0299888757c83b667b2f429265a5e4749327b8e43dbefbb9db419dc8d7e8932099115ae0015d54332aa2416fcee95e9bdbf5da6181dc22f9002f1e842ff
7
+ data.tar.gz: 212cd8cc7260e7a9b709b6ef9c38b91632dade5d11c29e591906412036567df2fa4066c6d403c33733a29c8d89a93f5a456b4073bf882a0294bde6c4884c66a8
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env jruby
2
2
  # frozen_string_literal: true
3
+
3
4
  lib_directory = File.expand_path('../../lib', __FILE__)
4
5
  $LOAD_PATH << lib_directory
5
6
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'java'
3
4
  require 'swt/minimal'
4
5
  require 'swt/core'
@@ -46,7 +47,7 @@ class Shoes
46
47
  end
47
48
 
48
49
  def self.initialize_backend
49
- return if @initialized
50
+ return if defined?(@initialized) && @initialized
50
51
  @initialized = true
51
52
 
52
53
  ::Shoes.configuration.backend = :swt
@@ -96,6 +97,7 @@ class Shoes
96
97
  require 'shoes/swt/font'
97
98
  require 'shoes/swt/gradient'
98
99
  require 'shoes/swt/image'
100
+ require 'shoes/swt/image_painter'
99
101
  require 'shoes/swt/image_pattern'
100
102
  require 'shoes/swt/key_listener'
101
103
  require 'shoes/swt/line'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Animation
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  shoes_icon = ::Shoes::ICON
@@ -24,16 +25,16 @@ class Shoes
24
25
 
25
26
  def initialize(dsl)
26
27
  if self.class.main_app_closed?
27
- Shoes.logger.error <<-EOS
28
- Sorry! You can't start another Shoes.app at after the main one has already
29
- finished like that! If you need multiple windows, try it more like this:
30
-
31
- Shoes.app do
32
- para "first!"
33
- Shoes.app do
34
- para "second!"
35
- end
36
- end
28
+ Shoes.logger.error <<~EOS
29
+ Sorry! You can't start another Shoes.app at after the main one has already
30
+ finished like that! If you need multiple windows, try it more like this:
31
+
32
+ Shoes.app do
33
+ para "first!"
34
+ Shoes.app do
35
+ para "second!"
36
+ end
37
+ end
37
38
  EOS
38
39
  exit 1
39
40
  end
@@ -197,7 +198,7 @@ EOS
197
198
  # Because SWT shutdown is hard to reverse, we only let you do it once
198
199
  # and warn you if you try to run again afterward.
199
200
  def self.main_app_closed?
200
- @main_app_closed
201
+ @main_app_closed ||= false
201
202
  end
202
203
 
203
204
  def self.mark_main_app_closed
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Arc
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class ArcPainter < Common::Painter
@@ -7,14 +8,14 @@ class Shoes
7
8
  def fill(graphics_context)
8
9
  if @obj.wedge?
9
10
  graphics_context.fill_arc(@obj.translate_left + @obj.element_left,
10
- @obj.translate_top + @obj.element_top,
11
+ @obj.translate_top + drawing_top,
11
12
  @obj.element_width,
12
13
  @obj.element_height,
13
14
  start_angle, sweep)
14
15
  else
15
16
  path = ::Swt::Path.new(::Swt.display)
16
17
  path.add_arc(@obj.translate_left + @obj.element_left,
17
- @obj.translate_top + @obj.element_top,
18
+ @obj.translate_top + drawing_top,
18
19
  @obj.element_width,
19
20
  @obj.element_height,
20
21
  start_angle, sweep)
@@ -26,7 +27,7 @@ class Shoes
26
27
  line_width = graphics_context.get_line_width
27
28
  if @obj.element_left && @obj.element_top && @obj.element_width && @obj.element_height
28
29
  graphics_context.draw_arc(@obj.translate_left + @obj.element_left + line_width / 2,
29
- @obj.translate_top + @obj.element_top + line_width / 2,
30
+ @obj.translate_top + drawing_top + line_width / 2,
30
31
  @obj.element_width - line_width,
31
32
  @obj.element_height - line_width,
32
33
  start_angle, sweep)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Arrow
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class ArrowPainter < Common::Painter
@@ -28,14 +29,14 @@ class Shoes
28
29
 
29
30
  body_left = @obj.translate_left + @obj.left - @obj.width * 0.5
30
31
  body_right = @obj.translate_left + @obj.left + @obj.width * 0.1
31
- body_top = @obj.translate_top + @obj.top - @obj.width * 0.2
32
- body_bottom = @obj.translate_top + @obj.top + @obj.width * 0.2
32
+ body_top = @obj.translate_top + drawing_top - @obj.width * 0.2
33
+ body_bottom = @obj.translate_top + drawing_top + @obj.width * 0.2
33
34
 
34
- middle = @obj.translate_top + @obj.top
35
+ middle = @obj.translate_top + drawing_top
35
36
 
36
37
  head_right = @obj.translate_left + @obj.left + @obj.width * 0.5
37
- head_top = @obj.translate_top + @obj.top - @obj.width * 0.4
38
- head_bottom = @obj.translate_top + @obj.top + @obj.width * 0.4
38
+ head_top = @obj.translate_top + drawing_top - @obj.width * 0.4
39
+ head_bottom = @obj.translate_top + drawing_top + @obj.width * 0.4
39
40
 
40
41
  path = ::Swt::Path.new(::Swt.display)
41
42
  path.move_to(body_left, middle)
@@ -56,6 +57,10 @@ class Shoes
56
57
  clear_path
57
58
  end
58
59
 
60
+ def after_painted
61
+ clear_path
62
+ end
63
+
59
64
  def clear_path
60
65
  @path.dispose unless @path.nil? || @path.disposed?
61
66
  @path = nil
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Background
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Border
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Button < SwtButton
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Check < CheckButton
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class CheckButton < SwtButton
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  # This class is intended as the single click listener held onto by the app.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class Color
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  # ColorFactory is used for tracking SWT-backed resources related to colors
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -25,7 +26,7 @@ class Shoes
25
26
 
26
27
  # @return [Integer] the angle to use when filling with a pattern
27
28
  def angle
28
- @angle || 0
29
+ dsl.angle || 0
29
30
  end
30
31
 
31
32
  # Just clear it out and let next paint recreate and save our SWT color
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -6,6 +7,10 @@ class Shoes
6
7
  def focus
7
8
  @real.set_focus
8
9
  end
10
+
11
+ def focused?
12
+ @real.has_focus
13
+ end
9
14
  end
10
15
  end
11
16
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -13,22 +14,27 @@ class Shoes
13
14
  tmpname = File.join(Dir.tmpdir, "__shoes4_#{Time.now.to_i}_#{File.basename(name)}")
14
15
  FileUtils.cp(name, tmpname)
15
16
 
16
- @cleanup_files ||= []
17
- @cleanup_files << tmpname
17
+ cleanup_files << tmpname
18
18
  tmpname
19
19
  end
20
20
 
21
21
  def cleanup_temporary_files
22
- return unless @cleanup_files
22
+ return unless cleanup_files.any?
23
23
 
24
- @cleanup_files.each do |file|
24
+ cleanup_files.each do |file|
25
25
  begin
26
26
  FileUtils.rm(file)
27
27
  rescue => e
28
28
  Shoes.logger.debug("Error during image temp file cleanup.\n#{e.class}: #{e.message}")
29
29
  end
30
30
  end
31
- @cleanup_files.clear
31
+ cleanup_files.clear
32
+ end
33
+
34
+ private
35
+
36
+ def cleanup_files
37
+ @cleanup_files ||= []
32
38
  end
33
39
  end
34
40
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -17,6 +18,7 @@ class Shoes
17
18
  end
18
19
 
19
20
  def paint_control(event)
21
+ before_painted
20
22
  graphics_context = event.gc
21
23
  reset_graphics_context graphics_context
22
24
  if @obj.dsl.visible? && @obj.dsl.positioned?
@@ -30,6 +32,8 @@ class Shoes
30
32
  #
31
33
  puts "SWALLOWED PAINT EXCEPTION ON #{@obj} - go take care of it: " + e.to_s
32
34
  puts 'Unfortunately we have to swallow it because it causes odd failures :('
35
+ ensure
36
+ after_painted
33
37
  end
34
38
 
35
39
  def paint_object(graphics_context)
@@ -42,7 +46,7 @@ class Shoes
42
46
  if obj.needs_rotate?
43
47
  set_rotate graphics_context, obj.rotate,
44
48
  obj.element_left + obj.element_width / 2.0,
45
- obj.element_top + obj.element_height / 2.0 do
49
+ drawing_top + obj.element_height / 2.0 do
46
50
  fill_and_draw(graphics_context)
47
51
  end
48
52
  else
@@ -101,6 +105,22 @@ class Shoes
101
105
  transform.translate(-left, -top)
102
106
  graphics_context.set_transform transform
103
107
  end
108
+
109
+ def drawing_top
110
+ dsl = @obj.dsl
111
+ dsl.element_top - dsl.parent.scroll_top
112
+ end
113
+
114
+ def drawing_bottom
115
+ dsl = @obj.dsl
116
+ dsl.element_bottom - dsl.parent.scroll_top
117
+ end
118
+
119
+ def before_painted
120
+ end
121
+
122
+ def after_painted
123
+ end
104
124
  end
105
125
  end
106
126
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
5
6
  module Remove
6
7
  def remove
7
- app.remove_paint_listener @painter
8
+ app.remove_paint_listener(painter)
8
9
  remove_click_listeners
9
- @real.dispose unless @real.nil? || @real.disposed?
10
+ real&.dispose unless real&.disposed?
10
11
  dispose_held_resources
11
12
  dispose
12
13
  end
13
14
 
14
15
  def dispose_held_resources
15
- @color_factory&.dispose
16
+ color_factory&.dispose
16
17
  end
17
18
 
18
19
  # Classes should override to dispose of any Swt resources they create
@@ -21,6 +22,18 @@ class Shoes
21
22
 
22
23
  private
23
24
 
25
+ def color_factory
26
+ @color_factory ||= nil
27
+ end
28
+
29
+ def painter
30
+ @painter ||= nil
31
+ end
32
+
33
+ def real
34
+ @real ||= nil
35
+ end
36
+
24
37
  def remove_click_listeners
25
38
  app.click_listener.remove_listeners_for(dsl)
26
39
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  class SelectionListener
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class Shoes
3
4
  module Swt
4
5
  module Common