glimmer-dsl-libui 0.5.0 → 0.5.1

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: 40d0cbf805427a73645a86c95d7fa1c36f030c24ca6a19b1273f7b37c2426f05
4
- data.tar.gz: f8e728ea7b9e8b3a4393e8ba02d2958b5330d8d4292ed694a8ed02b0b651a1c9
3
+ metadata.gz: 04aa1c93edebb982ee709366ff59b81a93a7dc79b8263ae17852f1d8302a3017
4
+ data.tar.gz: ca30e790f8c93262de84920fbd0a22c584eab485d5fc4467f3ac9d52310a4410
5
5
  SHA512:
6
- metadata.gz: b79c4c8bb0138fb0059cd9bc0a9dfd5327245214c1eb1c4270c914b31065f832d065b73a6f365643eb7807c92420ed222ee91b8324dfde599c8047d6d2fc45ff
7
- data.tar.gz: c2583ac2d4f84aa26f8a6528e49392c1bc2e7fea908f62787bf9378929093adc1e4058450e687e5d61cbf2ed58157b59a34300d70a1f44ea4714f757324fb399
6
+ metadata.gz: 4c553da5930af45532c1b9ea8cb11c48d29d0b24a6229c7abeb28854c71d4e2e3cc933f2bc8a5231c8fe5debc7e424a03b316b56a805c68a235d25605ef7ff2c
7
+ data.tar.gz: a06cf47acaa964bfd73d5385082c4949ef9b76e0a54db230d29d961626367880e13e8e00cf63e3b78e40bb1cdafec29ea589e40b934ecc08268e768a5a2b48ac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.5.1
4
+
5
+ - Upgrade to libui 0.0.14
6
+ - Alter `Shape#contain?` to support `outline: ` and `distance_tolerance: ` options as per perfect-shape gem
7
+ - 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?)
8
+ - 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?)
9
+
3
10
  ## 0.5.0
4
11
 
5
12
  - 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.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 LibUI 0.5.1
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.0'
522
+ gem 'glimmer-dsl-libui', '~> 0.5.1'
523
523
  ```
524
524
 
525
525
  Test that installation worked by running the [Meta-Example](#examples):
@@ -5533,7 +5533,7 @@ class ColorTheCircles
5533
5533
 
5534
5534
  def color_circle(x, y)
5535
5535
  clicked_circle_data = @circles_data.find do |circle_data|
5536
- circle_data[:fill].nil? && circle_data[:circle]&.include?(x, y)
5536
+ circle_data[:fill].nil? && circle_data[:circle]&.contain?(x, y)
5537
5537
  end
5538
5538
  if clicked_circle_data
5539
5539
  clicked_circle_data[:fill] = clicked_circle_data[:stroke]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -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]&.include?(x, y)
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]
Binary file
@@ -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
@@ -45,8 +45,13 @@ module Glimmer
45
45
  super
46
46
  end
47
47
 
48
- def include?(x, y)
49
- (x - x_center)**2 + (y - y_center)**2 < radius**2
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
@@ -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: @perfect_shape_dependencies[0], y: @perfect_shape_dependencies[1], width: @perfect_shape_dependencies[2], height: @perfect_shape_dependencies[3])
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
@@ -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
- def contain?(*point)
151
- perfect_shape&.contain?(*point)
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
- perfect_shape&.contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
162
+ contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
159
163
  else
160
- perfect_shape&.contain?(*point)
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.0
4
+ version: 0.5.1
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-13 00:00:00.000000000 Z
11
+ date: 2022-02-16 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.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.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.13
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.13
88
+ version: 0.0.14
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: chunky_png
91
91
  requirement: !ruby/object:Gem::Requirement