Fix Windows, minor refactor
This commit is contained in:
committed by
Joshua Granick
parent
d7064bd064
commit
dcad37447e
@@ -6,18 +6,20 @@ import lime.system.*;
|
|||||||
import lime.ui.*;
|
import lime.ui.*;
|
||||||
|
|
||||||
|
|
||||||
class Application implements IKeyEventListener implements IMouseEventListener implements IRenderEventListener implements ITouchEventListener implements IUpdateEventListener implements IWindowEventListener {
|
class Application implements IKeyEventListener implements IMouseEventListener implements ITouchEventListener implements IWindowEventListener {
|
||||||
|
|
||||||
|
|
||||||
public var handle:Dynamic;
|
public var handle:Dynamic;
|
||||||
|
|
||||||
private var config:Config;
|
private var config:Config;
|
||||||
|
private var delegate:EventDelegate;
|
||||||
private var lastUpdate:Int;
|
private var lastUpdate:Int;
|
||||||
private var windows:Array<Window>;
|
private var windows:Array<Window>;
|
||||||
|
|
||||||
|
|
||||||
public function new () {
|
public function new () {
|
||||||
|
|
||||||
|
delegate = new EventDelegate (this);
|
||||||
lastUpdate = 0;
|
lastUpdate = 0;
|
||||||
windows = new Array ();
|
windows = new Array ();
|
||||||
|
|
||||||
@@ -47,11 +49,12 @@ class Application implements IKeyEventListener implements IMouseEventListener im
|
|||||||
new UpdateEventManager ();
|
new UpdateEventManager ();
|
||||||
new WindowEventManager ();
|
new WindowEventManager ();
|
||||||
|
|
||||||
|
RenderEventManager.addEventListener (delegate);
|
||||||
|
UpdateEventManager.addEventListener (delegate);
|
||||||
|
|
||||||
KeyEventManager.addEventListener (this);
|
KeyEventManager.addEventListener (this);
|
||||||
MouseEventManager.addEventListener (this);
|
MouseEventManager.addEventListener (this);
|
||||||
RenderEventManager.addEventListener (this);
|
|
||||||
TouchEventManager.addEventListener (this);
|
TouchEventManager.addEventListener (this);
|
||||||
UpdateEventManager.addEventListener (this);
|
|
||||||
WindowEventManager.addEventListener (this);
|
WindowEventManager.addEventListener (this);
|
||||||
|
|
||||||
var window = new Window (this);
|
var window = new Window (this);
|
||||||
@@ -85,13 +88,25 @@ class Application implements IKeyEventListener implements IMouseEventListener im
|
|||||||
public function onMouseDown (event:MouseEvent):Void {}
|
public function onMouseDown (event:MouseEvent):Void {}
|
||||||
public function onMouseMove (event:MouseEvent):Void {}
|
public function onMouseMove (event:MouseEvent):Void {}
|
||||||
public function onMouseUp (event:MouseEvent):Void {}
|
public function onMouseUp (event:MouseEvent):Void {}
|
||||||
public function onRender (event:RenderEvent):Void {}
|
|
||||||
public function onTouchEnd (event:TouchEvent):Void {}
|
public function onTouchEnd (event:TouchEvent):Void {}
|
||||||
public function onTouchMove (event:TouchEvent):Void {}
|
public function onTouchMove (event:TouchEvent):Void {}
|
||||||
public function onTouchStart (event:TouchEvent):Void {}
|
public function onTouchStart (event:TouchEvent):Void {}
|
||||||
public function onUpdate (event:UpdateEvent):Void {}
|
|
||||||
public function onWindowActivate (event:WindowEvent):Void {}
|
public function onWindowActivate (event:WindowEvent):Void {}
|
||||||
public function onWindowDeactivate (event:WindowEvent):Void {}
|
public function onWindowDeactivate (event:WindowEvent):Void { }
|
||||||
|
|
||||||
|
|
||||||
|
public function render ():Void {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function update ():Void {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if (cpp || neko)
|
#if (cpp || neko)
|
||||||
@@ -101,4 +116,45 @@ class Application implements IKeyEventListener implements IMouseEventListener im
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@:access(lime.app.Application)
|
||||||
|
private class EventDelegate implements IRenderEventListener implements IUpdateEventListener {
|
||||||
|
|
||||||
|
|
||||||
|
private var application:Application;
|
||||||
|
|
||||||
|
|
||||||
|
public function new (application:Application) {
|
||||||
|
|
||||||
|
this.application = application;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function onRender (event:RenderEvent):Void {
|
||||||
|
|
||||||
|
application.render ();
|
||||||
|
|
||||||
|
for (window in application.windows) {
|
||||||
|
|
||||||
|
if (window.currentRenderer != null) {
|
||||||
|
|
||||||
|
window.currentRenderer.flip ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function onUpdate (event:UpdateEvent):Void {
|
||||||
|
|
||||||
|
application.update ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,23 +5,32 @@ import lime.system.System;
|
|||||||
import lime.ui.Window;
|
import lime.ui.Window;
|
||||||
|
|
||||||
|
|
||||||
class Renderer implements IRenderEventListener {
|
class Renderer {
|
||||||
|
|
||||||
|
|
||||||
public var handle:Dynamic;
|
public var handle:Dynamic;
|
||||||
|
|
||||||
|
private var window:Window;
|
||||||
|
|
||||||
|
|
||||||
public function new (window:Window) {
|
public function new (window:Window) {
|
||||||
|
|
||||||
|
this.window = window;
|
||||||
|
this.window.currentRenderer = this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function create ():Void {
|
||||||
|
|
||||||
#if (cpp || neko)
|
#if (cpp || neko)
|
||||||
handle = lime_renderer_create (window.handle);
|
handle = lime_renderer_create (window.handle);
|
||||||
RenderEventManager.addEventListener (this, -99999999);
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onRender (event:RenderEvent):Void {
|
public function flip ():Void {
|
||||||
|
|
||||||
#if (cpp || neko)
|
#if (cpp || neko)
|
||||||
lime_renderer_flip (handle);
|
lime_renderer_flip (handle);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package lime.ui;
|
|||||||
import lime.app.Application;
|
import lime.app.Application;
|
||||||
import lime.app.Config;
|
import lime.app.Config;
|
||||||
import lime.app.UpdateEventManager;
|
import lime.app.UpdateEventManager;
|
||||||
|
import lime.graphics.Renderer;
|
||||||
import lime.graphics.RenderEvent;
|
import lime.graphics.RenderEvent;
|
||||||
import lime.graphics.RenderEventManager;
|
import lime.graphics.RenderEventManager;
|
||||||
import lime.system.System;
|
import lime.system.System;
|
||||||
@@ -22,6 +23,7 @@ class Window {
|
|||||||
|
|
||||||
public static var instance:Window;
|
public static var instance:Window;
|
||||||
|
|
||||||
|
public var currentRenderer:Renderer;
|
||||||
#if js
|
#if js
|
||||||
public var element:HtmlElement;
|
public var element:HtmlElement;
|
||||||
#end
|
#end
|
||||||
@@ -189,6 +191,12 @@ class Window {
|
|||||||
UpdateEventManager.registerWindow (this);
|
UpdateEventManager.registerWindow (this);
|
||||||
WindowEventManager.registerWindow (this);
|
WindowEventManager.registerWindow (this);
|
||||||
|
|
||||||
|
if (currentRenderer != null) {
|
||||||
|
|
||||||
|
currentRenderer.create ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
#define LIME_UI_WINDOW_H
|
#define LIME_UI_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <app/Application.h>
|
|
||||||
|
|
||||||
#ifdef CreateWindow
|
#ifdef CreateWindow
|
||||||
#undef CreateWindow
|
#undef CreateWindow
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <app/Application.h>
|
||||||
|
|
||||||
|
|
||||||
namespace lime {
|
namespace lime {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user