[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [STUMP] tree-height and tree-width
From: |
Shawn Betts |
Subject: |
Re: [STUMP] tree-height and tree-width |
Date: |
Tue, 29 Jun 2004 19:28:26 -0700 (PDT) |
User-agent: |
SquirrelMail/1.4.0 |
> Look closely at these function definitions in core.lisp:
>
> (defun tree-x (screen tree)
> (tree-accum-fn tree #'min (lambda (n)
> (let ((f (frame-data screen n)))
> (frame-x f)))))
>
> (defun tree-y (screen tree)
> (tree-accum-fn tree #'min (lambda (n)
> (let ((f (frame-data screen n)))
> (frame-y f)))))
>
> (defun tree-width (screen tree)
> (tree-accum-fn tree #'+ (lambda (n)
> (let ((f (frame-data screen n)))
> (frame-width f)))))
>
> (defun tree-height (screen tree)
> (tree-accum-fn tree #'+ (lambda (n)
> (let ((f (frame-data screen n)))
> (frame-height f)))))
>
> tree-x and tree-y are correct. tree-width and tree-height are not.
> For example, if you have two frames next to eachother, tree-height
> will add their heights and return twice the correct result.
>
> One way to fix this is to add tree-right and tree-bottom, making them
> similar to tree-x and tree-y, and define tree-width as (- tree-right
> tree-x) and likewise for tree-height. But this would mean traversing
> the tree twice to get width or height. Can someone see a more elegant
> solution?
Hi Magnus,
Given that the number of frames are probably never going to be more than
9, walking the tree twice is probably fine. Also, having tree-bottom and
tree-right would be useful anyway. I see no problem with your proposal.
Shawn