glimmer-dsl-libui 0.5.0 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +11 -3
- data/VERSION +1 -1
- data/examples/color_the_circles.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +5 -1
- data/lib/glimmer/libui/shape/arc.rb +17 -0
- data/lib/glimmer/libui/shape/bezier.rb +9 -0
- data/lib/glimmer/libui/shape/circle.rb +7 -2
- data/lib/glimmer/libui/shape/figure.rb +12 -0
- data/lib/glimmer/libui/shape/line.rb +9 -0
- data/lib/glimmer/libui/shape/polybezier.rb +12 -0
- data/lib/glimmer/libui/shape/polygon.rb +11 -0
- data/lib/glimmer/libui/shape/polyline.rb +11 -0
- data/lib/glimmer/libui/shape/rectangle.rb +2 -2
- data/lib/glimmer/libui/shape.rb +9 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e20f859c1f0147fbdcdfe39d0caf2a284c922f0fd62d848e01a1ac6e6c05b6ee
|
4
|
+
data.tar.gz: a7cdd076d22cfeeb5675780c4f918364fac9f1207aa7d890ed1104effcb1ab3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abe17c4c1f3a398cf3e318a68e8502ab8c657e55e80f90c9ecaa5980e16494732a970e023421d9b5bf39908ab06360458fa3cff08776879b701912c00cf86fab
|
7
|
+
data.tar.gz: 5c7224ebd340795677d51673fc1d6f477f4db15134ce683f4dc16f3b29c070cc34eedf748b4ffd81c41fec22e95beeac50c34ab0263826591baf420f111592f4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.5.4
|
4
|
+
|
5
|
+
- Support `figure` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
6
|
+
- Have `path` `draw_fill_mode` return `:winding` or `:alternate` while `draw_fill_mode_value` returns `0` or `1` respectively
|
7
|
+
|
8
|
+
## 0.5.3
|
9
|
+
|
10
|
+
- Support `polyline` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
11
|
+
- Support `polygon` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
12
|
+
- Support `polybezier` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
13
|
+
|
14
|
+
## 0.5.2
|
15
|
+
|
16
|
+
- Support `line` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
17
|
+
- Support `bezier` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
18
|
+
|
19
|
+
## 0.5.1
|
20
|
+
|
21
|
+
- Upgrade to libui 0.0.14
|
22
|
+
- Alter `Shape#contain?` to support `outline: ` and `distance_tolerance: ` options as per perfect-shape gem
|
23
|
+
- Support `arc` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
24
|
+
- Support `circle` `bounding_box` (minx, miny, width, height), `contain?` method (checking if shape contains point inside) and `include?` method (checking on outline if stroked and inside if filled?)
|
25
|
+
|
3
26
|
## 0.5.0
|
4
27
|
|
5
28
|
- Upgrade to glimmer 2.6.0
|
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 LibUI 0.5.
|
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 LibUI 0.5.4
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
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)
|
@@ -519,7 +519,7 @@ gem install glimmer-dsl-libui
|
|
519
519
|
Or install via Bundler `Gemfile`:
|
520
520
|
|
521
521
|
```ruby
|
522
|
-
gem 'glimmer-dsl-libui', '~> 0.5.
|
522
|
+
gem 'glimmer-dsl-libui', '~> 0.5.4'
|
523
523
|
```
|
524
524
|
|
525
525
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -985,6 +985,14 @@ Mac | Windows | Linux
|
|
985
985
|
----|---------|------
|
986
986
|
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png) | ![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png) | ![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
987
987
|
|
988
|
+
##### Shape Methods
|
989
|
+
|
990
|
+
- `::parameters`: returns parameters of a shape class
|
991
|
+
- `#bounding_box`: returns `Array` containing `[min_x, min_y, width, height]`
|
992
|
+
- `#contain?(*point, outline: false, distance_tolerance: 0)`: Returns if point (`[x, y]` `Array` or args) is inside the shape when `outline` is `false` or on the outline when `outline` is `true`. `distance_tolerance` is used when `outline` is `true` as a fuzz factor for declaring a point on the outline of the shape (e.g. helps users select a shape from its outline more easily).
|
993
|
+
- `#include?(*point)`: Returns if point (`[x, y]` `Array` or args) is inside the shape when filled (having `fill` value) or on the outline when stroked (not having `fill` value yet `stroke` value only)
|
994
|
+
- `#perfect_shape`: returns [PerfectShape](https://github.com/AndyObtiva/perfect-shape) object matching the [libui](https://github.com/andlabs/libui) shape.
|
995
|
+
|
988
996
|
#### Area Text
|
989
997
|
|
990
998
|
To draw `text` in an `area`, you simply nest a `text(x, y, width)` control directly under `area` or inside a `on_draw` listener, and then nest attributed `string {[attributes]; string_value}` controls underneath it returning an actual `String` (think of them as the `<span>` or `<p>` element in html, which contains a string of text). Alternatively, you can nest attributed `string(string_value) {[attributes]}` if `string_value` is a short single-line string. An attributed `string` value can be changed dynamically via its `string` property.
|
@@ -5533,7 +5541,7 @@ class ColorTheCircles
|
|
5533
5541
|
|
5534
5542
|
def color_circle(x, y)
|
5535
5543
|
clicked_circle_data = @circles_data.find do |circle_data|
|
5536
|
-
circle_data[:fill].nil? && circle_data[:circle]&.
|
5544
|
+
circle_data[:fill].nil? && circle_data[:circle]&.contain?(x, y)
|
5537
5545
|
end
|
5538
5546
|
if clicked_circle_data
|
5539
5547
|
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
@@ -81,7 +81,7 @@ class ColorTheCircles
|
|
81
81
|
|
82
82
|
def color_circle(x, y)
|
83
83
|
clicked_circle_data = @circles_data.find do |circle_data|
|
84
|
-
circle_data[:fill].nil? && circle_data[:circle]&.
|
84
|
+
circle_data[:fill].nil? && circle_data[:circle]&.contain?(x, y)
|
85
85
|
end
|
86
86
|
if clicked_circle_data
|
87
87
|
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -60,6 +60,10 @@ module Glimmer
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def draw_fill_mode
|
63
|
+
@args[0].is_a?(Integer) ? (@args[0] == 0 ? :winding : :alternate ) : ((@args[0].is_a?(String) || @args[0].is_a?(Symbol)) ? @args[0].to_sym : :winding)
|
64
|
+
end
|
65
|
+
|
66
|
+
def draw_fill_mode_value
|
63
67
|
@args[0].is_a?(Integer) ? @args[0] : @args[0].to_s == 'alternate' ? 1 : 0
|
64
68
|
end
|
65
69
|
|
@@ -159,7 +163,7 @@ module Glimmer
|
|
159
163
|
private
|
160
164
|
|
161
165
|
def build_control
|
162
|
-
@libui = ::LibUI.draw_new_path(
|
166
|
+
@libui = ::LibUI.draw_new_path(draw_fill_mode_value)
|
163
167
|
end
|
164
168
|
|
165
169
|
def init_draw_brush(draw_brush, draw_brush_args)
|
@@ -44,6 +44,23 @@ module Glimmer
|
|
44
44
|
end
|
45
45
|
super
|
46
46
|
end
|
47
|
+
|
48
|
+
def perfect_shape
|
49
|
+
perfect_shape_dependencies = [x_center, y_center, radius, start_angle, sweep, is_negative]
|
50
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
51
|
+
x_center, y_center, radius, start_angle, sweep, is_negative = @perfect_shape_dependencies = perfect_shape_dependencies
|
52
|
+
sign = is_negative ? 1 : -1
|
53
|
+
start = is_negative ? (360 - start_angle) : -1*start_angle
|
54
|
+
extent = is_negative ? (360 - sweep) : -1*sweep
|
55
|
+
@perfect_shape = PerfectShape::Arc.new(
|
56
|
+
type: :open,
|
57
|
+
center_x: x_center, center_y: y_center,
|
58
|
+
radius_x: radius, radius_y: radius,
|
59
|
+
start: start, extent: extent
|
60
|
+
)
|
61
|
+
end
|
62
|
+
@perfect_shape
|
63
|
+
end
|
47
64
|
end
|
48
65
|
end
|
49
66
|
end
|
@@ -49,6 +49,15 @@ module Glimmer
|
|
49
49
|
def include_start_point?
|
50
50
|
x && y
|
51
51
|
end
|
52
|
+
|
53
|
+
def perfect_shape
|
54
|
+
perfect_shape_dependencies = [x, y, c1_x, c1_y, c2_x, c2_y, end_x, end_y]
|
55
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
56
|
+
x, y, c1_x, c1_y, c2_x, c2_y, end_x, end_y = @perfect_shape_dependencies = perfect_shape_dependencies
|
57
|
+
@perfect_shape = PerfectShape::CubicBezierCurve.new(points: [x, y, c1_x, c1_y, c2_x, c2_y, end_x, end_y].compact)
|
58
|
+
end
|
59
|
+
@perfect_shape
|
60
|
+
end
|
52
61
|
end
|
53
62
|
end
|
54
63
|
end
|
@@ -45,8 +45,13 @@ module Glimmer
|
|
45
45
|
super
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
|
48
|
+
def perfect_shape
|
49
|
+
perfect_shape_dependencies = [x_center, y_center, radius]
|
50
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
51
|
+
x_center, y_center, radius = @perfect_shape_dependencies = perfect_shape_dependencies
|
52
|
+
@perfect_shape = PerfectShape::Circle.new(center_x: x_center, center_y: y_center, radius: radius)
|
53
|
+
end
|
54
|
+
@perfect_shape
|
50
55
|
end
|
51
56
|
end
|
52
57
|
end
|
@@ -50,6 +50,18 @@ module Glimmer
|
|
50
50
|
alias closed= closed
|
51
51
|
alias set_closed closed
|
52
52
|
alias closed? closed
|
53
|
+
|
54
|
+
def perfect_shape
|
55
|
+
perfect_shape_dependencies = [x, y, closed, parent.draw_fill_mode, children]
|
56
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
57
|
+
x, y, closed, draw_fill_mode, children = @perfect_shape_dependencies = perfect_shape_dependencies
|
58
|
+
path_shapes = [[x, y]]
|
59
|
+
path_shapes += children.map(&:perfect_shape)
|
60
|
+
winding_rule = draw_fill_mode == :winding ? :wind_non_zero : :wind_even_odd
|
61
|
+
@perfect_shape = PerfectShape::Path.new(closed: closed, winding_rule: winding_rule, shapes: path_shapes)
|
62
|
+
end
|
63
|
+
@perfect_shape
|
64
|
+
end
|
53
65
|
end
|
54
66
|
end
|
55
67
|
end
|
@@ -52,6 +52,15 @@ module Glimmer
|
|
52
52
|
# start point
|
53
53
|
!parent.is_a?(Figure) && end_x && end_y
|
54
54
|
end
|
55
|
+
|
56
|
+
def perfect_shape
|
57
|
+
perfect_shape_dependencies = [x, y, end_x, end_y]
|
58
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
59
|
+
x, y, end_x, end_y = @perfect_shape_dependencies = perfect_shape_dependencies
|
60
|
+
@perfect_shape = PerfectShape::Line.new(points: [x, y, end_x, end_y].compact)
|
61
|
+
end
|
62
|
+
@perfect_shape
|
63
|
+
end
|
55
64
|
end
|
56
65
|
end
|
57
66
|
end
|
@@ -39,6 +39,18 @@ module Glimmer
|
|
39
39
|
end
|
40
40
|
super
|
41
41
|
end
|
42
|
+
|
43
|
+
def perfect_shape
|
44
|
+
perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
|
45
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
46
|
+
point_array = @perfect_shape_dependencies = perfect_shape_dependencies
|
47
|
+
path_shapes = [point_array.first]
|
48
|
+
bezier_shape_points = point_array.drop(1).each.with_index.to_a.group_by {|pair| pair.last/3}.values.map {|arr| arr.map(&:first)}
|
49
|
+
path_shapes += bezier_shape_points.map { |points| PerfectShape::CubicBezierCurve.new(points: points) }
|
50
|
+
@perfect_shape = PerfectShape::Path.new(closed: false, shapes: path_shapes)
|
51
|
+
end
|
52
|
+
@perfect_shape
|
53
|
+
end
|
42
54
|
end
|
43
55
|
end
|
44
56
|
end
|
@@ -40,6 +40,17 @@ module Glimmer
|
|
40
40
|
end
|
41
41
|
super
|
42
42
|
end
|
43
|
+
|
44
|
+
def perfect_shape
|
45
|
+
perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
|
46
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
47
|
+
point_array = @perfect_shape_dependencies = perfect_shape_dependencies
|
48
|
+
path_shapes = [point_array.first]
|
49
|
+
path_shapes += point_array.drop(1).map { |point| PerfectShape::Line.new(points: [point]) }
|
50
|
+
@perfect_shape = PerfectShape::Path.new(closed: true, shapes: path_shapes)
|
51
|
+
end
|
52
|
+
@perfect_shape
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
@@ -39,6 +39,17 @@ module Glimmer
|
|
39
39
|
end
|
40
40
|
super
|
41
41
|
end
|
42
|
+
|
43
|
+
def perfect_shape
|
44
|
+
perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
|
45
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
46
|
+
point_array = @perfect_shape_dependencies = perfect_shape_dependencies
|
47
|
+
path_shapes = [point_array.first]
|
48
|
+
path_shapes += point_array.drop(1).map { |point| PerfectShape::Line.new(points: [point]) }
|
49
|
+
@perfect_shape = PerfectShape::Path.new(closed: false, shapes: path_shapes)
|
50
|
+
end
|
51
|
+
@perfect_shape
|
52
|
+
end
|
42
53
|
end
|
43
54
|
end
|
44
55
|
end
|
@@ -36,8 +36,8 @@ module Glimmer
|
|
36
36
|
def perfect_shape
|
37
37
|
perfect_shape_dependencies = [x, y, width, height]
|
38
38
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
39
|
-
@perfect_shape_dependencies = perfect_shape_dependencies
|
40
|
-
@perfect_shape = PerfectShape::Rectangle.new(x:
|
39
|
+
x, y, width, height = @perfect_shape_dependencies = perfect_shape_dependencies
|
40
|
+
@perfect_shape = PerfectShape::Rectangle.new(x: x, y: y, width: width, height: height)
|
41
41
|
end
|
42
42
|
@perfect_shape
|
43
43
|
end
|
data/lib/glimmer/libui/shape.rb
CHANGED
@@ -146,18 +146,22 @@ module Glimmer
|
|
146
146
|
alias transform= transform
|
147
147
|
alias set_transform transform
|
148
148
|
|
149
|
-
# Returns if shape contains point on the inside
|
150
|
-
|
151
|
-
|
149
|
+
# Returns if shape contains point on the inside when outline is false (default)
|
150
|
+
# or if point is on the outline when outline is true
|
151
|
+
# distance_tolerance is used when outline is true to enable a fuzz factor in
|
152
|
+
# determining if a point lies on the outline (e.g. makes it easier to select
|
153
|
+
# a shape by mouse)
|
154
|
+
def contain?(*point, outline: false, distance_tolerance: 0)
|
155
|
+
perfect_shape&.contain?(*point, outline: outline, distance_tolerance: distance_tolerance)
|
152
156
|
end
|
153
157
|
|
154
158
|
# Returns if shape includes point on the inside when filled
|
155
159
|
# or if shape includes point on the outline when stroked
|
156
160
|
def include?(*point)
|
157
161
|
if fill.empty?
|
158
|
-
|
162
|
+
contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
|
159
163
|
else
|
160
|
-
|
164
|
+
contain?(*point)
|
161
165
|
end
|
162
166
|
end
|
163
167
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.
|
33
|
+
version: 1.0.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.
|
40
|
+
version: 1.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: os
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.0.
|
81
|
+
version: 0.0.14
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 0.0.
|
88
|
+
version: 0.0.14
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: chunky_png
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|