Allow null Application config
This commit is contained in:
@@ -153,13 +153,17 @@ class FlashApplication {
|
||||
Window.onWindowMove.add (parent.onWindowMove);
|
||||
Window.onWindowResize.add (parent.onWindowResize);
|
||||
|
||||
var window = new Window (config);
|
||||
var renderer = new Renderer (window);
|
||||
|
||||
window.width = config.width;
|
||||
window.height = config.height;
|
||||
|
||||
parent.addWindow (window);
|
||||
if (config != null) {
|
||||
|
||||
var window = new Window (config);
|
||||
var renderer = new Renderer (window);
|
||||
|
||||
window.width = config.width;
|
||||
window.height = config.height;
|
||||
|
||||
parent.addWindow (window);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -108,14 +108,18 @@ class HTML5Application {
|
||||
Window.onWindowMove.add (parent.onWindowMove);
|
||||
Window.onWindowResize.add (parent.onWindowResize);
|
||||
|
||||
var window = new Window (config);
|
||||
var renderer = new Renderer (window);
|
||||
|
||||
window.width = config.width;
|
||||
window.height = config.height;
|
||||
window.backend.element = config.element;
|
||||
|
||||
parent.addWindow (window);
|
||||
if (config != null) {
|
||||
|
||||
var window = new Window (config);
|
||||
var renderer = new Renderer (window);
|
||||
|
||||
window.width = config.width;
|
||||
window.height = config.height;
|
||||
window.backend.element = config.element;
|
||||
|
||||
parent.addWindow (window);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -80,13 +80,17 @@ class NativeApplication {
|
||||
Window.onWindowMove.add (parent.onWindowMove);
|
||||
Window.onWindowResize.add (parent.onWindowResize);
|
||||
|
||||
var window = new Window (config);
|
||||
var renderer = new Renderer (window);
|
||||
|
||||
window.width = config.width;
|
||||
window.height = config.height;
|
||||
|
||||
parent.addWindow (window);
|
||||
if (config != null) {
|
||||
|
||||
var window = new Window (config);
|
||||
var renderer = new Renderer (window);
|
||||
|
||||
window.width = config.width;
|
||||
window.height = config.height;
|
||||
|
||||
parent.addWindow (window);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,26 +40,33 @@ class NativeWindow {
|
||||
|
||||
public function create (application:Application):Void {
|
||||
|
||||
var title = "Lime Application";
|
||||
var flags = 0;
|
||||
|
||||
if (parent.config.antialiasing >= 4) {
|
||||
if (parent.config != null) {
|
||||
|
||||
flags |= cast WindowFlags.WINDOW_FLAG_HW_AA_HIRES;
|
||||
if (parent.config.antialiasing >= 4) {
|
||||
|
||||
flags |= cast WindowFlags.WINDOW_FLAG_HW_AA_HIRES;
|
||||
|
||||
} else if (parent.config.antialiasing >= 2) {
|
||||
|
||||
flags |= cast WindowFlags.WINDOW_FLAG_HW_AA;
|
||||
|
||||
}
|
||||
|
||||
} else if (parent.config.antialiasing >= 2) {
|
||||
if (parent.config.borderless) flags |= cast WindowFlags.WINDOW_FLAG_BORDERLESS;
|
||||
if (parent.config.depthBuffer) flags |= cast WindowFlags.WINDOW_FLAG_DEPTH_BUFFER;
|
||||
if (parent.config.fullscreen) flags |= cast WindowFlags.WINDOW_FLAG_FULLSCREEN;
|
||||
if (parent.config.resizable) flags |= cast WindowFlags.WINDOW_FLAG_RESIZABLE;
|
||||
if (parent.config.stencilBuffer) flags |= cast WindowFlags.WINDOW_FLAG_STENCIL_BUFFER;
|
||||
if (parent.config.vsync) flags |= cast WindowFlags.WINDOW_FLAG_VSYNC;
|
||||
|
||||
flags |= cast WindowFlags.WINDOW_FLAG_HW_AA;
|
||||
title = parent.config.title;
|
||||
|
||||
}
|
||||
|
||||
if (parent.config.borderless) flags |= cast WindowFlags.WINDOW_FLAG_BORDERLESS;
|
||||
if (parent.config.depthBuffer) flags |= cast WindowFlags.WINDOW_FLAG_DEPTH_BUFFER;
|
||||
if (parent.config.fullscreen) flags |= cast WindowFlags.WINDOW_FLAG_FULLSCREEN;
|
||||
if (parent.config.resizable) flags |= cast WindowFlags.WINDOW_FLAG_RESIZABLE;
|
||||
if (parent.config.stencilBuffer) flags |= cast WindowFlags.WINDOW_FLAG_STENCIL_BUFFER;
|
||||
if (parent.config.vsync) flags |= cast WindowFlags.WINDOW_FLAG_VSYNC;
|
||||
|
||||
handle = lime_window_create (application.backend.handle, parent.width, parent.height, flags, parent.config.title);
|
||||
handle = lime_window_create (application.backend.handle, parent.width, parent.height, flags, title);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,25 @@ class Window {
|
||||
@:noCompletion public var backend:WindowBackend;
|
||||
|
||||
|
||||
public function new (config:Config) {
|
||||
public function new (config:Config = null) {
|
||||
|
||||
this.config = config;
|
||||
|
||||
if (config == null) {
|
||||
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
} else {
|
||||
|
||||
width = config.width;
|
||||
height = config.height;
|
||||
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
||||
backend = new WindowBackend (this);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package lime;
|
||||
|
||||
|
||||
import lime.app.Application;
|
||||
import lime.ui.Window;
|
||||
import massive.munit.Assert;
|
||||
|
||||
|
||||
class WindowTest {
|
||||
|
||||
|
||||
private var app:Application;
|
||||
|
||||
|
||||
public function new () {
|
||||
|
||||
|
||||
@@ -14,9 +19,39 @@ class WindowTest {
|
||||
}
|
||||
|
||||
|
||||
@Test public function todo ():Void {
|
||||
@BeforeClass public function beforeClass ():Void {
|
||||
|
||||
Assert.isTrue(true);
|
||||
app = new Application ();
|
||||
app.create (null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test public function addWindow ():Void {
|
||||
|
||||
Assert.isNull (app.window);
|
||||
Assert.areEqual (0, app.windows.length);
|
||||
|
||||
var window = new Window ();
|
||||
app.addWindow (window);
|
||||
|
||||
Assert.isNotNull (app.window);
|
||||
Assert.areEqual (1, app.windows.length);
|
||||
Assert.areEqual (window, app.window);
|
||||
Assert.areEqual (window, app.windows[0]);
|
||||
|
||||
//Assert.areEqual (0, window.width);
|
||||
//Assert.areEqual (0, window.height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AfterClass public function afterClass ():Void {
|
||||
|
||||
// shutdown
|
||||
|
||||
//app = new Application ();
|
||||
//app.create (null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user