Create CirclePoster to address MaskGroup not scaling with resolution
This commit is contained in:
1 parent
6e84809923
commit
d99151ff21
4 files changed
+58
-18
No files matched your search
@@ -21,16 +21,12 @@
|
||||
width="104"
|
||||
height="104"
|
||||
uri="pkg:/images/circle-mask-500.png">
|
||||
<!-- TODO:P0 figure out why the masksize need to be 150 but the image is 100 -->
|
||||
<MaskGroup
|
||||
translation="[2,2]"
|
||||
masksize="[150,150]"
|
||||
maskuri="pkg:/images/circle-mask-500.png">
|
||||
<Poster
|
||||
id="thumbnail"
|
||||
width="100"
|
||||
height="100" />
|
||||
</MaskGroup>
|
||||
|
||||
<CirclePoster
|
||||
id="thumbnail"
|
||||
width="100"
|
||||
height="100"
|
||||
translation="[2,2]" />
|
||||
</Poster>
|
||||
|
||||
<Label
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
function Init()
|
||||
m.top.poster = m.top.findNode("Poster")
|
||||
m.top.maskGroup = m.top.findNode("MaskGroup")
|
||||
end function
|
||||
|
||||
function UpdateMaskSize()
|
||||
width = m.top.poster.width
|
||||
height = m.top.poster.height
|
||||
|
||||
maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
|
||||
m.top.maskGroup.maskSize = maskSize
|
||||
end function
|
||||
|
||||
' MaskGroup component do not scale with with UI resolution
|
||||
function GetScaleFactor() as float
|
||||
if m.scaleFactor <> invalid
|
||||
return m.scaleFactor
|
||||
end if
|
||||
deviceInfo = CreateObject("roDeviceInfo")
|
||||
uiResolutionWidth = deviceInfo.GetUIResolution().width
|
||||
' divide by 1280 because we have ui_resolutions=hd in manifest
|
||||
m.scaleFactor = uiResolutionWidth / 1280
|
||||
return m.scaleFactor
|
||||
end function
|
||||
@@ -0,0 +1,23 @@
|
||||
<component name="CirclePoster" extends="Group">
|
||||
<interface>
|
||||
<field id="poster" type="node" />
|
||||
<field id="maskGroup" type="node" />
|
||||
|
||||
<field id="width" type="integer" alias="Poster.width" onChange="UpdateMaskSize" />
|
||||
<field id="height" type="integer" alias="Poster.height" onChange="UpdateMaskSize" />
|
||||
<field id="uri" type="uri" alias="Poster.uri" />
|
||||
<field id="loadingBitmapUri" type="uri" alias="Poster.loadingBitmapUri" />
|
||||
<field id="failedBitmapUri" type="uri" alias="Poster.failedBitmapUri" />
|
||||
<field id="loadStatus" type="string" alias="Poster.loadStatus" />
|
||||
|
||||
<field id="maskUri" type="uri" value="pkg:/images/circle-mask-500.png" alias="MaskGroup.maskuri" />
|
||||
</interface>
|
||||
<children>
|
||||
<MaskGroup
|
||||
id="MaskGroup"
|
||||
maskuri="pkg:/images/circle-mask-500.png">
|
||||
<Poster
|
||||
id="Poster" />
|
||||
</MaskGroup>
|
||||
</children>
|
||||
</component>
|
||||
@@ -8,14 +8,11 @@
|
||||
<children>
|
||||
<LayoutGroup
|
||||
itemSpacings="[24,5,5]">
|
||||
<MaskGroup
|
||||
masksize="[294,294]"
|
||||
maskuri="pkg:/images/circle-mask-500.png">
|
||||
<Poster
|
||||
id="thumbnail"
|
||||
width="196"
|
||||
height="196" />
|
||||
</MaskGroup>
|
||||
|
||||
<CirclePoster
|
||||
id="thumbnail"
|
||||
width="196"
|
||||
height="196" />
|
||||
|
||||
<Label
|
||||
id="authorLabel"
|
||||
|
||||
Reference in new issue
Block a user