[GUI] Dynamic ... something

Alastair Reid alastair@reid-consulting-uk.ltd.uk
Mon, 14 Apr 2003 08:14:26 +0100


Axel Simon <A.Simon@ukc.ac.uk> writes:
> How would it look like?
>
>   placeWidget :: Container -> Int -> Int -> Widget -> IO ()
>
> What are the two Ints? Pixels? Dialog units? Fractions of something?
> I just wonder if it is really simple. Convince me that it is! :-)

Note that this is a problem that will have to be resolved no matter
what placement mechanism is used.  

For example, when resizing a dialog box, we might want to specify a
minimum horizontal and vertical distance that will be maintained
between the objects inside the box and we will have to decide whether
it is relative to font size, screen resolution, etc.

As far as I can see, the only thing different about absolute placement
is that the issue is more visible because that's all we have to worry
about but it will still be an issue for every alternate mechanism
(with the exception of interface builders, I guess).


Two obvious answers to your question are:

1) Pixels.  (Easy to implement but hard to create portable systems)

2) All your suggestions and more:

   data Unit 

     = -- raw pixels
       Pixel Int                   

     | -- millimetres
       MM    Int                   

     | -- Printer's point size
       Point Int                   

     | -- fraction of some property of a font
       -- (but _which_ property??? width, height, ascent, descent?)
       FontFraction FontID Double  

     | -- some property of some random GUI object                        
       -- where the proprty is extracted by the function argument
       GUIObject a => GUIFraction a (a -> Double) Double 
                                   
     | ...

     | -- we can even put a little expression language in here...
       Plus Unit Unit

     | ...

   I should say that this isn't intended as a complete or fully worked
   out suggestion but, rather, as a starting point for further
   exploration with the hope of finding something which is useful both
   of absolute positioning and for many of the alternatives we want to
   cover.  In particular, if we went down this road, I think we'd want
   to use constructor functions (i.e., pixel, not Pixel) in the API to
   make it easier to add new ways of specifying sizes in the future.

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/