glimmer-dsl-libui 0.5.9 → 0.5.10
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 +126 -2
- data/VERSION +1 -1
- data/examples/shape_coloring.rb +93 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/listener_expression.rb +1 -1
- data/lib/glimmer/libui/shape.rb +10 -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: a21485d1722dad246e40058c46dc14b63103e93b1243db1c0ae49bc3b96f96ab
|
4
|
+
data.tar.gz: 390bac7628f29d016bfac073d926011d5fd91d10e7c23a95cae8b59c0bb4a55f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43aa1f65c47353b9ce340ff18264edaf6d9e6c09ee700919e3661b56d2bc8db00f1b31dd365b0a62ae7e39323dc07ba247bb0d06da24f51b01e477ceefa99a34
|
7
|
+
data.tar.gz: c58efb32bc59359ec84cc804eec113004191fa0031676f0af7224c91b8271fb4851939ea761ddbecbc9ca912065bd4616869c76c05c95306991e5e0c68c73bf3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.5.10
|
4
|
+
|
5
|
+
- Support nesting area mouse and keyboard listeners underneath shapes directly given the newly added support for the `include?(x, y)` method, which can be used to detect if a mouse or keyboard event fired for a specific shape
|
6
|
+
- examples/shape_coloring.rb
|
7
|
+
|
3
8
|
## 0.5.9
|
4
9
|
|
5
10
|
- Upgrade to glimmer v2.7.3
|
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.10
|
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)
|
@@ -428,6 +428,7 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
|
|
428
428
|
- [Tetris](#tetris)
|
429
429
|
- [Tic Tac Toe](#tic-tac-toe)
|
430
430
|
- [Timer](#timer)
|
431
|
+
- [Shape Coloring](#shape-coloring)
|
431
432
|
- [Applications](#applications)
|
432
433
|
- [Manga2PDF](#manga2pdf)
|
433
434
|
- [Befunge98 GUI](#befunge98-gui)
|
@@ -578,7 +579,7 @@ gem install glimmer-dsl-libui
|
|
578
579
|
Or install via Bundler `Gemfile`:
|
579
580
|
|
580
581
|
```ruby
|
581
|
-
gem 'glimmer-dsl-libui', '~> 0.5.
|
582
|
+
gem 'glimmer-dsl-libui', '~> 0.5.10'
|
582
583
|
```
|
583
584
|
|
584
585
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -1392,6 +1393,10 @@ In general, it is recommended to use declarative stable paths whenever feasible
|
|
1392
1393
|
|
1393
1394
|
#### Area Listeners
|
1394
1395
|
|
1396
|
+
`area` supports a number of keyboard and mouse listeners to enable observing the control for user interaction to execute some logic.
|
1397
|
+
|
1398
|
+
The same listeners can be nested directly under `area` shapes like `rectangle` and `circle`, and [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) will automatically detect when the mouse lands within those shapes to constrain triggering the listeners by the shape regions.
|
1399
|
+
|
1395
1400
|
`area` supported listeners are:
|
1396
1401
|
- `on_key_event {|area_key_event| ...}`: general catch-all key event (recommend using fine-grained key events below instead)
|
1397
1402
|
- `on_key_down {|area_key_event| ...}`
|
@@ -11016,6 +11021,125 @@ end
|
|
11016
11021
|
Timer.new
|
11017
11022
|
```
|
11018
11023
|
|
11024
|
+
#### Shape Coloring
|
11025
|
+
|
11026
|
+
This example demonstrates being able to nest a listener within shapes directly, and [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) will automatically detect when the mouse lands inside a shape to notify listener.
|
11027
|
+
|
11028
|
+
[examples/shape_coloring.rb](examples/shape_coloring.rb)
|
11029
|
+
|
11030
|
+
Run with this command from the root of the project if you cloned the project:
|
11031
|
+
|
11032
|
+
```
|
11033
|
+
ruby -r './lib/glimmer-dsl-libui' examples/shape_coloring.rb
|
11034
|
+
```
|
11035
|
+
|
11036
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
11037
|
+
|
11038
|
+
```
|
11039
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/shape_coloring'"
|
11040
|
+
```
|
11041
|
+
|
11042
|
+
![glimmer-dsl-libui-mac-shape-coloring.png](images/glimmer-dsl-libui-mac-shape-coloring.png)
|
11043
|
+
![glimmer-dsl-libui-mac-shape-coloring-color-dialog.png](images/glimmer-dsl-libui-mac-shape-coloring-color-dialog.png)
|
11044
|
+
|
11045
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
11046
|
+
|
11047
|
+
```ruby
|
11048
|
+
require 'glimmer-dsl-libui'
|
11049
|
+
|
11050
|
+
class ShapeColoring
|
11051
|
+
include Glimmer::LibUI::Application
|
11052
|
+
|
11053
|
+
COLOR_SELECTION = Glimmer::LibUI.interpret_color(:red)
|
11054
|
+
|
11055
|
+
before_body {
|
11056
|
+
@shapes = []
|
11057
|
+
}
|
11058
|
+
|
11059
|
+
body {
|
11060
|
+
window('Shape Coloring', 200, 200) {
|
11061
|
+
margined false
|
11062
|
+
|
11063
|
+
grid {
|
11064
|
+
label("Click a shape to select and\nchange color via color button") {
|
11065
|
+
left 0
|
11066
|
+
top 0
|
11067
|
+
hexpand true
|
11068
|
+
halign :center
|
11069
|
+
vexpand false
|
11070
|
+
}
|
11071
|
+
|
11072
|
+
color_button { |cb|
|
11073
|
+
left 0
|
11074
|
+
top 1
|
11075
|
+
hexpand true
|
11076
|
+
vexpand false
|
11077
|
+
|
11078
|
+
on_changed do
|
11079
|
+
@selected_shape&.fill = cb.color
|
11080
|
+
end
|
11081
|
+
}
|
11082
|
+
|
11083
|
+
area {
|
11084
|
+
left 0
|
11085
|
+
top 2
|
11086
|
+
hexpand true
|
11087
|
+
vexpand true
|
11088
|
+
|
11089
|
+
rectangle(0, 0, 600, 400) { # background shape
|
11090
|
+
fill :white
|
11091
|
+
}
|
11092
|
+
|
11093
|
+
@shapes << colorable(:rectangle, 20, 20, 40, 20) { |shape|
|
11094
|
+
fill :lime
|
11095
|
+
}
|
11096
|
+
|
11097
|
+
@shapes << colorable(:square, 80, 20, 20) { |shape|
|
11098
|
+
fill :blue
|
11099
|
+
}
|
11100
|
+
|
11101
|
+
@shapes << colorable(:circle, 75, 70, 20, 20) { |shape|
|
11102
|
+
fill :green
|
11103
|
+
}
|
11104
|
+
|
11105
|
+
@shapes << colorable(:arc, 120, 70, 40, 0, 145) { |shape|
|
11106
|
+
fill :orange
|
11107
|
+
}
|
11108
|
+
|
11109
|
+
@shapes << colorable(:polygon, 120, 10, 120, 50, 150, 10, 150, 50) {
|
11110
|
+
fill :cyan
|
11111
|
+
}
|
11112
|
+
|
11113
|
+
@shapes << colorable(:polybezier, 20, 40,
|
11114
|
+
30, 100, 50, 80, 80, 110,
|
11115
|
+
40, 120, 20, 120, 30, 91) {
|
11116
|
+
fill :pink
|
11117
|
+
}
|
11118
|
+
}
|
11119
|
+
}
|
11120
|
+
}
|
11121
|
+
}
|
11122
|
+
|
11123
|
+
def colorable(shape_symbol, *args, &content)
|
11124
|
+
send(shape_symbol, *args) do |shape|
|
11125
|
+
on_mouse_up do |area_mouse_event|
|
11126
|
+
old_stroke = Glimmer::LibUI.interpret_color(shape.stroke).slice(:r, :g, :b)
|
11127
|
+
@shapes.each {|sh| sh.stroke = nil}
|
11128
|
+
@selected_shape = nil
|
11129
|
+
unless old_stroke == COLOR_SELECTION
|
11130
|
+
shape.stroke = COLOR_SELECTION.merge(thickness: 2)
|
11131
|
+
@selected_shape = shape
|
11132
|
+
end
|
11133
|
+
end
|
11134
|
+
|
11135
|
+
content.call(shape)
|
11136
|
+
end
|
11137
|
+
end
|
11138
|
+
end
|
11139
|
+
|
11140
|
+
ShapeColoring.launch
|
11141
|
+
```
|
11142
|
+
|
11019
11143
|
## Applications
|
11020
11144
|
|
11021
11145
|
Here are some applications built with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.10
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
|
3
|
+
class ShapeColoring
|
4
|
+
include Glimmer::LibUI::Application
|
5
|
+
|
6
|
+
COLOR_SELECTION = Glimmer::LibUI.interpret_color(:red)
|
7
|
+
|
8
|
+
before_body {
|
9
|
+
@shapes = []
|
10
|
+
}
|
11
|
+
|
12
|
+
body {
|
13
|
+
window('Shape Coloring', 200, 200) {
|
14
|
+
margined false
|
15
|
+
|
16
|
+
grid {
|
17
|
+
label("Click a shape to select and\nchange color via color button") {
|
18
|
+
left 0
|
19
|
+
top 0
|
20
|
+
hexpand true
|
21
|
+
halign :center
|
22
|
+
vexpand false
|
23
|
+
}
|
24
|
+
|
25
|
+
color_button { |cb|
|
26
|
+
left 0
|
27
|
+
top 1
|
28
|
+
hexpand true
|
29
|
+
vexpand false
|
30
|
+
|
31
|
+
on_changed do
|
32
|
+
@selected_shape&.fill = cb.color
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
area {
|
37
|
+
left 0
|
38
|
+
top 2
|
39
|
+
hexpand true
|
40
|
+
vexpand true
|
41
|
+
|
42
|
+
rectangle(0, 0, 600, 400) { # background shape
|
43
|
+
fill :white
|
44
|
+
}
|
45
|
+
|
46
|
+
@shapes << colorable(:rectangle, 20, 20, 40, 20) { |shape|
|
47
|
+
fill :lime
|
48
|
+
}
|
49
|
+
|
50
|
+
@shapes << colorable(:square, 80, 20, 20) { |shape|
|
51
|
+
fill :blue
|
52
|
+
}
|
53
|
+
|
54
|
+
@shapes << colorable(:circle, 75, 70, 20, 20) { |shape|
|
55
|
+
fill :green
|
56
|
+
}
|
57
|
+
|
58
|
+
@shapes << colorable(:arc, 120, 70, 40, 0, 145) { |shape|
|
59
|
+
fill :orange
|
60
|
+
}
|
61
|
+
|
62
|
+
@shapes << colorable(:polygon, 120, 10, 120, 50, 150, 10, 150, 50) {
|
63
|
+
fill :cyan
|
64
|
+
}
|
65
|
+
|
66
|
+
@shapes << colorable(:polybezier, 20, 40,
|
67
|
+
30, 100, 50, 80, 80, 110,
|
68
|
+
40, 120, 20, 120, 30, 91) {
|
69
|
+
fill :pink
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
def colorable(shape_symbol, *args, &content)
|
77
|
+
send(shape_symbol, *args) do |shape|
|
78
|
+
on_mouse_up do |area_mouse_event|
|
79
|
+
old_stroke = Glimmer::LibUI.interpret_color(shape.stroke).slice(:r, :g, :b)
|
80
|
+
@shapes.each {|sh| sh.stroke = nil}
|
81
|
+
@selected_shape = nil
|
82
|
+
unless old_stroke == COLOR_SELECTION
|
83
|
+
shape.stroke = COLOR_SELECTION.merge(thickness: 2)
|
84
|
+
@selected_shape = shape
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
content.call(shape)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
ShapeColoring.launch
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -27,7 +27,7 @@ module Glimmer
|
|
27
27
|
module Libui
|
28
28
|
class ListenerExpression < Expression
|
29
29
|
def can_interpret?(parent, keyword, *args, &block)
|
30
|
-
parent.is_a?(Glimmer::LibUI::ControlProxy) and
|
30
|
+
(parent.is_a?(Glimmer::LibUI::ControlProxy) or parent.is_a?(Glimmer::LibUI::Shape)) and
|
31
31
|
block_given? and
|
32
32
|
parent.can_handle_listener?(keyword)
|
33
33
|
end
|
data/lib/glimmer/libui/shape.rb
CHANGED
@@ -147,6 +147,16 @@ module Glimmer
|
|
147
147
|
end
|
148
148
|
alias transform= transform
|
149
149
|
alias set_transform transform
|
150
|
+
|
151
|
+
def can_handle_listener?(listener_name)
|
152
|
+
area_proxy.can_handle_listener?(listener_name)
|
153
|
+
end
|
154
|
+
|
155
|
+
def handle_listener(listener_name, &listener)
|
156
|
+
area_proxy.handle_listener(listener_name) do |event|
|
157
|
+
listener.call(event) if include?(event[:x], event[:y])
|
158
|
+
end
|
159
|
+
end
|
150
160
|
|
151
161
|
def respond_to?(method_name, *args, &block)
|
152
162
|
self.class.parameters.include?(method_name.to_s.sub(/=$/, '').sub(/^set_/, '').to_sym) or
|
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.10
|
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-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -355,6 +355,7 @@ files:
|
|
355
355
|
- examples/midi_player.rb
|
356
356
|
- examples/midi_player2.rb
|
357
357
|
- examples/midi_player3.rb
|
358
|
+
- examples/shape_coloring.rb
|
358
359
|
- examples/simple_notepad.rb
|
359
360
|
- examples/snake.rb
|
360
361
|
- examples/snake/model/apple.rb
|