glimmer-dsl-swt 0.5.1 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9125e62ffb8b2d214ba60942f71052d615ab2c875c3d436f1a1260252b67ade
4
- data.tar.gz: 8d756fc26f9cd2eb30232e546ff49a1736ad8831bf0cb179dfab36cb60828d05
3
+ metadata.gz: 3db01899522fb71b0c6248500a33dea99db22fb65290a05ad08ace90b8b0abf8
4
+ data.tar.gz: 4cc5bc3f816a1b452e29e36d178ce9c77addfee660abd89bdf047f6d21660508
5
5
  SHA512:
6
- metadata.gz: b7c40f5d85005f1c8a2de46c36ef9b734e3b21e83dc06f775afde6d564562350117fd76b673d1124273352ee9d1e520db6611bdbb6d268197989ed847776389f
7
- data.tar.gz: 8076087a4567e24823ad85ebec3326b6e0446fc17b4e268c34afb9152389f9095a4fef8629df516cd2e0ca95afefeeb9676d46b8e1848a53b6ab4ce2d43363e8
6
+ metadata.gz: ecbb06bef3ba8d11c71107b1f68ce8be3a1beb8147cf845f346a7561d193252a7774cd9460b3b05b1f664e502c8ca6cdf1a7cd444561834783e1097d29b5890a
7
+ data.tar.gz: 74c311becb1cc511005cc6c92804f81001757cb0a04f927f7b07811f1a3f5fcd6dd5d3a48e9504777d452781899b953432ee512abc72ba90858bd7aadbd7c3ea
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.5.1 (Desktop GUI)
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.5.6 (Desktop GUI)
2
2
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
3
3
  [![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.6
@@ -105,7 +105,6 @@ end
105
105
  Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
106
106
  method = method_symbol.to_s
107
107
  result = false
108
- result ||= method.start_with?('on_swt_') && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
109
108
  result ||= method == 'dispose' && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
110
109
  result ||= ['drag_source_proxy', 'drop_target_proxy'].include?(method) && is_a?(Glimmer::UI::CustomWidget)
111
110
  result ||= method == 'post_initialize_child'
@@ -21,7 +21,7 @@ module Glimmer
21
21
  system('warble config')
22
22
  new_config = File.read('config/warble.rb').split("\n").inject('') do |output, line|
23
23
  if line.include?('config.dirs =')
24
- line = line.sub('# ', '').sub(/=[^=\n]+$/, '= %w(app config db lib script bin docs fonts icons images sounds videos vendor)')
24
+ line = line.sub('# ', '').sub(/=[^=\n]+$/, '= %w(app bin config db docs fonts icons images lib package script sounds vendor videos)')
25
25
  end
26
26
  if line.include?('config.includes =')
27
27
  line = line.sub('# ', '').sub(/=[^=\n]+$/, "= FileList['LICENSE.txt', 'VERSION']")
@@ -5,7 +5,7 @@ module Glimmer
5
5
  module SWT
6
6
  # Proxy for org.eclipse.swt.graphics.Color
7
7
  #
8
- # Invoking `#swt_color` returns the SWT color object wrapped by this proxy
8
+ # Invoking `#swt_color` returns the SWT Color object wrapped by this proxy
9
9
  #
10
10
  # Follows the Proxy Design Pattern
11
11
  class ColorProxy
@@ -0,0 +1,63 @@
1
+ module Glimmer
2
+ module SWT
3
+ # Proxy for org.eclipse.swt.graphics.Image
4
+ #
5
+ # Invoking `#swt_image` returns the SWT Image object wrapped by this proxy
6
+ #
7
+ # Follows the Proxy Design Pattern
8
+ class ImageProxy
9
+ include_package 'org.eclipse.swt.graphics'
10
+
11
+ attr_reader :jar_file_path, :image_data
12
+
13
+ # Initializes a proxy for an SWT Image object
14
+ #
15
+ # Takes the same args as the SWT Image class
16
+ # Alternatively, takes a file path string or a uri:classloader file path string (generated by JRuby when invoking `File.expand_path` inside a JAR file)
17
+ # and returns an image object.
18
+ def initialize(*args)
19
+ @args = args
20
+ @jar_file_path = @args.first if @args.first.is_a?(String) && @args.size == 1
21
+
22
+ end
23
+
24
+ def swt_image
25
+ unless @swt_image
26
+ if @jar_file_path
27
+ file_path = @jar_file_path
28
+ if file_path.start_with?('uri:classloader')
29
+ file_path = file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac
30
+ object = java.lang.Object.new
31
+ file_input_stream = object.java_class.resource_as_stream(file_path)
32
+ buffered_file_input_stream = java.io.BufferedInputStream.new(file_input_stream)
33
+ end
34
+ @image_data = ImageData.new(buffered_file_input_stream || file_path)
35
+ @swt_image = Image.new(DisplayProxy.instance.swt_display, @image_data)
36
+ else
37
+ @swt_image = Image.new(*@args)
38
+ end
39
+ end
40
+ @swt_image
41
+ end
42
+
43
+ def scale_to(width, height)
44
+ return @swt_image if image_data.nil?
45
+ scaled_image_data = image_data.scaledTo(width, height)
46
+ device = swt_image.device
47
+ swt_image.dispose
48
+ @swt_image = Image.new(device, scaled_image_data)
49
+ end
50
+
51
+ def method_missing(method, *args, &block)
52
+ swt_image.send(method, *args, &block)
53
+ rescue => e
54
+ Glimmer::Config.logger.debug {"Neither ImageProxy nor #{swt_image.class.name} can handle the method ##{method}"}
55
+ super
56
+ end
57
+
58
+ def respond_to?(method, *args, &block)
59
+ super || swt_image.respond_to?(method, *args, &block)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -130,7 +130,7 @@ module Glimmer
130
130
  begin
131
131
  @display.sleep unless @display.readAndDispatch
132
132
  rescue => e
133
- Glimmer::Config.logger.debug {e.full_message}
133
+ Glimmer::Config.logger.info {e.full_message}
134
134
  end
135
135
  end
136
136
  end
@@ -61,6 +61,7 @@ module Glimmer
61
61
  combo: {
62
62
  widget_value_property: :text,
63
63
  editor_gui: lambda do |args, model, property, table_proxy|
64
+ first_time = true
64
65
  table_proxy.table_editor.minimumHeight = 25
65
66
  table_editor_widget_proxy = combo(*args) {
66
67
  items model.send("#{property}_options")
@@ -77,7 +78,9 @@ module Glimmer
77
78
  end
78
79
  }
79
80
  on_widget_selected {
80
- table_proxy.finish_edit!
81
+ if !OS.windows? || !first_time || first_time && model.send(property) != table_editor_widget_proxy.swt_widget.text
82
+ table_proxy.finish_edit!
83
+ end
81
84
  }
82
85
  }
83
86
  table_editor_widget_proxy
@@ -3,6 +3,7 @@ require 'glimmer/swt/color_proxy'
3
3
  require 'glimmer/swt/font_proxy'
4
4
  require 'glimmer/swt/swt_proxy'
5
5
  require 'glimmer/swt/dnd_proxy'
6
+ require 'glimmer/swt/image_proxy'
6
7
 
7
8
  # TODO refactor to make file smaller and extract sub-widget-proxies out of this
8
9
 
@@ -22,7 +23,7 @@ module Glimmer
22
23
 
23
24
  DEFAULT_STYLES = {
24
25
  "text" => [:border],
25
- "table" => [:virtual, :border],
26
+ "table" => [:virtual, :border, :full_selection],
26
27
  "tree" => [:virtual, :border, :h_scroll, :v_scroll],
27
28
  "spinner" => [:border],
28
29
  "styled_text" => [:border],
@@ -590,21 +591,18 @@ module Glimmer
590
591
  @property_type_converters ||= {
591
592
  :background => color_converter,
592
593
  :background_image => lambda do |value|
594
+ image_proxy = nil
593
595
  if value.is_a?(String)
594
- if value.start_with?('uri:classloader')
595
- value = value.sub(/^uri\:classloader\:\//, '')
596
- object = java.lang.Object.new
597
- value = object.java_class.resource_as_stream(value)
598
- value = java.io.BufferedInputStream.new(value)
599
- end
600
- image_data = ImageData.new(value)
601
- # TODO in the future, look into unregistering this listener when no longer needed
596
+ image_proxy = ImageProxy.new(value)
597
+ elsif value.is_a?(Array)
598
+ image_proxy = ImageProxy.new(*value)
599
+ end
600
+ if image_proxy
602
601
  on_swt_Resize do |resize_event|
603
- new_image_data = image_data.scaledTo(@swt_widget.getSize.x, @swt_widget.getSize.y)
604
- @swt_widget.getBackgroundImage&.dispose
605
- @swt_widget.setBackgroundImage(Image.new(@swt_widget.getDisplay, new_image_data))
602
+ image_proxy.scale_to(@swt_widget.getSize.x, @swt_widget.getSize.y)
603
+ @swt_widget.setBackgroundImage(image_proxy.swt_image)
606
604
  end
607
- Image.new(@swt_widget.getDisplay, image_data)
605
+ image_proxy.swt_image
608
606
  else
609
607
  value
610
608
  end
@@ -618,6 +616,26 @@ module Glimmer
618
616
  value
619
617
  end
620
618
  end,
619
+ :image => lambda do |value|
620
+ if value.is_a?(String)
621
+ ImageProxy.new(value).swt_image
622
+ elsif value.is_a?(Array)
623
+ ImageProxy.new(*value).swt_image
624
+ else
625
+ value
626
+ end
627
+ end,
628
+ :images => lambda do |array|
629
+ array.to_a.map do |value|
630
+ if value.is_a?(String)
631
+ ImageProxy.new(value).swt_image
632
+ elsif value.is_a?(Array)
633
+ ImageProxy.new(*value).swt_image
634
+ else
635
+ value
636
+ end
637
+ end.to_java(Image)
638
+ end,
621
639
  :items => lambda do |value|
622
640
  value.to_java :string
623
641
  end,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-27 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -344,6 +344,7 @@ files:
344
344
  - lib/glimmer/swt/display_proxy.rb
345
345
  - lib/glimmer/swt/dnd_proxy.rb
346
346
  - lib/glimmer/swt/font_proxy.rb
347
+ - lib/glimmer/swt/image_proxy.rb
347
348
  - lib/glimmer/swt/layout_data_proxy.rb
348
349
  - lib/glimmer/swt/layout_proxy.rb
349
350
  - lib/glimmer/swt/menu_proxy.rb