Custom masks for Scrollviews in Graphics 2.0

Is it not possible anymore to give custom masks for scrollviews, as to how it worked in Graphics v1? 

I initially thought omitting maskFile parameter would automatically create a mask for the scrollView, and giving one will use the mask specified in maskFile. 
Apparently that’s not the case… 

Is it possible? Or do I have to edit the widget library code to implement this?

Hi @Satheesh,

You can’t use the “maskFile” parameter in V2, however, I’m 99% sure that you can simply apply a mask to the widget view itself (which is a group) using the standard masking APIs.

http://docs.coronalabs.com/guide/media/imageMask/index.html#groupmask

Brent

Not working. 

I tried scrollView:setMask  AND scrollView._view:setMask

Only the default mask gets applied. 

Hi Satheesh,

Applying the mask to the actual scrollView works fine for me. Both the scrollView and the actual mask image are sized at 280x216.

[lua]

local scrollView = widget.newScrollView {

    width = 280,

    height = 216,

    left = 100,

    top = 200,

    scrollWidth = 800,

    scrollHeight =  1200

}

local back = display.newImage( “mountains.png” )

scrollView:insert( back )

back.x = 140

back.y = 100

local mask = graphics.newMask( “maskframe.png” )

scrollView:setMask( mask )

[/lua]

*Facepalm*

I was giving 
 

local mask = "mask.png" local maskObj = graphics.newMask(mask) scrollView:setMask(mask)  

I was using the filename instead of the mask object. 
Ugh! 

Thanks Brent!

Quick question though. 
When I give a custom mask for the scrollView,  are both masks applied separately in different groups within the scrollview (or) does my custom mask replace the original mask?

I am asking because I do not want to exceed the texture limit for nested masks, since I am already using a higher layer mask.

Hey Satheesh,

When you apply a custom mask, two masks are applied separately. The reason behind that is that in G2.0, scrollview and tableview use containers ( which provide their own automatic mask for clipping ). So if you apply any further mask, it counts towards the texture limit.

Hope this helps,

alex

Ah. was afraid of that! 
Would be nice to have an option which disables the use of containers/default-masks for scrollViews…

Thanks Alex! 

Hi @Satheesh,

You can’t use the “maskFile” parameter in V2, however, I’m 99% sure that you can simply apply a mask to the widget view itself (which is a group) using the standard masking APIs.

http://docs.coronalabs.com/guide/media/imageMask/index.html#groupmask

Brent

Not working. 

I tried scrollView:setMask  AND scrollView._view:setMask

Only the default mask gets applied. 

Hi Satheesh,

Applying the mask to the actual scrollView works fine for me. Both the scrollView and the actual mask image are sized at 280x216.

[lua]

local scrollView = widget.newScrollView {

    width = 280,

    height = 216,

    left = 100,

    top = 200,

    scrollWidth = 800,

    scrollHeight =  1200

}

local back = display.newImage( “mountains.png” )

scrollView:insert( back )

back.x = 140

back.y = 100

local mask = graphics.newMask( “maskframe.png” )

scrollView:setMask( mask )

[/lua]

*Facepalm*

I was giving 
 

local mask = "mask.png" local maskObj = graphics.newMask(mask) scrollView:setMask(mask)  

I was using the filename instead of the mask object. 
Ugh! 

Thanks Brent!

Quick question though. 
When I give a custom mask for the scrollView,  are both masks applied separately in different groups within the scrollview (or) does my custom mask replace the original mask?

I am asking because I do not want to exceed the texture limit for nested masks, since I am already using a higher layer mask.

Hey Satheesh,

When you apply a custom mask, two masks are applied separately. The reason behind that is that in G2.0, scrollview and tableview use containers ( which provide their own automatic mask for clipping ). So if you apply any further mask, it counts towards the texture limit.

Hope this helps,

alex

Ah. was afraid of that! 
Would be nice to have an option which disables the use of containers/default-masks for scrollViews…

Thanks Alex!