glimmer-dsl-libui 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/README.md +298 -19
- data/VERSION +1 -1
- data/examples/snake/model/snake.rb +43 -17
- data/examples/snake.rb +6 -2
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a37cb8210f604b9307693af84b47ba0e21cf2a2b1059139af1d4ffa2eb727bf8
|
4
|
+
data.tar.gz: 88443d069ff718e8d28c90dbb59fc6ff5e5a05a5f3e9f5be78418d1754868769
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2e8c3f162744fe2266d66a088bceb7595b04643a141b0dd526309b6155362e24fad6c760cc8eb060030fec35352ab96b9dfad7e601e5a168271e1150aa7789
|
7
|
+
data.tar.gz: 90674bbf9623bcd0e985a94824698c3117a8a70bea79f7ee81d11364054c70d57f260466123717d2f292aa50f113cfb11201580a3f74bc74400a100f9c049d6d
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.10.2
|
4
|
+
|
5
|
+
- In Snake example, change snake direction on key press instead of key release to be more responsive for players who are not used to releasing pressed keys quickly
|
6
|
+
- In Snake example, fix issue with detecting collision too soon if a snake fills the entire space horizontally or vertically
|
7
|
+
- In Snake example, fix issue of hearing beeps on every direction change because of not properly informing LibUI when the area key down event is handled
|
8
|
+
- In Snake example, refactor `Snake::Model::Snake` to be more readable like high-level game domain rules (especially `move` method)
|
9
|
+
|
10
|
+
## 0.10.1
|
11
|
+
|
12
|
+
- Scaffold custom shape
|
13
|
+
- Scaffold custom shape gem
|
14
|
+
- List Custom Shape Gems (expected name format: `glimmer-libui-cs-gemname-namespace`) via `glimmer list:gems:customshape[query]`
|
15
|
+
|
3
16
|
## 0.10.0
|
4
17
|
|
5
|
-
- Support Custom Shapes
|
18
|
+
- Support Custom Shapes by mixing in `Glimmer::LibUI::CustomShape` to abstract composite shapes/text/image concepts inside an `area`
|
6
19
|
- `examples/basic_custom_shape.rb` example
|
7
20
|
- Support nesting listeners under a Custom Shape that will automatically get added to its `body_root` control
|
8
21
|
- Support nesting listeners under a Custom Control that will automatically get added to its `body_root` control
|
22
|
+
- Do not include `Glimmer` in top-level class when scaffolding Applications/Custom-Window-gems as it is unnecessary
|
9
23
|
|
10
24
|
## 0.9.7
|
11
25
|
|
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.2
|
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
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](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.2'
|
432
435
|
```
|
433
436
|
|
434
437
|
Test that installation worked by running the [Glimmer Meta-Example](#examples):
|
@@ -545,7 +548,6 @@ glimmer
|
|
545
548
|
```
|
546
549
|
|
547
550
|
```
|
548
|
-
% bin/glimmer
|
549
551
|
Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library) - Ruby Gem: glimmer-dsl-libui v0.8.0
|
550
552
|
|
551
553
|
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-ruby-option]...] (application.rb or task[task_args])
|
@@ -757,7 +759,7 @@ glimmer scaffold:cc[name,namespace]
|
|
757
759
|
For example by running this command under a `hello_world` application:
|
758
760
|
|
759
761
|
```
|
760
|
-
glimmer scaffold:
|
762
|
+
glimmer scaffold:cc[model_form]
|
761
763
|
```
|
762
764
|
|
763
765
|
That will generate this class under `app/hello_world/view/model_form`:
|
@@ -831,7 +833,7 @@ window {
|
|
831
833
|
Here is an example that generates a [custom control](#custom-components) with a namespace:
|
832
834
|
|
833
835
|
```
|
834
|
-
glimmer scaffold:
|
836
|
+
glimmer scaffold:cc[model_form,common]
|
835
837
|
```
|
836
838
|
|
837
839
|
That will generate this class under `app/common/view/model_form`:
|
@@ -1078,6 +1080,204 @@ Or another `train` custom window view:
|
|
1078
1080
|
hello_world__view__train.show
|
1079
1081
|
```
|
1080
1082
|
|
1083
|
+
### Scaffold Custom Shape
|
1084
|
+
|
1085
|
+
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:
|
1086
|
+
|
1087
|
+
```
|
1088
|
+
glimmer scaffold:customshape[name,namespace]
|
1089
|
+
```
|
1090
|
+
|
1091
|
+
The `name` represents the [custom shape](#custom-components) view class name (it can be underscored, and Glimmer will automatically classify it).
|
1092
|
+
|
1093
|
+
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).
|
1094
|
+
|
1095
|
+
You can also use the shorter `cs` alias for `customshape`:
|
1096
|
+
|
1097
|
+
```
|
1098
|
+
glimmer scaffold:cs[name,namespace]
|
1099
|
+
```
|
1100
|
+
|
1101
|
+
For example by running this command under a `hello_world` application:
|
1102
|
+
|
1103
|
+
```
|
1104
|
+
glimmer scaffold:cs[heart]
|
1105
|
+
```
|
1106
|
+
|
1107
|
+
That will generate this class under `app/hello_world/view/heart`:
|
1108
|
+
|
1109
|
+
```ruby
|
1110
|
+
class HelloWorld
|
1111
|
+
module View
|
1112
|
+
class Heart
|
1113
|
+
include Glimmer::LibUI::CustomShape
|
1114
|
+
|
1115
|
+
## Add options like the following to configure CustomShape by outside consumers
|
1116
|
+
#
|
1117
|
+
# options :option1, option2, option3
|
1118
|
+
option :background_color, default: :red
|
1119
|
+
option :size_width, default: 100
|
1120
|
+
option :size_height, default: 100
|
1121
|
+
option :location_x, default: 0
|
1122
|
+
option :location_y, default: 0
|
1123
|
+
|
1124
|
+
## Use before_body block to pre-initialize variables to use in body
|
1125
|
+
#
|
1126
|
+
#
|
1127
|
+
# before_body do
|
1128
|
+
#
|
1129
|
+
# end
|
1130
|
+
|
1131
|
+
## Use after_body block to setup observers for shapes in body
|
1132
|
+
#
|
1133
|
+
# after_body do
|
1134
|
+
#
|
1135
|
+
# end
|
1136
|
+
|
1137
|
+
## Add shape content under custom shape body
|
1138
|
+
#
|
1139
|
+
body {
|
1140
|
+
# Replace example content below (heart shape) with custom shape content
|
1141
|
+
shape(location_x, location_y) {
|
1142
|
+
# This fill color is shared under all direct children of `shape`
|
1143
|
+
fill background_color
|
1144
|
+
|
1145
|
+
bezier(
|
1146
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1147
|
+
size_width*0.65 - size_width*0.66, 0 - size_height*0.33,
|
1148
|
+
size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1149
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1150
|
+
)
|
1151
|
+
|
1152
|
+
bezier(
|
1153
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1154
|
+
size_width*1.35 - size_width*0.66, 0 - size_height*0.33,
|
1155
|
+
size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1156
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1157
|
+
)
|
1158
|
+
}
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
end
|
1162
|
+
end
|
1163
|
+
end
|
1164
|
+
```
|
1165
|
+
|
1166
|
+
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:
|
1167
|
+
|
1168
|
+
```ruby
|
1169
|
+
window {
|
1170
|
+
area {
|
1171
|
+
heart
|
1172
|
+
}
|
1173
|
+
}
|
1174
|
+
```
|
1175
|
+
|
1176
|
+
You can pass `heart` options (as defined with `option` near the top of the class):
|
1177
|
+
|
1178
|
+
```ruby
|
1179
|
+
window {
|
1180
|
+
area {
|
1181
|
+
heart(location_x: 25, location_y: 50)
|
1182
|
+
}
|
1183
|
+
}
|
1184
|
+
```
|
1185
|
+
|
1186
|
+
Here is an example that generates a [custom shape](#custom-components) with a namespace:
|
1187
|
+
|
1188
|
+
```
|
1189
|
+
glimmer scaffold:cs[heart,acme]
|
1190
|
+
```
|
1191
|
+
|
1192
|
+
That will generate this class under `app/acme/view/heart`:
|
1193
|
+
|
1194
|
+
```ruby
|
1195
|
+
module Acme
|
1196
|
+
module View
|
1197
|
+
class Heart
|
1198
|
+
include Glimmer::LibUI::CustomShape
|
1199
|
+
|
1200
|
+
## Add options like the following to configure CustomShape by outside consumers
|
1201
|
+
#
|
1202
|
+
# options :option1, option2, option3
|
1203
|
+
option :background_color, default: :red
|
1204
|
+
option :size_width, default: 100
|
1205
|
+
option :size_height, default: 100
|
1206
|
+
option :location_x, default: 0
|
1207
|
+
option :location_y, default: 0
|
1208
|
+
|
1209
|
+
## Use before_body block to pre-initialize variables to use in body
|
1210
|
+
#
|
1211
|
+
#
|
1212
|
+
# before_body do
|
1213
|
+
#
|
1214
|
+
# end
|
1215
|
+
|
1216
|
+
## Use after_body block to setup observers for shapes in body
|
1217
|
+
#
|
1218
|
+
# after_body do
|
1219
|
+
#
|
1220
|
+
# end
|
1221
|
+
|
1222
|
+
## Add shape content under custom shape body
|
1223
|
+
#
|
1224
|
+
body {
|
1225
|
+
# Replace example content below (heart shape) with your own custom shape content
|
1226
|
+
shape(location_x, location_y) {
|
1227
|
+
# This fill color is shared under all direct children of `shape`
|
1228
|
+
fill background_color
|
1229
|
+
|
1230
|
+
bezier(
|
1231
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1232
|
+
size_width*0.65 - size_width*0.66, 0 - size_height*0.33,
|
1233
|
+
size_width/2 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1234
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1235
|
+
)
|
1236
|
+
|
1237
|
+
bezier(
|
1238
|
+
size_width - size_width*0.66, size_height/2 - size_height*0.33,
|
1239
|
+
size_width*1.35 - size_width*0.66, 0 - size_height*0.33,
|
1240
|
+
size_width*1.5 - size_width*0.66, size_height*0.75 - size_height*0.33,
|
1241
|
+
size_width - size_width*0.66, size_height - size_height*0.33
|
1242
|
+
)
|
1243
|
+
}
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
end
|
1247
|
+
end
|
1248
|
+
end
|
1249
|
+
```
|
1250
|
+
|
1251
|
+
When that file is required in another view (e.g. `require 'acme/view/heart'`), the `heart` keyword becomes available:
|
1252
|
+
|
1253
|
+
```ruby
|
1254
|
+
window {
|
1255
|
+
area {
|
1256
|
+
heart
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
```
|
1260
|
+
|
1261
|
+
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:
|
1262
|
+
|
1263
|
+
```ruby
|
1264
|
+
window {
|
1265
|
+
area {
|
1266
|
+
acme__view__heart
|
1267
|
+
}
|
1268
|
+
}
|
1269
|
+
```
|
1270
|
+
|
1271
|
+
Or another `heart` [custom shape](#custom-components) view:
|
1272
|
+
|
1273
|
+
```ruby
|
1274
|
+
window {
|
1275
|
+
area {
|
1276
|
+
hello_world__view__heart
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
```
|
1280
|
+
|
1081
1281
|
### Scaffold Custom Control Gem
|
1082
1282
|
|
1083
1283
|
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 +1324,7 @@ Or by using the raw rake command:
|
|
1124
1324
|
rake gemspec:generate
|
1125
1325
|
```
|
1126
1326
|
|
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::
|
1327
|
+
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
1328
|
|
1129
1329
|
For example:
|
1130
1330
|
|
@@ -1192,7 +1392,7 @@ rake gemspec:generate
|
|
1192
1392
|
|
1193
1393
|
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
1394
|
|
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::
|
1395
|
+
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
1396
|
|
1197
1397
|
For example:
|
1198
1398
|
|
@@ -1204,6 +1404,86 @@ greeter.show
|
|
1204
1404
|
...
|
1205
1405
|
```
|
1206
1406
|
|
1407
|
+
### Scaffold Custom Shape Gem
|
1408
|
+
|
1409
|
+
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:
|
1410
|
+
|
1411
|
+
```
|
1412
|
+
glimmer scaffold:gem:customshape[name,namespace]
|
1413
|
+
```
|
1414
|
+
|
1415
|
+
That will generate a [custom shape](#custom-components) gem project under the naming convention: `glimmer-libui-cc-name-namespace`
|
1416
|
+
|
1417
|
+
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.
|
1418
|
+
|
1419
|
+
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).
|
1420
|
+
|
1421
|
+
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.
|
1422
|
+
|
1423
|
+
Here is a shorter alias for the [custom shape](#custom-components) gem scaffolding command:
|
1424
|
+
|
1425
|
+
```
|
1426
|
+
glimmer scaffold:gem:cs[name,namespace]
|
1427
|
+
```
|
1428
|
+
|
1429
|
+
You can package the newly scaffolded project as a Ruby gem by running this command:
|
1430
|
+
|
1431
|
+
```
|
1432
|
+
glimmer package:gem
|
1433
|
+
```
|
1434
|
+
|
1435
|
+
Or by using the raw rake command:
|
1436
|
+
|
1437
|
+
```
|
1438
|
+
rake build
|
1439
|
+
```
|
1440
|
+
|
1441
|
+
You can generate the application gemspec explicitly if needed with this command (though it is not needed to build the gem):
|
1442
|
+
|
1443
|
+
```
|
1444
|
+
glimmer package:gemspec
|
1445
|
+
```
|
1446
|
+
|
1447
|
+
Or by using the raw rake command:
|
1448
|
+
|
1449
|
+
```
|
1450
|
+
rake gemspec:generate
|
1451
|
+
```
|
1452
|
+
|
1453
|
+
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.
|
1454
|
+
|
1455
|
+
For example:
|
1456
|
+
|
1457
|
+
```ruby
|
1458
|
+
require 'glimmer-libui-cs-heart-acme'
|
1459
|
+
|
1460
|
+
...
|
1461
|
+
window {
|
1462
|
+
area {
|
1463
|
+
heart
|
1464
|
+
}
|
1465
|
+
}
|
1466
|
+
...
|
1467
|
+
```
|
1468
|
+
|
1469
|
+
### List Custom Control Gems
|
1470
|
+
|
1471
|
+
Custom control gems are scaffolded to follow the naming convention: `glimmer-libui-cc-name-namespace`
|
1472
|
+
|
1473
|
+
The naming convention helps with discoverability of Ruby gems using the command:
|
1474
|
+
|
1475
|
+
```
|
1476
|
+
glimmer list:gems:customcontrol[query]
|
1477
|
+
```
|
1478
|
+
|
1479
|
+
Or by using the shorter alias:
|
1480
|
+
|
1481
|
+
```
|
1482
|
+
glimmer list:gems:cc[query]
|
1483
|
+
```
|
1484
|
+
|
1485
|
+
The filtering `query` is optional.
|
1486
|
+
|
1207
1487
|
### List Custom Window Gems
|
1208
1488
|
|
1209
1489
|
Custom window gems are scaffolded to follow the naming convention: `glimmer-libui-cw-name-namespace`
|
@@ -1222,21 +1502,20 @@ glimmer list:gems:cw[query]
|
|
1222
1502
|
|
1223
1503
|
The filtering `query` is optional.
|
1224
1504
|
|
1505
|
+
### List Custom Shape Gems
|
1225
1506
|
|
1226
|
-
|
1227
|
-
|
1228
|
-
Custom control gems are scaffolded to follow the naming convention: `glimmer-libui-cw-name-namespace`
|
1507
|
+
Custom shape gems are scaffolded to follow the naming convention: `glimmer-libui-cs-name-namespace`
|
1229
1508
|
|
1230
1509
|
The naming convention helps with discoverability of Ruby gems using the command:
|
1231
1510
|
|
1232
1511
|
```
|
1233
|
-
glimmer list:gems:
|
1512
|
+
glimmer list:gems:customshape[query]
|
1234
1513
|
```
|
1235
1514
|
|
1236
1515
|
Or by using the shorter alias:
|
1237
1516
|
|
1238
1517
|
```
|
1239
|
-
glimmer list:gems:
|
1518
|
+
glimmer list:gems:cs[query]
|
1240
1519
|
```
|
1241
1520
|
|
1242
1521
|
The filtering `query` is optional.
|
@@ -2611,19 +2890,19 @@ SpinnerExample.new.launch
|
|
2611
2890
|
|
2612
2891
|
### Custom Components
|
2613
2892
|
|
2614
|
-
Custom components like custom controls, custom windows, and custom shapes can be defined to provide new features or act as composites of
|
2893
|
+
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
2894
|
|
2616
2895
|
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
2896
|
|
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
|
2897
|
+
There are two ways to define custom components:
|
2898
|
+
- 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)`).
|
2899
|
+
- 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
2900
|
|
2622
2901
|
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
2902
|
|
2624
2903
|
#### Method-Based Custom Controls
|
2625
2904
|
|
2626
|
-
Simply define a method representing the
|
2905
|
+
Simply define a method representing the custom component you want (e.g. `address_view`) with any arguments needed (e.g. `address(address_model)`).
|
2627
2906
|
|
2628
2907
|
Example that defines `form_field`, `address_form`, `label_pair`, and `address_view` keywords (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
2629
2908
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.2
|
@@ -47,10 +47,33 @@ class Snake
|
|
47
47
|
self.joins.clear
|
48
48
|
end
|
49
49
|
|
50
|
+
def turn_right
|
51
|
+
head.orientation = RIGHT_TURN_MAP[head.orientation]
|
52
|
+
end
|
53
|
+
|
54
|
+
def turn_left
|
55
|
+
head.orientation = LEFT_TURN_MAP[head.orientation]
|
56
|
+
end
|
57
|
+
|
50
58
|
def move
|
51
|
-
|
59
|
+
create_new_head
|
60
|
+
remove_old_tail
|
61
|
+
if detect_collision?
|
62
|
+
collide_and_die
|
63
|
+
else
|
64
|
+
append_new_head
|
65
|
+
eat_apple if detect_apple?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def remove_old_tail
|
70
|
+
@old_tail = tail.dup # save in case of growing and keeping old tail
|
71
|
+
@vertebrae.delete(tail)
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_new_head
|
52
75
|
@new_head = head.dup
|
53
|
-
case
|
76
|
+
case head.orientation
|
54
77
|
when :east
|
55
78
|
@new_head.column = (@new_head.column + 1) % @game.width
|
56
79
|
when :west
|
@@ -60,25 +83,28 @@ class Snake
|
|
60
83
|
when :north
|
61
84
|
@new_head.row = (@new_head.row - 1) % @game.height
|
62
85
|
end
|
63
|
-
if @vertebrae.map {|v| [v.row, v.column]}.include?([@new_head.row, @new_head.column])
|
64
|
-
self.collided = true
|
65
|
-
@game.over = true
|
66
|
-
else
|
67
|
-
@vertebrae.append(@new_head)
|
68
|
-
@vertebrae.delete(tail)
|
69
|
-
if head.row == @game.apple.row && head.column == @game.apple.column
|
70
|
-
grow
|
71
|
-
@game.apple.generate
|
72
|
-
end
|
73
|
-
end
|
74
86
|
end
|
75
87
|
|
76
|
-
def
|
77
|
-
|
88
|
+
def append_new_head
|
89
|
+
@vertebrae.append(@new_head)
|
78
90
|
end
|
79
91
|
|
80
|
-
def
|
81
|
-
|
92
|
+
def detect_collision?
|
93
|
+
@vertebrae.map {|v| [v.row, v.column]}.include?([@new_head.row, @new_head.column])
|
94
|
+
end
|
95
|
+
|
96
|
+
def collide_and_die
|
97
|
+
self.collided = true
|
98
|
+
@game.over = true
|
99
|
+
end
|
100
|
+
|
101
|
+
def detect_apple?
|
102
|
+
head.row == @game.apple.row && head.column == @game.apple.column
|
103
|
+
end
|
104
|
+
|
105
|
+
def eat_apple
|
106
|
+
grow
|
107
|
+
@game.apple.generate
|
82
108
|
end
|
83
109
|
|
84
110
|
def grow
|
data/examples/snake.rb
CHANGED
@@ -72,12 +72,16 @@ class Snake
|
|
72
72
|
fill <= [@grid.cells[row][column], :color] # data-bind square fill to grid cell color
|
73
73
|
}
|
74
74
|
|
75
|
-
|
75
|
+
on_key_down do |area_key_event|
|
76
|
+
handled = true # assume we will handle the event
|
76
77
|
if area_key_event[:key] == ' '
|
77
78
|
@game.toggle_pause
|
78
|
-
|
79
|
+
elsif %i[up right down left].include?(area_key_event[:ext_key])
|
79
80
|
@keypress_queue << area_key_event[:ext_key]
|
81
|
+
else
|
82
|
+
handled = false # we won't handle the event after all
|
80
83
|
end
|
84
|
+
handled
|
81
85
|
end
|
82
86
|
}
|
83
87
|
end
|
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
|
|
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.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|