On Mon, May 5, 2008 at 2:25 PM, Freddie Witherden <[EMAIL PROTECTED]> wrote:
>  > I was thinking more like widgetAdd(parentWidget,
>  > frameOfReferenceWidget, side, offsetX, offsetY);
>  >
>  > Putting an icon in the lowest right side of the main window:
>  > widgetAdd(screen, screen, BottomLeft, 10, 10);
>  > Adding the third button in a row inside a window: widgetAdd(window,
>  > second, Right, 20, 0);
>
>  We then have to make the assumption about the size of the first icon
>  (that it is 10 units). This is basically what we have at the moment -
>  adding widgets requires knowledge about the size of other widgets.
>
>  Lets say at a later date we decide to make our icons a bit bigger,
>  say 12 units. We then need to find all of our widgetAdd calls and fix
>  them.
>
>  Or am I missing something?

Yes. The idea is that the offsets are from the end side of the frame
of reference widget, (they are relative to the second widget given,)
so if the size or position of that changes, the position of the added
widget changes automatically.

Adding a row of three buttons at the lower right of the screen would
be like this:
first = widgetAdd( screen, screen, BOTTOM_LEFT, 10, 10 );
second = widgetAdd( screen, first, LEFT, 5, 0 );
third = widgetAdd( screen, second, LEFT, 5, 0 );

On 5 May 2008, at 13:22, Dennis Schridde wrote:
> Am Sonntag, 4. Mai 2008 23:49:57 schrieb Freddie Witherden:
>> The problem I am having is how a widget should tell its parent where
>> it wants to be? Should it be relative to other widgets? Should it be
>> relative to a side (north, east, south, west)?
> My proposal is "stolen" from Qt: "layouts" and ~"hints".
>
>
> Layouts:
> myLayout = newHBoxLayout();
> myLayout->add( wdg1 );
> myLayout->add( wdg2 );

This kind of layout is designed for application GUIs, and I am not
convinced they will work very for us. We have some rather complicated
UI elements (eg the reticule), and I would like to be able to specify
somehow the amount of offset there should be from one widget to
another, rather than the GUI code spacing them out over the available
area. For most use cases, I think we want widgets to snap to a border,
instead of centering and evenly spacing items as such layout schemes
usually do.

If we want something similar to this, I would suggest that we create
snap layouts that keep track of which widgets you have added, but also
allow you to specify offsets yourself, eg

myLayout = newSnapLBHLayout(); // snap to Lower Bottom and lay them
out Horizontally
myLayout->add( widg1, 10, 0 );
myLayout->add( widg2, 10, 0 );
myLayout->add( widg3, 10, 0 );  // widg1..3 are put tightly together
myLayout->add( widg4, 20, 0 ); // widg4 is pushed slightly apart

But I think you will quickly find that writing such layout engines (of
either kind) are very hard and take a lot of time.

  - Per

_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to