glimmer-dsl-swing 0.0.4 → 0.0.5

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: 839a9058d2f94757fbe185bb825a23a10fd840a0588b9e5f4fc44ede4ca4d511
4
- data.tar.gz: efd4e9dead40a0076b3d3647657fe27642101f498b7381efe7cf554a3d440d51
3
+ metadata.gz: f105e5227247c67f51be098e70d2ea1fdb1e084fcecf00f1960c838b4fd65c48
4
+ data.tar.gz: '07290abf4d15a2f70b38829ba540f3c9efd98a61cc4b8417484e30db8bfee1d6'
5
5
  SHA512:
6
- metadata.gz: 88bb15d31a9186a28d5e321f35080ff97bcdd055747f815e672c481e549dfd2076d9202f905e76d18528aead464ef8b5e920dd65a90736debedbc986a0cfecc7
7
- data.tar.gz: 1bda4d359a7974c9f8ee4fa4ca21ef30d6f833038b200dc0de8acd7e8dae7b9ac717a15d984a48d7e8c4cb7d600b440259b57e3f8d9dde23c50cc745c4716d0c
6
+ metadata.gz: e34417a4033877f520b7ead9871a734ab859fa3cfece7e02ea32d1cad4d278db870573182e46e23cbe4b037eda0a0ba8410dcf4c31a6ac63fc2b3319f16ecd71
7
+ data.tar.gz: e19f0b1bed9dea8e5cf4cc98939a83e0f00b7210ce1ef5a5b0282822a3ab11a58af95ec142dff27824789fdb9a040b14a05d082cad9da6410e99843962e93afd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.5
4
+
5
+ - Support `path`, which can primarily contain `move_to`, `line_to`, `curve_to`, `close_path` calls, and secondarily other shapes like `line` or `rectangle`.
6
+ - Support invoking component/shape operations in their content (e.g. nesting `move_to` inside `path`)
7
+
3
8
  ## 0.0.4
4
9
 
5
10
  - Support setting `stroke` attribute in shapes
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 Swing 0.0.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 Swing 0.0.5
2
2
  ## JRuby Swing Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swing.svg)](http://badge.fury.io/rb/glimmer-dsl-swing)
4
4
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -57,14 +57,14 @@ Note: On the Mac, if you have [Glimmer DSL for SWT](https://github.com/AndyObtiv
57
57
 
58
58
  Run this command to install directly:
59
59
  ```
60
- gem install glimmer-dsl-swing -v0.0.4
60
+ gem install glimmer-dsl-swing -v0.0.5
61
61
  ```
62
62
 
63
63
  ### Option 2: Bundler
64
64
 
65
65
  Add the following to `Gemfile`:
66
66
  ```
67
- gem 'glimmer-dsl-swing', '0.0.4'
67
+ gem 'glimmer-dsl-swing', '0.0.5'
68
68
  ```
69
69
 
70
70
  And, then run:
@@ -189,7 +189,7 @@ Despite `#show` being deprecated in the Java API, it is recommended to use `#sho
189
189
 
190
190
  In Smalltalk-MVC ([Model View Controller](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) Architectural Pattern), the View is an active View that observes the Model for changes and updates itself.
191
191
 
192
- ![MVC](https://camo.githubusercontent.com/0651c35cc70c5ba422876936733b07667368835bbd3cdbf5e706151410bdea04/68747470733a2f2f7777772e7265736561726368676174652e6e65742f70726f66696c652f44616e6e792d5765796e732f7075626c69636174696f6e2f3236393330333631312f6669677572652f666967322f41533a38353831333330353634363238363640313538313630363237323830302f536d616c6c74616c6b38302d4d56432d7061747465726e2d566965772d616e642d436f6e74726f6c6c65722d776f726b2d61732d612d706169722d616c6c6f77696e672d7468652d757365722d746f2d696e7465726163742e70706d)
192
+ ![MVC](http://3.bp.blogspot.com/-4eW59Ao0ess/ToiBzAiYdZI/AAAAAAAAAOg/SiYa6XHwBFE/s320/Screen+shot+2011-10-02+at+10.22.11+AM.png)
193
193
 
194
194
  This can be achieved with the Glimmer GUI DSL using the `observe` keyword, which takes a model (any object, including `self`) and attribute Symbol or String expression (e.g. `:count` or `'address.street'`).
195
195
 
@@ -254,6 +254,12 @@ Additionally, you can set these shape properties:
254
254
  - `fill_paint` (alias: `fill_color`): takes [`java.awt.Color`](https://docs.oracle.com/javase/8/docs/api/java/awt/Color.html) rgba arguments to use color for filling
255
255
  - `stroke`: takes [`java.awt.BasicStroke`](https://docs.oracle.com/javase/8/docs/api/java/awt/BasicStroke.html) line width and other arguments to use for drawing
256
256
 
257
+ `path` can have the following operations nested:
258
+ - `move_to x, y`: move to point
259
+ - `line_to x2, y2`: connect line to end point
260
+ - `curve_to ctrl_x1, ctrl_y1, ctrl_x2, ctrl_y2, x2, y2`: connect curve to control point 1, control point 2, and end point
261
+ - `close_path`: close path, reconnecting last shape/point back to first point
262
+
257
263
  Example:
258
264
 
259
265
  ```ruby
@@ -314,6 +320,32 @@ jframe('Hello, Shapes!') {
314
320
  draw_paint 0, 0, 255
315
321
  stroke 3
316
322
  }
323
+
324
+ path {
325
+ move_to 200, 150
326
+ line_to 270, 170
327
+ line_to 250, 220
328
+ line_to 220, 190
329
+ line_to 200, 200
330
+ line_to 180, 170
331
+
332
+ close_path
333
+
334
+ fill_paint 0, 255, 0
335
+ draw_paint 0, 0, 255
336
+ stroke 3
337
+ }
338
+
339
+ path {
340
+ move_to 160, 300
341
+ curve_to 190, 260, 200, 280, 210, 270
342
+ curve_to 240, 280, 250, 300, 260, 290
343
+ curve_to 290, 290, 300, 310, 310, 300
344
+
345
+ fill_paint 0, 255, 0
346
+ draw_paint 0, 0, 255
347
+ stroke 3
348
+ }
317
349
  }.show
318
350
  ```
319
351
 
@@ -514,6 +546,32 @@ jframe('Hello, Shapes!') {
514
546
  draw_paint 0, 0, 255
515
547
  stroke 3
516
548
  }
549
+
550
+ path {
551
+ move_to 200, 150
552
+ line_to 270, 170
553
+ line_to 250, 220
554
+ line_to 220, 190
555
+ line_to 200, 200
556
+ line_to 180, 170
557
+
558
+ close_path
559
+
560
+ fill_paint 0, 255, 0
561
+ draw_paint 0, 0, 255
562
+ stroke 3
563
+ }
564
+
565
+ path {
566
+ move_to 160, 300
567
+ curve_to 190, 260, 200, 280, 210, 270
568
+ curve_to 240, 280, 250, 300, 260, 290
569
+ curve_to 290, 290, 300, 310, 310, 300
570
+
571
+ fill_paint 0, 255, 0
572
+ draw_paint 0, 0, 255
573
+ stroke 3
574
+ }
517
575
  }.show
518
576
  ```
519
577
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
Binary file
@@ -38,6 +38,7 @@ module Glimmer
38
38
  %w[
39
39
  listener
40
40
  property
41
+ operation
41
42
  component
42
43
  shape
43
44
  ]
@@ -0,0 +1,45 @@
1
+ # Copyright (c) 2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/swing/component_proxy'
24
+ require 'glimmer/swing/shape_proxy'
25
+
26
+ module Glimmer
27
+ module DSL
28
+ module Swing
29
+ class OperationExpression < Expression
30
+ def can_interpret?(parent, keyword, *args, &block)
31
+ (
32
+ parent.is_a?(Glimmer::Swing::ComponentProxy) or
33
+ parent.is_a?(Glimmer::Swing::ShapeProxy)
34
+ ) and
35
+ block.nil? and
36
+ parent.respond_to?(keyword, *args)
37
+ end
38
+
39
+ def interpret(parent, keyword, *args, &block)
40
+ parent.send(keyword, *args)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -116,9 +116,7 @@ module Glimmer
116
116
 
117
117
  # Subclasses may override to perform post initialization work on an added child (normally must also call super)
118
118
  def post_initialize_child(child)
119
- if child.is_a?(ShapeProxy)
120
- add(child)
121
- end
119
+ @original.append(child.original, false) if @original&.is_a?(Path2D) && child.is_a?(ShapeProxy)
122
120
  end
123
121
 
124
122
  def respond_to?(method_name, *args, &block)
@@ -55,4 +55,30 @@ jframe('Hello, Shapes!') {
55
55
  draw_paint 0, 0, 255
56
56
  stroke 3
57
57
  }
58
+
59
+ path {
60
+ move_to 200, 150
61
+ line_to 270, 170
62
+ line_to 250, 220
63
+ line_to 220, 190
64
+ line_to 200, 200
65
+ line_to 180, 170
66
+
67
+ close_path
68
+
69
+ fill_paint 0, 255, 0
70
+ draw_paint 0, 0, 255
71
+ stroke 3
72
+ }
73
+
74
+ path {
75
+ move_to 160, 300
76
+ curve_to 190, 260, 200, 280, 210, 270
77
+ curve_to 240, 280, 250, 300, 260, 290
78
+ curve_to 290, 290, 300, 310, 310, 300
79
+
80
+ fill_paint 0, 255, 0
81
+ draw_paint 0, 0, 255
82
+ stroke 3
83
+ }
58
84
  }.show
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-swing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-15 00:00:00.000000000 Z
11
+ date: 2021-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +217,7 @@ files:
217
217
  - lib/glimmer/dsl/swing/dsl.rb
218
218
  - lib/glimmer/dsl/swing/listener_expression.rb
219
219
  - lib/glimmer/dsl/swing/observe_expression.rb
220
+ - lib/glimmer/dsl/swing/operation_expression.rb
220
221
  - lib/glimmer/dsl/swing/property_expression.rb
221
222
  - lib/glimmer/dsl/swing/shape_expression.rb
222
223
  - lib/glimmer/swing.rb