glimmer-dsl-libui 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +331 -13
- data/VERSION +1 -1
- data/examples/area_gallery.rb +1 -1
- data/examples/area_gallery2.rb +113 -0
- data/examples/area_gallery3.rb +54 -0
- data/examples/area_gallery4.rb +115 -0
- data/examples/basic_table_progress_bar.rb +13 -3
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/arc.rb +1 -0
- data/lib/glimmer/libui/area_proxy.rb +1 -1
- data/lib/glimmer/libui/bezier.rb +1 -0
- data/lib/glimmer/libui/figure.rb +3 -2
- data/lib/glimmer/libui/line.rb +2 -1
- data/lib/glimmer/libui/path_proxy.rb +1 -1
- data/lib/glimmer/libui/rectangle.rb +1 -0
- data/lib/glimmer/libui/shape.rb +15 -0
- data/lib/glimmer/libui/square.rb +1 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc9eaa2a61420e3a1d976ab3b6882bd1e34c82a945780a39ab7c22f4146f1c93
|
4
|
+
data.tar.gz: 35afb04fac90b577482203540944df84138267bf3de14551e6e3cb5c836c2149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 935beb60983735533a31c2a25c20bb2c817c0a184113cbafaeb2918bf9a8d485b784b86bed2273141bbf068bff005bebcb5806de82650cfeee45c14af28a0f72
|
7
|
+
data.tar.gz: 4d9ae69fe974dc8a91e03577856f171f3270a4d02e8075c0796a6d9aaaa94ea2c6fd9e0d93086f1000aa4bc34c4e16db3d44b6bf3bd5038f7faf6957490eba0b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.1.4
|
4
|
+
|
5
|
+
- Update examples/basic_table_progress_bar.rb with a listener
|
6
|
+
- Set default values for shape parameters and support passing shape parameters as properties inside their body (e.g. `rectangle {x 2; y 3; width 400; height 800}`)
|
7
|
+
- New examples/area_gallery2.rb (utilizing properties instead of args)
|
8
|
+
- New examples/area_gallery3.rb (semi-declarative on_draw dynamic paths)
|
9
|
+
- New examples/area_gallery4.rb (utilizing properties instead of args with semi-declarative on_draw dynamic paths)
|
10
|
+
|
3
11
|
## 0.1.3
|
4
12
|
|
5
13
|
- New examples/area_gallery.rb
|
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.1.
|
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.1.4
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
@@ -47,13 +47,23 @@ data = [
|
|
47
47
|
['task 5', -1],
|
48
48
|
]
|
49
49
|
|
50
|
-
window('Task
|
51
|
-
|
50
|
+
window('Task Progress', 300, 200) {
|
51
|
+
vertical_box {
|
52
52
|
table {
|
53
53
|
text_column('Task')
|
54
54
|
progress_bar_column('Progress')
|
55
55
|
|
56
|
-
cell_rows data
|
56
|
+
cell_rows data # implicit data-binding
|
57
|
+
}
|
58
|
+
|
59
|
+
button('Mark All As Done') {
|
60
|
+
stretchy false
|
61
|
+
|
62
|
+
on_clicked do
|
63
|
+
data.each_with_index do |row_data, row|
|
64
|
+
data[row] = [row_data[0], 100] # automatically updates table due to implicit data-binding
|
65
|
+
end
|
66
|
+
end
|
57
67
|
}
|
58
68
|
}
|
59
69
|
}.show
|
@@ -94,7 +104,7 @@ window('Area Gallery', 400, 400) {
|
|
94
104
|
}
|
95
105
|
|
96
106
|
fill r: 202, g: 102, b: 104, a: 0.5
|
97
|
-
stroke
|
107
|
+
stroke r: 0, g: 0, b: 0
|
98
108
|
}
|
99
109
|
path { # declarative stable path
|
100
110
|
figure(0, 0) {
|
@@ -135,7 +145,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
135
145
|
|
136
146
|
## Table of Contents
|
137
147
|
|
138
|
-
- [Glimmer DSL for LibUI 0.1.
|
148
|
+
- [Glimmer DSL for LibUI 0.1.4](#-glimmer-dsl-for-libui-014)
|
139
149
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
140
150
|
- [Usage](#usage)
|
141
151
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
@@ -263,7 +273,7 @@ gem install glimmer-dsl-libui
|
|
263
273
|
Or install via Bundler `Gemfile`:
|
264
274
|
|
265
275
|
```ruby
|
266
|
-
gem 'glimmer-dsl-libui', '~> 0.1.
|
276
|
+
gem 'glimmer-dsl-libui', '~> 0.1.4'
|
267
277
|
```
|
268
278
|
|
269
279
|
Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
|
@@ -351,7 +361,7 @@ Control(Args) | Properties | Listeners
|
|
351
361
|
`date_time_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
|
352
362
|
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
353
363
|
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
354
|
-
`figure(x as Numeric, y as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `closed` (Boolean) | None
|
364
|
+
`figure(x=nil as Numeric, y=nil as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `closed` (Boolean) | None
|
355
365
|
`font_button` | `font` [read-only] (`Hash` of keys: `:family`, `:size`, `:weight`, `:italic`, `:stretch`), `family` as `String`, `size` as `Float`, `weight` as `Integer`, `italic` as `Integer`, `stretch` as `Integer` | `on_changed`
|
356
366
|
`form` | `padded` (Boolean) | None
|
357
367
|
`grid` | `padded` (Boolean) | None
|
@@ -580,7 +590,7 @@ Available nested `path` shapes:
|
|
580
590
|
- `arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)`
|
581
591
|
- `line(x as Numeric, y as Numeric)`
|
582
592
|
- `bezier(c1_x as Numeric, c1_y as Numeric, c2_x as Numeric, c2_y as Numeric, end_x as Numeric, end_y as Numeric)`
|
583
|
-
- `figure(x as Numeric, y as Numeric)` (composite that can contain other shapes) (can set `closed true` to connect last point to first point automatically)
|
593
|
+
- `figure(x=nil as Numeric, y=nil as Numeric)` (composite that can contain other shapes) (can set `closed true` to connect last point to first point automatically)
|
584
594
|
|
585
595
|
In general, it is recommended to use declarative stable paths whenever feasible since they require less code and simpler maintenance. But, in more advanced cases, semi-declarative dynamic paths could be used instead, especially if there are thousands of paths.
|
586
596
|
|
@@ -622,6 +632,7 @@ To redraw an `area`, you may call `#queue_redraw_all` method.
|
|
622
632
|
|
623
633
|
- 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`).
|
624
634
|
- `table` `checkbox_column` and `checkbox_text_column` checkbox editing only works on Windows and Linux (not Mac) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
|
635
|
+
- It seems that `arc` `start_angle` and `sweep` properties are ignored by [libui](https://github.com/andlabs/libui) and always set to `0` and `360` respectively, producing a full circle.
|
625
636
|
|
626
637
|
### Original API
|
627
638
|
|
@@ -2729,13 +2740,23 @@ data = [
|
|
2729
2740
|
['task 5', -1],
|
2730
2741
|
]
|
2731
2742
|
|
2732
|
-
window('Task
|
2733
|
-
|
2743
|
+
window('Task Progress', 300, 200) {
|
2744
|
+
vertical_box {
|
2734
2745
|
table {
|
2735
2746
|
text_column('Task')
|
2736
2747
|
progress_bar_column('Progress')
|
2737
2748
|
|
2738
|
-
cell_rows data
|
2749
|
+
cell_rows data # implicit data-binding
|
2750
|
+
}
|
2751
|
+
|
2752
|
+
button('Mark All As Done') {
|
2753
|
+
stretchy false
|
2754
|
+
|
2755
|
+
on_clicked do
|
2756
|
+
data.each_with_index do |row_data, row|
|
2757
|
+
data[row] = [row_data[0], 100] # automatically updates table due to implicit data-binding
|
2758
|
+
end
|
2759
|
+
end
|
2739
2760
|
}
|
2740
2761
|
}
|
2741
2762
|
}.show
|
@@ -3247,7 +3268,7 @@ window('Area Gallery', 400, 400) {
|
|
3247
3268
|
}
|
3248
3269
|
|
3249
3270
|
fill r: 202, g: 102, b: 104, a: 0.5
|
3250
|
-
stroke
|
3271
|
+
stroke r: 0, g: 0, b: 0
|
3251
3272
|
}
|
3252
3273
|
path { # declarative stable path
|
3253
3274
|
figure(0, 0) {
|
@@ -3272,6 +3293,303 @@ window('Area Gallery', 400, 400) {
|
|
3272
3293
|
}.show
|
3273
3294
|
```
|
3274
3295
|
|
3296
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2:
|
3297
|
+
|
3298
|
+
```ruby
|
3299
|
+
require 'glimmer-dsl-libui'
|
3300
|
+
|
3301
|
+
include Glimmer
|
3302
|
+
|
3303
|
+
window('Area Gallery', 400, 400) {
|
3304
|
+
vertical_box {
|
3305
|
+
area {
|
3306
|
+
path { # declarative stable path
|
3307
|
+
square {
|
3308
|
+
x 0
|
3309
|
+
y 0
|
3310
|
+
length 100
|
3311
|
+
}
|
3312
|
+
square {
|
3313
|
+
x 100
|
3314
|
+
y 100
|
3315
|
+
length 400
|
3316
|
+
}
|
3317
|
+
|
3318
|
+
fill r: 102, g: 102, b: 204
|
3319
|
+
}
|
3320
|
+
path { # declarative stable path
|
3321
|
+
rectangle {
|
3322
|
+
x 0
|
3323
|
+
y 100
|
3324
|
+
width 100
|
3325
|
+
height 400
|
3326
|
+
}
|
3327
|
+
rectangle {
|
3328
|
+
x 100
|
3329
|
+
y 0
|
3330
|
+
width 400
|
3331
|
+
height 100
|
3332
|
+
}
|
3333
|
+
|
3334
|
+
fill r: 204, g: 102, b: 204
|
3335
|
+
}
|
3336
|
+
path { # declarative stable path
|
3337
|
+
figure {
|
3338
|
+
x 100
|
3339
|
+
y 100
|
3340
|
+
|
3341
|
+
line {
|
3342
|
+
x 100
|
3343
|
+
y 400
|
3344
|
+
}
|
3345
|
+
line {
|
3346
|
+
x 400
|
3347
|
+
y 100
|
3348
|
+
}
|
3349
|
+
line {
|
3350
|
+
x 400
|
3351
|
+
y 400
|
3352
|
+
}
|
3353
|
+
|
3354
|
+
closed true
|
3355
|
+
}
|
3356
|
+
|
3357
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
3358
|
+
stroke r: 0, g: 0, b: 0
|
3359
|
+
}
|
3360
|
+
path { # declarative stable path
|
3361
|
+
figure {
|
3362
|
+
x 0
|
3363
|
+
y 0
|
3364
|
+
|
3365
|
+
bezier {
|
3366
|
+
c1_x 200
|
3367
|
+
c1_y 100
|
3368
|
+
c2_x 100
|
3369
|
+
c2_y 200
|
3370
|
+
end_x 400
|
3371
|
+
end_y 100
|
3372
|
+
}
|
3373
|
+
bezier {
|
3374
|
+
c1_x 300
|
3375
|
+
c1_y 100
|
3376
|
+
c2_x 100
|
3377
|
+
c2_y 300
|
3378
|
+
end_x 100
|
3379
|
+
end_y 400
|
3380
|
+
}
|
3381
|
+
bezier {
|
3382
|
+
c1_x 100
|
3383
|
+
c1_y 300
|
3384
|
+
c2_x 300
|
3385
|
+
c2_y 100
|
3386
|
+
end_x 400
|
3387
|
+
end_y 400
|
3388
|
+
}
|
3389
|
+
|
3390
|
+
closed true
|
3391
|
+
}
|
3392
|
+
|
3393
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
3394
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
3395
|
+
}
|
3396
|
+
path { # declarative stable path
|
3397
|
+
arc {
|
3398
|
+
x_center 200
|
3399
|
+
y_center 200
|
3400
|
+
radius 90
|
3401
|
+
start_angle 0
|
3402
|
+
sweep 360
|
3403
|
+
is_negative false
|
3404
|
+
}
|
3405
|
+
|
3406
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
3407
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
3408
|
+
}
|
3409
|
+
}
|
3410
|
+
}
|
3411
|
+
}.show
|
3412
|
+
```
|
3413
|
+
|
3414
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3:
|
3415
|
+
|
3416
|
+
```ruby
|
3417
|
+
require 'glimmer-dsl-libui'
|
3418
|
+
|
3419
|
+
include Glimmer
|
3420
|
+
|
3421
|
+
window('Area Gallery', 400, 400) {
|
3422
|
+
vertical_box {
|
3423
|
+
area {
|
3424
|
+
on_draw do |area_draw_params|
|
3425
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3426
|
+
square(0, 0, 100)
|
3427
|
+
square(100, 100, 400)
|
3428
|
+
|
3429
|
+
fill r: 102, g: 102, b: 204
|
3430
|
+
}
|
3431
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3432
|
+
rectangle(0, 100, 100, 400)
|
3433
|
+
rectangle(100, 0, 400, 100)
|
3434
|
+
|
3435
|
+
fill r: 204, g: 102, b: 204
|
3436
|
+
}
|
3437
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3438
|
+
figure(100, 100) {
|
3439
|
+
line(100, 400)
|
3440
|
+
line(400, 100)
|
3441
|
+
line(400, 400)
|
3442
|
+
|
3443
|
+
closed true
|
3444
|
+
}
|
3445
|
+
|
3446
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
3447
|
+
stroke r: 0, g: 0, b: 0
|
3448
|
+
}
|
3449
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3450
|
+
figure(0, 0) {
|
3451
|
+
bezier(200, 100, 100, 200, 400, 100)
|
3452
|
+
bezier(300, 100, 100, 300, 100, 400)
|
3453
|
+
bezier(100, 300, 300, 100, 400, 400)
|
3454
|
+
|
3455
|
+
closed true
|
3456
|
+
}
|
3457
|
+
|
3458
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
3459
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
3460
|
+
}
|
3461
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3462
|
+
arc(200, 200, 90, 0, 360, false)
|
3463
|
+
|
3464
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
3465
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
3466
|
+
}
|
3467
|
+
end
|
3468
|
+
}
|
3469
|
+
}
|
3470
|
+
}.show
|
3471
|
+
```
|
3472
|
+
|
3473
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 4:
|
3474
|
+
|
3475
|
+
```ruby
|
3476
|
+
require 'glimmer-dsl-libui'
|
3477
|
+
|
3478
|
+
include Glimmer
|
3479
|
+
|
3480
|
+
window('Area Gallery', 400, 400) {
|
3481
|
+
vertical_box {
|
3482
|
+
area {
|
3483
|
+
on_draw do |area_draw_params|
|
3484
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3485
|
+
square {
|
3486
|
+
x 0
|
3487
|
+
y 0
|
3488
|
+
length 100
|
3489
|
+
}
|
3490
|
+
square {
|
3491
|
+
x 100
|
3492
|
+
y 100
|
3493
|
+
length 400
|
3494
|
+
}
|
3495
|
+
|
3496
|
+
fill r: 102, g: 102, b: 204
|
3497
|
+
}
|
3498
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3499
|
+
rectangle {
|
3500
|
+
x 0
|
3501
|
+
y 100
|
3502
|
+
width 100
|
3503
|
+
height 400
|
3504
|
+
}
|
3505
|
+
rectangle {
|
3506
|
+
x 100
|
3507
|
+
y 0
|
3508
|
+
width 400
|
3509
|
+
height 100
|
3510
|
+
}
|
3511
|
+
|
3512
|
+
fill r: 204, g: 102, b: 204
|
3513
|
+
}
|
3514
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3515
|
+
figure {
|
3516
|
+
x 100
|
3517
|
+
y 100
|
3518
|
+
|
3519
|
+
line {
|
3520
|
+
x 100
|
3521
|
+
y 400
|
3522
|
+
}
|
3523
|
+
line {
|
3524
|
+
x 400
|
3525
|
+
y 100
|
3526
|
+
}
|
3527
|
+
line {
|
3528
|
+
x 400
|
3529
|
+
y 400
|
3530
|
+
}
|
3531
|
+
|
3532
|
+
closed true
|
3533
|
+
}
|
3534
|
+
|
3535
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
3536
|
+
stroke r: 0, g: 0, b: 0
|
3537
|
+
}
|
3538
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3539
|
+
figure {
|
3540
|
+
x 0
|
3541
|
+
y 0
|
3542
|
+
|
3543
|
+
bezier {
|
3544
|
+
c1_x 200
|
3545
|
+
c1_y 100
|
3546
|
+
c2_x 100
|
3547
|
+
c2_y 200
|
3548
|
+
end_x 400
|
3549
|
+
end_y 100
|
3550
|
+
}
|
3551
|
+
bezier {
|
3552
|
+
c1_x 300
|
3553
|
+
c1_y 100
|
3554
|
+
c2_x 100
|
3555
|
+
c2_y 300
|
3556
|
+
end_x 100
|
3557
|
+
end_y 400
|
3558
|
+
}
|
3559
|
+
bezier {
|
3560
|
+
c1_x 100
|
3561
|
+
c1_y 300
|
3562
|
+
c2_x 300
|
3563
|
+
c2_y 100
|
3564
|
+
end_x 400
|
3565
|
+
end_y 400
|
3566
|
+
}
|
3567
|
+
|
3568
|
+
closed true
|
3569
|
+
}
|
3570
|
+
|
3571
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
3572
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
3573
|
+
}
|
3574
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
3575
|
+
arc {
|
3576
|
+
x_center 200
|
3577
|
+
y_center 200
|
3578
|
+
radius 90
|
3579
|
+
start_angle 0
|
3580
|
+
sweep 360
|
3581
|
+
is_negative false
|
3582
|
+
}
|
3583
|
+
|
3584
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
3585
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
3586
|
+
}
|
3587
|
+
end
|
3588
|
+
}
|
3589
|
+
}
|
3590
|
+
}.show
|
3591
|
+
```
|
3592
|
+
|
3275
3593
|
## Contributing to glimmer-dsl-libui
|
3276
3594
|
|
3277
3595
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/examples/area_gallery.rb
CHANGED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
|
3
|
+
include Glimmer
|
4
|
+
|
5
|
+
window('Area Gallery', 400, 400) {
|
6
|
+
vertical_box {
|
7
|
+
area {
|
8
|
+
path { # declarative stable path
|
9
|
+
square {
|
10
|
+
x 0
|
11
|
+
y 0
|
12
|
+
length 100
|
13
|
+
}
|
14
|
+
square {
|
15
|
+
x 100
|
16
|
+
y 100
|
17
|
+
length 400
|
18
|
+
}
|
19
|
+
|
20
|
+
fill r: 102, g: 102, b: 204
|
21
|
+
}
|
22
|
+
path { # declarative stable path
|
23
|
+
rectangle {
|
24
|
+
x 0
|
25
|
+
y 100
|
26
|
+
width 100
|
27
|
+
height 400
|
28
|
+
}
|
29
|
+
rectangle {
|
30
|
+
x 100
|
31
|
+
y 0
|
32
|
+
width 400
|
33
|
+
height 100
|
34
|
+
}
|
35
|
+
|
36
|
+
fill r: 204, g: 102, b: 204
|
37
|
+
}
|
38
|
+
path { # declarative stable path
|
39
|
+
figure {
|
40
|
+
x 100
|
41
|
+
y 100
|
42
|
+
|
43
|
+
line {
|
44
|
+
x 100
|
45
|
+
y 400
|
46
|
+
}
|
47
|
+
line {
|
48
|
+
x 400
|
49
|
+
y 100
|
50
|
+
}
|
51
|
+
line {
|
52
|
+
x 400
|
53
|
+
y 400
|
54
|
+
}
|
55
|
+
|
56
|
+
closed true
|
57
|
+
}
|
58
|
+
|
59
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
60
|
+
stroke r: 0, g: 0, b: 0
|
61
|
+
}
|
62
|
+
path { # declarative stable path
|
63
|
+
figure {
|
64
|
+
x 0
|
65
|
+
y 0
|
66
|
+
|
67
|
+
bezier {
|
68
|
+
c1_x 200
|
69
|
+
c1_y 100
|
70
|
+
c2_x 100
|
71
|
+
c2_y 200
|
72
|
+
end_x 400
|
73
|
+
end_y 100
|
74
|
+
}
|
75
|
+
bezier {
|
76
|
+
c1_x 300
|
77
|
+
c1_y 100
|
78
|
+
c2_x 100
|
79
|
+
c2_y 300
|
80
|
+
end_x 100
|
81
|
+
end_y 400
|
82
|
+
}
|
83
|
+
bezier {
|
84
|
+
c1_x 100
|
85
|
+
c1_y 300
|
86
|
+
c2_x 300
|
87
|
+
c2_y 100
|
88
|
+
end_x 400
|
89
|
+
end_y 400
|
90
|
+
}
|
91
|
+
|
92
|
+
closed true
|
93
|
+
}
|
94
|
+
|
95
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
96
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
97
|
+
}
|
98
|
+
path { # declarative stable path
|
99
|
+
arc {
|
100
|
+
x_center 200
|
101
|
+
y_center 200
|
102
|
+
radius 90
|
103
|
+
start_angle 0
|
104
|
+
sweep 360
|
105
|
+
is_negative false
|
106
|
+
}
|
107
|
+
|
108
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
109
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}.show
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
|
3
|
+
include Glimmer
|
4
|
+
|
5
|
+
window('Area Gallery', 400, 400) {
|
6
|
+
vertical_box {
|
7
|
+
area {
|
8
|
+
on_draw do |area_draw_params|
|
9
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
10
|
+
square(0, 0, 100)
|
11
|
+
square(100, 100, 400)
|
12
|
+
|
13
|
+
fill r: 102, g: 102, b: 204
|
14
|
+
}
|
15
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
16
|
+
rectangle(0, 100, 100, 400)
|
17
|
+
rectangle(100, 0, 400, 100)
|
18
|
+
|
19
|
+
fill r: 204, g: 102, b: 204
|
20
|
+
}
|
21
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
22
|
+
figure(100, 100) {
|
23
|
+
line(100, 400)
|
24
|
+
line(400, 100)
|
25
|
+
line(400, 400)
|
26
|
+
|
27
|
+
closed true
|
28
|
+
}
|
29
|
+
|
30
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
31
|
+
stroke r: 0, g: 0, b: 0
|
32
|
+
}
|
33
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
34
|
+
figure(0, 0) {
|
35
|
+
bezier(200, 100, 100, 200, 400, 100)
|
36
|
+
bezier(300, 100, 100, 300, 100, 400)
|
37
|
+
bezier(100, 300, 300, 100, 400, 400)
|
38
|
+
|
39
|
+
closed true
|
40
|
+
}
|
41
|
+
|
42
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
43
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
44
|
+
}
|
45
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
46
|
+
arc(200, 200, 90, 0, 360, false)
|
47
|
+
|
48
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
49
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
50
|
+
}
|
51
|
+
end
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}.show
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
|
3
|
+
include Glimmer
|
4
|
+
|
5
|
+
window('Area Gallery', 400, 400) {
|
6
|
+
vertical_box {
|
7
|
+
area {
|
8
|
+
on_draw do |area_draw_params|
|
9
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
10
|
+
square {
|
11
|
+
x 0
|
12
|
+
y 0
|
13
|
+
length 100
|
14
|
+
}
|
15
|
+
square {
|
16
|
+
x 100
|
17
|
+
y 100
|
18
|
+
length 400
|
19
|
+
}
|
20
|
+
|
21
|
+
fill r: 102, g: 102, b: 204
|
22
|
+
}
|
23
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
24
|
+
rectangle {
|
25
|
+
x 0
|
26
|
+
y 100
|
27
|
+
width 100
|
28
|
+
height 400
|
29
|
+
}
|
30
|
+
rectangle {
|
31
|
+
x 100
|
32
|
+
y 0
|
33
|
+
width 400
|
34
|
+
height 100
|
35
|
+
}
|
36
|
+
|
37
|
+
fill r: 204, g: 102, b: 204
|
38
|
+
}
|
39
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
40
|
+
figure {
|
41
|
+
x 100
|
42
|
+
y 100
|
43
|
+
|
44
|
+
line {
|
45
|
+
x 100
|
46
|
+
y 400
|
47
|
+
}
|
48
|
+
line {
|
49
|
+
x 400
|
50
|
+
y 100
|
51
|
+
}
|
52
|
+
line {
|
53
|
+
x 400
|
54
|
+
y 400
|
55
|
+
}
|
56
|
+
|
57
|
+
closed true
|
58
|
+
}
|
59
|
+
|
60
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
61
|
+
stroke r: 0, g: 0, b: 0
|
62
|
+
}
|
63
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
64
|
+
figure {
|
65
|
+
x 0
|
66
|
+
y 0
|
67
|
+
|
68
|
+
bezier {
|
69
|
+
c1_x 200
|
70
|
+
c1_y 100
|
71
|
+
c2_x 100
|
72
|
+
c2_y 200
|
73
|
+
end_x 400
|
74
|
+
end_y 100
|
75
|
+
}
|
76
|
+
bezier {
|
77
|
+
c1_x 300
|
78
|
+
c1_y 100
|
79
|
+
c2_x 100
|
80
|
+
c2_y 300
|
81
|
+
end_x 100
|
82
|
+
end_y 400
|
83
|
+
}
|
84
|
+
bezier {
|
85
|
+
c1_x 100
|
86
|
+
c1_y 300
|
87
|
+
c2_x 300
|
88
|
+
c2_y 100
|
89
|
+
end_x 400
|
90
|
+
end_y 400
|
91
|
+
}
|
92
|
+
|
93
|
+
closed true
|
94
|
+
}
|
95
|
+
|
96
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
97
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
98
|
+
}
|
99
|
+
path(area_draw_params) { # a dynamic path is added semi-declaratively inside on_draw block
|
100
|
+
arc {
|
101
|
+
x_center 200
|
102
|
+
y_center 200
|
103
|
+
radius 90
|
104
|
+
start_angle 0
|
105
|
+
sweep 360
|
106
|
+
is_negative false
|
107
|
+
}
|
108
|
+
|
109
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
110
|
+
stroke thickness: 2, r: 0, g: 0, b: 0
|
111
|
+
}
|
112
|
+
end
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}.show
|
@@ -12,13 +12,23 @@ data = [
|
|
12
12
|
['task 5', -1],
|
13
13
|
]
|
14
14
|
|
15
|
-
window('Task
|
16
|
-
|
15
|
+
window('Task Progress', 300, 200) {
|
16
|
+
vertical_box {
|
17
17
|
table {
|
18
18
|
text_column('Task')
|
19
19
|
progress_bar_column('Progress')
|
20
20
|
|
21
|
-
cell_rows data
|
21
|
+
cell_rows data # implicit data-binding
|
22
|
+
}
|
23
|
+
|
24
|
+
button('Mark All As Done') {
|
25
|
+
stretchy false
|
26
|
+
|
27
|
+
on_clicked do
|
28
|
+
data.each_with_index do |row_data, row|
|
29
|
+
data[row] = [row_data[0], 100] # automatically updates table due to implicit data-binding
|
30
|
+
end
|
31
|
+
end
|
22
32
|
}
|
23
33
|
}
|
24
34
|
}.show
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui/arc.rb
CHANGED
@@ -25,6 +25,7 @@ module Glimmer
|
|
25
25
|
module LibUI
|
26
26
|
class Arc < Shape
|
27
27
|
parameters :x_center, :y_center, :radius, :start_angle, :sweep, :is_negative
|
28
|
+
parameter_defaults 0, 0, 0, 0, 360, false
|
28
29
|
|
29
30
|
def draw(area_draw_params)
|
30
31
|
@args[5] ||= ControlProxy.boolean_to_integer(@args[5], allow_nil: false)
|
@@ -80,7 +80,7 @@ module Glimmer
|
|
80
80
|
@area_handler.Draw = fiddle_closure_block_caller(0, [1, 1, 1]) do |_, _, area_draw_params|
|
81
81
|
area_draw_params = ::LibUI::FFI::AreaDrawParams.new(area_draw_params)
|
82
82
|
area_draw_params = area_draw_params_hash(area_draw_params)
|
83
|
-
children.each {|child| child.draw(area_draw_params)}
|
83
|
+
children.dup.each {|child| child.draw(area_draw_params)}
|
84
84
|
on_draw.each {|listener| listener.call(area_draw_params) }
|
85
85
|
end
|
86
86
|
@area_handler.MouseEvent = fiddle_closure_block_caller(0, [0]) {}
|
data/lib/glimmer/libui/bezier.rb
CHANGED
data/lib/glimmer/libui/figure.rb
CHANGED
@@ -27,10 +27,11 @@ module Glimmer
|
|
27
27
|
# Can optionally have `closed true` property (connecting last point to first point automatically)
|
28
28
|
class Figure < Shape
|
29
29
|
parameters :x, :y
|
30
|
+
parameter_defaults nil, nil
|
30
31
|
|
31
32
|
def draw(area_draw_params)
|
32
|
-
::LibUI.draw_path_new_figure(path_proxy.libui, *@args) unless @args.empty? # TODO if args empty then wait till there is an arc child and it starts the figure
|
33
|
-
children.each {|child| child.draw(area_draw_params)}
|
33
|
+
::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
|
34
|
+
children.dup.each {|child| child.draw(area_draw_params)}
|
34
35
|
::LibUI.draw_path_close_figure(path_proxy.libui) if closed?
|
35
36
|
super
|
36
37
|
end
|
data/lib/glimmer/libui/line.rb
CHANGED
@@ -56,7 +56,7 @@ module Glimmer
|
|
56
56
|
|
57
57
|
def draw(area_draw_params)
|
58
58
|
build_control
|
59
|
-
children.each {|child| child.draw(area_draw_params)}
|
59
|
+
children.dup.each {|child| child.draw(area_draw_params)}
|
60
60
|
::LibUI.draw_path_end(@libui)
|
61
61
|
::LibUI.draw_fill(area_draw_params[:context], @libui, fill_draw_brush.to_ptr) unless fill.empty?
|
62
62
|
::LibUI.draw_stroke(area_draw_params[:context], @libui, stroke_draw_brush, draw_stroke_params) unless stroke.empty?
|
data/lib/glimmer/libui/shape.rb
CHANGED
@@ -46,6 +46,14 @@ module Glimmer
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def parameter_defaults(*defaults)
|
50
|
+
if defaults.empty?
|
51
|
+
@parameter_defaults
|
52
|
+
else
|
53
|
+
@parameter_defaults = defaults
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
49
57
|
private
|
50
58
|
|
51
59
|
def constant_symbol(keyword)
|
@@ -60,6 +68,7 @@ module Glimmer
|
|
60
68
|
@parent = parent
|
61
69
|
@args = args
|
62
70
|
@block = block
|
71
|
+
set_parameter_defaults
|
63
72
|
post_add_content if @block.nil?
|
64
73
|
end
|
65
74
|
|
@@ -117,6 +126,12 @@ module Glimmer
|
|
117
126
|
|
118
127
|
private
|
119
128
|
|
129
|
+
def set_parameter_defaults
|
130
|
+
self.class.parameter_defaults.each_with_index do |default, i|
|
131
|
+
@args[i] ||= default
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
120
135
|
def find_parent_in_ancestors(&condition)
|
121
136
|
found = self
|
122
137
|
until condition.call(found)
|
data/lib/glimmer/libui/square.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -195,6 +195,9 @@ files:
|
|
195
195
|
- bin/girb
|
196
196
|
- bin/girb_runner.rb
|
197
197
|
- examples/area_gallery.rb
|
198
|
+
- examples/area_gallery2.rb
|
199
|
+
- examples/area_gallery3.rb
|
200
|
+
- examples/area_gallery4.rb
|
198
201
|
- examples/basic_area.rb
|
199
202
|
- examples/basic_area2.rb
|
200
203
|
- examples/basic_button.rb
|