glimmer-dsl-libui 0.10.0 → 0.10.1
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 +7 -0
- data/README.md +298 -18
- data/VERSION +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/rake_task/scaffold.rb +18 -11
- data/lib/glimmer/rake_task.rb +18 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21db2452d3dfbb5c34356de87e7c40380d4e887a25181854321a226cee7640b5
|
4
|
+
data.tar.gz: 5f62aa411e6c890e0c8228d286f273d4ebb056af7b771313a49db0344340a773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fabf5fd00b7994fce070e6c200814381c3fbc7df0c38e7742e5d1207d76f0c0e9d1946d5b882ee5c372acd7cc6876e485596d760127a52ada556e6402de2dd31
|
7
|
+
data.tar.gz: 37f4312b11de8d5f2678c2f31e966acfed33617224fcdd4217effdd169bcfd61721b1d1ff64236a4e0957d991f86127fc6c0db55170b3e0b92d5831c5cbc51ec
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.10.1
|
4
|
+
|
5
|
+
- Scaffold custom shape
|
6
|
+
- Scaffold custom shape gem
|
7
|
+
- List Custom Shape Gems (expected name format: `glimmer-libui-cs-gemname-namespace`) via `glimmer list:gems:customshape[query]`
|
8
|
+
|
3
9
|
## 0.10.0
|
4
10
|
|
5
11
|
- Support Custom Shapes, describing composite shapes/text/image concepts inside an `area`
|
6
12
|
- `examples/basic_custom_shape.rb` example
|
7
13
|
- Support nesting listeners under a Custom Shape that will automatically get added to its `body_root` control
|
8
14
|
- Support nesting listeners under a Custom Control that will automatically get added to its `body_root` control
|
15
|
+
- Do not include `Glimmer` in top-level class when scaffolding Applications/Custom-Window-gems as it is unnecessary
|
9
16
|
|
10
17
|
## 0.9.7
|
11
18
|
|
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.10.
|
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.10.1
|
2
2
|
## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
|
3
3
|
### The Quickest Way From Zero To GUI
|
4
4
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
@@ -26,7 +26,7 @@ The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/gl
|
|
26
26
|
- [Declarative DSL syntax](#glimmer-gui-dsl-concepts) that visually maps to the GUI control hierarchy
|
27
27
|
- [Convention over configuration](#smart-defaults-and-conventions) via smart defaults and automation of low-level details
|
28
28
|
- Requiring the [least amount of syntax](#glimmer-gui-dsl-concepts) possible to build GUI
|
29
|
-
- [Custom
|
29
|
+
- [Custom Component](#custom-components) support (Custom Controls, Custom Windows, and Custom Shapes)
|
30
30
|
- [Bidirectional/Unidirectional Data-Binding](#data-binding) to declaratively wire and automatically synchronize GUI Views with Models
|
31
31
|
- [Scaffolding](#scaffold-application) for new custom windows/controls, apps, and gems
|
32
32
|
- [Far Future Plan] Native-Executable packaging on Mac, Windows, and Linux.
|
@@ -353,10 +353,13 @@ Learn more about the differences between various [Glimmer](https://github.com/An
|
|
353
353
|
- [Scaffold Application](#scaffold-application)
|
354
354
|
- [Scaffold Custom Control](#scaffold-custom-control)
|
355
355
|
- [Scaffold Custom Window](#scaffold-custom-window)
|
356
|
+
- [Scaffold Custom Shape](#scaffold-custom-shape)
|
356
357
|
- [Scaffold Custom Control Gem](#scaffold-custom-control-gem)
|
357
358
|
- [Scaffold Custom Window Gem](#scaffold-custom-window-gem)
|
358
|
-
- [
|
359
|
+
- [Scaffold Custom Shape Gem](#scaffold-custom-shape-gem)
|
359
360
|
- [List Custom Control Gems](#list-custom-control-gems)
|
361
|
+
- [List Custom Window Gems](#list-custom-window-gems)
|
362
|
+
- [List Custom Shape Gems](#list-custom-shape-gems)
|
360
363
|
- [List Glimmer DSLs](#list-glimmer-dsls)
|
361
364
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
362
365
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
@@ -428,7 +431,7 @@ gem install glimmer-dsl-libui
|
|
428
431
|
Or install via Bundler `Gemfile`:
|
429
432
|
|
430
433
|
```ruby
|
431
|
-
gem 'glimmer-dsl-libui', '~> 0.10.
|
434
|
+
gem 'glimmer-dsl-libui', '~> 0.10.1'
|
432
435
|
```
|
433
436
|
|
434
437
|
Test that installation worked by running the [Glimmer Meta-Example](#examples):
|
@@ -757,7 +760,7 @@ glimmer scaffold:cc[name,namespace]
|
|
757
760
|
For example by running this command under a `hello_world` application:
|
758
761
|
|
759
762
|
```
|
760
|
-
glimmer scaffold:
|
763
|
+
glimmer scaffold:cc[model_form]
|
761
764
|
```
|
762
765
|
|
763
766
|
That will generate this class under `app/hello_world/view/model_form`:
|
@@ -831,7 +834,7 @@ window {
|
|
831
834
|
Here is an example that generates a [custom control](#custom-components) with a namespace:
|
832
835
|
|
833
836
|
```
|
834
|
-
glimmer scaffold:
|
837
|
+
glimmer scaffold:cc[model_form,common]
|
835
838
|
```
|
836
839
|
|
837
840
|
That will generate this class under `app/common/view/model_form`:
|
@@ -1078,6 +1081,204 @@ Or another `train` custom window view:
|
|
1078
1081
|
hello_world__view__train.show
|
1079
1082
|
```
|
1080
1083
|
|
1084
|
+
### Scaffold Custom Shape
|
1085
|
+
|
1086
|
+
When you are in a scaffolded application, you can scaffold a new [custom shape](#custom-components) (a shape that you can put anything in to represent a view concept in your application) by running this command:
|
1087
|
+
|
1088
|
+
```
|
1089
|
+
glimmer scaffold:customshape[name,namespace]
|
1090
|
+
```
|
1091
|
+
|
1092
|
+
The `name` represents the [custom shape](#custom-components) view class name (it can be underscored, and Glimmer will automatically classify it).
|
1093
|
+
|
1094
|
+
The `namespace` is optional and represents the module that the [custom shape](#custom-components) view class will live under. If left off, the main application class namespace is used (e.g. the top-level `HelloWorld` class namespace for a `hello_world` application).
|
1095
|
+
|
1096
|
+
You can also use the shorter `cs` alias for `customshape`:
|
1097
|
+
|
1098
|
+
```
|
1099
|
+
glimmer scaffold:cs[name,namespace]
|
1100
|
+
```
|
1101
|
+
|
1102
|
+
For example by running this command under a `hello_world` application:
|
1103
|
+
|
1104
|
+
```
|
1105
|
+
glimmer scaffold:cs[heart]
|
1106
|
+
```
|
1107
|
+
|
1108
|
+
That will generate this class under `app/hello_world/view/heart`:
|
1109
|
+
|
1110
|
+
```ruby
|
1111
|
+
class HelloWorld
|
1112
|
+
module View
|
1113
|
+
class Heart
|
1114
|
+
include Glimmer::LibUI::CustomShape
|
1115
|
+
|
1116
|
+
## Add options like the following to configure CustomShape by outside consumers
|
1117
|
+
#
|
1118
|
+
# options :option1, option2, option3
|
1119
|
+
option :background_color, default: :red
|
1120
|
+
option :size_width, default: 100
|
1121
|
+
option :size_height, default: 100
|
1122
|
+
option :location_x, default: 0
|
1123
|
+
option :location_y, default: 0
|
1124
|
+
|
1125
|
+
## Use before_body block to pre-initialize variables to use in body
|
1126
|
+
#
|
1127
|
+
#
|
1128
|
+
# before_body do
|
1129
|
+
#
|
1130
|
+
# end
|
1131
|
+
|
1132
|
+
## Use after_body block to setup observers for shapes in body
|
1133
|
+
#
|
1134
|
+
# after_body do
|
1135
|
+
#
|
1136
|
+
# end
|
1137
|
+
|
1138
|
+
## Add shape content under custom shape body
|
1139
|
+
#
|
1140
|
+
body {
|
1141
|
+
# Replace example content below (heart shape) with custom shape content
|
1142
|
+
shape(location_x, location_y) {
|
1143
|
+
# This fill color is shared under all direct children of `shape`
|
1144
|
+
fill background_color
|
1145
|
+
|
1146
|
+
bezier(
|
1147
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1148
|
+
size_width*0.65 - size_width*0.66, 0 - size_height*0.33,
|
1149
|
+
size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1150
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1151
|
+
)
|
1152
|
+
|
1153
|
+
bezier(
|
1154
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1155
|
+
size_width*1.35 - size_width*0.66, 0 - size_height*0.33,
|
1156
|
+
size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1157
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1158
|
+
)
|
1159
|
+
}
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
end
|
1165
|
+
```
|
1166
|
+
|
1167
|
+
When the generated file is required in another view (e.g. `require 'hello_world/view/heart'`), the [custom shape](#custom-components) keyword `heart` become available and reusable, like by calling:
|
1168
|
+
|
1169
|
+
```ruby
|
1170
|
+
window {
|
1171
|
+
area {
|
1172
|
+
heart
|
1173
|
+
}
|
1174
|
+
}
|
1175
|
+
```
|
1176
|
+
|
1177
|
+
You can pass `heart` options (as defined with `option` near the top of the class):
|
1178
|
+
|
1179
|
+
```ruby
|
1180
|
+
window {
|
1181
|
+
area {
|
1182
|
+
heart(location_x: 25, location_y: 50)
|
1183
|
+
}
|
1184
|
+
}
|
1185
|
+
```
|
1186
|
+
|
1187
|
+
Here is an example that generates a [custom shape](#custom-components) with a namespace:
|
1188
|
+
|
1189
|
+
```
|
1190
|
+
glimmer scaffold:cs[heart,acme]
|
1191
|
+
```
|
1192
|
+
|
1193
|
+
That will generate this class under `app/acme/view/heart`:
|
1194
|
+
|
1195
|
+
```ruby
|
1196
|
+
module Acme
|
1197
|
+
module View
|
1198
|
+
class Heart
|
1199
|
+
include Glimmer::LibUI::CustomShape
|
1200
|
+
|
1201
|
+
## Add options like the following to configure CustomShape by outside consumers
|
1202
|
+
#
|
1203
|
+
# options :option1, option2, option3
|
1204
|
+
option :background_color, default: :red
|
1205
|
+
option :size_width, default: 100
|
1206
|
+
option :size_height, default: 100
|
1207
|
+
option :location_x, default: 0
|
1208
|
+
option :location_y, default: 0
|
1209
|
+
|
1210
|
+
## Use before_body block to pre-initialize variables to use in body
|
1211
|
+
#
|
1212
|
+
#
|
1213
|
+
# before_body do
|
1214
|
+
#
|
1215
|
+
# end
|
1216
|
+
|
1217
|
+
## Use after_body block to setup observers for shapes in body
|
1218
|
+
#
|
1219
|
+
# after_body do
|
1220
|
+
#
|
1221
|
+
# end
|
1222
|
+
|
1223
|
+
## Add shape content under custom shape body
|
1224
|
+
#
|
1225
|
+
body {
|
1226
|
+
# Replace example content below (heart shape) with your own custom shape content
|
1227
|
+
shape(location_x, location_y) {
|
1228
|
+
# This fill color is shared under all direct children of `shape`
|
1229
|
+
fill background_color
|
1230
|
+
|
1231
|
+
bezier(
|
1232
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1233
|
+
size_width*0.65 - size_width*0.66, 0 - size_height*0.33,
|
1234
|
+
size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1235
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1236
|
+
)
|
1237
|
+
|
1238
|
+
bezier(
|
1239
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1240
|
+
size_width*1.35 - size_width*0.66, 0 - size_height*0.33,
|
1241
|
+
size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1242
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1243
|
+
)
|
1244
|
+
}
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
end
|
1248
|
+
end
|
1249
|
+
end
|
1250
|
+
```
|
1251
|
+
|
1252
|
+
When that file is required in another view (e.g. `require 'acme/view/heart'`), the `heart` keyword becomes available:
|
1253
|
+
|
1254
|
+
```ruby
|
1255
|
+
window {
|
1256
|
+
area {
|
1257
|
+
heart
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
```
|
1261
|
+
|
1262
|
+
If for whatever reason, you end up with 2 [custom shape](#custom-components) views having the same name with different namespaces, then you can invoke the specific [custom shape](#custom-components) you want by including the Ruby namespace in underscored format separated by double-underscores:
|
1263
|
+
|
1264
|
+
```ruby
|
1265
|
+
window {
|
1266
|
+
area {
|
1267
|
+
acme__view__heart
|
1268
|
+
}
|
1269
|
+
}
|
1270
|
+
```
|
1271
|
+
|
1272
|
+
Or another `heart` [custom shape](#custom-components) view:
|
1273
|
+
|
1274
|
+
```ruby
|
1275
|
+
window {
|
1276
|
+
area {
|
1277
|
+
hello_world__view__heart
|
1278
|
+
}
|
1279
|
+
}
|
1280
|
+
```
|
1281
|
+
|
1081
1282
|
### Scaffold Custom Control Gem
|
1082
1283
|
|
1083
1284
|
You can scaffold a Ruby gem around a reusable [custom control](#custom-components) to expose publicly and make available for multiple projects by running this command:
|
@@ -1124,7 +1325,7 @@ Or by using the raw rake command:
|
|
1124
1325
|
rake gemspec:generate
|
1125
1326
|
```
|
1126
1327
|
|
1127
|
-
Typically, consumers of the gem would include it in their own project, which makes the gem keyword available in the Glimmer GUI DSL anywhere `Glimmer`. `Glimmer::LibUI::Application`, `Glimmer::LibUI::CustomWindow`, or `Glimmer::LibUI::
|
1328
|
+
Typically, consumers of the gem would include it in their own project, which makes the gem keyword available in the Glimmer GUI DSL anywhere `Glimmer`. `Glimmer::LibUI::Application`, `Glimmer::LibUI::CustomWindow`, `Glimmer::LibUI::CustomControl`, or `Glimmer::LibUI::CustomShape` is mixed.
|
1128
1329
|
|
1129
1330
|
For example:
|
1130
1331
|
|
@@ -1192,7 +1393,7 @@ rake gemspec:generate
|
|
1192
1393
|
|
1193
1394
|
The project optionally allows you to run the custom window as its own separate app with a executable script (`bin/gem_name`) to see it, which helps with prototyping it.
|
1194
1395
|
|
1195
|
-
But, typically consumers of the gem would include it in their own project, which makes the gem keyword available in the Glimmer GUI DSL anywhere `Glimmer`. `Glimmer::LibUI::Application`, `Glimmer::LibUI::CustomWindow`, or `Glimmer::LibUI::
|
1396
|
+
But, typically consumers of the gem would include it in their own project, which makes the gem keyword available in the Glimmer GUI DSL anywhere `Glimmer`. `Glimmer::LibUI::Application`, `Glimmer::LibUI::CustomWindow`, `Glimmer::LibUI::CustomControl`, or `Glimmer::LibUI::CustomShape` is mixed.
|
1196
1397
|
|
1197
1398
|
For example:
|
1198
1399
|
|
@@ -1204,6 +1405,86 @@ greeter.show
|
|
1204
1405
|
...
|
1205
1406
|
```
|
1206
1407
|
|
1408
|
+
### Scaffold Custom Shape Gem
|
1409
|
+
|
1410
|
+
You can scaffold a Ruby gem around a reusable [custom shape](#custom-components) to expose publicly and make available for multiple projects by running this command:
|
1411
|
+
|
1412
|
+
```
|
1413
|
+
glimmer scaffold:gem:customshape[name,namespace]
|
1414
|
+
```
|
1415
|
+
|
1416
|
+
That will generate a [custom shape](#custom-components) gem project under the naming convention: `glimmer-libui-cc-name-namespace`
|
1417
|
+
|
1418
|
+
The naming convention helps with discoverability of Ruby gems using the command `glimmer list:gems:customshape[query]` (or alias: `glimmer list:gems:cs[query]`) where filtering `query` is optional.
|
1419
|
+
|
1420
|
+
The `name` is the [custom shape](#custom-components) class name, which must not contain dashes by convention (multiple words can be concatenated or can use underscores between them).
|
1421
|
+
|
1422
|
+
The `namespace` is needed to avoid clashing with other [custom shape](#custom-components) gems that other software engineers might have thought of. It is recommended not to include dashes between words in it by convention yet concatenated words or underscores between them.
|
1423
|
+
|
1424
|
+
Here is a shorter alias for the [custom shape](#custom-components) gem scaffolding command:
|
1425
|
+
|
1426
|
+
```
|
1427
|
+
glimmer scaffold:gem:cs[name,namespace]
|
1428
|
+
```
|
1429
|
+
|
1430
|
+
You can package the newly scaffolded project as a Ruby gem by running this command:
|
1431
|
+
|
1432
|
+
```
|
1433
|
+
glimmer package:gem
|
1434
|
+
```
|
1435
|
+
|
1436
|
+
Or by using the raw rake command:
|
1437
|
+
|
1438
|
+
```
|
1439
|
+
rake build
|
1440
|
+
```
|
1441
|
+
|
1442
|
+
You can generate the application gemspec explicitly if needed with this command (though it is not needed to build the gem):
|
1443
|
+
|
1444
|
+
```
|
1445
|
+
glimmer package:gemspec
|
1446
|
+
```
|
1447
|
+
|
1448
|
+
Or by using the raw rake command:
|
1449
|
+
|
1450
|
+
```
|
1451
|
+
rake gemspec:generate
|
1452
|
+
```
|
1453
|
+
|
1454
|
+
Typically, consumers of the gem would include it in their own project, which makes the gem keyword available in the Glimmer GUI DSL anywhere `Glimmer`. `Glimmer::LibUI::Application`, `Glimmer::LibUI::CustomWindow`, `Glimmer::LibUI::CustomControl`, or `Glimmer::LibUI::CustomShape` is mixed.
|
1455
|
+
|
1456
|
+
For example:
|
1457
|
+
|
1458
|
+
```ruby
|
1459
|
+
require 'glimmer-libui-cs-heart-acme'
|
1460
|
+
|
1461
|
+
...
|
1462
|
+
window {
|
1463
|
+
area {
|
1464
|
+
heart
|
1465
|
+
}
|
1466
|
+
}
|
1467
|
+
...
|
1468
|
+
```
|
1469
|
+
|
1470
|
+
### List Custom Control Gems
|
1471
|
+
|
1472
|
+
Custom control gems are scaffolded to follow the naming convention: `glimmer-libui-cc-name-namespace`
|
1473
|
+
|
1474
|
+
The naming convention helps with discoverability of Ruby gems using the command:
|
1475
|
+
|
1476
|
+
```
|
1477
|
+
glimmer list:gems:customcontrol[query]
|
1478
|
+
```
|
1479
|
+
|
1480
|
+
Or by using the shorter alias:
|
1481
|
+
|
1482
|
+
```
|
1483
|
+
glimmer list:gems:cc[query]
|
1484
|
+
```
|
1485
|
+
|
1486
|
+
The filtering `query` is optional.
|
1487
|
+
|
1207
1488
|
### List Custom Window Gems
|
1208
1489
|
|
1209
1490
|
Custom window gems are scaffolded to follow the naming convention: `glimmer-libui-cw-name-namespace`
|
@@ -1222,21 +1503,20 @@ glimmer list:gems:cw[query]
|
|
1222
1503
|
|
1223
1504
|
The filtering `query` is optional.
|
1224
1505
|
|
1506
|
+
### List Custom Shape Gems
|
1225
1507
|
|
1226
|
-
|
1227
|
-
|
1228
|
-
Custom control gems are scaffolded to follow the naming convention: `glimmer-libui-cw-name-namespace`
|
1508
|
+
Custom shape gems are scaffolded to follow the naming convention: `glimmer-libui-cs-name-namespace`
|
1229
1509
|
|
1230
1510
|
The naming convention helps with discoverability of Ruby gems using the command:
|
1231
1511
|
|
1232
1512
|
```
|
1233
|
-
glimmer list:gems:
|
1513
|
+
glimmer list:gems:customshape[query]
|
1234
1514
|
```
|
1235
1515
|
|
1236
1516
|
Or by using the shorter alias:
|
1237
1517
|
|
1238
1518
|
```
|
1239
|
-
glimmer list:gems:
|
1519
|
+
glimmer list:gems:cs[query]
|
1240
1520
|
```
|
1241
1521
|
|
1242
1522
|
The filtering `query` is optional.
|
@@ -2611,19 +2891,19 @@ SpinnerExample.new.launch
|
|
2611
2891
|
|
2612
2892
|
### Custom Components
|
2613
2893
|
|
2614
|
-
Custom components like custom controls, custom windows, and custom shapes can be defined to provide new features or act as composites of
|
2894
|
+
Custom components like custom controls, custom windows, and custom shapes can be defined to provide new features or act as composites of existing controls/shapes that need to be reused multiple times in an application or across multiple applications. Custom components save a lot of development time through reuse, improving productivity and maintainability immensely.
|
2615
2895
|
|
2616
2896
|
For example, you can define a custom `address_view` control as an aggregate of multiple `label` controls to reuse multiple times as a standard address View, displaying street, city, state, and zip code.
|
2617
2897
|
|
2618
|
-
There are two ways to define
|
2619
|
-
- Method-Based: simply define a method representing the
|
2620
|
-
- Class-Based: define a class matching the camelcased name of the
|
2898
|
+
There are two ways to define custom components:
|
2899
|
+
- Method-Based: simply define a method representing the custom component you want (e.g. `address_view`) with any options needed (e.g. `address(address_model: some_model)`).
|
2900
|
+
- Class-Based: define a class matching the camelcased name of the custom component by convention (e.g. the `address_view` custom component keyword would have a class called `AddressView`) and `include Glimmer::LibUI::CustomControl`, `include Glimmer::LibUI::CustomWindow`, or `include Glimmer::LibUI::CustomShape` depending on if the component represents a standard control, a whole window, or an [area canvas graphics shape](#area-path-shapes). Classes add the benefit of being able to distribute the custom components into a separate file for external reuse from multiple views or for sharing as a Ruby gem.
|
2621
2901
|
|
2622
2902
|
It is OK to use the terms "custom control", "custom component", and "custom keyword" synonymously though "custom component" is a broader term that covers things other than controls too like custom shapes (e.g. `cube`), custom attributed strings (e.g. `alternating_color_string`), and custom transforms (`isometric_transform`).
|
2623
2903
|
|
2624
2904
|
#### Method-Based Custom Controls
|
2625
2905
|
|
2626
|
-
Simply define a method representing the
|
2906
|
+
Simply define a method representing the custom component you want (e.g. `address_view`) with any arguments needed (e.g. `address(address_model)`).
|
2627
2907
|
|
2628
2908
|
Example that defines `form_field`, `address_form`, `label_pair`, and `address_view` keywords (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
2629
2909
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.1
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -633,7 +633,7 @@ require '#{window_type == :app ? current_dir_name : namespace}/model/greeting'
|
|
633
633
|
#
|
634
634
|
body {
|
635
635
|
window {
|
636
|
-
# Replace example content below with custom window content
|
636
|
+
# Replace example content below with your own custom window content
|
637
637
|
content_size 240, 240
|
638
638
|
title '#{human_name(namespace)}'
|
639
639
|
|
@@ -809,17 +809,24 @@ end
|
|
809
809
|
## Add shape content under custom shape body
|
810
810
|
#
|
811
811
|
body {
|
812
|
-
# Replace example content below with custom shape content
|
812
|
+
# Replace example content below (heart shape) with your own custom shape content
|
813
813
|
shape(location_x, location_y) {
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
814
|
+
# This fill color is shared under all direct children of `shape`
|
815
|
+
fill background_color
|
816
|
+
|
817
|
+
bezier(
|
818
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
819
|
+
size_width*0.65 - size_width*0.66, 0 - size_height*0.33,
|
820
|
+
size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
821
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
822
|
+
)
|
823
|
+
|
824
|
+
bezier(
|
825
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
826
|
+
size_width*1.35 - size_width*0.66, 0 - size_height*0.33,
|
827
|
+
size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
828
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
829
|
+
)
|
823
830
|
}
|
824
831
|
}
|
825
832
|
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -114,15 +114,15 @@ namespace :glimmer do
|
|
114
114
|
task :custom_control, [:name, :namespace] => :customcontrol
|
115
115
|
task :"custom-control", [:name, :namespace] => :customcontrol
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
117
|
+
desc 'Scaffold Glimmer::UI::CustomShape subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cs]'
|
118
|
+
task :customshape, [:name, :namespace] do |t, args|
|
119
|
+
require_relative 'rake_task/scaffold'
|
120
|
+
Glimmer::RakeTask::Scaffold.custom_shape(args[:name], args[:namespace])
|
121
|
+
end
|
122
|
+
|
123
|
+
task :cs, [:name, :namespace] => :customshape
|
124
|
+
task :custom_shape, [:name, :namespace] => :customshape
|
125
|
+
task :"custom-shape", [:name, :namespace] => :customshape
|
126
126
|
|
127
127
|
namespace :gem do
|
128
128
|
desc 'Scaffold Glimmer::UI::CustomWindow subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cw]'
|
@@ -145,15 +145,15 @@ namespace :glimmer do
|
|
145
145
|
task :custom_control, [:name, :namespace] => :customcontrol
|
146
146
|
task :"custom-control", [:name, :namespace] => :customcontrol
|
147
147
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
148
|
+
desc 'Scaffold Glimmer::UI::CustomShape subclass (part of a view) under its own Ruby gem project (namespace is required) [alt: scaffold:gem:cs]'
|
149
|
+
task :customshape, [:name, :namespace] do |t, args|
|
150
|
+
require_relative 'rake_task/scaffold'
|
151
|
+
Glimmer::RakeTask::Scaffold.custom_shape_gem(args[:name], args[:namespace])
|
152
|
+
end
|
153
|
+
|
154
|
+
task :cs, [:name, :namespace] => :customshape
|
155
|
+
task :custom_shape, [:name, :namespace] => :customshape
|
156
|
+
task :"custom-shape", [:name, :namespace] => :customshape
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|