glimmer-dsl-libui 0.5.10 → 0.5.13
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 -1
- data/README.md +92 -19
- data/VERSION +1 -1
- data/examples/shape_coloring.rb +56 -12
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +4 -0
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +17 -3
- data/lib/glimmer/libui/perfect_shaped.rb +19 -0
- data/lib/glimmer/libui/shape/arc.rb +5 -0
- data/lib/glimmer/libui/shape/bezier.rb +11 -0
- data/lib/glimmer/libui/shape/circle.rb +5 -0
- data/lib/glimmer/libui/shape/figure.rb +6 -0
- data/lib/glimmer/libui/shape/line.rb +7 -0
- data/lib/glimmer/libui/shape/polybezier.rb +4 -0
- data/lib/glimmer/libui/shape/polygon.rb +4 -0
- data/lib/glimmer/libui/shape/polyline.rb +4 -0
- data/lib/glimmer/libui/shape/rectangle.rb +5 -0
- data/lib/glimmer/libui/shape/square.rb +5 -0
- data/lib/glimmer/libui/shape.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec966c5f1dcd6315fe94455e2a8257df7ed6274ada0d74419e53b9abeab99bb
|
4
|
+
data.tar.gz: 5f1f410e8a239735c1188d4a7bdad00f9fed6e34ba71ba5c2ac65f01b8f49037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 574718284c8933f27d088777e9ffd77a37922f3f51ec90e85026f1d86f572c84bea4d86141fc3b67bb5192769ac03e13dca791b3ce6b8d2ae88235008ba4cbcf
|
7
|
+
data.tar.gz: 87656800ed048be0ffc15520e5988b911fac60bcdb73db16fd962e5820d2d2c948a08a14c1c22aaef4543623d8f2c803c7d10e0c106bc40c13942bddaf83cfda
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,30 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.5.13
|
4
|
+
|
5
|
+
- Fix issue with rendering table content changes when having many rows
|
6
|
+
|
7
|
+
## 0.5.12
|
8
|
+
|
9
|
+
- Upgrade `perfect-shape` gem to 1.0.5 to address Ruby 3.1 issue with `matrix` gem getting extracted from Ruby into a bundled gem
|
10
|
+
|
11
|
+
## 0.5.11
|
12
|
+
|
13
|
+
- Upgrade to perfect-shape 1.0.4
|
14
|
+
- Update examples/shape_coloring.rb with basic drag and drop support
|
15
|
+
- Support `#move_by(x_delta, y_delta)` (alias `translate`) method on all shapes and `path` (e.g. useful in drag and drop)
|
16
|
+
- Support `#move(x, y)` method on all shapes and `path` to move to x,y coordinate directly
|
17
|
+
- Support `#min_x` minimum x coordinate of shape/`path` (of top-left corner)
|
18
|
+
- Support `#min_y` minimum y coordinate of shape/`path` (of top-left corner)
|
19
|
+
- Support `#max_x` maximum x coordinate of shape/`path` (of bottom-right corner)
|
20
|
+
- Support `#max_y` maximum y coordinate of shape/`path` (of bottom-right corner)
|
21
|
+
- Support `#center_point` (`Array` of x,y) center point of shape/`path`
|
22
|
+
- Support `#center_x` center x coordinate of shape/`path`
|
23
|
+
- Support `#center_y` center y coordinate of shape/`path`
|
24
|
+
|
3
25
|
## 0.5.10
|
4
26
|
|
5
|
-
- Support nesting area mouse
|
27
|
+
- Support nesting area mouse listeners underneath shapes directly given the newly added support for the `include?(x, y)` method, which can be used to detect if a mouse event fired for a specific shape
|
6
28
|
- examples/shape_coloring.rb
|
7
29
|
|
8
30
|
## 0.5.9
|
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.13
|
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)
|
@@ -433,6 +433,8 @@ DSL | Platforms | Native? | Vector Graphics? | Pros | Cons | Prereqs
|
|
433
433
|
- [Manga2PDF](#manga2pdf)
|
434
434
|
- [Befunge98 GUI](#befunge98-gui)
|
435
435
|
- [i3off Gtk Ruby](#i3off-gtk-ruby)
|
436
|
+
- [Chess](#chess)
|
437
|
+
- [RubyCrumbler](#rubycrumbler)
|
436
438
|
- [Process](#process)
|
437
439
|
- [Resources](#resources)
|
438
440
|
- [Help](#help)
|
@@ -579,7 +581,7 @@ gem install glimmer-dsl-libui
|
|
579
581
|
Or install via Bundler `Gemfile`:
|
580
582
|
|
581
583
|
```ruby
|
582
|
-
gem 'glimmer-dsl-libui', '~> 0.5.
|
584
|
+
gem 'glimmer-dsl-libui', '~> 0.5.13'
|
583
585
|
```
|
584
586
|
|
585
587
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -1088,13 +1090,22 @@ Mac | Windows | Linux
|
|
1088
1090
|
----|---------|------
|
1089
1091
|
![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)
|
1090
1092
|
|
1091
|
-
##### Shape Methods
|
1093
|
+
##### Area Path Shape Methods
|
1092
1094
|
|
1093
1095
|
- `::parameters`: returns parameters of a shape class
|
1094
1096
|
- `#bounding_box`: returns `Array` containing `[min_x, min_y, width, height]`
|
1095
1097
|
- `#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).
|
1096
1098
|
- `#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)
|
1097
1099
|
- `#perfect_shape`: returns [PerfectShape](https://github.com/AndyObtiva/perfect-shape) object matching the [libui](https://github.com/andlabs/libui) shape.
|
1100
|
+
- `#move_by(x_delta, y_delta)` (alias: `translate`): moves (translates) shape by x,y delta
|
1101
|
+
- `#move(x, y)`: moves (translates) shape to x,y coordinates (in the top-left x,y corner of the shape)
|
1102
|
+
- `#min_x`: minimum x coordinate of shape (of top-left corner)
|
1103
|
+
- `#min_y`: minimum y coordinate of shape (of top-left corner)
|
1104
|
+
- `#max_x`: maximum x coordinate of shape (of bottom-right corner)
|
1105
|
+
- `#max_y`: maximum y coordinate of shape (of bottom-right corner)
|
1106
|
+
- `#center_point` (`Array` of x,y): center point of shape
|
1107
|
+
- `#center_x`: center x coordinate of shape
|
1108
|
+
- `#center_y`: center y coordinate of shape
|
1098
1109
|
|
1099
1110
|
#### Area Text
|
1100
1111
|
|
@@ -1604,7 +1615,8 @@ SpinnerExample.new.launch
|
|
1604
1615
|
- All controls nested under a `horizontal_box`, `vertical_box`, and `form` have `stretchy` property (fill maximum space) as `true` by default (passed to `box_append`/`form_append` method)
|
1605
1616
|
- If an event listener is repeated under a control (e.g. two `on_clicked {}` listeners under `button`), it does not overwrite the previous listener, yet it is added to an `Array` of listeners for the event. [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) provides multiple-event-listener support unlike [LibUI](https://github.com/kojix2/LibUI)
|
1606
1617
|
- `window` instatiation args can be left off, having the following defaults when unspecified: `title` as `''`, `width` as `190`, `height` as `150`, and `has_menubar` as `true`)
|
1607
|
-
- `window` has an `on_closing` listener by default that quits application upon hitting the close button (can be overridden with a manual `on_closing` implementation that returns integer `0` for
|
1618
|
+
- `window` has an `on_closing` listener by default that quits application upon hitting the close button (can be overridden with a manual `on_closing` implementation that returns integer `1` for closing and `0` for remaining open). When creating/showing a child window other than the main window and then closing it, the entire app closes by default unless you implement an `on_closing` listener on the secondary child window that returns `1` at the end.
|
1619
|
+
|
1608
1620
|
- `group` has `title` property default to `''` if not specified in instantiation args, so it can be instantiated without args with `title` property specified in nested block (e.g. `group {title 'Address'; ...}`)
|
1609
1621
|
- `button`, `checkbox`, and `label` have `text` default to `''` if not specified in instantiation args, so they can be instantiated without args with `text` property specified in nested block (e.g. `button {text 'Greet'; on_clicked {puts 'Hello'}}`)
|
1610
1622
|
- `quit_menu_item` has an `on_clicked` listener by default that quits application upon selecting the quit menu item (can be overridden with a manual `on_clicked` implementation that returns integer `0` for success)
|
@@ -2192,7 +2204,6 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
|
|
2192
2204
|
- There is no proper way to destroy `grid` children due to [libui](https://github.com/andlabs/libui) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`).
|
2193
2205
|
- `table` `checkbox_column` checkbox editing only works on Linux and Windows (not Mac) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
|
2194
2206
|
- `table` `checkbox_text_column` checkbox editing only works on Linux (not Mac or Windows) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
|
2195
|
-
- `checkbox` only supports obtaining the `checked` property, but not updating it due to a current limitation in [libui](https://github.com/andlabs/libui).
|
2196
2207
|
- `text` `align` property seems not to work on the Mac ([libui](https://github.com/andlabs/libui) has an [issue](https://github.com/andlabs/libui/pull/407) about it)
|
2197
2208
|
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
2198
2209
|
- `table` `progress_bar` column on Windows cannot be updated with a positive value if it started initially with `-1` (it ignores update to avoid crashing due to an issue in [libui](https://github.com/andlabs/libui) on Windows.
|
@@ -2200,7 +2211,6 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
|
|
2200
2211
|
- It seems that [libui](https://github.com/andlabs/libui) does not support nesting multiple `area` controls under a `grid` as only the first one shows up in that scenario. To workaround that limitation, use a `vertical_box` with nested `horizontal_box`s instead to include multiple `area`s in a GUI.
|
2201
2212
|
- As per the code of [examples/basic_transform.rb](#basic-transform), Windows requires different ordering of transforms than Mac and Linux.
|
2202
2213
|
- `scrolling_area#scroll_to` does not seem to work on Windows and Linux, but works fine on Mac
|
2203
|
-
- When creating/showing a window other than the main window and then closing the secondary window, the entire app closes. This is a current limitation to the windowing system that should be fixed with [child window support](https://github.com/andlabs/libui/issues/137) in [libui](https://github.com/andlabs/libui)
|
2204
2214
|
|
2205
2215
|
### Original API
|
2206
2216
|
|
@@ -11023,7 +11033,9 @@ Timer.new
|
|
11023
11033
|
|
11024
11034
|
#### Shape Coloring
|
11025
11035
|
|
11026
|
-
This example demonstrates being able to nest
|
11036
|
+
This example demonstrates being able to nest listeners within shapes directly, and [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) will automatically detect when the mouse lands inside the shapes to notify listeners.
|
11037
|
+
|
11038
|
+
This example also demonstrates very basic drag and drop support, implemented manually with shape listeners.
|
11027
11039
|
|
11028
11040
|
[examples/shape_coloring.rb](examples/shape_coloring.rb)
|
11029
11041
|
|
@@ -11039,7 +11051,12 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
11039
11051
|
ruby -r glimmer-dsl-libui -e "require 'examples/shape_coloring'"
|
11040
11052
|
```
|
11041
11053
|
|
11054
|
+
Shape Coloring Example
|
11055
|
+
|
11042
11056
|
![glimmer-dsl-libui-mac-shape-coloring.png](images/glimmer-dsl-libui-mac-shape-coloring.png)
|
11057
|
+
|
11058
|
+
![glimmer-dsl-libui-mac-shape-coloring-drag-and-drop.png](images/glimmer-dsl-libui-mac-shape-coloring-drag-and-drop.png)
|
11059
|
+
|
11043
11060
|
![glimmer-dsl-libui-mac-shape-coloring-color-dialog.png](images/glimmer-dsl-libui-mac-shape-coloring-color-dialog.png)
|
11044
11061
|
|
11045
11062
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
@@ -11057,11 +11074,11 @@ class ShapeColoring
|
|
11057
11074
|
}
|
11058
11075
|
|
11059
11076
|
body {
|
11060
|
-
window('Shape Coloring', 200,
|
11077
|
+
window('Shape Coloring', 200, 220) {
|
11061
11078
|
margined false
|
11062
11079
|
|
11063
11080
|
grid {
|
11064
|
-
label("
|
11081
|
+
label("Drag & drop shapes to move or\nclick a shape to select and\nchange color via color button") {
|
11065
11082
|
left 0
|
11066
11083
|
top 0
|
11067
11084
|
hexpand true
|
@@ -11090,19 +11107,19 @@ class ShapeColoring
|
|
11090
11107
|
fill :white
|
11091
11108
|
}
|
11092
11109
|
|
11093
|
-
@shapes << colorable(:rectangle, 20, 20, 40, 20) {
|
11110
|
+
@shapes << colorable(:rectangle, 20, 20, 40, 20) {
|
11094
11111
|
fill :lime
|
11095
11112
|
}
|
11096
11113
|
|
11097
|
-
@shapes << colorable(:square, 80, 20, 20) {
|
11114
|
+
@shapes << colorable(:square, 80, 20, 20) {
|
11098
11115
|
fill :blue
|
11099
11116
|
}
|
11100
11117
|
|
11101
|
-
@shapes << colorable(:circle, 75, 70, 20
|
11118
|
+
@shapes << colorable(:circle, 75, 70, 20) {
|
11102
11119
|
fill :green
|
11103
11120
|
}
|
11104
11121
|
|
11105
|
-
@shapes << colorable(:arc, 120, 70, 40, 0, 145) {
|
11122
|
+
@shapes << colorable(:arc, 120, 70, 40, 0, 145) {
|
11106
11123
|
fill :orange
|
11107
11124
|
}
|
11108
11125
|
|
@@ -11115,6 +11132,14 @@ class ShapeColoring
|
|
11115
11132
|
40, 120, 20, 120, 30, 91) {
|
11116
11133
|
fill :pink
|
11117
11134
|
}
|
11135
|
+
|
11136
|
+
on_mouse_dragged do |area_mouse_event|
|
11137
|
+
mouse_dragged(area_mouse_event)
|
11138
|
+
end
|
11139
|
+
|
11140
|
+
on_mouse_dropped do |area_mouse_event|
|
11141
|
+
mouse_dropped(area_mouse_event)
|
11142
|
+
end
|
11118
11143
|
}
|
11119
11144
|
}
|
11120
11145
|
}
|
@@ -11123,18 +11148,54 @@ class ShapeColoring
|
|
11123
11148
|
def colorable(shape_symbol, *args, &content)
|
11124
11149
|
send(shape_symbol, *args) do |shape|
|
11125
11150
|
on_mouse_up do |area_mouse_event|
|
11126
|
-
|
11127
|
-
|
11128
|
-
|
11129
|
-
|
11130
|
-
|
11131
|
-
|
11151
|
+
unless @dragged_shape
|
11152
|
+
old_stroke = Glimmer::LibUI.interpret_color(shape.stroke).slice(:r, :g, :b)
|
11153
|
+
@shapes.each {|sh| sh.stroke = nil}
|
11154
|
+
@selected_shape = nil
|
11155
|
+
unless old_stroke == COLOR_SELECTION
|
11156
|
+
shape.stroke = COLOR_SELECTION.merge(thickness: 2)
|
11157
|
+
@selected_shape = shape
|
11158
|
+
end
|
11132
11159
|
end
|
11133
11160
|
end
|
11134
11161
|
|
11162
|
+
on_mouse_drag_started do |area_mouse_event|
|
11163
|
+
mouse_drag_started(shape, area_mouse_event)
|
11164
|
+
end
|
11165
|
+
|
11166
|
+
on_mouse_dragged do |area_mouse_event|
|
11167
|
+
mouse_dragged(area_mouse_event)
|
11168
|
+
end
|
11169
|
+
|
11170
|
+
on_mouse_dropped do |area_mouse_event|
|
11171
|
+
mouse_dropped(area_mouse_event)
|
11172
|
+
end
|
11173
|
+
|
11135
11174
|
content.call(shape)
|
11136
11175
|
end
|
11137
11176
|
end
|
11177
|
+
|
11178
|
+
def mouse_drag_started(dragged_shape, area_mouse_event)
|
11179
|
+
@dragged_shape = dragged_shape
|
11180
|
+
@dragged_shape_x = area_mouse_event[:x]
|
11181
|
+
@dragged_shape_y = area_mouse_event[:y]
|
11182
|
+
end
|
11183
|
+
|
11184
|
+
def mouse_dragged(area_mouse_event)
|
11185
|
+
if @dragged_shape && @dragged_shape_x && @dragged_shape_y
|
11186
|
+
x_delta = area_mouse_event[:x] - @dragged_shape_x
|
11187
|
+
y_delta = area_mouse_event[:y] - @dragged_shape_y
|
11188
|
+
@dragged_shape.move_by(x_delta, y_delta)
|
11189
|
+
@dragged_shape_x = area_mouse_event[:x]
|
11190
|
+
@dragged_shape_y = area_mouse_event[:y]
|
11191
|
+
end
|
11192
|
+
end
|
11193
|
+
|
11194
|
+
def mouse_dropped(area_mouse_event)
|
11195
|
+
@dragged_shape = nil
|
11196
|
+
@dragged_shape_x = nil
|
11197
|
+
@dragged_shape_y = nil
|
11198
|
+
end
|
11138
11199
|
end
|
11139
11200
|
|
11140
11201
|
ShapeColoring.launch
|
@@ -11168,6 +11229,16 @@ https://github.com/iraamaro/i3off-gtk-ruby
|
|
11168
11229
|
|
11169
11230
|
https://github.com/mikeweber/chess
|
11170
11231
|
|
11232
|
+
### RubyCrumbler
|
11233
|
+
|
11234
|
+
NLP (Natural Language Processing) App
|
11235
|
+
|
11236
|
+
https://github.com/joh-ga/RubyCrumbler
|
11237
|
+
|
11238
|
+
MacOS | Windows | Linux
|
11239
|
+
| :---: | :---: | :---:
|
11240
|
+
![mac_31](https://user-images.githubusercontent.com/72874215/159339948-b7ae1bf2-60c1-4dae-ac1a-4e13a6048ef0.gif)|![windows_4](https://user-images.githubusercontent.com/72874215/160242473-c38439be-0955-4e89-9f3f-b3d0567531fd.gif)|![rubycrumbler_linux](https://user-images.githubusercontent.com/72874215/160242460-99af1c8c-b43f-458d-bd69-1274a0bd9814.gif)
|
11241
|
+
|
11171
11242
|
## Process
|
11172
11243
|
|
11173
11244
|
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
@@ -11201,6 +11272,8 @@ These features have been planned or suggested. You might see them in a future ve
|
|
11201
11272
|
|
11202
11273
|
## Contributing
|
11203
11274
|
|
11275
|
+
If you would like to contribute to the project, please adhere to the [Open-Source Etiquette](https://github.com/AndyObtiva/open-source-etiquette) to ensure the best results.
|
11276
|
+
|
11204
11277
|
- Check out the latest master to make sure the feature hasn't been
|
11205
11278
|
implemented or the bug hasn't been fixed yet.
|
11206
11279
|
- Check out the issue tracker to make sure someone already hasn't
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.13
|
data/examples/shape_coloring.rb
CHANGED
@@ -10,11 +10,11 @@ class ShapeColoring
|
|
10
10
|
}
|
11
11
|
|
12
12
|
body {
|
13
|
-
window('Shape Coloring', 200,
|
13
|
+
window('Shape Coloring', 200, 220) {
|
14
14
|
margined false
|
15
15
|
|
16
16
|
grid {
|
17
|
-
label("
|
17
|
+
label("Drag & drop shapes to move or\nclick a shape to select and\nchange color via color button") {
|
18
18
|
left 0
|
19
19
|
top 0
|
20
20
|
hexpand true
|
@@ -43,19 +43,19 @@ class ShapeColoring
|
|
43
43
|
fill :white
|
44
44
|
}
|
45
45
|
|
46
|
-
@shapes << colorable(:rectangle, 20, 20, 40, 20) {
|
46
|
+
@shapes << colorable(:rectangle, 20, 20, 40, 20) {
|
47
47
|
fill :lime
|
48
48
|
}
|
49
49
|
|
50
|
-
@shapes << colorable(:square, 80, 20, 20) {
|
50
|
+
@shapes << colorable(:square, 80, 20, 20) {
|
51
51
|
fill :blue
|
52
52
|
}
|
53
53
|
|
54
|
-
@shapes << colorable(:circle, 75, 70, 20
|
54
|
+
@shapes << colorable(:circle, 75, 70, 20) {
|
55
55
|
fill :green
|
56
56
|
}
|
57
57
|
|
58
|
-
@shapes << colorable(:arc, 120, 70, 40, 0, 145) {
|
58
|
+
@shapes << colorable(:arc, 120, 70, 40, 0, 145) {
|
59
59
|
fill :orange
|
60
60
|
}
|
61
61
|
|
@@ -68,6 +68,14 @@ class ShapeColoring
|
|
68
68
|
40, 120, 20, 120, 30, 91) {
|
69
69
|
fill :pink
|
70
70
|
}
|
71
|
+
|
72
|
+
on_mouse_dragged do |area_mouse_event|
|
73
|
+
mouse_dragged(area_mouse_event)
|
74
|
+
end
|
75
|
+
|
76
|
+
on_mouse_dropped do |area_mouse_event|
|
77
|
+
mouse_dropped(area_mouse_event)
|
78
|
+
end
|
71
79
|
}
|
72
80
|
}
|
73
81
|
}
|
@@ -76,18 +84,54 @@ class ShapeColoring
|
|
76
84
|
def colorable(shape_symbol, *args, &content)
|
77
85
|
send(shape_symbol, *args) do |shape|
|
78
86
|
on_mouse_up do |area_mouse_event|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
87
|
+
unless @dragged_shape
|
88
|
+
old_stroke = Glimmer::LibUI.interpret_color(shape.stroke).slice(:r, :g, :b)
|
89
|
+
@shapes.each {|sh| sh.stroke = nil}
|
90
|
+
@selected_shape = nil
|
91
|
+
unless old_stroke == COLOR_SELECTION
|
92
|
+
shape.stroke = COLOR_SELECTION.merge(thickness: 2)
|
93
|
+
@selected_shape = shape
|
94
|
+
end
|
85
95
|
end
|
86
96
|
end
|
87
97
|
|
98
|
+
on_mouse_drag_started do |area_mouse_event|
|
99
|
+
mouse_drag_started(shape, area_mouse_event)
|
100
|
+
end
|
101
|
+
|
102
|
+
on_mouse_dragged do |area_mouse_event|
|
103
|
+
mouse_dragged(area_mouse_event)
|
104
|
+
end
|
105
|
+
|
106
|
+
on_mouse_dropped do |area_mouse_event|
|
107
|
+
mouse_dropped(area_mouse_event)
|
108
|
+
end
|
109
|
+
|
88
110
|
content.call(shape)
|
89
111
|
end
|
90
112
|
end
|
113
|
+
|
114
|
+
def mouse_drag_started(dragged_shape, area_mouse_event)
|
115
|
+
@dragged_shape = dragged_shape
|
116
|
+
@dragged_shape_x = area_mouse_event[:x]
|
117
|
+
@dragged_shape_y = area_mouse_event[:y]
|
118
|
+
end
|
119
|
+
|
120
|
+
def mouse_dragged(area_mouse_event)
|
121
|
+
if @dragged_shape && @dragged_shape_x && @dragged_shape_y
|
122
|
+
x_delta = area_mouse_event[:x] - @dragged_shape_x
|
123
|
+
y_delta = area_mouse_event[:y] - @dragged_shape_y
|
124
|
+
@dragged_shape.move_by(x_delta, y_delta)
|
125
|
+
@dragged_shape_x = area_mouse_event[:x]
|
126
|
+
@dragged_shape_y = area_mouse_event[:y]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def mouse_dropped(area_mouse_event)
|
131
|
+
@dragged_shape = nil
|
132
|
+
@dragged_shape_x = nil
|
133
|
+
@dragged_shape_y = nil
|
134
|
+
end
|
91
135
|
end
|
92
136
|
|
93
137
|
ShapeColoring.launch
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -162,6 +162,10 @@ module Glimmer
|
|
162
162
|
@parent_proxy&.request_auto_redraw
|
163
163
|
end
|
164
164
|
|
165
|
+
def move_by(x_delta, y_delta)
|
166
|
+
children.each {|child| child.move_by(x_delta, y_delta)}
|
167
|
+
end
|
168
|
+
|
165
169
|
def perfect_shape
|
166
170
|
perfect_shape_dependencies = [draw_fill_mode, children]
|
167
171
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -303,16 +303,30 @@ module Glimmer
|
|
303
303
|
def register_cell_rows_observer
|
304
304
|
@cell_rows_observer = Glimmer::DataBinding::Observer.proc do |new_cell_rows|
|
305
305
|
if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
|
306
|
-
@last_cell_rows.
|
306
|
+
@last_cell_rows.each_with_index do |old_row_data, row|
|
307
|
+
if old_row_data != @cell_rows[row]
|
308
|
+
::LibUI.table_model_row_changed(model, row) if model && row
|
309
|
+
notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
|
310
|
+
end
|
311
|
+
end
|
312
|
+
(@last_cell_rows.size - @cell_rows.size).times do |n|
|
313
|
+
row = @last_cell_rows.size - n - 1
|
307
314
|
::LibUI.table_model_row_deleted(model, row) if model && row
|
308
315
|
notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
|
309
316
|
end
|
310
317
|
elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
|
311
|
-
@cell_rows.
|
318
|
+
(@cell_rows.size - @last_cell_rows.size).times do |n|
|
319
|
+
row = @last_cell_rows.size + n
|
312
320
|
::LibUI.table_model_row_inserted(model, row) if model && row
|
313
321
|
notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
|
314
322
|
end
|
315
|
-
|
323
|
+
@cell_rows.each_with_index do |new_row_data, row|
|
324
|
+
if new_row_data != @last_cell_rows[row]
|
325
|
+
::LibUI.table_model_row_changed(model, row) if model && row
|
326
|
+
notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
|
327
|
+
end
|
328
|
+
end
|
329
|
+
elsif @cell_rows != @last_cell_rows
|
316
330
|
@cell_rows.each_with_index do |new_row_data, row|
|
317
331
|
if new_row_data != @last_cell_rows[row]
|
318
332
|
::LibUI.table_model_row_changed(model, row) if model && row
|
@@ -1,7 +1,14 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
module Glimmer
|
2
4
|
module LibUI
|
3
5
|
# GUI View objects that can be represented by PerfectShape objects
|
4
6
|
module PerfectShaped
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def_delegators :perfect_shape,
|
10
|
+
:min_x, :min_y, :max_x, :max_y, :center_point, :center_x, :center_y
|
11
|
+
|
5
12
|
# Returns if shape contains point on the inside when outline is false (default)
|
6
13
|
# or if point is on the outline when outline is true
|
7
14
|
# distance_tolerance is used when outline is true to enable a fuzz factor in
|
@@ -34,6 +41,18 @@ module Glimmer
|
|
34
41
|
]
|
35
42
|
end
|
36
43
|
|
44
|
+
# moves by x delta and y delta. Classes must implement
|
45
|
+
def move_by(x_delta, y_delta)
|
46
|
+
# No Op
|
47
|
+
end
|
48
|
+
alias translate move_by
|
49
|
+
|
50
|
+
def move(x, y)
|
51
|
+
x_delta = x - perfect_shape.min_x
|
52
|
+
y_delta = y - perfect_shape.min_y
|
53
|
+
move_by(x_delta, y_delta)
|
54
|
+
end
|
55
|
+
|
37
56
|
# Returns PerfectShape object matching this shape to enable
|
38
57
|
# executing computational geometry algorithms
|
39
58
|
#
|
@@ -45,6 +45,11 @@ module Glimmer
|
|
45
45
|
super
|
46
46
|
end
|
47
47
|
|
48
|
+
def move_by(x_delta, y_delta)
|
49
|
+
self.x_center += x_delta
|
50
|
+
self.y_center += y_delta
|
51
|
+
end
|
52
|
+
|
48
53
|
def perfect_shape
|
49
54
|
perfect_shape_dependencies = [x_center, y_center, radius, start_angle, sweep, is_negative]
|
50
55
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -50,6 +50,17 @@ module Glimmer
|
|
50
50
|
x && y
|
51
51
|
end
|
52
52
|
|
53
|
+
def move_by(x_delta, y_delta)
|
54
|
+
self.x += x_delta
|
55
|
+
self.y += y_delta
|
56
|
+
self.c1_x += x_delta
|
57
|
+
self.c1_y += y_delta
|
58
|
+
self.c2_x += x_delta
|
59
|
+
self.c2_y += y_delta
|
60
|
+
self.end_x += x_delta
|
61
|
+
self.end_y += y_delta
|
62
|
+
end
|
63
|
+
|
53
64
|
def perfect_shape
|
54
65
|
perfect_shape_dependencies = [x, y, c1_x, c1_y, c2_x, c2_y, end_x, end_y]
|
55
66
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -45,6 +45,11 @@ module Glimmer
|
|
45
45
|
super
|
46
46
|
end
|
47
47
|
|
48
|
+
def move_by(x_delta, y_delta)
|
49
|
+
self.x_center += x_delta
|
50
|
+
self.y_center += y_delta
|
51
|
+
end
|
52
|
+
|
48
53
|
def perfect_shape
|
49
54
|
perfect_shape_dependencies = [x_center, y_center, radius]
|
50
55
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -51,6 +51,12 @@ module Glimmer
|
|
51
51
|
alias set_closed closed
|
52
52
|
alias closed? closed
|
53
53
|
|
54
|
+
def move_by(x_delta, y_delta)
|
55
|
+
self.x += x_delta
|
56
|
+
self.y += y_delta
|
57
|
+
children.each {|child| child.move_by(x_delta, y_delta)}
|
58
|
+
end
|
59
|
+
|
54
60
|
def perfect_shape
|
55
61
|
perfect_shape_dependencies = [x, y, closed, parent.draw_fill_mode, children]
|
56
62
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -53,6 +53,13 @@ module Glimmer
|
|
53
53
|
!parent.is_a?(Figure) && end_x && end_y
|
54
54
|
end
|
55
55
|
|
56
|
+
def move_by(x_delta, y_delta)
|
57
|
+
self.x += x_delta
|
58
|
+
self.y += y_delta
|
59
|
+
self.end_x += x_delta
|
60
|
+
self.end_y += y_delta
|
61
|
+
end
|
62
|
+
|
56
63
|
def perfect_shape
|
57
64
|
perfect_shape_dependencies = [x, y, end_x, end_y]
|
58
65
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -40,6 +40,10 @@ module Glimmer
|
|
40
40
|
super
|
41
41
|
end
|
42
42
|
|
43
|
+
def move_by(x_delta, y_delta)
|
44
|
+
self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
|
45
|
+
end
|
46
|
+
|
43
47
|
def perfect_shape
|
44
48
|
perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
|
45
49
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -41,6 +41,10 @@ module Glimmer
|
|
41
41
|
super
|
42
42
|
end
|
43
43
|
|
44
|
+
def move_by(x_delta, y_delta)
|
45
|
+
self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
|
46
|
+
end
|
47
|
+
|
44
48
|
def perfect_shape
|
45
49
|
perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
|
46
50
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -40,6 +40,10 @@ module Glimmer
|
|
40
40
|
super
|
41
41
|
end
|
42
42
|
|
43
|
+
def move_by(x_delta, y_delta)
|
44
|
+
self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
|
45
|
+
end
|
46
|
+
|
43
47
|
def perfect_shape
|
44
48
|
perfect_shape_dependencies = PerfectShape::MultiPoint.normalize_point_array(point_array)
|
45
49
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -33,6 +33,11 @@ module Glimmer
|
|
33
33
|
super
|
34
34
|
end
|
35
35
|
|
36
|
+
def move_by(x_delta, y_delta)
|
37
|
+
self.x += x_delta
|
38
|
+
self.y += y_delta
|
39
|
+
end
|
40
|
+
|
36
41
|
def perfect_shape
|
37
42
|
perfect_shape_dependencies = [x, y, width, height]
|
38
43
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
@@ -35,6 +35,11 @@ module Glimmer
|
|
35
35
|
|
36
36
|
# TODO look into refactoring/unifying code with Rectangle
|
37
37
|
|
38
|
+
def move_by(x_delta, y_delta)
|
39
|
+
self.x += x_delta
|
40
|
+
self.y += y_delta
|
41
|
+
end
|
42
|
+
|
38
43
|
def perfect_shape
|
39
44
|
perfect_shape_dependencies = [x, y, length]
|
40
45
|
if perfect_shape_dependencies != @perfect_shape_dependencies
|
data/lib/glimmer/libui/shape.rb
CHANGED
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.13
|
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-06-17 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.5
|
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.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: super_module
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -511,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
511
511
|
- !ruby/object:Gem::Version
|
512
512
|
version: '0'
|
513
513
|
requirements: []
|
514
|
-
rubygems_version: 3.3.
|
514
|
+
rubygems_version: 3.3.3
|
515
515
|
signing_key:
|
516
516
|
specification_version: 4
|
517
517
|
summary: Glimmer DSL for LibUI
|