-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDisplay.yaml
773 lines (708 loc) · 23.8 KB
/
Display.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
id: display
name: Display & Keyboard
subtitle: Using the Viewer's Display Modes
ordering:
- Display Modes
- Layout
- Showing and Hiding the Keyboard
- Recording Video of Your Project
- Backing Types
- Viewer Actions
functions:
#---------------------------------
# viewer.mode
#---------------------------------
- category: property
description: Changes the display mode of the viewer. You can use this to render
your games and simulations in fullscreen mode, fullscreen mode without buttons,
standard mode, or overlay mode.
examples:
- example: |
function setup()
--Set the viewer to fullscreen
viewer.mode = FULLSCREEN
end
- example: |
function setup()
--Set the viewer to standard
--i.e. visible parameters and output
viewer.mode = STANDARD
end
- example: |
function setup()
--Set the viewer to overlay
viewer.mode = OVERLAY
end
- example: |
function setup()
--Set the viewer to fullscreen
--Hide back/pause/play buttons
viewer.mode = FULLSCREEN_NO_BUTTONS
end
group: Display Modes
id: viewer.mode
name: viewer.mode
parameters:
- description: >
Either `STANDARD`, `OVERLAY`, `FULLSCREEN` or `FULLSCREEN_NO_BUTTONS`
name: mode
related:
- STANDARD
- OVERLAY
- FULLSCREEN
- FULLSCREEN_NO_BUTTONS
syntax: |
viewer.mode = STANDARD |
OVERLAY |
FULLSCREEN |
FULLSCREEN_NO_BUTTONS
returns: The current display mode
#---------------------------------
#---------------------------------
# viewer.preferredFPS
#---------------------------------
- category: property
description: >
Sets the preferred framerate of the viewer. You can set this to values of
0, 15, 30, 60 or 120. The value `0` is the default and will use the maximum framerate
of your device. Most devices support up to 60 frames per second, with some supporting
up to 120 frames per second
Note that this sets the preferred framerate, you should set this to a rate you
believe your project can consistently maintain. If the framerate cannot be maintained
it will drop below your preferred setting to the next lower value
examples:
- example: |
function setup()
--Set the viewer to a low framerate
viewer.preferredFPS = 15
end
group: Display Modes
id: viewer.preferredFPS
name: viewer.preferredFPS
parameters:
- description: >
Either 0, 15, 30, 60 or 120
name: preferredFPS
syntax: |
viewer.preferredFPS = 30
returns: The current display mode
#---------------------------------
#---------------------------------
# viewer.isPresenting
#---------------------------------
- category: property
description: >
Returns a boolean indicating whether the viewer is presenting
an alert or share sheet, or there is some other view obscuring
the viewer
examples:
- example: |
function draw()
if viewer.isPresenting == false then
-- Do something
end
end
group: Display Modes
id: viewer.isPresenting
name: viewer.isPresenting
parameters:
- description: >
true if the viewer is presenting a view
name: isPresenting
syntax: |
viewer.isPresenting
returns: Whether the viewer is presenting a view
#---------------------------------
#---------------------------------
# FULLSCREEN
#---------------------------------
- category: const
description: Use this value for `viewer.mode` to set the viewer to fullscreen
mode. The Back, Pause, Play and Reset buttons will still be visible in the lower
left corner of the screen.
group: Display Modes
id: FULLSCREEN
name: FULLSCREEN
related:
- viewer.mode
syntax: FULLSCREEN
#---------------------------------
#---------------------------------
# STANDARD
#---------------------------------
- category: const
description: >
When set on `viewer.mode` this sets the viewer to standard screen mode.
You will be able to see the output and parameters panes to the left of the viewer,
and the Back, Pause, Play and Reset buttons will be visible in the lower left
corner of the screen.
group: Display Modes
id: STANDARD
name: STANDARD
related:
- viewer.mode
syntax: |
viewer.mode = STANDARD
#---------------------------------
#---------------------------------
# OVERLAY
#---------------------------------
- category: const
description: >
This value is used with `viewer.mode` to set the viewer to overlay screen mode.
In this mode you will be able to see the output and parameter panes overlaid on
the viewer, the panes are semi-transparent in this mode so that you can see your
content through them.
group: Display Modes
id: OVERLAY
name: OVERLAY
related:
- viewer.mode
syntax: |
viewer.mode = OVERLAY
#---------------------------------
#---------------------------------
# FULLSCREEN_NO_BUTTONS
#---------------------------------
- category: const
description: >
Set this value on `viewer.mode` to set the viewer to fullscreen
mode and hide *all* buttons on the screen. Note: you will not be able
to exit the viewer unless you implement your own call to the `viewer.close()`
function. You can force the standard Back button to appear by triple-tapping
the screen with three fingers.
group: Display Modes
id: FULLSCREEN_NO_BUTTONS
name: FULLSCREEN_NO_BUTTONS
related:
- viewer.mode
- viewer.close
syntax: |
viewer.mode = FULLSCREEN_NO_BUTTONS
#---------------------------------
#---------------------------------
# Layout Overview
#---------------------------------
- category: overview
description: >
Codea will run your projects in any configuration your device supports, this could be in portrait or landscape orientation, in a split-view environment, or with the sidebar taking up space in your view.
Some devices include "safe areas," these areas are regions of the screen in which you should avoid rendering your content. You can access the safe area insets through the `layout.safeArea` property. These values are insets, and represent how much you should inset your content from the respective edge of the view in order to ensure it remains visible and interactive.
When the view size changes, Codea calls the global function `sizeChanged( width, height )` and passes it the new view size.
examples:
- example: |
function setup()
end
function sizeChanged( newWidth, newHeight )
-- This function gets called when
-- the view size changes
end
group: Layout
id: layoutOverview
name: Layout Overview
related:
- layout.horizontal
- layout.vertical
- layout.safeArea
- CurrentOrientation
#---------------------------------
#---------------------------------
# layout.safeArea
#---------------------------------
- category: const
description: >
This property contains a table specifying the current safe area insets of the viewer, access them by using `layout.safeArea.top`, `layout.safeArea.bottom`, `layout.safeArea.left`, and `layout.safeArea.right`
The safe area insets indicate how far from the respective edge of the screen you should avoid rendering your content into. For example, a safe area inset of `60` on the top edge might indicate your code is running on a device with a notched display, and so you should offset your interactive content `60` points from the top of the view in order to ensure its visibility.
examples:
- example: |
function setup()
-- We might have a bottom safe area
-- inset if we are running on a
-- device with an on-screen home
-- indicator
print(layout.safeArea.bottom)
end
group: Layout
id: layout.safeArea
name: layout.safeArea
parameters:
- description: >
number, the safe area inset for the top of the viewer
name: top
- description: >
number, the safe area inset for the left of the viewer
name: left
- description: >
number, the safe area inset for the bottom of the viewer
name: bottom
- description: >
number, the safe area inset for the right of the viewer
name: right
related:
- layoutOverview
#---------------------------------
#---------------------------------
# layout.horizontal
#---------------------------------
- category: const
description: >
This property specifies whether the viewer is running in a regular or compact horizontal layout mode. For example, when running Codea in split-view the horizontal layout mode of the viewer may switch to compact. You can use this property to switch your application into a state which may better deal with a smaller screen area.
The value of this property can be `layout.COMPACT`, `layout.REGULAR`, or `layout.UNSPECIFIED`
examples:
- example: |
-- This example prints the size class whenever
-- the viewer size changes, try adjusting into
-- split-view and back to see the mode change
function sizeChanged(w, h)
printSizeClass()
end
function printSizeClass()
if layout.horizontal == layout.REGULAR then
print("Regular size")
else
print("Compact size")
end
end
group: Layout
id: layout.horizontal
name: layout.horizontal
related:
- layoutOverview
- layout.vertical
#---------------------------------
#---------------------------------
# layout.vertical
#---------------------------------
- category: const
description: >
This property specifies whether the viewer is running in a regular or compact vertical layout mode. The vertical layout class may change when switching from portrait to landscape orientation on certain devices. Use this property to react accordingly.
The value of this property can be `layout.COMPACT`, `layout.REGULAR`, or `layout.UNSPECIFIED`
group: Layout
id: layout.vertical
name: layout.vertical
related:
- layoutOverview
- layout.horizontal
#---------------------------------
#---------------------------------
# layout.COMPACT
#---------------------------------
- category: const
description: >
This value indicates a compact layout environment for the specified dimension
group: Layout
id: layout.COMPACT
name: layout.COMPACT
related:
- layoutOverview
- layout.horizontal
- layout.vertical
#---------------------------------
#---------------------------------
# layout.REGULAR
#---------------------------------
- category: const
description: >
This value indicates a regular layout environment for the specified dimension
group: Layout
id: layout.REGULAR
name: layout.REGULAR
related:
- layoutOverview
- layout.horizontal
- layout.vertical
#---------------------------------
#---------------------------------
# CurrentOrientation
#---------------------------------
- category: const
description: >
This global contains the current orientation and can be one of
the following: `PORTRAIT`, `PORTRAIT_UPSIDE_DOWN`, `LANDSCAPE_LEFT`, `LANDSCAPE_RIGHT`.
group: Layout
id: CurrentOrientation
name: CurrentOrientation
related:
- PORTRAIT
- PORTRAIT_UPSIDE_DOWN
- LANDSCAPE_LEFT
- LANDSCAPE_RIGHT
#---------------------------------
#---------------------------------
# PORTRAIT
#---------------------------------
- category: const
description: Check for this value in `CurrentOrientation` to detect if the
device is in standard portrait orientation (home button at the bottom).
group: Layout
id: PORTRAIT
name: PORTRAIT
related:
- CurrentOrientation
- PORTRAIT_UPSIDE_DOWN
syntax: CurrentOrientation == PORTRAIT
#---------------------------------
#---------------------------------
# PORTRAIT_UPSIDE_DOWN
#---------------------------------
- category: const
description: Check for this value in `CurrentOrientation` to detect if the
device is in inverted portrait orientation (home button at the top).
group: Layout
id: PORTRAIT_UPSIDE_DOWN
name: PORTRAIT_UPSIDE_DOWN
related:
- CurrentOrientation
- PORTRAIT
syntax: CurrentOrientation == PORTRAIT_UPSIDE_DOWN
#---------------------------------
#---------------------------------
# LANDSCAPE_LEFT
#---------------------------------
- category: const
description: Check for this value in `CurrentOrientation` to detect if the
device is in landscape left orientation (home button on left).
group: Layout
id: LANDSCAPE_LEFT
name: LANDSCAPE_LEFT
related:
- CurrentOrientation
- LANDSCAPE_RIGHT
syntax: CurrentOrientation == LANDSCAPE_LEFT
#---------------------------------
#---------------------------------
# LANDSCAPE_RIGHT
#---------------------------------
- category: const
description: Check for this value in `CurrentOrientation` to detect if the
device is in landscape right orientation (home button on right).
group: Layout
id: LANDSCAPE_RIGHT
name: LANDSCAPE_RIGHT
related:
- CurrentOrientation
- LANDSCAPE_LEFT
syntax: CurrentOrientation == LANDSCAPE_RIGHT
#---------------------------------
#---------------------------------
# Using the Keyboard
#---------------------------------
- category: overview
description: |
You can use the keyboard in Codea to receive text input in your projects. In order to begin receiving keyboard events, call the `showKeyboard()` function. This will show the on-screen keyboard, unless an external keyboard is present. When key presses are made Codea calls the global function `keyboard( key )`. You must implement this function to receive keyboard events.
function keyboard( key )
print("Key pressed: '".. key .."'")
end
Alternatively you can read the current keyboard buffer by calling `keyboardBuffer()`. See the `keyboardBuffer()` documentation for an example.
group: Showing and Hiding the Keyboard
id: keyboardOverview
name: Using the Keyboard
related:
- showKeyboard
- hideKeyboard
- isKeyboardShowing
- keyboardBuffer
#---------------------------------
#---------------------------------
# showKeyboard
#---------------------------------
- category: function
description: This function enables keyboard input and displays the software
keyboard if necessary. After calling `showKeyboard()`, keyboard events
will be delivered to a global function `keyboard( key )`. The current keyboard
buffer can be read with the `keyboardBuffer()` function.
examples:
- example: |
function touched(touch)
--Show keyboard when the screen is touched
showKeyboard()
end
group: Showing and Hiding the Keyboard
id: showKeyboard
name: showKeyboard()
related:
- hideKeyboard
- isKeyboardShowing
- keyboardBuffer
syntax: showKeyboard()
#---------------------------------
#---------------------------------
# hideKeyboard
#---------------------------------
- category: function
description: This function disables keyboard input and hides the software keyboard
if necessary.
group: Showing and Hiding the Keyboard
id: hideKeyboard
name: hideKeyboard()
related:
- showKeyboard
- isKeyboardShowing
- keyboardBuffer
syntax: hideKeyboard()
#---------------------------------
#---------------------------------
# isKeyboardShowing
#---------------------------------
- category: function
description: This function returns whether the keyboard is currently active in the viewer.
group: Showing and Hiding the Keyboard
id: isKeyboardShowing
name: isKeyboardShowing()
returns: >
`true` if the keyboard is showing, `false` if not
related:
- showKeyboard
- hideKeyboard
- keyboardBuffer
syntax: isKeyboardShowing()
#---------------------------------
#---------------------------------
# keyboardBuffer
#---------------------------------
- category: function
description: This function reads the current keyboard buffer. Note that the
keyboard buffer is cleared when the keyboard is shown.
examples:
- example: |
function touched(touch)
--Show keyboard when the screen is touched
showKeyboard()
end
function draw()
background(40,40,50)
fill(255)
textMode(CORNER)
buffer = keyboardBuffer()
_,bufferHeight = textSize(buffer)
if buffer then
text( buffer, 10, HEIGHT - 30 - bufferHeight )
end
end
group: Showing and Hiding the Keyboard
id: keyboardBuffer
name: keyboardBuffer()
related:
- showKeyboard
- hideKeyboard
returns: Contents of keyboard buffer as a string
syntax: buffer = keyboardBuffer()
#---------------------------------
#---------------------------------
# BACKSPACE
#---------------------------------
- category: const
description: You can use this to check whether the key delivered to the global
`keyboard( key )` function was the backspace key..
examples:
- example: |
function keyboard(key)
-- Did the user press backspace?
if key == BACKSPACE then
-- Do something
end
end
group: Showing and Hiding the Keyboard
id: BACKSPACE
name: BACKSPACE
related:
- keyboardOverview
- showKeyboard
syntax: BACKSPACE
#---------------------------------
#---------------------------------
# startRecording
#---------------------------------
- category: function
description: This function initiates the video recording feature of Codea.
To stop video recording use the `stopRecording()` function. This function
is identical to pressing the video record button in the viewer interface. Do
not call this function in your `setup()` function.
group: Recording Video of Your Project
id: startRecording
name: startRecording()
related:
- stopRecording
- isRecording
syntax: startRecording()
#---------------------------------
#---------------------------------
# stopRecording
#---------------------------------
- category: function
description: Use this function to stop Codea's video recording feature and
save the recorded video to the device's camera roll.
group: Recording Video of Your Project
id: stopRecording
name: stopRecording()
related:
- startRecording
- isRecording
syntax: stopRecording()
#---------------------------------
#---------------------------------
# isRecording
#---------------------------------
- category: function
description: Use this function to programatically determine whether Codea is
currently recording the screen.
group: Recording Video of Your Project
id: isRecording
name: isRecording()
related:
- startRecording
- stopRecording
returns: Boolean, whether Codea is recording the screen
syntax: isRecording()
#---------------------------------
#---------------------------------
# viewer.retainedBacking
#---------------------------------
- category: property
description: Gets or sets the backing mode of the viewer. The default, `false`,
is the fastest drawing mode and **may not preserve** the contents of the
previously drawn frame when setting up next frame.
Set this to `true` force the viewer to copy the contents of the previous frame
into the current frame each time `draw()` is called. This is useful for
projects that need to paint onto the screen and preserve the screen's contents,
for example, painting or drawing applications.
examples:
- example: |
function setup()
--Use a standard backing mode (default)
viewer.retainedBacking = false
end
- example: |
function setup()
--Use a retained backing mode
viewer.retainedBacking = true
end
group: Backing Types
id: viewer.retainedBacking
name: viewer.retainedBacking
parameters:
- description: >
Either `true` or `false`
name: retainedBacking
related:
- viewer.mode
syntax: viewer.retainedBacking = true | false
#---------------------------------
#---------------------------------
# viewer.close
#---------------------------------
- category: function
description: Closes the viewer and returns to the editor. Calling `viewer.close()`
is functionally the same as pressing the on-screen Back button. This function
is useful if you are using `viewer.mode` with the `FULLSCREEN_NO_BUTTONS`
mode
examples:
- example: |
function touched(touch)
--Exit if user taps
if touch.tapCount == 1 and touch.state == ENDED then
viewer.close()
end
end
group: Viewer Actions
id: viewer.close
name: viewer.close()
related:
- viewer.mode
- FULLSCREEN_NO_BUTTONS
syntax: viewer.close()
#---------------------------------
# viewer.restart
#---------------------------------
- category: function
description: Restarts the viewer, starting your project again. Calling `viewer.restart()`
is functionally the same as pressing the on-screen Restart button. You can use
this function to restart your game, for example.
examples:
- example: |
function touched(touch)
--Restart if user taps
if touch.tapCount == 1 and touch.state == ENDED then
viewer.restart()
end
end
group: Viewer Actions
id: viewer.restart
name: viewer.restart()
related:
- viewer.close
syntax: viewer.restart()
#---------------------------------
# viewer.snapshot
#---------------------------------
- category: function
description: >
Captures the contents of the screen and returns it as an `image`
Note this only includes the rendered portion of your scene and does not include the
sidebar UI
examples:
- example: |
function touched(touch)
-- Capture the screen on tap
if touch.tapCount == 1 and touch.state == ENDED then
snapshot = viewer.snapshot()
end
end
group: Viewer Actions
id: viewer.snapshot
name: viewer.snapshot()
related:
- image
syntax: local img = viewer.snapshot()
returns: image, the contents of the screen
#---------------------------------
# viewer.alert
#---------------------------------
- category: function
description: >
Brings up a system alert view. The `message` parameter specifies
the message to display. The optional `title` parameter provides the title of
the alert view. If no title is specified, the title "Alert" is used.
examples:
- example: |
function touched(touch)
--Show alert if user taps
if touch.tapCount == 1 and touch.state == ENDED then
viewer.alert( "Hello World" )
end
end
group: Viewer Actions
parameters:
- description: string, message to display
name: message
- description: string, title of alert view
name: title
id: viewer.alert
name: viewer.alert()
syntax: |
viewer.alert( message )
viewer.alert( message, title )
#---------------------------------
# viewer.share
#---------------------------------
- category: function
description: >
Brings up a system share view for an image or text string. This allows you
to share content to a third-party service, save it to your device, or copy
it to the pasteboard.
examples:
- example: |
function touched(touch)
--Share the contents of the screen on tap
if touch.tapCount == 1 and touch.state == ENDED then
viewer.share(viewer.snapshot())
end
end
group: Viewer Actions
parameters:
- description: image or string, content to share
name: content
id: viewer.share
name: viewer.share()
syntax: |
viewer.share( image )
viewer.share( string )