glimmer-dsl-swt 0.5.6 → 0.6.0

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: 3db01899522fb71b0c6248500a33dea99db22fb65290a05ad08ace90b8b0abf8
4
- data.tar.gz: 4cc5bc3f816a1b452e29e36d178ce9c77addfee660abd89bdf047f6d21660508
3
+ metadata.gz: 0c023dda45b9c92e69ef9a44ef07fde1f45f5161284cf1b46b70d15a661b3ccc
4
+ data.tar.gz: 77be63700930812f4da66669003df863d77a1644495e2d37b776e97a5e5f145b
5
5
  SHA512:
6
- metadata.gz: ecbb06bef3ba8d11c71107b1f68ce8be3a1beb8147cf845f346a7561d193252a7774cd9460b3b05b1f664e502c8ca6cdf1a7cd444561834783e1097d29b5890a
7
- data.tar.gz: 74c311becb1cc511005cc6c92804f81001757cb0a04f927f7b07811f1a3f5fcd6dd5d3a48e9504777d452781899b953432ee512abc72ba90858bd7aadbd7c3ea
6
+ metadata.gz: ce300717322a9a905a67c589bf1a9398adcd09abf33421283c5d3265ed68b8ce4dbdf25ac33a37812de355c00ba027d7fe33ce284a9c2eb2932817087130a281
7
+ data.tar.gz: 353b5a6f43cf7d070ae9a2f775ea2430a4eda54bf346210a8ca5e1ee899a35c44f639fbca3e2cd5338aa73c3f1c9b97209c84ea669c436f36f4ce31a0bf9b1b8
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.6 (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.6.0 (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)
@@ -1 +1 @@
1
- jruby-9.2.12.0
1
+ jruby-9.2.13.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.6.0
@@ -0,0 +1,26 @@
1
+ require 'glimmer/dsl/expression'
2
+ require 'glimmer/dsl/top_level_expression'
3
+ require 'glimmer/swt/cursor_proxy'
4
+
5
+ module Glimmer
6
+ module DSL
7
+ module SWT
8
+ # cursor expression
9
+ # Note: Cannot be a static expression because it clashes with cursor property expression
10
+ class CursorExpression < Expression
11
+ include TopLevelExpression
12
+
13
+ def can_interpret?(parent, keyword, *args, &block)
14
+ keyword.to_s == 'cursor' and
15
+ (parent.nil? or !parent.respond_to?('cursor')) and
16
+ args.size == 1 and
17
+ (args.first.is_a?(Integer) or textual?(args.first))
18
+ end
19
+
20
+ def interpret(parent, keyword, *args, &block)
21
+ Glimmer::SWT::CursorProxy.new(*args)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -24,6 +24,8 @@ module Glimmer
24
24
  tree_items_data_binding
25
25
  table_items_data_binding
26
26
  data_binding
27
+ cursor
28
+ font
27
29
  property
28
30
  block_property
29
31
  widget
@@ -0,0 +1,24 @@
1
+ require 'glimmer/dsl/expression'
2
+ require 'glimmer/dsl/top_level_expression'
3
+ require 'glimmer/swt/font_proxy'
4
+
5
+ module Glimmer
6
+ module DSL
7
+ module SWT
8
+ # font expression
9
+ # Note: Cannot be a static expression because it clashes with font property expression
10
+ class FontExpression < Expression
11
+ include TopLevelExpression
12
+
13
+ def can_interpret?(parent, keyword, *args, &block)
14
+ keyword.to_s == 'font' and
15
+ (parent.nil? || !parent.respond_to?('font')) && args.size == 1 && args.first.is_a?(Hash)
16
+ end
17
+
18
+ def interpret(parent, keyword, *args, &block)
19
+ Glimmer::SWT::FontProxy.new(*args)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ require 'glimmer/error'
2
+ require 'glimmer/swt/swt_proxy'
3
+ require 'glimmer/swt/display_proxy'
4
+
5
+ module Glimmer
6
+ module SWT
7
+ # Proxy for org.eclipse.swt.graphics.Cursor
8
+ #
9
+ # Invoking `#swt_cursor` returns the SWT Cursor object wrapped by this proxy
10
+ #
11
+ # Follows the Proxy Design Pattern
12
+ class CursorProxy
13
+ CURSOR_STYLES = org.eclipse.swt.SWT.constants.select {|c| c.to_s.downcase.start_with?('cursor_')}.map {|c| c.to_s.downcase.sub('cursor_', '').to_sym}
14
+ ERROR_INVALID_CURSOR_STYLE = " is an invalid cursor style! Valid values are #{CURSOR_STYLES.map(&:to_s).join(", ")}"
15
+
16
+ include_package 'org.eclipse.swt.graphics'
17
+
18
+ attr_reader :swt_cursor, :cursor_style
19
+
20
+ # Builds a new CursorProxy from passed in cursor SWT style (e.g. :appstarting, :hand, or :help)
21
+ #
22
+ # Cursor SWT styles are those that begin with "CURSOR_" prefix
23
+ #
24
+ # They are expected to be passed in in short form without the prefix (but would work with the prefix too)
25
+ def initialize(cursor_style)
26
+ @cursor_style = cursor_style
27
+ @cursor_style = SWTProxy.reverse_lookup(@cursor_style).detect { |symbol| symbol.to_s.downcase.start_with?('cursor_') } if cursor_style.is_a?(Integer)
28
+ @cursor_style = @cursor_style.to_s.downcase
29
+ @cursor_style = @cursor_style.sub(/^cursor\_/, '') if @cursor_style.start_with?('cursor_')
30
+ detect_invalid_cursor_style
31
+ @swt_cursor = DisplayProxy.instance.swt_display.get_system_cursor(SWTProxy[swt_style])
32
+ end
33
+
34
+ def swt_style
35
+ @swt_style ||= @cursor_style.upcase.start_with?('CURSOR_') ? @cursor_style : "CURSOR_#{@cursor_style}"
36
+ end
37
+
38
+ private
39
+
40
+ def detect_invalid_cursor_style
41
+ raise Error, cursor_style.to_s + ERROR_INVALID_CURSOR_STYLE unless CURSOR_STYLES.include?(cursor_style.to_s.downcase.to_sym)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -6,11 +6,10 @@ module Glimmer
6
6
  module SWT
7
7
  # Proxy for org.eclipse.swt.graphics.Font
8
8
  #
9
- # This class is meant to be used with WidgetProxy to manipulate
10
- # an SWT widget font.
9
+ # This class can be optionally used with WidgetProxy to manipulate
10
+ # an SWT widget font (reusing its FontData but building a new Font)
11
11
  #
12
- # It is not meant to create new SWT fonts form scratch without
13
- # a widget proxy.
12
+ # Otherwise, if no WidgetProxy is passed to constructor, it builds new FontData
14
13
  #
15
14
  # Invoking `#swt_font` returns the SWT Font object wrapped by this proxy
16
15
  #
@@ -21,7 +20,7 @@ module Glimmer
21
20
 
22
21
  include_package 'org.eclipse.swt.graphics'
23
22
 
24
- attr_reader :widget_proxy, :swt_font
23
+ attr_reader :widget_proxy, :swt_font, :font_properties
25
24
 
26
25
  # Builds a new font proxy from passed in widget_proxy and font_properties hash,
27
26
  #
@@ -31,8 +30,9 @@ module Glimmer
31
30
  #
32
31
  # Style (:style value) can only be one of FontProxy::FONT_STYLES values:
33
32
  # that is :normal, :bold, or :italic
34
- def initialize(widget_proxy, font_properties)
33
+ def initialize(widget_proxy = nil, font_properties)
35
34
  @widget_proxy = widget_proxy
35
+ @font_properties = font_properties
36
36
  detect_invalid_font_property(font_properties)
37
37
  font_properties[:style] = SWTProxy[*font_properties[:style]]
38
38
  font_data_args = [:name, :height, :style].map do |font_property_name|
@@ -57,7 +57,7 @@ module Glimmer
57
57
  private
58
58
 
59
59
  def font_datum
60
- @font_datum ||= @widget_proxy.swt_widget.getFont.getFontData[0]
60
+ @font_datum ||= @widget_proxy ? @widget_proxy.swt_widget.getFont.getFontData[0] : FontData.new
61
61
  end
62
62
 
63
63
  def detect_invalid_font_property(font_properties)
@@ -106,7 +106,17 @@ module Glimmer
106
106
  def deconstruct(integer)
107
107
  constant_source_class.constants.reduce([]) do |found, c|
108
108
  constant_value = constant_source_class.const_get(c) rescue -1
109
- is_found = constant_value.is_a?(Integer) && (constant_value & integer) == constant_value
109
+ is_found = constant_value.is_a?(Integer) && (integer & constant_value) == integer
110
+ is_found ? found += [c] : found
111
+ end
112
+ end
113
+
114
+ # Reverse engineer a style integer into a symbol
115
+ # Useful for debugging
116
+ def reverse_lookup(integer)
117
+ constant_source_class.constants.reduce([]) do |found, c|
118
+ constant_value = constant_source_class.const_get(c) rescue -1
119
+ is_found = constant_value.is_a?(Integer) && integer == constant_value
110
120
  is_found ? found += [c] : found
111
121
  end
112
122
  end
@@ -607,6 +607,15 @@ module Glimmer
607
607
  value
608
608
  end
609
609
  end,
610
+ :cursor => lambda do |value|
611
+ cursor_proxy = nil
612
+ if value.is_a?(CursorProxy)
613
+ cursor_proxy = value
614
+ elsif value.is_a?(Symbol) || value.is_a?(String) || value.is_a?(Integer)
615
+ cursor_proxy = CursorProxy.new(value)
616
+ end
617
+ cursor_proxy ? cursor_proxy.swt_cursor : value
618
+ end,
610
619
  :foreground => color_converter,
611
620
  :font => lambda do |value|
612
621
  if value.is_a?(Hash)
Binary file
Binary file
Binary file
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.6
4
+ version: 0.6.0
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-30 00:00:00.000000000 Z
11
+ date: 2020-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -309,6 +309,7 @@ files:
309
309
  - lib/glimmer/dsl/swt/color_expression.rb
310
310
  - lib/glimmer/dsl/swt/column_properties_expression.rb
311
311
  - lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb
312
+ - lib/glimmer/dsl/swt/cursor_expression.rb
312
313
  - lib/glimmer/dsl/swt/custom_widget_expression.rb
313
314
  - lib/glimmer/dsl/swt/data_binding_expression.rb
314
315
  - lib/glimmer/dsl/swt/dialog_expression.rb
@@ -316,6 +317,7 @@ files:
316
317
  - lib/glimmer/dsl/swt/dnd_expression.rb
317
318
  - lib/glimmer/dsl/swt/dsl.rb
318
319
  - lib/glimmer/dsl/swt/exec_expression.rb
320
+ - lib/glimmer/dsl/swt/font_expression.rb
319
321
  - lib/glimmer/dsl/swt/layout_data_expression.rb
320
322
  - lib/glimmer/dsl/swt/layout_expression.rb
321
323
  - lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb
@@ -341,6 +343,7 @@ files:
341
343
  - lib/glimmer/rake_task/list.rb
342
344
  - lib/glimmer/scaffold.rb
343
345
  - lib/glimmer/swt/color_proxy.rb
346
+ - lib/glimmer/swt/cursor_proxy.rb
344
347
  - lib/glimmer/swt/display_proxy.rb
345
348
  - lib/glimmer/swt/dnd_proxy.rb
346
349
  - lib/glimmer/swt/font_proxy.rb