display.contentWidth vs display.viewableContentWidth

Could any explain the specific difference between display.contentWidth and display.viewableContentWidth?

from the docs:

display.contentWidth
A read-only property representing the original width of the content in pixels. This will default to the screen width, but may be another value if you are using content scaling in config.lua.
display.viewableContentWidth
A read-only property that contains the width of the viewable screen area in pixels, within the coordinate system of the original content. This is useful since depending on which dynamic scaling mode is used, and the aspect ratio of the device used to view the content, some of the original content may be scaled in such a way that portions are off-screen.

Just wanted to post those because I’ve read them over and over, and still can’t figure out what the difference is. Could someone provide a practical example to illustrate how they differ?
[import]uid: 49447 topic_id: 17682 reply_id: 317682[/import]

Good question. I use display.contentWidth (and no problem so far), but I’ve always wondered how I might use display.viewableContentWidth. I’ve read the description over and over too, but I don’t quite get the difference in a way that may matter in practice. Example that illustrates the difference would be super helpful.

Naomi [import]uid: 67217 topic_id: 17682 reply_id: 67302[/import]

Hello Naomi,

We have the app HerbStat for iPhone and iPad. The code is in LUA and done with Corona… the problem is that the guy who did the programming used corona build 591 and did not format the text correctly for anything other than the iPhone/iPod… for the iPad it looks a little strange and for the Android (which we can’t upload because of the formatting problem) the text rolls off of the left side of the screen.

Do you do freelance work? We would like to be able to get the information out there to the Android people too…

Please let us know.

Ken Gremillion
Ana Corripio

statisticalnature@me.com
www.statisticalnature.com
[import]uid: 26285 topic_id: 17682 reply_id: 79776[/import]

Hey, Ken & Ana, thank you for asking. It’s really nice of you.

At the moment, I don’t do freelance work. I’m super focused on the game I’m building right now, and after I deploy it to iOS market, I’ll work on converting it for Android market. So… it will be a while before I’d be ready for a new project.

Thanks again for asking.

Naomi [import]uid: 67217 topic_id: 17682 reply_id: 79805[/import]

I had no idea what that meant either, but after some tests, I think it is reference to using “zoomEven” for scale in your config.lua file.
Corona will scale everything evenly until both scale values are greater than or equal to what you specify in the config file. If you specify 320x480 in your config and then test it on an both iPhones, you won’t see any difference. But if you test it on an iPad, some of the content is going to end up off the screen. And so viewableContentWidth/Height will return what is actually visible and not the full dimension value (unless it is all in view).

…hopefully I just didn’t make that more confusing.

[import]uid: 94868 topic_id: 17682 reply_id: 79826[/import]

@zaggy - I will be happy to help you out, if you are still looking for help.

[import]uid: 84539 topic_id: 17682 reply_id: 79829[/import]

Yes, thanks, we just sent you an email! [import]uid: 26285 topic_id: 17682 reply_id: 79834[/import]

@Screaming Leaf, I appreciate the explanation, but still not sure I understand the difference between the two.

I strongly feel that they should be renamed so that they are a bit more meaningful (self-documenting API anyone?). I’m not sure why you would want to use one over the other, in addition to not realizing how the actually differ. [import]uid: 49447 topic_id: 17682 reply_id: 79851[/import]

To me the display.viewableContentWidth output seems quite odd.

I’m building an app at 1280x800 with a scaleEven scale mode for the ipad.

I want to position a button in the bottom right corner of the screen. I would expect that on the iPad the value for display.viewableContentWidth to be 1024 but it’s not.

Ended up using some code from this post http://developer.anscamobile.com/code/device-metrics-scaling-based-screen-size but I think it’s something that should be addressed.

[import]uid: 91921 topic_id: 17682 reply_id: 85991[/import]

dr_stripes, thanks for the link! I have not seen that solution before, and appreciate you pointing it out.

While it may not be the most scalable solution, it looks like it solves a very annoying problem. Thanks again. [import]uid: 49447 topic_id: 17682 reply_id: 86090[/import]