Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android
Posted: Thu Aug 19, 2021 12:14 am
It probably goes back to the Hollywood 8 version of the Android player.
The Cross-Platform Multimedia Application Layer
https://forums.hollywood-mal.com/
Code: Select all
@REQUIRE "RapaGUI", {ScaleHollywood = False}
@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":
SystemRequest("Test", "Test", "OK"); THIS IS THE LINE THAT MAKES ALL THE DIFFERENCE
If moai.get("Main", "Orientation")="Portrait"
Local ScreenWidth, ScreenHeight
Repeat
ScreenWidth = moai.get("Main", "Width")
ScreenHeight = moai.get("Main", "Height")
VWait
Until ScreenHeight>ScreenWidth
ScreenHeight = ScreenHeight*ScaleFactor-DisplayScreenDiff
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
ElseIf moai.get("Main", "Orientation")="Landscape"
Local ScreenWidth, ScreenHeight
Repeat
ScreenWidth = moai.get("Main", "Width")
ScreenHeight = moai.get("Main", "Height")
VWait
Until ScreenWidth>ScreenHeight
ScreenHeight = ScreenHeight*ScaleFactor-DisplayScreenDiff
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
EndIf
EndSwitch
EndFunction
InstallEventHandler({RapaGUI=p_RapaGUIEvents})
Function p_FirstScale()
ScaleFactor=GetAttribute(#DISPLAY, 1, #ATTRHOSTSCALE)
Local TempVar=moai.get("Main", "Height")*ScaleFactor
Local ScreenHeight=GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT)
DisplayScreenDiff=TempVar-ScreenHeight
SetDisplayAttributes({ScaleWidth=100*(ScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(ScreenHeight/DesiredHeight) .. "%"})
EndFunction
SetTimeout(1, p_FirstScale, 100)
Repeat
WaitEvent
Forever