Page MenuHome

UI: Improvements to Tolerant Area Joins
Needs ReviewPublic

Authored by Harley Acheson (harley) on Sun, Sep 8, 9:02 PM.



TL;DR version: fixes issues like those shown in the video at the end of this page:

Long Version:

My earlier changes to area joins works great in most simple situations, but will fail in some complex arrangements. It was a bit naive. For example both areas to be joined could have multiple simultaneous neighbors on all edges, so it isn't enough to consider only the edges of the two areas to be joined. All edges must be examined and multiples potentially changed.

This fixes that perfectly. It starts by adding two helper routines, screen_edges_halign() & screen_edges_valign(), which can vertically or horizontally align screen verts within a range. So if you have a number of vertical edges for different areas that are within a tolerance, they can all be set to a new value without affecting horizontal position. Or so the same for horizontal edges.

Then screen_areas_align() is added that takes two screen areas and an int that specifies their relationship (output from area_getorientation()). This adjusts all screen edges to allow the two areas to be merged.

For example if we have two areas that are to be merged vertically, so sharing a horizontal edge. We have to adjust all vertical edges that exactly match the horizontal positions of the two area's vertical edges. All of them are changed to a new value based on an average taken from the two areas to be joined. Further, because this uses an average my very conservative tolerance value is increased a bit (to just half of a U.widget_unit). In theory there could be many times when this tolerance could be much greater, but will require a bit more work to examine the edge lengths, and will be a fun exercise for later.

Diff Detail

rB Blender