glimmer-dsl-libui 0.5.8 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +26 -0
- data/lib/glimmer/libui/perfect_shaped.rb +46 -0
- data/lib/glimmer/libui/shape/figure.rb +7 -2
- data/lib/glimmer/libui/shape.rb +3 -41
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a198df8af13246ffee6aa56434bfa89740e9211e19da28fb0dddb1705000eec
|
4
|
+
data.tar.gz: cb4c0b685980983fb17cc3f501165d8fa788a56ce4da9ced03630a78329045af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3809a094cb6cd607d94c0d37c10f67213c3bab4cc3d74d7d8d3c4d49514da75e3ae2b99328d09291f4905b7d3c85aea14f6935f22d3cac249edf533eff5e575d
|
7
|
+
data.tar.gz: 3efefe3c53b4520b077165df099f9427f112c7cc1acafed0d878fe187d65657264b6317de470e6330a12c63bde1edd4694455bc675be87f8e374ee0113235ae0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.5.9
|
4
|
+
|
5
|
+
- Upgrade to glimmer v2.7.3
|
6
|
+
- Upgrade to perfect-shape v1.0.3
|
7
|
+
- Support `path`/`figure`/shape `#contain?`, `#include?`, and `#bounding_box` methods via perfect-shape algorithms applying the path winding rule (aka `draw_fill_mode`)
|
8
|
+
|
3
9
|
## 0.5.8
|
4
10
|
|
5
11
|
- Support `code_area` class-based custom control as a code-syntax-highlighted `area` control using the `rouge` gem
|
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.9
|
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)
|
@@ -322,11 +322,11 @@ Mac | Windows | Linux
|
|
322
322
|
|
323
323
|
[Check Out Many More Examples Over Here!](#examples)
|
324
324
|
|
325
|
-
![glimmer-dsl-libui-mac-snake.gif](images/glimmer-dsl-libui-mac-snake.gif)
|
325
|
+
[![glimmer-dsl-libui-mac-snake.gif](images/glimmer-dsl-libui-mac-snake.gif)](https://github.com/AndyObtiva/glimmer-dsl-libui#snake)
|
326
326
|
|
327
|
-
![glimmer-dsl-libui-mac-color-the-circles.gif](images/glimmer-dsl-libui-mac-color-the-circles.gif)
|
327
|
+
[![glimmer-dsl-libui-mac-color-the-circles.gif](images/glimmer-dsl-libui-mac-color-the-circles.gif)](https://github.com/AndyObtiva/glimmer-dsl-libui#color-the-circles)
|
328
328
|
|
329
|
-
![glimmer-dsl-libui-mac-tetris.gif](images/glimmer-dsl-libui-mac-tetris.gif)
|
329
|
+
[![glimmer-dsl-libui-mac-tetris.gif](images/glimmer-dsl-libui-mac-tetris.gif)](https://github.com/AndyObtiva/glimmer-dsl-libui#tetris)
|
330
330
|
|
331
331
|
NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is 100% feature-complete with regards to covering the C [libui](https://github.com/andlabs/libui) library API and in beta mode (though the C [libui](https://github.com/andlabs/libui) is still mid-alpha, which is why [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) cannot be declared v1.0.0 yet). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. The more feedback and issues you report the better.
|
332
332
|
|
@@ -578,7 +578,7 @@ gem install glimmer-dsl-libui
|
|
578
578
|
Or install via Bundler `Gemfile`:
|
579
579
|
|
580
580
|
```ruby
|
581
|
-
gem 'glimmer-dsl-libui', '~> 0.5.
|
581
|
+
gem 'glimmer-dsl-libui', '~> 0.5.9'
|
582
582
|
```
|
583
583
|
|
584
584
|
Test that installation worked by running the [Meta-Example](#examples):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.9
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -23,6 +23,7 @@ require 'glimmer/libui/control_proxy'
|
|
23
23
|
require 'glimmer/libui/control_proxy/area_proxy'
|
24
24
|
require 'glimmer/libui/parent'
|
25
25
|
require 'glimmer/libui/control_proxy/transformable'
|
26
|
+
require 'glimmer/libui/perfect_shaped'
|
26
27
|
|
27
28
|
module Glimmer
|
28
29
|
module LibUI
|
@@ -32,6 +33,7 @@ module Glimmer
|
|
32
33
|
# Follows the Proxy Design Pattern
|
33
34
|
class PathProxy < ControlProxy
|
34
35
|
include Parent
|
36
|
+
include PerfectShaped
|
35
37
|
prepend Transformable
|
36
38
|
|
37
39
|
def initialize(keyword, parent, args, &block)
|
@@ -160,6 +162,30 @@ module Glimmer
|
|
160
162
|
@parent_proxy&.request_auto_redraw
|
161
163
|
end
|
162
164
|
|
165
|
+
def perfect_shape
|
166
|
+
perfect_shape_dependencies = [draw_fill_mode, children]
|
167
|
+
if perfect_shape_dependencies != @perfect_shape_dependencies
|
168
|
+
draw_fill_mode, children = @perfect_shape_dependencies = perfect_shape_dependencies
|
169
|
+
shapes = children.map(&:perfect_shape)
|
170
|
+
new_shapes = []
|
171
|
+
shapes.each do |shape|
|
172
|
+
if shape.is_a?(PerfectShape::Path)
|
173
|
+
new_shapes += shape.basic_shapes
|
174
|
+
else
|
175
|
+
new_shapes << shape
|
176
|
+
end
|
177
|
+
end
|
178
|
+
shapes = new_shapes
|
179
|
+
winding_rule = draw_fill_mode == :winding ? :wind_non_zero : :wind_even_odd
|
180
|
+
@perfect_shape = PerfectShape::Path.new(
|
181
|
+
shapes: shapes,
|
182
|
+
winding_rule: winding_rule,
|
183
|
+
line_to_complex_shapes: true
|
184
|
+
)
|
185
|
+
end
|
186
|
+
@perfect_shape
|
187
|
+
end
|
188
|
+
|
163
189
|
private
|
164
190
|
|
165
191
|
def build_control
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Glimmer
|
2
|
+
module LibUI
|
3
|
+
# GUI View objects that can be represented by PerfectShape objects
|
4
|
+
module PerfectShaped
|
5
|
+
# Returns if shape contains point on the inside when outline is false (default)
|
6
|
+
# or if point is on the outline when outline is true
|
7
|
+
# distance_tolerance is used when outline is true to enable a fuzz factor in
|
8
|
+
# determining if a point lies on the outline (e.g. makes it easier to select
|
9
|
+
# a shape by mouse)
|
10
|
+
def contain?(*point, outline: false, distance_tolerance: 0)
|
11
|
+
perfect_shape&.contain?(*point, outline: outline, distance_tolerance: distance_tolerance)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns if shape includes point on the inside when filled
|
15
|
+
# or if shape includes point on the outline when stroked
|
16
|
+
def include?(*point)
|
17
|
+
if fill.empty?
|
18
|
+
contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
|
19
|
+
else
|
20
|
+
contain?(*point)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns bounding box Array consisting of
|
25
|
+
# [minx, miny, width, height]
|
26
|
+
def bounding_box
|
27
|
+
perfect_shape_bounding_box = perfect_shape&.bounding_box
|
28
|
+
return if perfect_shape_bounding_box.nil?
|
29
|
+
[
|
30
|
+
perfect_shape_bounding_box.x,
|
31
|
+
perfect_shape_bounding_box.y,
|
32
|
+
perfect_shape_bounding_box.width,
|
33
|
+
perfect_shape_bounding_box.height,
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns PerfectShape object matching this shape to enable
|
38
|
+
# executing computational geometry algorithms
|
39
|
+
#
|
40
|
+
# Including classes must implement
|
41
|
+
def perfect_shape
|
42
|
+
# No Op
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -29,7 +29,7 @@ module Glimmer
|
|
29
29
|
class Figure < Shape
|
30
30
|
parameters :x, :y
|
31
31
|
parameter_defaults nil, nil
|
32
|
-
|
32
|
+
|
33
33
|
def draw(area_draw_params)
|
34
34
|
::LibUI.draw_path_new_figure(path_proxy.libui, *@args) unless @args.compact.empty? # TODO if args empty then wait till there is an arc child and it starts the figure
|
35
35
|
children.dup.each {|child| child.draw(area_draw_params)}
|
@@ -58,7 +58,12 @@ module Glimmer
|
|
58
58
|
path_shapes = [[x, y]]
|
59
59
|
path_shapes += children.map(&:perfect_shape)
|
60
60
|
winding_rule = draw_fill_mode == :winding ? :wind_non_zero : :wind_even_odd
|
61
|
-
@perfect_shape = PerfectShape::Path.new(
|
61
|
+
@perfect_shape = PerfectShape::Path.new(
|
62
|
+
closed: closed,
|
63
|
+
winding_rule: winding_rule,
|
64
|
+
shapes: path_shapes,
|
65
|
+
line_to_complex_shapes: true
|
66
|
+
)
|
62
67
|
end
|
63
68
|
@perfect_shape
|
64
69
|
end
|
data/lib/glimmer/libui/shape.rb
CHANGED
@@ -23,6 +23,7 @@ require 'glimmer/libui/parent'
|
|
23
23
|
require 'glimmer/libui/control_proxy/area_proxy'
|
24
24
|
require 'glimmer/libui/control_proxy/path_proxy'
|
25
25
|
require 'glimmer/libui/data_bindable'
|
26
|
+
require 'glimmer/libui/perfect_shaped'
|
26
27
|
|
27
28
|
module Glimmer
|
28
29
|
module LibUI
|
@@ -65,6 +66,7 @@ module Glimmer
|
|
65
66
|
end
|
66
67
|
|
67
68
|
include Parent
|
69
|
+
include PerfectShaped
|
68
70
|
include DataBindable
|
69
71
|
|
70
72
|
attr_reader :parent, :args, :keyword, :block, :content_added
|
@@ -145,47 +147,7 @@ module Glimmer
|
|
145
147
|
end
|
146
148
|
alias transform= transform
|
147
149
|
alias set_transform transform
|
148
|
-
|
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)
|
156
|
-
end
|
157
|
-
|
158
|
-
# Returns if shape includes point on the inside when filled
|
159
|
-
# or if shape includes point on the outline when stroked
|
160
|
-
def include?(*point)
|
161
|
-
if fill.empty?
|
162
|
-
contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
|
163
|
-
else
|
164
|
-
contain?(*point)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
# Returns bounding box Array consisting of
|
169
|
-
# [minx, miny, width, height]
|
170
|
-
def bounding_box
|
171
|
-
perfect_shape_bounding_box = perfect_shape&.bounding_box
|
172
|
-
return if perfect_shape_bounding_box.nil?
|
173
|
-
[
|
174
|
-
perfect_shape_bounding_box.x,
|
175
|
-
perfect_shape_bounding_box.y,
|
176
|
-
perfect_shape_bounding_box.width,
|
177
|
-
perfect_shape_bounding_box.height,
|
178
|
-
]
|
179
|
-
end
|
180
|
-
|
181
|
-
# Returns PerfectShape object matching this shape to enable
|
182
|
-
# executing computational geometry algorithms
|
183
|
-
#
|
184
|
-
# Subclasses must implement
|
185
|
-
def perfect_shape
|
186
|
-
# No Op
|
187
|
-
end
|
188
|
-
|
150
|
+
|
189
151
|
def respond_to?(method_name, *args, &block)
|
190
152
|
self.class.parameters.include?(method_name.to_s.sub(/=$/, '').sub(/^set_/, '').to_sym) or
|
191
153
|
super(method_name, true)
|
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.9
|
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-
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.7.
|
19
|
+
version: 2.7.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.7.
|
26
|
+
version: 2.7.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: perfect-shape
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.
|
33
|
+
version: 1.0.3
|
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.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: super_module
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -471,6 +471,7 @@ files:
|
|
471
471
|
- lib/glimmer/libui/data_bindable.rb
|
472
472
|
- lib/glimmer/libui/image_path_renderer.rb
|
473
473
|
- lib/glimmer/libui/parent.rb
|
474
|
+
- lib/glimmer/libui/perfect_shaped.rb
|
474
475
|
- lib/glimmer/libui/shape.rb
|
475
476
|
- lib/glimmer/libui/shape/arc.rb
|
476
477
|
- lib/glimmer/libui/shape/bezier.rb
|
@@ -509,7 +510,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
509
510
|
- !ruby/object:Gem::Version
|
510
511
|
version: '0'
|
511
512
|
requirements: []
|
512
|
-
rubygems_version: 3.3.
|
513
|
+
rubygems_version: 3.3.1
|
513
514
|
signing_key:
|
514
515
|
specification_version: 4
|
515
516
|
summary: Glimmer DSL for LibUI
|