[Lazarus] Anchoring buttons (or other graphical elements)

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Feb 17 01:12:16 CET 2012


On Thu, 16 Feb 2012 17:28:15 +0100
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:

> Mattias Gaertner schrieb:
>  >> And second that was my experience too. But I just tried it again on a
>  >> fresh project and now suddenly vertical alignment behave the same! This
>  >> "eratic" (unpredictable, at least to me) behaviour was the reason I
>  >> wanted to look into the documentation but it did not make it clearer 
> but
>  >> more obscure. It seems I have to invest much more time into this than I
>  >> wanted...
>  > There is only one difference between vertical and horizontal and that
>  > is Delphi compatible: Align applies alTop and alBottom before alLeft
>  > and alRight.
> 
> 
> I just remember the situation that made me wonder about the alignment 
> algorithm:
> 
> If I align the *top* of an element B to the *top* of another element A 
> then any margin defined in A is ignored. Only the margin values for B 
> are valid. This looks quite inconsistent to me. 

At the beginning both borderspacings of A and B were used for
for the distance of "same sides" anchoring (e.g. left/left). It
was confusing and no one needed it. So it was changed and each of the
three modi "same sides", "opposite sides" and "center" have their own
rules.
I have to draw more pictures to explain it better in the docs.


> To what will B be aligned? To the border of the element or to the border plus margin? When 
> I change the alignment so that the top of B is aligned to the *bottom* 
> of A then suddenly the (bottom) margins of A are take into account. That 
> drove me nuts the first time because the alignment editor only shows me 
> the margin values of the element I wanted to align but I never thought 
> that margins of the other element play any role here. And it seems that 
> for *some* cases this is true but for others it is not.

Anchoring "opposite sides": borderspacing of both controls are used.
Anchoring "same sides" A to B: borderspacing of the anchoring control
A is used.
Anchoring "center": no borderspacing is used.


Mattias




More information about the Lazarus mailing list