ANNOUNCE - graphics package

Joe Armstrong <>
Tue Jan 20 11:59:31 CET 2004


On Tue, 20 Jan 2004, Peter-Henry Mander wrote:

> 
> Hi Gurus,
> 
> GUI is one subject that seems to generate a lot of discussion here! :-)
> 
> I'd like to apply Occam's razor, and try to define the absolute minimum basic characteristics that widgets must have to enable more sophisiticated and specialised widgets to be created as an additional layer of s/w over the basic widget set.
> 
> The parent-child-sibling organisation of Xwindow maps neatly into processes. If ex11 can become a concurrent set of loosly coupled Xwindows mapped as processes, I reckon that designing new widgets will become easy enough not to require a huge library if canned widgets that we generally see in most windowing environments.
> 


Yes - this is *exactly* how I'm building things. The only problem is
garbage collecting the windows and graphics context etc when you
kill the windows.

----

Yesterday I made a wonderful simplification. I make a simple draggable
blob widget.

      Draggable = makeDraggable(Parent, X, Y, Width, Ht, Border, Color)

Creates a draggable blob.

Then you send it a fun

	Draggable ! {onMove, fun(X,Y) -> ....}

So when the draggable is moved to X,Y it executes fun(X,Y)

Now a window is just a draggable border + a frame

     +------------------------+
     |  border                |
     +------------------------+
     |                        |
     |  Frame                 |
     |                        |
     +------------------------+

So Wrote

mkWindow(Parent, X, Y, Width, Ht) ->
	Border = makeDraggable(Win, X, Y, Width, 10, ?blue),
	Frame  = makeRectangle(Win, X, Y+10, Width, Ht-10),
	Border ! {onMove, fun(X,Y) ->
		              Frame ! {setXY,X,Y+10}
		          end},
	Frame.

Which worked like a charm.

I wondered if the border might temporarily detach itself from the frame
but no - the border and the frame moved instantaneously.

My "draggable" can even be used as the basis of a scrollbar etc...

All this is nicely held together by the concurrency.

Now suppose you want to add a resizing "handle"

Like this:


     +------------------------+
     |  border                |
     +------------------------+
     |                        |
     |  Frame                 |
     |                     +--|--+
     +---------------------|--+  |
                           +-----+


mkWindow(Parent, X, Y, Width, Ht) ->
	Border = makeDraggable(Win, X, Y, Width, 10, ?blue),
	Frame  = makeRectangle(Win, X, Y+10, Width, Ht-10),
	Resizer = makeDraggable(Win, X+Width-5, Y+Ht-5, 10, 10, ?black),
        Border ! {onMove, fun(X,Y) ->	
		              Frame ! {setXY,X,Y+10},
		              Resizer ! {setXY, X+Width-5,Y+Ht+5} 
		          end},
	Resizer ! {onMove, fun(X, Y) ->
				Border ! {setWidth, ...}
				Frame ! {setWidth, ...}
				...
			   end
	Frame.


Which again is pretty simple :-)

But note how everything is built from a few powerful primitive widgets -
these widgets are just X-windows primitive windows + some control glue.


> True, some commonly expected widgets need to be supplied, but I'd be disappointed if ex11 becomes tightly coupled to a set of widgets.
> 

  No - a  small set of primitive widgets  (draggables, drawables, ...)
with powerful glue.


> Pete
> 
> 

/Joe







More information about the erlang-questions mailing list