AIR: map orientation values from AIR to Lime
This commit is contained in:
@@ -8,11 +8,13 @@ import flash.display.NativeWindowSystemChrome;
|
|||||||
import flash.geom.Point;
|
import flash.geom.Point;
|
||||||
import flash.events.Event;
|
import flash.events.Event;
|
||||||
import flash.events.NativeWindowBoundsEvent;
|
import flash.events.NativeWindowBoundsEvent;
|
||||||
|
import flash.events.StageOrientationEvent;
|
||||||
import flash.html.HTMLLoader;
|
import flash.html.HTMLLoader;
|
||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
import lime._internal.backend.flash.FlashApplication;
|
import lime._internal.backend.flash.FlashApplication;
|
||||||
import lime._internal.backend.flash.FlashWindow;
|
import lime._internal.backend.flash.FlashWindow;
|
||||||
import lime.app.Application;
|
import lime.app.Application;
|
||||||
|
import lime.system.Orientation;
|
||||||
import lime.ui.Window;
|
import lime.ui.Window;
|
||||||
|
|
||||||
@:access(lime._internal.backend.flash.FlashApplication)
|
@:access(lime._internal.backend.flash.FlashApplication)
|
||||||
@@ -168,6 +170,8 @@ class AIRWindow extends FlashWindow
|
|||||||
parent.context.attributes.depth = true;
|
parent.context.attributes.depth = true;
|
||||||
parent.context.attributes.stencil = true;
|
parent.context.attributes.stencil = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, handleStageOrientationChangeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function focus():Void
|
public override function focus():Void
|
||||||
@@ -178,6 +182,41 @@ class AIRWindow extends FlashWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function handleStageOrientationChangeEvent(event:StageOrientationEvent):Void
|
||||||
|
{
|
||||||
|
if (parent.application.window == parent)
|
||||||
|
{
|
||||||
|
var newDeviceOrientation:Orientation = UNKNOWN;
|
||||||
|
switch (parent.stage.deviceOrientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
newDeviceOrientation = PORTRAIT;
|
||||||
|
case UPSIDE_DOWN:
|
||||||
|
newDeviceOrientation = PORTRAIT_FLIPPED;
|
||||||
|
case ROTATED_LEFT:
|
||||||
|
newDeviceOrientation = LANDSCAPE;
|
||||||
|
case ROTATED_RIGHT:
|
||||||
|
newDeviceOrientation = LANDSCAPE_FLIPPED;
|
||||||
|
default:
|
||||||
|
newDeviceOrientation = UNKNOWN;
|
||||||
|
}
|
||||||
|
parent.application.onDeviceOrientationChange.dispatch(newDeviceOrientation);
|
||||||
|
}
|
||||||
|
var newDisplayOrientation:Orientation = UNKNOWN;
|
||||||
|
switch (event.afterOrientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
newDisplayOrientation = PORTRAIT;
|
||||||
|
case UPSIDE_DOWN:
|
||||||
|
newDisplayOrientation = PORTRAIT_FLIPPED;
|
||||||
|
case ROTATED_LEFT:
|
||||||
|
newDisplayOrientation = LANDSCAPE_FLIPPED;
|
||||||
|
case ROTATED_RIGHT:
|
||||||
|
newDisplayOrientation = LANDSCAPE;
|
||||||
|
default:
|
||||||
|
newDisplayOrientation = UNKNOWN;
|
||||||
|
}
|
||||||
|
parent.application.onDisplayOrientationChange.dispatch(parent.display.id, newDisplayOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
private function handleNativeWindowEvent(event:Event):Void
|
private function handleNativeWindowEvent(event:Event):Void
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
|
|||||||
@@ -661,6 +661,20 @@ class Application extends Module
|
|||||||
{
|
{
|
||||||
#if (lime_cffi && !macro)
|
#if (lime_cffi && !macro)
|
||||||
return cast NativeCFFI.lime_system_get_device_orientation();
|
return cast NativeCFFI.lime_system_get_device_orientation();
|
||||||
|
#elseif air
|
||||||
|
switch (__window.stage.deviceOrientation)
|
||||||
|
{
|
||||||
|
case DEFAULT:
|
||||||
|
return PORTRAIT;
|
||||||
|
case UPSIDE_DOWN:
|
||||||
|
return PORTRAIT_FLIPPED;
|
||||||
|
case ROTATED_LEFT:
|
||||||
|
return LANDSCAPE;
|
||||||
|
case ROTATED_RIGHT:
|
||||||
|
return LANDSCAPE_FLIPPED;
|
||||||
|
default:
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
#elseif (js && html5)
|
#elseif (js && html5)
|
||||||
if (Browser.window.screen.orientation != null)
|
if (Browser.window.screen.orientation != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -310,6 +310,23 @@ class System
|
|||||||
#if flash
|
#if flash
|
||||||
display.dpi = Capabilities.screenDPI;
|
display.dpi = Capabilities.screenDPI;
|
||||||
display.currentMode = new DisplayMode(Std.int(Capabilities.screenResolutionX), Std.int(Capabilities.screenResolutionY), 60, ARGB32);
|
display.currentMode = new DisplayMode(Std.int(Capabilities.screenResolutionX), Std.int(Capabilities.screenResolutionY), 60, ARGB32);
|
||||||
|
#if air
|
||||||
|
switch (flash.Lib.current.stage.orientation) {
|
||||||
|
case DEFAULT:
|
||||||
|
display.orientation = PORTRAIT;
|
||||||
|
case UPSIDE_DOWN:
|
||||||
|
display.orientation = PORTRAIT_FLIPPED;
|
||||||
|
case ROTATED_LEFT:
|
||||||
|
display.orientation = LANDSCAPE_FLIPPED;
|
||||||
|
case ROTATED_RIGHT:
|
||||||
|
display.orientation = LANDSCAPE;
|
||||||
|
default:
|
||||||
|
display.orientation = UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
display.orientation = UNKNOWN;
|
||||||
|
#end
|
||||||
#elseif (js && html5)
|
#elseif (js && html5)
|
||||||
// var div = Browser.document.createElement ("div");
|
// var div = Browser.document.createElement ("div");
|
||||||
// div.style.width = "1in";
|
// div.style.width = "1in";
|
||||||
|
|||||||
Reference in New Issue
Block a user