Hi Josh, I have done quite a bit of this stuff.
The easiest way I see to do this is subclass LayoutContainer. Create another subclass of Layout. Then you can switch to this layout at runtime or compile time. Anyway, the purpose of this is to abstract the layout logic from the container. If you are adding no real new public API, then creating a class layout defining these rules is the best implementation. In your layout class you override measure and updateDisplayList. This way your layout code will always be separate from the component code. If your willing to mock up a diagram in a paint program, I might just give it a stab to give you an example, something else to put on my blog. :) If this is something you can't share to that degree, just let me know if the above doesn't make sense. OR since I might be over engineering this, you could try layout constraints in the Canvas. If you are defining a new 'layout' I would suggest the above implementation. Mike On Tue, Jun 17, 2008 at 6:16 PM, Josh McDonald <[EMAIL PROTECTED]> wrote: > Hey guys, > > About to build this based on a Container (with nested Grids perhaps?), but > if there's something out there that's a closer starting point I don't wanna > completely re-invent the wheel :) Here's what I need to do: > > I need to layout a bunch of rectangular components in something resembling > a 2 x n grid, but with flexible cell widths per row, ie everything lines up > horizontally, not necessarily vertically. > > Components are added to the container without any sizing / positioning > info, and the container does all the measuring and positioning to make the > best possible use of the space available > > If I've got 2 components of size 1x1, and one that's 1x2, I want the two > square ones on the left, and the long one on the right to make a 2x2 grid > > Rows of variable height, but every component in a row must be expanded to > fit that height > > Each row takes up the complete width of the widest row - if two components > in a row are each < width / 2, they'll be expanded to width / 2 each. > > If two "squareish" components are together less than one row width, but one > is > row width / 2, the smaller one will be made wider to keep things > looking neat. > > Only vertical scrolling, and only if necessary. I know, it can mean double > ups on measure() etc, and the Adobe guys clearly disagree with me, but as > far as I'm concerned it's the only acceptable solution UX-wise. > > Does something close to this exist, that I can base my component on? If > not, will it be of any use to the community when I'm done? It's probably the > kind of thing I can easily get the OK from the boss to open source. > > Cheers, > -Josh > > -- > "Therefore, send not to know For whom the bell tolls. It tolls for thee." > > :: Josh 'G-Funk' McDonald > :: 0437 221 380 :: [EMAIL PROTECTED] > > -- Teoti Graphix, LLC http://www.teotigraphix.com Teoti Graphix Blog http://www.blog.teotigraphix.com You can find more by solving the problem then by 'asking the question'.
