Thank you so much! Nice work!
Thanks. I manage to have this dynamic mask’ing for my scrollview. Just to add :
"GENERIC_MASK_WIDTH " is the width of the mask file (png picture)
I implemented it as a function with slight changes ; A param which states the ‘mask filename’. In my example, the mask is 360x570 in size. By havingg this param, i have the flexibility of putting in other mask files to suit the page style.
function applyMask(params) local GENERIC\_MASK\_FILE = DEFAULT\_MASK\_FILE\_TABLE\_VIEW local generic\_mask\_width = 360 local generic\_mask\_height = 570 if params.object == nil then return end if params.width == nil then params.width = params.object.width end if params.height == nil then params.height = params.object.height end if params.mask == nil then params.mask = DEFAULT\_MASK\_FILE\_TABLE\_VIEW end local myMask = graphics.newMask(params.mask) params.object:setMask(myMask) params.object.maskScaleX = params.width/generic\_mask\_width params.object.maskScaleY = params.height/generic\_mask\_height --there may be a need in the future add logic to the positioning for different reference points params.object.maskX = params.width/2 params.object.maskY = params.height/2 end
Thank you dennis97! Just what I needed
@dennis97 thanks! It saves my day.
I was originally using display.save() to generate the mask file but something went wrong. I thought dennis method was not working! It took me one hour to realize the size of the saved file varies depending on the device. If someone is doing the same, hope it helps a bit.
I’m now working with daily build 2153, and I need to use tableview widget. To get started, I’ve looked at the ListView3 sample code that comes bundled with Corona SDK – and I noticed that the options table for the widget.newTableView includes maskFile.
However, I don’t see any description of it documented here: http://docs.coronalabs.com/daily/api/library/widget/newTableView.html
I also looked up the feature request: http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3577113-automatic-masks-for-scrollview-and-tableview-widge
David mentioned it would be implemented with Graphics 2.0, but the feature request page doesn’t suggest it’s been done and released yet.
Since Graphics 2.0 has been out for a while now, I’m wondering if this maskFile is automatically and dynamically scaled, or if we still need to implement our own workaround (and if so, I’ll definitely use the mask.lua that dennis97 graciously shared with us. Thank you so much.)
And if it does scale dynamically, do we need to supply @2x, @4x mask file, or no need since it just needs to be a solid white graphic image?
I’d so appreciate hearing the status of tableview widget as it relates to automatic mask feature.
Naomi
No need for it anymore since G2.0 since the scrollView and tableView are now a container at the top level so they mask automatically like containers do.
Not sure if tableView resizes if you change width or height after creation or it will just mask out part of it so watch for that.
@primoz.cerar, thank you. That sounds great! I have no intention of changing the size of the table after I create it, so I suppose I won’t have to worry about potential problem there.
Thanks again!
Naomi
Hi Naomi!
With Graphics 2.0, widget.newScrollView and widget.newTableView now automatically create a rectangular mask based on the set width and height of the object. It uses the display.newContainer() feature under the hood. The benefit to this is that you no longer have to mask the tableView. The drawBack is that now it’s a rectangular mask. Some people were using rounded corners to give it a non-rectangular shape.
I think you can still set a mask to do this, but it’s going to seriously push your nested masking limits.
As for the 2x 4x question, masks don’t need to have @2x and @4x versions since the 1x version will scale to any size.
Rob
Hey, Rob, thanks for the info. It sounds like I don’t need to include maskFile in the options param table for widget.newTableView at all then – especially since I don’t particularly need rounded corners for the table.
Perfect.
Cheers,
Naomi
^^ Exactly. I’m surprised the CL samples still have the masks in them.
Would be nice if maskFile was included that CL would skip adding the container mask. Would make it work for all cases, yes?
There are some situations where non-rectangular masks are desired.
Jay
I agree, that would make it very versatile. I believe the official response on that front is that if non-rectangular masks still required then people must file a feature request as this “previously existing” feature has been dropped in favor of the dynamic masking. Can’t recall which thread I read this on but I think the official position is either this or the other. I might be wrong.
I’m now working with daily build 2153, and I need to use tableview widget. To get started, I’ve looked at the ListView3 sample code that comes bundled with Corona SDK – and I noticed that the options table for the widget.newTableView includes maskFile.
However, I don’t see any description of it documented here: http://docs.coronalabs.com/daily/api/library/widget/newTableView.html
I also looked up the feature request: http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/3577113-automatic-masks-for-scrollview-and-tableview-widge
David mentioned it would be implemented with Graphics 2.0, but the feature request page doesn’t suggest it’s been done and released yet.
Since Graphics 2.0 has been out for a while now, I’m wondering if this maskFile is automatically and dynamically scaled, or if we still need to implement our own workaround (and if so, I’ll definitely use the mask.lua that dennis97 graciously shared with us. Thank you so much.)
And if it does scale dynamically, do we need to supply @2x, @4x mask file, or no need since it just needs to be a solid white graphic image?
I’d so appreciate hearing the status of tableview widget as it relates to automatic mask feature.
Naomi
No need for it anymore since G2.0 since the scrollView and tableView are now a container at the top level so they mask automatically like containers do.
Not sure if tableView resizes if you change width or height after creation or it will just mask out part of it so watch for that.
@primoz.cerar, thank you. That sounds great! I have no intention of changing the size of the table after I create it, so I suppose I won’t have to worry about potential problem there.
Thanks again!
Naomi
Hi Naomi!
With Graphics 2.0, widget.newScrollView and widget.newTableView now automatically create a rectangular mask based on the set width and height of the object. It uses the display.newContainer() feature under the hood. The benefit to this is that you no longer have to mask the tableView. The drawBack is that now it’s a rectangular mask. Some people were using rounded corners to give it a non-rectangular shape.
I think you can still set a mask to do this, but it’s going to seriously push your nested masking limits.
As for the 2x 4x question, masks don’t need to have @2x and @4x versions since the 1x version will scale to any size.
Rob
Hey, Rob, thanks for the info. It sounds like I don’t need to include maskFile in the options param table for widget.newTableView at all then – especially since I don’t particularly need rounded corners for the table.
Perfect.
Cheers,
Naomi
^^ Exactly. I’m surprised the CL samples still have the masks in them.
Would be nice if maskFile was included that CL would skip adding the container mask. Would make it work for all cases, yes?
There are some situations where non-rectangular masks are desired.
Jay