[REBOL] Re: win-offset? screen-offset? bug
From: rotenca:telvia:it at: 23-Mar-2002 14:32
----- Original Message -----
From: "Brett Handley" <[brett--codeconscious--com]>
To: <[rebol-list--rebol--com]>
Sent: Saturday, March 23, 2002 5:05 AM
Subject: [REBOL] Re: win-offset? screen-offset? bug
> Hi Romano,
>
> > I find these standard functions wrong (beyond they have the same comment):
> >
> > win-offset?: func [
> > screen-offset?: func [
> Yes and no.
After the post i have made some check and now i 'm retty sure they are wrong,
at the end i post my patches.
> The functions are correct in my opinion as they should not be
> dependent on VID styles. I believe the problem is with panels/layout.
> Look at this example code, the panel-face variable is pointing
> to something that does not exist in the face object model.
I know that problem, but it is another problem. It can be solved in this way:
l: layout [p: panel [button]]
p: p/parent-face
The only "error" of layout is the variable assignement, not the cascade of
face/pane (else it does not works) which, btw, is fully set for a window only
by the display code activated by View, not by the layout function (this means
that immediately after a layout the parent-face field is not correctely set in
ALL the faces, but this is another problem :-).
The win-offset? give a wrong result also if you do not use the panel style:
l: layout [p: box 200x200 edge [size: 50x50]]
f: make-face/spec 'button [action: func [face value][print win-offset? f]]
p/pane: reduce [f]
view l
which gives 20x20 when the true offset of the button f in the window is 70x70.
> The panel-face variable appears to get set to some intermediate face made
> during
> the construction of the panel but which is not actually part of the final
> face object
> model.
> I haven't worked out how to fix it but you can see a work around in the code
> anyway.
Yes, to reach the right face you must get the parent-face of the face pointed
by the var, in your example:
panel-face: panel-face/parent-face
Here are my patched win-offset? screen-offset?:
win-offset?: func [
{Given any face, returns its window offset. Patched by Ana}
face [object!]
/local xy
][
xy: 0x0
if face/parent-face [
xy: face/offset
while [face: face/parent-face] [
if face/parent-face [
xy: xy + face/offset + either face/edge [face/edge/size][0x0]
]
]
]
xy
]
screen-offset?: func [
{Given any face, returns its screen absolute offset. Patched by Ana}
face [object!]
/local xy
][
xy: face/offset
while [face: face/parent-face][
xy: xy + face/offset + either face/edge [face/edge/size][0x0]
]
xy
]
---
Ciao
Romano