Permalink
Browse files

Mimic screen color with canvas when not showing bezel

  • Loading branch information...
nvh committed Apr 16, 2017
1 parent b9956e9 commit 376bc04969aee441b7e0dddbe615d0fbf8e9eab8
Showing with 40 additions and 0 deletions.
  1. +13 −0 framer/Components/DeviceComponent.coffee
  2. +27 −0 test/tests/DeviceComponentTest.coffee
@@ -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()
###########################################################################
@@ -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.