   GUI layout algorithm?
  I use C++/SDL/OpenGL(if this is relevant?) for creating a GUI system for a game. I have worked out the input/rendering part of the GUI. Now I want to create an layout engine for the GUI so it's easy to create nice windows without the buttons goes outside the window when user resize the the window(limit the window size automatically). Or if I want a text box to expand all over the window when the user resizes it.I have just figure it out that I would need Minimum/Maximum/Preferred size properties on the widgets.Is there any kind of algorithm for this? Or how do you calculate and prioritize the layout of the window when users resize the windows?Some general advice on building layout engines for GUI:s would be nice.   
  I use the following:The positions of the widgets are stored as floats.There are 4 basic kinds of widget alignments: left/bottom right/top middle floating.Both for left/bottom and right/top sides of a widget rectangle.window resize update:I calculate the differences between the new and the old window size:delta_w, delta_hAnd I iterate through all the children widgets of the window, and calculate the new positions depending on the alignment type:left: x = x;middle: x += delta_w*0.5;right: x += delta_w;floating: x = x/window_old_width*window_new_width;the same for right side, left and top.EDIT:Every widget has its own resize function, so there can be any kind of stuff happening on resize (for example the textbox resize function recalculates the number of lines in the widget, if lines are broken to fit the box). But basically all functions point to the general algorithm shown above.Since it uses the delta of the window sizes, it is called after the window size restrictions. (minimum/maximum size)I think you get the idea. (but I'm not sure my post made much sense...)[Edited by - szecs on April 19, 2010 8:32:19 AM];  I'm also rather interested in this.Have you looked at Java's layout managers? I think some are pretty smart, although none seems to fully satisfy me.   