glimmer-dsl-libui 0.4.18 → 0.4.19
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 +44 -33
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/examples/method_based_custom_keyword.rb +9 -9
- data/examples/method_based_custom_keyword2.rb +9 -9
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/observe_expression.rb +1 -1
- data/lib/glimmer/libui/shape/bezier.rb +20 -3
- data/lib/glimmer/libui/shape/line.rb +23 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da444c365d1e7febf1868c1cc63e1d3714eca5e1c3340b0e4694c74e8427f458
|
4
|
+
data.tar.gz: ad68dbc1451dd6b3dc388657b25f8039418fc333ce3876b55e878109a43f88d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8cb2a4b292b10b35a3a058a23af3e5ca7b37bcbf968d498a831b5e40d0d9896fcf0fad428f8857eae0e59785b979e039d0d62cab1a1c83aeb4c8028ed208aff
|
7
|
+
data.tar.gz: 11314401a9da405b96055351321088352cb6503abe74d9d75280c4350266b8aa11772380cdac691609c4499e18d12c2da9d7ee789eb3f72f592b3d09af1888b8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.4.19
|
4
|
+
|
5
|
+
- Have `line` optionally support 4 arguments instead of 2 to use outside of a `figure`
|
6
|
+
- Have `bezier` optionally support 8 arguments instead of 6 to use outside of a `figure`
|
7
|
+
- Minor fix to `observe` keyword code (had the wrong DSL name)
|
8
|
+
|
3
9
|
## 0.4.18
|
4
10
|
|
5
11
|
- Support setting `table` `cell_rows` after the `table` definition completed (e.g. `@table.cell_rows = data` after `table {}` curly braces closed already)
|
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.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.4.19
|
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)
|
@@ -506,7 +506,7 @@ gem install glimmer-dsl-libui
|
|
506
506
|
Or install via Bundler `Gemfile`:
|
507
507
|
|
508
508
|
```ruby
|
509
|
-
gem 'glimmer-dsl-libui', '~> 0.4.
|
509
|
+
gem 'glimmer-dsl-libui', '~> 0.4.19'
|
510
510
|
```
|
511
511
|
|
512
512
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -595,7 +595,7 @@ Keyword(Args) | Properties | Listeners
|
|
595
595
|
`area` | `auto_draw_enabled` | `on_draw(area_draw_params)`, `on_mouse_event(area_mouse_event)`, `on_mouse_down(area_mouse_event)`, `on_mouse_up(area_mouse_event)`, `on_mouse_drag_started(area_mouse_event)`, `on_mouse_dragged(area_mouse_event)`, `on_mouse_dropped(area_mouse_event)`, `on_mouse_entered`, `on_mouse_exited`, `on_key_event(area_key_event)`, `on_key_down(area_key_event)`, `on_key_up(area_key_event)`
|
596
596
|
`arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)` | `x_center` (`Numeric`), `y_center` (`Numeric`), `radius` (`Numeric`), `start_angle` (`Numeric`), `sweep` (`Numeric`), `is_negative` (Boolean) | None
|
597
597
|
`background_color_column` | None | None
|
598
|
-
`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)` | `c1_x` (`Numeric`), `c1_y` (`Numeric`), `c2_x` (`Numeric`), `c2_y` (`Numeric`), `end_x` (`Numeric`), `end_y` (`Numeric`) | None
|
598
|
+
`bezier(x = nil as Numeric, y = nil as Numeric, c1_x as Numeric, c1_y as Numeric, c2_x as Numeric, c2_y as Numeric, end_x as Numeric, end_y as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `c1_x` (`Numeric`), `c1_y` (`Numeric`), `c2_x` (`Numeric`), `c2_y` (`Numeric`), `end_x` (`Numeric`), `end_y` (`Numeric`) | None
|
599
599
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
600
600
|
`button_column(name as String)` | `enabled` (Boolean) | None
|
601
601
|
`checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
|
@@ -622,7 +622,7 @@ Keyword(Args) | Properties | Listeners
|
|
622
622
|
`image_text_column(name as String)` | None | None
|
623
623
|
`image_text_color_column(name as String)` | None | None
|
624
624
|
`label(text as String)` | `text` (`String`) | None
|
625
|
-
`line(x as Numeric, y as Numeric)` | `x` (`Numeric`), `y` (`Numeric`) | None
|
625
|
+
`line(x as Numeric, y as Numeric, end_x = nil as Numeric, end_y = nil as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `end_x` (`Numeric`), `end_y` (`Numeric`) | None
|
626
626
|
`matrix(m11 = nil as Numeric, m12 = nil as Numeric, m21 = nil as Numeric, m22 = nil as Numeric, m31 = nil as Numeric, m32 = nil as Numeric)` | `m11` (`Numeric`), `m12` (`Numeric`), `m21` (`Numeric`), `m22` (`Numeric`), `m31` (`Numeric`), `m32` (`Numeric`) | None
|
627
627
|
`menu(text as String)` | None | None
|
628
628
|
`menu_item(text as String)` | None | `on_clicked`
|
@@ -958,8 +958,8 @@ Available `path` shapes (that can be nested explicitly under `path` or implicitl
|
|
958
958
|
- `square(x as Numeric, y as Numeric, length as Numeric)`
|
959
959
|
- `arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)`
|
960
960
|
- `circle(x_center as Numeric, y_center as Numeric, radius as Numeric)`
|
961
|
-
- `line(x as Numeric, y as Numeric)`: must be placed in a figure (check `polyline`/`polygon` alternatives that do not require a `figure`)
|
962
|
-
- `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)`: must be placed in a figure (check `polybezier` alternative that does not require a `figure`)
|
961
|
+
- `line(x as Numeric, y as Numeric, end_x = nil as Numeric, end_y = nil as Numeric)`: must be placed in a `figure` if only `x`/`y` are specified or have `end_x`/`end_y` otherwise if outside of `figure` (check `polyline`/`polygon` alternatives that do not require a `figure`)
|
962
|
+
- `bezier(x = nil as Numeric, y = nil as Numeric, c1_x as Numeric, c1_y as Numeric, c2_x as Numeric, c2_y as Numeric, end_x as Numeric, end_y as Numeric)`: must be placed in a `figure` if `x`/`y` are not specified or have `x`/`y` as start point otherwise if outside of `figure` (check `polybezier` alternative that does not require a `figure`)
|
963
963
|
- `polygon(point_array as Array of Arrays of Numeric or Array of Numeric)`: shortcut for a closed figure of lines; can receive points as [[x1, y1], [x2, y2], ...] or [x1, y1, x2, y2, ...]
|
964
964
|
- `polyline(point_array as Array of Arrays of Numeric or Array of Numeric)`: shortcut for an open figure of lines; can receive points as [[x1, y1], [x2, y2], ...] or [x1, y1, x2, y2, ...]
|
965
965
|
- `polybezier(point_array as Array of Arrays of Numeric or Array of Numeric)`: shortcut for an open figure of beziers; can receive points as [[start_x1, start_y1], [c1_x2, c1_y2, c2_x2, c2_y2, end_x2, end_y2], [c1_x3, c1_y3, c2_x3, c2_y3, end_x3, end_y3], ...] or [start_x1, start_y1, c1_x2, c1_y2, c2_x2, c2_y2, end_x2, end_y2, c1_x3, c1_y3, c2_x3, c2_y3, end_x3, end_y3, ...]
|
@@ -1384,6 +1384,7 @@ Note that `area`, `path`, and nested shapes are all truly declarative, meaning t
|
|
1384
1384
|
- `scrolling_area` `#scroll_to` 3rd and 4th arguments (`width` and `height`) default to main window width and height if not specified.
|
1385
1385
|
- `area` paths are specified declaratively with shapes/figures underneath (e.g. `rectangle`), and `area` draw listener is automatically generated
|
1386
1386
|
- `area` path shapes can be added directly under `area` without declaring `path` explicitly as a convenient shorthand
|
1387
|
+
- `line` and `bezier` automatically start a new figure if placed outside of `figure`
|
1387
1388
|
- Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
|
1388
1389
|
- Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
|
1389
1390
|
- Observe `text` and `string` properties for changes and automatically redraw containing area accordingly
|
@@ -1395,7 +1396,13 @@ Note that `area`, `path`, and nested shapes are all truly declarative, meaning t
|
|
1395
1396
|
|
1396
1397
|
### Custom Keywords
|
1397
1398
|
|
1398
|
-
|
1399
|
+
Custom keywords can be defined to represent custom controls (components) that provide new features or act as composites of [existing controls](#supported-keywords) that need to be reused multiple times in an application or across multiple applications. Custom keywords save a lot of development time, improving productivity and maintainbility.
|
1400
|
+
|
1401
|
+
For example, you can define a custom `address` control as an aggregate of multiple `label` controls to reuse multiple times as a standard address View, displaying street, city, state, and zip code.
|
1402
|
+
|
1403
|
+
To define custom keywords, simply define a method representing the custom control you want (e.g. `address`) with any arguments needed (e.g. `address(address_model)`).
|
1404
|
+
|
1405
|
+
To make custom keywords externally reusable, you can define in modules and simply include the modules in the view classes that need them.
|
1399
1406
|
|
1400
1407
|
Example that defines `form_field`, `address_form`, `label_pair`, and `address` keywords (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1401
1408
|
|
@@ -1407,44 +1414,37 @@ include Glimmer
|
|
1407
1414
|
|
1408
1415
|
Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code)
|
1409
1416
|
|
1410
|
-
def form_field(model,
|
1411
|
-
|
1417
|
+
def form_field(model, attribute)
|
1418
|
+
attribute = attribute.to_s
|
1412
1419
|
entry { |e|
|
1413
|
-
label
|
1414
|
-
text model
|
1415
|
-
|
1416
|
-
on_changed do
|
1417
|
-
model.send("#{property}=", e.text)
|
1418
|
-
end
|
1420
|
+
label attribute.underscore.split('_').map(&:capitalize).join(' ')
|
1421
|
+
text <=> [model, attribute]
|
1419
1422
|
}
|
1420
1423
|
end
|
1421
1424
|
|
1422
|
-
def address_form(
|
1425
|
+
def address_form(address_model)
|
1423
1426
|
form {
|
1424
|
-
form_field(
|
1425
|
-
form_field(
|
1426
|
-
form_field(
|
1427
|
-
form_field(
|
1428
|
-
form_field(
|
1427
|
+
form_field(address_model, :street)
|
1428
|
+
form_field(address_model, :p_o_box)
|
1429
|
+
form_field(address_model, :city)
|
1430
|
+
form_field(address_model, :state)
|
1431
|
+
form_field(address_model, :zip_code)
|
1429
1432
|
}
|
1430
1433
|
end
|
1431
1434
|
|
1432
1435
|
def label_pair(model, attribute, value)
|
1433
|
-
name_label = nil
|
1434
|
-
value_label = nil
|
1435
1436
|
horizontal_box {
|
1436
|
-
|
1437
|
-
|
1437
|
+
label(attribute.to_s.underscore.split('_').map(&:capitalize).join(' '))
|
1438
|
+
label(value.to_s) {
|
1439
|
+
text <= [model, attribute]
|
1440
|
+
}
|
1438
1441
|
}
|
1439
|
-
Glimmer::DataBinding::Observer.proc do
|
1440
|
-
value_label.text = model.send(attribute)
|
1441
|
-
end.observe(model, attribute)
|
1442
1442
|
end
|
1443
1443
|
|
1444
|
-
def address(
|
1444
|
+
def address(address_model)
|
1445
1445
|
vertical_box {
|
1446
|
-
|
1447
|
-
label_pair(
|
1446
|
+
address_model.each_pair do |attribute, value|
|
1447
|
+
label_pair(address_model, attribute, value)
|
1448
1448
|
end
|
1449
1449
|
}
|
1450
1450
|
end
|
@@ -1501,6 +1501,12 @@ window('Method-Based Custom Keyword') {
|
|
1501
1501
|
|
1502
1502
|
![glimmer-dsl-libui-mac-method-based-custom-keyword.png](images/glimmer-dsl-libui-mac-method-based-custom-keyword.png)
|
1503
1503
|
|
1504
|
+
The [`area`](#area-api) control can be utilized to build non-native custom controls from scratch by leveraging vector graphics, formattable text, keyboard events, and mouse events.
|
1505
|
+
|
1506
|
+
Defining custom keywords enables unlimited extension of the [Glimmer GUI DSL](#glimmer-gui-dsl). The sky is the limit on what can be done with custom keywords as a result. You can compose new visual vocabulary to build applications in any domain from higher concepts rather than [mere standard controls](#supported-keywords). For example, in a traffic signaling app, you could define `street`, `light_signal`, `traffic_sign`, and `car` as custom keywords and build your application from these concepts directly, saving enormous time and achieving much higher productivity.
|
1507
|
+
|
1508
|
+
Learn more from custom keyword usage in [Method-Based Custom Keyword](#method-based-custom-keyword), [Histogram](#histogram), and [Tetris](#tetris) examples.
|
1509
|
+
|
1504
1510
|
### Observer Pattern
|
1505
1511
|
|
1506
1512
|
The [Observer Design Pattern](https://en.wikipedia.org/wiki/Observer_pattern) (a.k.a. Observer Pattern) is fundamental to building GUIs (Graphical User Interfaces) following the [MVC (Model View Controller) Architectural Pattern](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) or any of its variations like [MVP (Model View Presenter)](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter). In the original Smalltalk-MVC, the View observes the Model for changes and updates itself accordingly.
|
@@ -1805,7 +1811,6 @@ Learn more from data-binding usage in [Login](#login) (4 data-binding versions),
|
|
1805
1811
|
- `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).
|
1806
1812
|
- `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)
|
1807
1813
|
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
1808
|
-
- `table` controls on Windows intentionally get an extra empty row at the end because if any row were to be deleted for the first time, double-deletion happens due to an issue in [libui](https://github.com/andlabs/libui) on Windows.
|
1809
1814
|
- `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.
|
1810
1815
|
- 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.
|
1811
1816
|
- As per the code of [examples/basic_transform.rb](#basic-transform), Windows requires different ordering of transforms than Mac and Linux.
|
@@ -8370,6 +8375,12 @@ window('Login') {
|
|
8370
8375
|
|
8371
8376
|
#### Method-Based Custom Keyword
|
8372
8377
|
|
8378
|
+
[Custom keywords](#custom-keywords) can be defined to represent custom controls (components) that provide new features or act as composites of existing controls that need to be reused multiple times in an application or across multiple applications. Custom keywords save a lot of development time, improving productivity and maintainbility.
|
8379
|
+
|
8380
|
+
This example defines `form_field`, `address_form`, `label_pair`, and `address` as custom control keywords.
|
8381
|
+
|
8382
|
+
The custom keywords are defined via methods (thus are "method-based").
|
8383
|
+
|
8373
8384
|
[examples/method_based_custom_keyword.rb](examples/method_based_custom_keyword.rb)
|
8374
8385
|
|
8375
8386
|
Run with this command from the root of the project if you cloned the project:
|
@@ -10107,7 +10118,7 @@ https://github.com/iraamaro/i3off-gtk-ruby
|
|
10107
10118
|
|
10108
10119
|
### Issues
|
10109
10120
|
|
10110
|
-
If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-libui/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use [libui](https://github.com/andlabs/libui) than what is possible with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-libui/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-libui/compare) on [GitHub](https://github.com). In the meantime, you may try older gem versions of [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) till you find one that works
|
10121
|
+
If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-libui/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use [libui](https://github.com/andlabs/libui) than what is possible with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-libui/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-libui/compare) on [GitHub](https://github.com). In the meantime, you may try older gem versions of [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) till you find one that works.
|
10111
10122
|
|
10112
10123
|
### Chat
|
10113
10124
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.19
|
data/bin/girb
CHANGED
File without changes
|
@@ -13,13 +13,13 @@ def form_field(model, attribute)
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
-
def address_form(
|
16
|
+
def address_form(address_model)
|
17
17
|
form {
|
18
|
-
form_field(
|
19
|
-
form_field(
|
20
|
-
form_field(
|
21
|
-
form_field(
|
22
|
-
form_field(
|
18
|
+
form_field(address_model, :street)
|
19
|
+
form_field(address_model, :p_o_box)
|
20
|
+
form_field(address_model, :city)
|
21
|
+
form_field(address_model, :state)
|
22
|
+
form_field(address_model, :zip_code)
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
@@ -32,10 +32,10 @@ def label_pair(model, attribute, value)
|
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
35
|
-
def address(
|
35
|
+
def address(address_model)
|
36
36
|
vertical_box {
|
37
|
-
|
38
|
-
label_pair(
|
37
|
+
address_model.each_pair do |attribute, value|
|
38
|
+
label_pair(address_model, attribute, value)
|
39
39
|
end
|
40
40
|
}
|
41
41
|
end
|
@@ -17,13 +17,13 @@ def form_field(model, property)
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
def address_form(
|
20
|
+
def address_form(address_model)
|
21
21
|
form {
|
22
|
-
form_field(
|
23
|
-
form_field(
|
24
|
-
form_field(
|
25
|
-
form_field(
|
26
|
-
form_field(
|
22
|
+
form_field(address_model, :street)
|
23
|
+
form_field(address_model, :p_o_box)
|
24
|
+
form_field(address_model, :city)
|
25
|
+
form_field(address_model, :state)
|
26
|
+
form_field(address_model, :zip_code)
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
@@ -39,10 +39,10 @@ def label_pair(model, attribute, value)
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def address(
|
42
|
+
def address(address_model)
|
43
43
|
vertical_box {
|
44
|
-
|
45
|
-
label_pair(
|
44
|
+
address_model.each_pair do |attribute, value|
|
45
|
+
label_pair(address_model, attribute, value)
|
46
46
|
end
|
47
47
|
}
|
48
48
|
end
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -25,13 +25,30 @@ module Glimmer
|
|
25
25
|
module LibUI
|
26
26
|
class Shape
|
27
27
|
class Bezier < Shape
|
28
|
-
parameters :c1_x, :c1_y, :c2_x, :c2_y, :end_x, :end_y
|
29
|
-
parameter_defaults 0, 0, 0, 0, 0, 0
|
28
|
+
parameters :x, :y, :c1_x, :c1_y, :c2_x, :c2_y, :end_x, :end_y
|
29
|
+
parameter_defaults nil, nil, 0, 0, 0, 0, 0, 0
|
30
|
+
|
31
|
+
def initialize(keyword, parent, args, &block)
|
32
|
+
args.prepend nil until args.size == 8
|
33
|
+
super(keyword, parent, args, &block)
|
34
|
+
end
|
30
35
|
|
31
36
|
def draw(area_draw_params)
|
32
|
-
|
37
|
+
if !parent.is_a?(Figure)
|
38
|
+
if include_start_point?
|
39
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, x, y)
|
40
|
+
else
|
41
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, 0, 0)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
::LibUI.draw_path_bezier_to(path_proxy.libui, c1_x, c1_y, c2_x, c2_y, end_x, end_y)
|
33
45
|
super
|
34
46
|
end
|
47
|
+
|
48
|
+
# Indicates if bezier is not part of a figure and yet it includes the start point in addition to other points
|
49
|
+
def include_start_point?
|
50
|
+
x && y
|
51
|
+
end
|
35
52
|
end
|
36
53
|
end
|
37
54
|
end
|
@@ -24,14 +24,34 @@ require 'glimmer/libui/shape'
|
|
24
24
|
module Glimmer
|
25
25
|
module LibUI
|
26
26
|
class Shape
|
27
|
+
# Line to use as part of a figure (when having 2 args)
|
28
|
+
# or independently (when having 4 args representing start point x/y and end point x/y)
|
27
29
|
class Line < Shape
|
28
|
-
parameters :x, :y
|
29
|
-
parameter_defaults 0, 0
|
30
|
+
parameters :x, :y, :end_x, :end_y
|
31
|
+
parameter_defaults 0, 0, nil, nil
|
30
32
|
|
31
33
|
def draw(area_draw_params)
|
32
|
-
|
34
|
+
if parent.is_a?(Figure)
|
35
|
+
::LibUI.draw_path_line_to(path_proxy.libui, x, y)
|
36
|
+
else
|
37
|
+
if include_start_point?
|
38
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, x, y)
|
39
|
+
::LibUI.draw_path_line_to(path_proxy.libui, end_x, end_y)
|
40
|
+
else
|
41
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, 0, 0)
|
42
|
+
::LibUI.draw_path_line_to(path_proxy.libui, x, y)
|
43
|
+
end
|
44
|
+
end
|
33
45
|
super
|
34
46
|
end
|
47
|
+
|
48
|
+
# Indicates if line is not part of a figure and yet it includes the start point in addition to end point
|
49
|
+
def include_start_point?
|
50
|
+
# if the last 2 args are available, it means that the first 2 args represent the start point
|
51
|
+
# if line is part of a figure, then the last 2 args are ignored and it is never assumed to include
|
52
|
+
# start point
|
53
|
+
!parent.is_a?(Figure) && end_x && end_y
|
54
|
+
end
|
35
55
|
end
|
36
56
|
end
|
37
57
|
end
|
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.4.
|
4
|
+
version: 0.4.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -209,7 +209,8 @@ description: Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development G
|
|
209
209
|
platform-independent native GUI that just works! Glimmer DSL for LibUI aims to provide
|
210
210
|
declarative DSL syntax that visually maps to GUI control hierarchy, convention over
|
211
211
|
configuration via smart defaults, automation of low-level details, requiring the
|
212
|
-
least amount of syntax possible to build GUI, and custom
|
212
|
+
least amount of syntax possible to build GUI, bidirectional data-binding, and custom
|
213
|
+
keyword support.
|
213
214
|
email: andy.am@gmail.com
|
214
215
|
executables:
|
215
216
|
- girb
|
@@ -449,7 +450,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
449
450
|
- !ruby/object:Gem::Version
|
450
451
|
version: '0'
|
451
452
|
requirements: []
|
452
|
-
rubygems_version: 3.2.
|
453
|
+
rubygems_version: 3.2.31
|
453
454
|
signing_key:
|
454
455
|
specification_version: 4
|
455
456
|
summary: Glimmer DSL for LibUI
|