Bug with Proportional Scaling in RapaGUI 2.0 on Android

Report any Hollywood bugs here
Post Reply
PEB
Posts: 229
Joined: Sun Feb 21, 2010 1:28 am

Bug with Proportional Scaling in RapaGUI 2.0 on Android

Post by PEB » Sat Feb 16, 2019 2:38 am

Please test the following code on the Android Hollywood player:

Code: Select all

@REQUIRE "RapaGUI"
@REQUIRE "polybios"
@DISPLAY {Color=#WHITE, Width=600, Height=1920, Layers=True, ScaleMode=#SCALEMODE_LAYER, SmoothScale=True, FitScale=True, KeepProportions=True, Hidden=True}

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" closegadget="true">
		<vgroup frame="true">
			<hollywood FixWidth="false" FixHeight="false" display="1"/>
		</vgroup>
	</window>
</application>]]
moai.CreateApp(AppGUI$)

Repeat
	WaitEvent
Forever
The proportional scaling is good; but what is not good is the large area of black on the right side of the display. Nothing should be black, since the display is set as #WHITE, and is filled with a brush that is #BLUE. (Also, the scaled display should appear in the center, not over to the left.)

User avatar
airsoftsoftwair
Posts: 2985
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android

Post by airsoftsoftwair » Sat Feb 16, 2019 1:30 pm

Yes, there's something wrong there. Will be fixed.

User avatar
airsoftsoftwair
Posts: 2985
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android

Post by airsoftsoftwair » Sat May 04, 2019 5:42 pm

Ok, so this probably won't be fixed. It is a general RapaGUI issue with "KeepProportions", i.e. it doesn't work on desktop systems either. As it looks, supporting "KeepProportions" in RapaGUI would mean going to some greater pains and this is probably not worth the effort.

PEB
Posts: 229
Joined: Sun Feb 21, 2010 1:28 am

Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android

Post by PEB » Sun May 05, 2019 12:20 am

That's too bad. (The main project that I'm working on right now needs proportional scaling to look right.)

I figured out a work-around that basically makes the display look the way that it should in both portrait and landscape orientation (but it involves some forced orientation changes at the start).

Here's the example from above with some work-around code added:

Code: Select all

@REQUIRE "RapaGUI"
@REQUIRE "polybios"
@DISPLAY {Title="Catechism", 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 FixWidth="false" FixHeight="false" display="1"/>
		</vgroup>
	</window>
</application>]]
moai.CreateApp(AppGUI$)

moai.set("Main", "Orientation", "Landscape")
moai.Set("Main", "open", True)
Wait(50)
LandscapeScreenHeight=GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT)
moai.set("Main", "Orientation", "Portrait")
Wait(50)
PortraitScreenHeight=GetAttribute(#DISPLAY, 1, #ATTRSCALEHEIGHT)
SetDisplayAttributes({ScaleWidth=100*(PortraitScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(PortraitScreenHeight/DesiredHeight) .. "%"})
moai.set("Main", "Orientation", "Device")

Function p_RapaGUIEvents(msg)
	Switch msg.attribute
	Case "Orientation":
		If moai.get("Main", "Orientation")="Portrait"
			SetDisplayAttributes({ScaleWidth=100*(PortraitScreenHeight/1844) .. "%", ScaleHeight=100*(PortraitScreenHeight/DesiredHeight) .. "%"})
		ElseIf moai.get("Main", "Orientation")="Landscape"
			SetDisplayAttributes({ScaleWidth=100*(LandscapeScreenHeight/DesiredHeight) .. "%", ScaleHeight=100*(LandscapeScreenHeight/DesiredHeight) .. "%"})
		EndIf
	EndSwitch
EndFunction
InstallEventHandler({RapaGUI=p_RapaGUIEvents})

Repeat
	WaitEvent
Forever
(If the display is not going to be rotated, then the work-around code can be simplified.)

Are there any other work-around solutions that you can suggest?

User avatar
airsoftsoftwair
Posts: 2985
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android

Post by airsoftsoftwair » Tue May 07, 2019 9:41 pm

PEB wrote:
Sun May 05, 2019 12:20 am
That's too bad. (The main project that I'm working on right now needs proportional scaling to look right.)
I've added a note about this on my to do list but don't count on it to happen because it's really complicated and needs lots of modifications in Hollywood, the Hollywood SDK, RapaGUI, and MUI Royale.
Are there any other work-around solutions that you can suggest?
Not if you need layers. If you don't need layers, you could just draw everything to a brush and then do the proportional scaling yourself. That's really simple and straightforward but of course it won't work with layers...

PEB
Posts: 229
Joined: Sun Feb 21, 2010 1:28 am

Re: Bug with Proportional Scaling in RapaGUI 2.0 on Android

Post by PEB » Thu Jun 13, 2019 4:25 am

Here's a much better work-around for the example above:

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
(This works nice and fast whether or not the screen is rotated.)

Post Reply