[cells-gtk-devel] cells-gtk drawing-area widget

Peter Hildebrandt peter.hildebrandt at gmail.com
Tue Jun 12 15:36:58 UTC 2007


Hi Martin, Hi Peter,

I'm afraid we're duplicating work here.

On Tue, 12 Jun 2007 07:16:21 -0700, Peter Denno <peter.denno at nist.gov>  
wrote:
> On Sunday 10 June 2007 00:56, Martin Flack wrote:
>> Hi guys,
>
> Hi, Martin.
>>
>> I've managed to get cells-gtk drawing-area to basically work. I'm
>> attaching the diff. A few notes follow.

I'm still working on it, creating a cells-like interface to cairo.

>>
>> In drawing.lisp I shuffled some stuff around and used the double
>> colon package selector to get it find all the symbols on first
>> load. There may be a slightly cleaner way to do this.
>
> Probably just exporting them from wherever they are would be fine.
>>
>> I fixed a bug where *window* was not bound on first run and caused
>> an error, but would be ok on later runs in the same Lisp image.
>>
>> I made button1-down, button2-down, and button3-down all cells so
>> that you can use them as inputs in the cells-gtk framework.

Did that, too.

>>
>> For the future, I suspect that drawing-expose-event-handler could
>> probably be simpler and not call init-graphics-context each time?
>> Also drawing-pointer-motion-handler produces an effect but probably
>> not quite what was intended (the image is moved while you hold down
>> the button, but excess areas are not cleaned so it looks slurred
>> along, and subsequent tries move it from 0,0 again).
>
> I don't recall any problems like that.

I haven't noticed that.  I will look at your patch later today and see  
what you did differently from me.

>
>>
>> I'm on SBCL on Ubuntu 7.04.
>
> I'll check it out soon, and if things work OK, merge it in. I haven't
> worked on this code in at least a year, but I seem to recall having a
> plan to use closures to draw things.  We are intending to switch to
> Cairo???  Also, ideally, we'd add example code to the test-gtk demo,
> as yet another tab in the notebook.

Actually this is was my plan, based on work seen here a few weeks ago.  I  
use the rather new cl-cairo2 as a backend.  Calls to drawing functions are  
wrapped in models such as cairo-line, cairo-arc, etc., which are stored in  
the :kids part of the drawing area.  The objects can be modified (or  
created, or removed), and the drawing-area updates accordingly.

Once this is done, the app can use the models provided by drawing-area as  
super classes for custom elements, which can be added to :kids as well.

At this point, there is no working prototype (because I have just started  
rewriting a bunch of things), but within two or three days there should be  
something to play with.

Martin, maybe we should exchange a few more ideas.

Peter.

> I found a call to the code that I was experimenting with. It looks
> like this:
> (defmodel instance-diagram (window)
>   ()
>   (:default-initargs
>    :md-name :instance-diagram :width 700 :height
> 500 :position :center ))
>    :kids
>    (list
>     (mk-drawing-area
>      :md-name :drawing-area :fill t :expand t
>      :draw-fn
>      #'(lambda (self) )))
> 	 (with-pixmap (p "demo" :widget self :width 100 :height 100)
>             (with-gc (p :fg "red") (draw-line p 0 0 100 100))
> 	    (draw-text p "this is text" 10 70)
> 	    (draw-rectangle p 10 10 30 30)
> 	    (draw-rectangle p 1 1 97 97)
> 	    (insert-pixmap p 0 0)
> 	    p))))))
>
>
>>
>> Martin Flack
>





More information about the cells-gtk-devel mailing list