play-co / timestep

GNU General Public License v3.0
16 stars 27 forks source link

Viewpools using boxlayout don't autoresize #14

Closed rampr closed 11 years ago

rampr commented 11 years ago

This particular scenario doesn't work

  1. Viewpools are created with box layout
  2. Viewpools are obtained displayed and then released
  3. Viewpools are obtained once more but this time the parent's dimensions(height,width) have changed.
  4. The Viewpools retain the old dimensions(x,y etc..) because I think the reflow event isn't triggered on them.

This has started appearing in the release-0.1.30 version of timestep. release-0.1.29 did not have this issue.

bubbleboy14 commented 11 years ago

Hey rampr. I can't reproduce this. Here's my test code:

import ui.View as View; import ui.ViewPool as ViewPool;

var colors = [ 'red', 'green', 'yellow', 'blue', 'purple' ]; var sizeIndex = 0; var sizes = [ '20%', '50%', '80%' ];

exports = Class(GC.Application, function () { this.initUI = function () { var supe = new View({ superview: this, backgroundColor: 'gray', layout: 'linear', direction: 'vertical', layoutWidth: '80%', layoutHeight: '80%', centerX: true, centerY: true }); var vp = new ViewPool({ ctor: View, initCount: 5, initOpts: { layout: 'box', flex: 1 } }); supe.on('InputSelect', function() { var kids = supe.getSubviews(); if (kids.length) { kids.forEach(function(kid) { kid.removeFromSuperview(); vp.releaseView(kid); }); } else { sizeIndex = (sizeIndex + 1) % 3; supe.style.layoutWidth = supe.style.layoutHeight = sizes[sizeIndex]; for (var i = 0; i < 5; i++) { var v = vp.obtainView(); v.updateOpts({ superview: supe, backgroundColor: colors[i], visible: true }); } } }); }; });

If you are still experiencing this bug, could you please provide a test case?

rampr commented 11 years ago

Hi, I'll try creating a testcase. Maybe the steps are more complex than what I mentioned to get the bug

jishnu7 commented 11 years ago

Hi, seems like problem is with box layout inside a parent box. here is your test case modified to create the problem. http://sprunge.us/UEPf

bubbleboy14 commented 11 years ago

Thanks for the bug report. Fixed!