ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

core: Implement proper automatic tab ordering

Open kjarosh opened this issue 9 months ago • 0 comments

Related to https://github.com/ruffle-rs/ruffle/issues/5443. Fixes https://github.com/ruffle-rs/ruffle/issues/15853.

This PR implements proper automatic tab ordering that behaves exactly the same as in FP.

The Behavior of Automatic Tab Ordering

The automatic order depends only on the position of the top-left highlight bound corner, referred to as (x,y). It does not depend on object's size or other corners.

The value of 6y+x is used to order objects by it. This means that the next object to be tabbed is the next one that touches the line y=-(x-p)/6 (with the smallest p).

When two objects have the same value of 6y+x (i.e. when the line touches two objects at the same time), only one of them is included.

This behavior is similar to the naive approach of "left-to-right, top-to-bottom", but (besides being sometimes seen as random jumps) takes into account the fact that the next object to the right may be positioned slightly higher. This is especially true for objects placed by hand or objects with different heights (as FP uses the top left corner instead of the center).

The following image presents this behavior visually.

This behavior has been discovered experimentally by placing tabbable objects randomly and bisecting one of their coordinates to find a difference in behavior.

kjarosh avatar May 14 '24 22:05 kjarosh