Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-04

Proposal for TControl.DoDock patch

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

After the recent AutoSize fixes of Mattias, easy docking with default LCL code is in sight.

I do propose the following fix for TControl.DoDock:

Change

     // adjust new bounds, so that they at least fit into the client area of
     // its parent
     LCLProc.MoveRectToFit(ARect, NewDockSite.GetLogicalClientRect)
To
     // adjust new bounds, so that they at least fit into the client area of
     // its parent
     IF not NewDockSite.AutoSize then
       LCLProc.MoveRectToFit(ARect, NewDockSite.GetLogicalClientRect)
     else
       ARect:=Rect(0,0,Width,Height);

Rationale:

If the new dock site has AutoSize set to 'True', then it should adapt itself to the control to be docked, and not vice versa. So the rectangle should be set to the current size of the control.

Maybe the rectangle can be improved to take into account alignment:

    else
      case align of
        alLeft,
        alRight : ARect:=Rect(0,0,Width,NewDockSite.ClientHeight)
        alTop,
        alBottom : ARect:=Rect(0,0,NewDockSite.ClientWidth,Height)
      else
        ARect:=Rect(0,0,Width,Height);
      end;

Applying this gives markedly better results.

What should happen if the docked control has Align=AlClient and the dock host control has AutoSize=True, is still a source of mystery to me :)

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 20 lines
Hello, After the recent AutoSize fixes of Mattias, easy docking with default LCL code is in sight. I do propose the following fix for TControl.DoDock: Change // adjust new bounds, so that they at least fit into the client area of // its parent LCLProc.MoveRectToFit(ARect, NewDockSite.GetLogicalClientRect) To // adjust new bounds, so that they at least fit into the client area of // its parent IF not NewDockSite.AutoSize then LCLProc.MoveRectToFit(ARect, NewDockSite.GetLogicalClientRect) else ARect:=Rect(0,0,Width,Height);

Thanks. Applied.

Mattias

Reply by email

Hans-Peter Diettrich
to Michael Van Canneyt: After the recent AutoSize fixes of Mattias, easy docking with default LCL code is in…
What should happen if the docked control has Align=AlClient and the dock host control has AutoSize=True, is still a source of mystery to me :)

That's why I would not implement too much automatism. An autosizing dock site sits in a common environment (form...), together with other components. Consequently it cannot enlarge itself arbitrarily, but only with regards to the other components in its parent.

When we drop the DockManager, in favor of an general layout manager, a docksite would become just another (possibly autosizeable) control. When a control is docked into such an autosize dock site, the docksite would request a recalculation of its extent, from its parent, and this request may ripple up to the outmost form, depending on the constraints of all involved controls. Then the new extent of *all* affected controls is determined, and the docksite will be told its new extent, just like every other control is told.

DoDi

Reply by email