Lisp HUG Maillist Archive

Pinboard-object drawing bug or expected behaviour?

I have noticed that unless I explicitly set the :x, :y, :width and :height
initargs of a pinboard-object in an interface the object is damaged when
something (say, another window, or pinboard-object in the same layout) covers
it. For example the following -

(define-interface test ()
  ()
  (:panes
    (pane drawn-pinboard-object
      :display-callback 'test-callback))
  (:layouts
    (pinboard pinboard-layout
      '(pane)
      :background :white))
  (:default-initargs
    :layout 'pinboard
    :best-width 300
    :best-height 300))

(defun test-callback (pane self x y width height)
  (declare (ignore self x y width height))
  (with-geometry pane
    (let ((x-radius (1- (floor %width% 2)))
          (y-radius (1- (floor %height% 2))))
      (gp:draw-ellipse pane (1+ (+ %x% x-radius)) (1+ (+ %y% y-radius)) 
                            x-radius y-radius))))

Unless I set the pane geometry via (pane :x 0 :y 0 :width 300 :height 300) in
the :layouts slot it suffers damage when covered. Is this a bug, or what I
should expect? In my application the objects I draw are scaled relative to the
geometry of the containing interface, so I don't want to have to actually
provide values for these initargs. I have a work-around, but is there a CAPI way
to solve this that I've missed?

Cheers,
Chris


Re: Pinboard-object drawing bug or expected behaviour?

Chris Melen <relativeflux@hotmail.co.uk> writes:

> Unless I set the pane geometry via (pane :x 0 :y 0 :width 300 :height 300) in
> the :layouts slot it suffers damage when covered. Is this a bug, or what I
> should expect? In my application the objects I draw are scaled relative to the
> geometry of the containing interface, so I don't want to have to actually
> provide values for these initargs. I have a work-around, but is there a CAPI way
> to solve this that I've missed?

Built-in objects, like capi:ellipse, handle much of this for you, but
if you use drawn-pinboard-object, you need to tell capi what its size
is.

I use (setf pinboard-pane-position) and (setf pinboard-pane-size) for
objects that move and change size.
-- 
  (espen)


Updated at: 2020-12-10 08:41 UTC