Re: [AD] new GUI focus selection algorithm |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> Now, to me, the obvious way to select the next focused dialog is to use
> the dialog with which the current one would collide if it moved into the
> direction for which the cursor key is pressed. The attached patch
> changes the behavior to do this.
It's better, but there are still some problems, for example:
A
C
B D
You can't go from B to C. I think you should with both the up and right keys,
provided that C is fully contained within the upper right quarter delimited
by the upper right corner of B. So I think the x-coordinate must be taken
into account together with the y-coordinate in all cases.
I think a better algorithm could be:
- partition the screen into two parts (using the upper edge of the object for
the up key and so on...); only objects fully contained within the part not
containing the origin object are to be considered,
- take the middle of the upper edge of the object as the base point and the
middle of the lower edge of the other objects as the target point for the up
arrow,
- calculate a distance between the base point and all tentative target
points,
- choose the valid object corresponding to the minimal distance.
--
Eric Botcazou