newScrollView - does it support resizing for orientation changes? (within storyboard/composer)

@Rob/@Brent

Do you know the answer to this offhand?  (i.e. before I start investing time trying to get it to work)

Question Does the new scrollView (newScrollView) support what would be required to handle orientation changes within a storyboard/composer environment? 

That is it would need to be able to handle calls to it to:

 - reset its size/width (not scrollable content size, which does seem to be supported)

 - reset its position 

 - then one would manually dispatch an event to UI components within the scroll view to re-lay these out as required.

Issue:  I did try initially and had problems then assumed it must not support this, so then went down the path of deleting and re-creating the whole scroll view area for the view each time you went in/out of the view, and on orientation change.  The issue is however it breaks to the storyboard/composer concept so you both lose the state of where you were in terms of scrolling, plus it adds additional time (response time) which is noticeable for the user.

If it doesn’t support this, perhaps it’s better to go back and create one’s own scrollview?  Wasn’t there an open source version of the v1 widgets?  Is there an open source version for v2?  Are there some negatives you can see to trying to go it alone here vs staying with the corona v2 widget?

The widgets are open source:

https://github.com/coronalabs/framework-widget

It would take some time to create your own scrollView, you can try to adjust the code to your needs.

BTW what issues did you have when trying to resize it?

it was a couple of weeks back so I can’t quite recall the details, however it was layout position related - I probably need to try again, however was interested to know if there were inherent problems…

re the github link - is the the widgets v2 source?    (if not, there could be extra work there I assume if one is now working with the latest build using Graphics 2.0?)

Yes it’s the V2 source.

It is currently synced with 2013.2114.

When you resize it you should be repositioning everything in the scroll view to fit the new size. It will take some fiddling I suppose.

ok primoz.cerar - I’ll have to give it another try then…    

OMG

I just found out today that I cannot change the scrollView’s height while the orientation changes.

I will be damned.

If :setScrollWidth() and :setScrollHeight() are not working, we will need a bug report (sample that demo’s the problem, with a config.lua and build.settings).  Please post the bugID back in this thread after you get the confirmation email.

In the mean time, I would consider having two scrollView’s, one sized for portrait and one sized for landscape.   Then based on the current orientation, hide the other one.  When you detect the orientation change, insert your objects in the other group and flip the visibility.  Depending on your scrolling, you would probably need to then reposition the scrollView to the right place.  Yes, this seems harsh, but orientation changes are harsh.   Even with Web sites, responsive designs have to execute a lot of JavaScript to re-draw the screen to fit the new layout.   This should be somethign that would happen fast enough to be covered in a single frame update.

HI Rob - it’s actually not the scrollable content height/width that I need to change, but the height/width of the scroll window.   It seems when you change the width/height (not scrollable content width/height) it partially works, but aspects such as the mask aren’t set properly.   

I’d thought I’d put a feature request in for this but it was for the same thing for newText (http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5416755-support-newtext-width-height-changes-e-g-to-supp)

What do you think, is this a bug or feature request?  Perhaps a feature request that widgets support width/height changes (and therefore orientation changes) in general?

Are you using a Mask?  With Graphics 2.0 They use containers which don’t need masks and I know containers are resizable.

I would go ahead and make a bug report because I think you should be able to change the width and height.

Rob

Yes, we are talking about the scrollView width & height, not the content’s.

I do redraw the whole scrollView when orientation happens for now, but to change a display object width/height should be supported directly I think.

submitted as bug - Case 31122

display.setStatusBar( display.HiddenStatusBar )  local widget = require( "widget" ) background = display.newRect( display.contentWidth/2, display.contentHeight/2, display.contentWidth, display.contentHeight) background.strokeWidth = 0 background:setFillColor(.9, 0.9, .8) ----------------------------------------- -- STTEP 1 - INITIAL SETUP ----------------------------------------- local scrollView = widget.newScrollView {     left = 50,    top = 50,     width = 200,    height = 100,     scrollWidth = 300, scrollHeight = 300,     id = "onBottom",     backgroundColor = { 0.8, 0.8, 0.8 }, } local lotsOfText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur imperdiet consectetur euismod. Phasellus non ipsum vel eros vestibulum consequat. Integer convallis quam id urna tristique eu viverra risus eleifend.\n\nAenean suscipit placerat venenatis. Pellentesque faucibus venenatis eleifend. Nam lorem felis, rhoncus vel rutrum quis, tincidunt in sapien. Proin eu elit tortor. Nam ut mauris pellentesque justo vulputate convallis eu vitae metus. Praesent mauris eros, hendrerit ac convallis vel, cursus quis sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque fermentum, dui in vehicula dapibus, lorem nisi placerat turpis, quis gravida elit lectus eget nibh. Mauris molestie auctor facilisis.\n\n " local lotsOfTextObject = display.newText( lotsOfText, display.contentCenterX, 0, 300, 0, native.systemFont, 14) lotsOfTextObject:setFillColor( 0 )  lotsOfTextObject.anchorY = 0.0        -- Top scrollView:insert( lotsOfTextObject ) ----------------------------------------- -- STTEP 2 - INITIAL SETUP ----------------------------------------- local testWithDynamicChange = true if testWithDynamicChange then     scrollView.width = 300     scrollView.height = 400 end  

I find that I am able to set the scrollView.height at runtime. What happens when you try?

ksan, try the code greg886 posted above.

I change the line for newText to

local lotsOfTextObject = display.newText( lotsOfText, 0, 0, 300, 0, native.systemFont, 14)

And you should see when the height/width of scrollView is changed, something is screwed.

I just tried with the latest build and the bug still exists (of course).

Yup. The background color for example does not readjust to the new size of the scrollView. The text also is placed funny. I totally agree there is lots to be fixed in there still. Thanks for submitting the bug report. The example is a little misleading though. The problem is not just related to the scrollView. The scrollView actually does resize but the text inside it does not. newText does not allow you to resize or change width etc at runtime. So you need to remove and readjust your text object placement in the scrollView.

Ksan,

in my own code, I do use texts inside the scrollView, however I don’t change the widths for the texts. I just want to change the height of the scrollView while orientation happens. And it doesn’t work as expected either. 

So if we just talk about changing the height, I think it can simplify a bit for the problem… still scrollView problem I think.

The widgets are open source:

https://github.com/coronalabs/framework-widget

It would take some time to create your own scrollView, you can try to adjust the code to your needs.

BTW what issues did you have when trying to resize it?

it was a couple of weeks back so I can’t quite recall the details, however it was layout position related - I probably need to try again, however was interested to know if there were inherent problems…

re the github link - is the the widgets v2 source?    (if not, there could be extra work there I assume if one is now working with the latest build using Graphics 2.0?)

Yes it’s the V2 source.

It is currently synced with 2013.2114.

When you resize it you should be repositioning everything in the scroll view to fit the new size. It will take some fiddling I suppose.

ok primoz.cerar - I’ll have to give it another try then…    

OMG

I just found out today that I cannot change the scrollView’s height while the orientation changes.

I will be damned.