Permalink
Browse files

Flip showBezel to hideBezel

  • Loading branch information...
eelco committed Apr 20, 2017
1 parent 2979f9b commit fc5f1f029bbcad5c2ebe37183a5a2c5c1e37e471
Showing with 23 additions and 22 deletions.
  1. +18 −17 framer/Components/DeviceComponent.coffee
  2. +5 −5 test/tests/DeviceComponentTest.coffee
@@ -307,7 +307,7 @@ class exports.DeviceComponent extends BaseClass
if /PhantomJS/.test(navigator.userAgent)
return
if @_shouldRenderFullScreen() or not @showBezel
if @_shouldRenderFullScreen() or @hideBezel
@phone.image = ""
@hands.image = ""
else if not @_deviceImageUrl(@_deviceImageName())
@@ -361,24 +361,25 @@ class exports.DeviceComponent extends BaseClass
return "#{resourceUrl}/#{name}"
@define "showBezel",
@define "hideBezel",
get: ->
return @_showBezel ? true
set: (showBezel) ->
@_showBezel = showBezel
if @_showBezel
@screen.off "change:backgroundColor"
@background.off "change:backgroundColor"
if @_previousBackgroundColor?
@background.backgroundColor = @_previousBackgroundColor
else
return @_hideBezel ? false
set: (hideBezel) ->
@_hideBezel = hideBezel
if @_hideBezel
@_previousBackgroundColor = @background.backgroundColor
@background.backgroundColor = @screen.backgroundColor
@screen.on "change:backgroundColor", (color) =>
@background.backgroundColor = color
@background.on "change:backgroundColor", (color) =>
@_previousBackgroundColor = color
@background.backgroundColor = @screen.backgroundColor
else
@screen.off "change:backgroundColor"
@background.off "change:backgroundColor"
if @_previousBackgroundColor?
@background.backgroundColor = @_previousBackgroundColor
@_update()
###########################################################################
@@ -426,23 +427,23 @@ class exports.DeviceComponent extends BaseClass
_calculatePhoneScale: ->
# Calculates a phone scale that fits the screen unless a fixed value is set
dimension = if @showBezel then @phone else @screen
dimension = if @hideBezel then @screen else @phone
[width, height] = @_getOrientationDimensions(dimension.width, dimension.height)
if @showBezel
if @hideBezel
padding = 0
else
paddingOffset = @_device?.paddingOffset or 0
padding = (@padding + paddingOffset) * 2
else
padding = 0
phoneScale = _.min([
(window.innerWidth - padding) / width,
(window.innerHeight - padding) / height
])
# Never scale the phone beyond 100%
phoneScale = 1 if phoneScale > 1 and @showBezel
phoneScale = 1 if phoneScale > 1 and not @hideBezel
@emit("change:phoneScale", phoneScale)
@@ -592,7 +593,7 @@ class exports.DeviceComponent extends BaseClass
# HANDS
handSwitchingSupported: ->
return @_device.hands isnt undefined and @showBezel
return @_device.hands isnt undefined and not @hideBezel
nextHand: ->
return if @hands.rotationZ isnt 0
@@ -175,25 +175,25 @@ describe "DeviceComponent", ->
it "the background color should follow the screen color", ->
Canvas.backgroundColor = "red"
Framer.Device.screen.backgroundColor = "green"
Framer.Device.showBezel = false
Framer.Device.hideBezel = true
Canvas.backgroundColor.toName().should.eql "green"
Framer.Device.screen.backgroundColor = "blue"
Canvas.backgroundColor.toName().should.equal "blue"
it "should keep track of background changes", ->
Canvas.backgroundColor = "red"
Framer.Device.screen.backgroundColor = "green"
Framer.Device.showBezel = false
Framer.Device.hideBezel = true
Canvas.backgroundColor = "blue"
Canvas.backgroundColor.toName().should.equal "green"
Framer.Device.showBezel = true
Framer.Device.hideBezel = false
Canvas.backgroundColor.toName().should.equal "blue"
describe "when showing bezel", ->
it "should revert to the background color before disabling the bezel", ->
Canvas.backgroundColor = "red"
Framer.Device.screen.backgroundColor = "green"
Framer.Device.showBezel = false
Framer.Device.hideBezel = true
Canvas.backgroundColor.toName().should.eql "green"
Framer.Device.showBezel = true
Framer.Device.hideBezel = false
Canvas.backgroundColor.toName().should.equal "red"

0 comments on commit fc5f1f0

Please sign in to comment.