dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] New anchor layouting code in Control.cs


From: Marc Haisenko
Subject: [Pnet-developers] New anchor layouting code in Control.cs
Date: Thu, 24 Feb 2005 16:09:19 +0100
User-agent: KMail/1.7.1

Hi folks,
I've just committed a completely new implementation of anchor layouting in 
Control.cs and would like to explain it here.

The old code tried to do anchoring by keeping track of size changes, then 
calculating deltas from these size changes and applying them to the child 
controls according to their AnchorStyles.

This was quite fragile and I tried to improve it once (patch #3714): I moved 
the information about the old size from the children into the parent and 
refactored the anchor code into a new function PerformAnchorLayout. This was 
the same way Mono did/does it, BTW.

But it didn't quite work correctly nevertheless as the Trumpf prototype showed 
me. After a few days of debugging, writing test applications and reading MS's 
class library documentation I decided to completely throw away the old 
anchoring code and start from scratch with a different method.

The new code now works in a more robust way: by keeping track of the intended 
"distances" of the child control relative to the parent edges. These 
distances are stored by the child and updated on every call to UpdateBounds 
(or SetBoundsCore which calls UpdateBounds). This way we can always calculate 
the correct anchoring positions without the troublesome "keep track of size 
changes".

Saving the distances is also when the parent changes, by the way.

According to my tests with a small test application the anchoring code now 
seems to work correct...

One more thing: I also made a minor change to PerformLayout(Control,String): 
we now allow layouting to occur even when no handle has been created yet 
(this is the way MS does it as well according to my tests and fixes yet 
another bug I was seeing in the Trumpf prototype).

C'ya,
        Marc

-- 
Marc Haisenko
http://darkdust.net
Today is Setting Orange, the 55th day of Chaos in the YOLD 3171


reply via email to

[Prev in Thread] Current Thread [Next in Thread]