Skip to content

Commit

Permalink
Mimic screen color with canvas when not showing bezel
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Apr 16, 2017
1 parent b9956e9 commit 376bc04
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions framer/Components/DeviceComponent.coffee
Expand Up @@ -366,6 +366,19 @@ class exports.DeviceComponent extends BaseClass
return @_showBezel ? true
set: (showBezel) ->
@_showBezel = showBezel
if @_showBezel
@screen.off "change:backgroundColor"
@background.off "change:backgroundColor"
if @_previousBackgroundColor?
@background.backgroundColor = @_previousBackgroundColor
else
@_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
@_update()

###########################################################################
Expand Down
27 changes: 27 additions & 0 deletions test/tests/DeviceComponentTest.coffee
Expand Up @@ -170,3 +170,30 @@ describe "DeviceComponent", ->
else
# Exceptions
assert(key in ["fullscreen", "custom", "sony-w85Oc", "test"], "#{key} should have a platform specified")

describe "when not showing bezel", ->
it "the background color should follow the screen color", ->
Canvas.backgroundColor = "red"
Framer.Device.screen.backgroundColor = "green"
Framer.Device.showBezel = false
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
Canvas.backgroundColor = "blue"
Canvas.backgroundColor.toName().should.equal "green"
Framer.Device.showBezel = true
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
Canvas.backgroundColor.toName().should.eql "green"
Framer.Device.showBezel = true
Canvas.backgroundColor.toName().should.equal "red"

0 comments on commit 376bc04

Please sign in to comment.