At the risk of extending this discussion beyond its usefulness, I would like to add this.
We will all agree that the position and shape of an object should be independent parameters.
A change in position should not influence shape and a change in shape should not influence position.
(Once I finish making my shelf, I can put it anywhere without changing its shape)
Position can be defined by any point in the shape. Often, I find it very useful to specify position of an object by its centroid.
And if I specify its shape relative to the centroid, the centroid will be at (0, 0). This makes my computations much simpler.
By convention, the positions of views are specified by their left/top point, and texts are specified by their bottom left point.
Rectangles are different. They are geometric shapes set in a Cartesian co-ordinate system. In general, a n-sided polygons requires n points to specify its
shape and position. Rectangles require four points, but if the sides are parallel to the axis of the co-ordinate system, only 2 points are needed.
The other 2 points can be derived from these two. That is how a B4XRect is specified. Note that a nice feature of this structure is that the
the centerX and centerY values are accessed as read-only.
Also note:
1. changing the width/height changes the right/bottom values
2. changing the right/bottom changes the width/height values
Dim r As B4XRect
r.Initialize(100, 0, 900, 1000)
Log(r.Left & TAB & r.Right & TAB & r.CenterX & TAB & r.Width) ' 100 900 500 800
r.Width = 200
Log(r.Left & TAB & r.Right & TAB & r.CenterX & TAB & r.Width) ' 100 300 200 200
r.Right = 900
Log(r.Left & TAB & r.Right & TAB & r.CenterX & TAB & r.Width) ' 100 900 500 800
This too is a convention. There is really no other reason to pick the left/top as the unchanging position anchor.
If you were to make the right/bottom the anchor, changing the width should change the left.
If you define structures with the centroid as the anchor, and use standard units [I use min(screen.width, screen.height) / 1000] then
a simple transform will adapt your geometric shapes to any size screen. It makes them screen-independent.
They also can be scaled easily.