neft
Version:
Universal Platform
66 lines (48 loc) • 1.66 kB
text/coffeescript
# Screen
'use strict'
utils = require 'src/utils'
signal = require 'src/signal'
assert = require 'src/assert'
module.exports = (Renderer, Impl, itemUtils) ->
class Screen extends signal.Emitter
constructor: ->
super()
= bindings: null
= false
= 1024
= 800
= 'Portrait'
Object.preventExtensions @
## ReadOnly *Boolean* Screen.touch = `false`
```javascript
Text {
text: Screen.touch ? 'Touch' : 'Mouse'
font.pixelSize: 30
}
```
utils.defineProperty @::, 'touch', null, ->
, null
## ReadOnly *Float* Screen.width = `1024`
utils.defineProperty @::, 'width', null, ->
, null
## ReadOnly *Float* Screen.height = `800`
utils.defineProperty @::, 'height', null, ->
, null
## ReadOnly *String* Screen.orientation = `'Portrait'`
May contains: Portrait, Landscape, InvertedPortrait, InvertedLandscape.
## *Signal* Screen.onOrientationChange(*String* oldValue)
itemUtils.defineProperty
constructor: @
name: 'orientation'
developmentSetter: (val) ->
assert.isString val
screen = new Screen
Impl.initScreenNamespace.call screen, ->
if Renderer.window
Renderer.window.width = screen.width
Renderer.window.height = screen.height
return
screen