gnue-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnue-dev] Layout Management and Forms


From: Jason Cater
Subject: [Gnue-dev] Layout Management and Forms
Date: Wed, 5 Jun 2002 17:53:36 -0500

Occasionally, the issue of widget positioning/layout management comes
up in IRC. The core forms team (myself included) are satisfied with
x,y positioning and have pushed the issue of layout management to the
bottom of our TODO list. I don't think our general attitude regarding
layout management has changed, but I think I've a way to accomodate
the gradual introduction of layout management into GNUe Forms without
cluttering up our core forms product/xml schema with layout tags.


First, the problem (in a nutshell): Forms is hardcoded to support
absolute positioning. This will work for the short-term; however, the
request is constantly made for some "better" layout management systems.
We have even received patches from coders (Madlocke in particular) that
implement several layout engines (such as GridBags, Boxes, et al). We
don't, however, want to clutter up the forms code or the forms GFParser
with support for all the different layout management styles.

My solution (also in a nutshell): Remove ANY positioning tags/attributes
from the basic Forms XML schema and implement all positioning using
Layout Adapters, qualified by an XML namespace in the XML file.
(Examples follow my comments -- you may want to look at a few at this
point and come back.) A few layout engine adapters would be part of the
core GNUe distribution and would always be available.  Official apps
could only use these core adapters, which of course initially would only
be Character (x,y) positioning.

The advantage of this approach is that it removes positioning ugliness
from the forms code and puts it in the Layout Adapter code. It allows us
to keep our current absolute positioning that has worked so well.
Finally, it allows anyone who feels they need more than absolute
positioning to write an adapter for their positioning logic without
needing access to the forms internals.

Now, the disadvantages: It will break any existing forms.  This could be
alleviated by adding code in GFObjects that implicitly converts
hardcoded x,y attributes to namespace-qualified x,y attributes.  This
has the added advantage that, whenever a form is opened in Designer and
resaved, it will be in the new format. Even without resaving, the old
format will be converted on the fly for the interim (interim == the next
few release cycles)

To implement, we will have to remove the current positioning logic from
the UI drivers and into an Absolute Positioning layout adapter.

If done properly, this might also be useful in Reports.  I haven't
really thought that comment through fully, so it might not be.  But,
still...

Any thoughts? Objections? Encouragements?

Without getting into too many implementation details, here are the
examples.(Note: these are partially based on examples provided by
Madlocke)


==================================================================
Sample using no layout management
==================================================================
<form>

 <!-- snip -->

 <page>
   <block>
     <label text="Hello world!"/>
     <label text="You want more text to appear?"/>
     <label text="Another comment"/>
   </block>
 </page>
</form>



==================================================================
Sample using Absolute Positioning
==================================================================
<form xmlns:abs="GNUe:Layout:Absolute">

 <!-- snip -->

 <page>
   <block>
     <label abs:x="1" abs:y="1" text="Hello world!"/>
     <label abs:x="1" abs:y="3" text="You want more text to appear?"/>
     <label abs:x="1" abs:y="5" text="Another comment"/>
   </block>
 </page>
</form>


==================================================================
Sample using Box Layout
==================================================================
<form xmlns:box="GNUe:Layout:Box">

 <!-- snip -->

 <page>
   <block>
     <box:boxLayout orientation="vertical">
       <label box:insets="0;0;0;0" box:alignX="left" text="123456"/>
       <label box:alignX="right" text="456"/>
       <label box:alignX="left" text="78901"/>
       <box:boxLayout orientation="vertical">
         <label box:alignX="center" text="nothing"/>
       </box:boxLayout>
     </box:boxLayout>
   </block>
 </page>
</form>


==================================================================
Sample using Box Layout
==================================================================
<form xmlns:box="GNUe:Layout:Box" xmlns:bag="GNUe:Layout:GridBag>

 <!-- snip -->

 <page>
   <block>
     <bag:gridBagLayout>
       <label text="Hello"/>
       <label text="Hello"/>
       <label text="Hello" bag:width="remainder"/>
       <label bag:anchor="northwest" bag:width="2" text="Hello"/>
       <box:boxLayout orientation="vertical" bag:width="remainder">
         <label box:insets="1;0;1;0" text="SuperDupa"/>
         <label box:alignX="right" text="EndeDas"/>
       </box:boxLayout>
     </bag:gridBagLayout>
   </block>
 </page>
</form>


Happy GNUe'n!

-- Jason




reply via email to

[Prev in Thread] Current Thread [Next in Thread]