From b212acdbf33fb508815aed2a1e87aba8bb7c24d4 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 7 Jul 2016 10:45:38 -0700 Subject: [PATCH] Allow transparent window background --- lime/_backend/html5/HTML5Renderer.hx | 2 +- lime/app/Config.hx | 2 +- lime/project/ProjectXMLParser.hx | 10 +++++++++- lime/project/WindowData.hx | 2 +- lime/system/System.hx | 2 +- lime/tools/platforms/HTML5Platform.hx | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lime/_backend/html5/HTML5Renderer.hx b/lime/_backend/html5/HTML5Renderer.hx index 1eb22a2fc..60b8155a7 100644 --- a/lime/_backend/html5/HTML5Renderer.hx +++ b/lime/_backend/html5/HTML5Renderer.hx @@ -64,7 +64,7 @@ class HTML5Renderer { var options = { - alpha: false, + alpha: (Reflect.hasField (parent.window.config, "background") && parent.window.config.background == null) ? true : false, antialias: Reflect.hasField (parent.window.config, "antialiasing") ? parent.window.config.antialiasing > 0 : false, depth: Reflect.hasField (parent.window.config, "depthBuffer") ? parent.window.config.depthBuffer : true, premultipliedAlpha: false, diff --git a/lime/app/Config.hx b/lime/app/Config.hx index 31e705e8d..77711d4d3 100644 --- a/lime/app/Config.hx +++ b/lime/app/Config.hx @@ -23,7 +23,7 @@ typedef WindowConfig = { @:optional var allowHighDPI:Bool; @:optional var antialiasing:Int; - @:optional var background:Int; + @:optional var background:Null; @:optional var borderless:Bool; @:optional var depthBuffer:Bool; @:optional var display:Int; diff --git a/lime/project/ProjectXMLParser.hx b/lime/project/ProjectXMLParser.hx index 19a832fbf..e3e6d559b 100644 --- a/lime/project/ProjectXMLParser.hx +++ b/lime/project/ProjectXMLParser.hx @@ -1784,7 +1784,15 @@ class ProjectXMLParser extends HXProject { } - windows[id].background = Std.parseInt (value); + if (value == "0x" || (value.length == 10 && StringTools.startsWith (value, "0x00"))) { + + windows[id].background = null; + + } else { + + windows[id].background = Std.parseInt (value); + + } case "orientation": diff --git a/lime/project/WindowData.hx b/lime/project/WindowData.hx index ecff64be8..dc8d3e6a8 100644 --- a/lime/project/WindowData.hx +++ b/lime/project/WindowData.hx @@ -7,7 +7,7 @@ typedef WindowData = { @:optional var height:Int; @:optional var x:Float; @:optional var y:Float; - @:optional var background:Int; + @:optional var background:Null; @:optional var parameters:String; @:optional var fps:Int; @:optional var hardware:Bool; diff --git a/lime/system/System.hx b/lime/system/System.hx index 2b4e4d9d5..418b10194 100644 --- a/lime/system/System.hx +++ b/lime/system/System.hx @@ -67,7 +67,7 @@ class System { var color = null; - if (background != null) { + if (background != null && background != "") { background = StringTools.replace (background, "#", ""); diff --git a/lime/tools/platforms/HTML5Platform.hx b/lime/tools/platforms/HTML5Platform.hx index 79654ce92..96592d239 100644 --- a/lime/tools/platforms/HTML5Platform.hx +++ b/lime/tools/platforms/HTML5Platform.hx @@ -169,7 +169,7 @@ class HTML5Platform extends PlatformTarget { var context = project.templateContext; - context.WIN_FLASHBACKGROUND = StringTools.hex (project.window.background, 6); + context.WIN_FLASHBACKGROUND = project.window.background != null ? StringTools.hex (project.window.background, 6) : ""; context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile;