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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +62 -4
- data/VERSION +1 -1
- data/glimmer-dsl-swing.gemspec +0 -0
- data/lib/glimmer/dsl/swing/dsl.rb +1 -0
- data/lib/glimmer/dsl/swing/operation_expression.rb +45 -0
- data/lib/glimmer/swing/shape_proxy.rb +1 -3
- data/samples/hello/hello_shapes.rb +26 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f105e5227247c67f51be098e70d2ea1fdb1e084fcecf00f1960c838b4fd65c48
|
4
|
+
data.tar.gz: '07290abf4d15a2f70b38829ba540f3c9efd98a61cc4b8417484e30db8bfee1d6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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.
|
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](
|
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.
|
1
|
+
0.0.5
|
data/glimmer-dsl-swing.gemspec
CHANGED
Binary file
|
@@ -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
|
+
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-
|
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
|