Bug with Proportional Scaling in RapaGUI 2.0 on Android
Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android
It probably goes back to the Hollywood 8 version of the Android player.
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android
Ok, I'll take a look.
Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android
I think the problem might be solved by delaying things like moai.get("Main", "Height") and GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT) until after the display has settled on its new attributes. It seems like the numbers are different initially (when first started and right after a screen rotation) compared to after a moment.
That seems to be why SetTimeout() helps for the initial scaling.
That seems to be why SetTimeout() helps for the initial scaling.
Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android
Revisiting an issue that has been troubling me for a while now...
The following code fixes the proportional scaling issue (kind of).
But the problem is that it requires a SystemRequest() message to be used. Without the message, the scaling is wrong (too long in Portrait mode and too short in Landscape mode); but with the message, the scaling is correct (at least on my phone).
Any ideas?
If a workaround can be used that does not require me to use SystemRequest(), that would be great.
The following code fixes the proportional scaling issue (kind of).
But the problem is that it requires a SystemRequest() message to be used. Without the message, the scaling is wrong (too long in Portrait mode and too short in Landscape mode); but with the message, the scaling is correct (at least on my phone).
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
If a workaround can be used that does not require me to use SystemRequest(), that would be great.