Add support for "Nine-Patch" stretchable button graphics

I’m continuing to be frustrated by the difficulty of developing non-game applications using Corona.

In Android, there is a feature called “Nine-Patch” stretchable PNG files that can be assigned to buttons. Basically it defines the corners and edges of a button so that a single background PNG file can be used for each button no matter what size the button is.

It’s fine that Corona started as an iPhone development system. But now with Android and all of the different screen sizes, we need much better ways to scale our graphics. Simply taking a single button bitmap background and scaling it to different screen sizes makes horrible looking buttons on some devices.

I suppose I could write all of my own graphics routines to try and take a 9-patch PNG file and split it into it’s different components and then draw my button background using all of those splits. But it should would be better if stuff like this was build into Corona so that we can make some actual REAL non-game apps using it.

If somebody has already done this, please point me in the right direction. I’ve already looked at the ui.lua file that is part of some of the sample apps. But it only supports a single bitmap image for the button and does not stretch properly. [import]uid: 12529 topic_id: 5846 reply_id: 305846[/import]

you could write a module that uses masking to take the various sections of your single button and return a display group containing the 9-slices, stretched as per parameters you pass to the initialize function

this would be better once we get a “render to texture” feature so that you’re not needing to display 9 masked images during rendering, but if you’re making an app that doesnt require superfast performance, this could work for now
[import]uid: 6645 topic_id: 5846 reply_id: 20054[/import]

Yes, I already said that I could probably do this myself. But doing this in Lua code is going to be a lot slower than having the API support this natively.

That is why I posted this to the “Feature Request” forum.

Android supports 9-patch natively so all Corona would need to do is handle it for iPhone.

Of course, the fact Corona doesn’t really even support buttons natively at all right now is probably a bigger issue. The stuff in ui.lua for making your own “buttons” shows the power of Lua, but Corona itself needs a lot more support for UI widgets (buttons, checkboxes, etc) for building non-game apps. [import]uid: 12529 topic_id: 5846 reply_id: 20198[/import]