Code: Select all
@REQUIRE "RapaGUI"
@REQUIRE "polybios"
@DISPLAY {Title="Test", Color=#WHITE, Layers=True, Width=600, Height=1920, ScaleMode=#SCALEMODE_LAYER, SmoothScale=True, Hidden=True, SingleMenu=True}
DesiredWidth=600
DesiredHeight=1920
CreateBrush(1, 600, 1920, #BLUE)
SetLineWidth(50)
SelectBrush(1)
Box(0, 0, 600, 1920, #RED)
Box(#CENTER, #CENTER, 400, 400, #RED)
EndSelect
DisplayBrush(1, 0, 0)
AppGUI$=[[<application id="app">
<window id="Main" notify="orientation">
<vgroup frame="true">
<hollywood id="HWDisplay" FixWidth="false" FixHeight="false" display="1"/>
</vgroup>
</window>
</application>]]
moai.CreateApp(AppGUI$)
Function p_RapaGUIEvents(msg)
Switch msg.attribute
Case "Orientation":
If moai.get("Main", "Orientation")="Portrait"
Local ScreenHeight=moai.get("Main", "Height")*2-DisplayScreenDiff
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
ElseIf moai.get("Main", "Orientation")="Landscape"
Local ScreenHeight=moai.get("Main", "Height")*2-DisplayScreenDiff
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
EndIf
EndSwitch
EndFunction
InstallEventHandler({RapaGUI=p_RapaGUIEvents})
Local TempVar=moai.get("Main", "Height")*2
Local ScreenHeight=GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT)
DisplayScreenDiff=TempVar-ScreenHeight
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
Repeat
WaitEvent
Forever