Changeset 359


Ignore:
Timestamp:
May 4, 2012, 12:27:25 PM (13 years ago)
Author:
chronos
Message:
  • Fixed: Regions size update on Control visible state change.
  • Added: Support for custom center region selection. Surrounding regions are aligned to edges and keep size on docksite resize.
Location:
Docking/CoolDocking
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/Demo/Testing/Demo.lpi

    r355 r359  
    3838      </Item2>
    3939    </RequiredPackages>
    40     <Units Count="114">
     40    <Units Count="115">
    4141      <Unit0>
    4242        <Filename Value="Demo.lpr"/>
     
    5656        <ResourceBaseClass Value="Form"/>
    5757        <UnitName Value="UMainForm"/>
    58         <IsVisibleTab Value="True"/>
    59         <EditorIndex Value="3"/>
    60         <WindowIndex Value="0"/>
    61         <TopLine Value="103"/>
    62         <CursorPos X="1" Y="114"/>
     58        <EditorIndex Value="2"/>
     59        <WindowIndex Value="0"/>
     60        <TopLine Value="119"/>
     61        <CursorPos X="29" Y="132"/>
    6362        <UsageCount Value="201"/>
    6463        <Loaded Value="True"/>
     
    134133        <EditorIndex Value="0"/>
    135134        <WindowIndex Value="0"/>
    136         <TopLine Value="1"/>
    137         <CursorPos X="32" Y="7"/>
     135        <TopLine Value="17"/>
     136        <CursorPos X="75" Y="3"/>
    138137        <UsageCount Value="200"/>
    139138        <Loaded Value="True"/>
     
    335334        <ResourceBaseClass Value="Form"/>
    336335        <UnitName Value="SampleDockableForm"/>
    337         <EditorIndex Value="2"/>
    338336        <WindowIndex Value="0"/>
    339337        <TopLine Value="1"/>
    340338        <CursorPos X="22" Y="17"/>
    341         <UsageCount Value="155"/>
    342         <Loaded Value="True"/>
     339        <UsageCount Value="159"/>
    343340        <DefaultSyntaxHighlighter Value="Delphi"/>
    344341      </Unit31>
     
    450447        <TopLine Value="1"/>
    451448        <CursorPos X="44" Y="45"/>
    452         <UsageCount Value="107"/>
     449        <UsageCount Value="111"/>
    453450        <Loaded Value="True"/>
    454451        <DefaultSyntaxHighlighter Value="Delphi"/>
     
    768765        <Filename Value="..\..\UCDConjoinForm.pas"/>
    769766        <UnitName Value="UCDConjoinForm"/>
    770         <EditorIndex Value="7"/>
     767        <EditorIndex Value="6"/>
    771768        <WindowIndex Value="0"/>
    772769        <TopLine Value="49"/>
    773770        <CursorPos X="1" Y="55"/>
    774         <UsageCount Value="13"/>
     771        <UsageCount Value="15"/>
    775772        <Loaded Value="True"/>
    776773      </Unit82>
     
    778775        <Filename Value="..\..\UCDCommon.pas"/>
    779776        <UnitName Value="UCDCommon"/>
    780         <EditorIndex Value="8"/>
     777        <EditorIndex Value="7"/>
    781778        <WindowIndex Value="0"/>
    782779        <TopLine Value="85"/>
    783780        <CursorPos X="44" Y="88"/>
    784         <UsageCount Value="13"/>
     781        <UsageCount Value="15"/>
    785782        <Loaded Value="True"/>
    786783      </Unit83>
     
    788785        <Filename Value="..\..\UCDManager.pas"/>
    789786        <UnitName Value="UCDManager"/>
    790         <EditorIndex Value="4"/>
    791         <WindowIndex Value="0"/>
    792         <TopLine Value="354"/>
    793         <CursorPos X="1" Y="362"/>
    794         <UsageCount Value="13"/>
     787        <EditorIndex Value="5"/>
     788        <WindowIndex Value="0"/>
     789        <TopLine Value="75"/>
     790        <CursorPos X="65" Y="90"/>
     791        <UsageCount Value="15"/>
    795792        <Loaded Value="True"/>
    796793      </Unit84>
     
    806803        <Filename Value="..\..\Managers\UCDManagerTabs.pas"/>
    807804        <UnitName Value="UCDManagerTabs"/>
    808         <EditorIndex Value="6"/>
    809         <WindowIndex Value="0"/>
    810         <TopLine Value="388"/>
     805        <WindowIndex Value="0"/>
     806        <TopLine Value="382"/>
    811807        <CursorPos X="57" Y="396"/>
    812         <UsageCount Value="13"/>
    813         <Loaded Value="True"/>
     808        <UsageCount Value="14"/>
    814809      </Unit86>
    815810      <Unit87>
     
    952947        <Filename Value="..\..\UCDMaster.pas"/>
    953948        <UnitName Value="UCDMaster"/>
    954         <EditorIndex Value="9"/>
     949        <EditorIndex Value="8"/>
    955950        <WindowIndex Value="0"/>
    956951        <TopLine Value="4"/>
    957952        <CursorPos X="66" Y="11"/>
    958         <UsageCount Value="12"/>
     953        <UsageCount Value="14"/>
    959954        <Loaded Value="True"/>
    960955      </Unit103>
     
    962957        <Filename Value="..\..\UCDClient.pas"/>
    963958        <UnitName Value="UCDClient"/>
    964         <EditorIndex Value="10"/>
     959        <EditorIndex Value="9"/>
    965960        <WindowIndex Value="0"/>
    966961        <TopLine Value="91"/>
    967962        <CursorPos X="1" Y="108"/>
    968         <UsageCount Value="12"/>
     963        <UsageCount Value="14"/>
    969964        <Loaded Value="True"/>
    970965      </Unit104>
     
    972967        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    973968        <UnitName Value="UCDManagerRegions"/>
    974         <EditorIndex Value="5"/>
    975         <WindowIndex Value="0"/>
    976         <TopLine Value="301"/>
    977         <CursorPos X="1" Y="314"/>
    978         <UsageCount Value="11"/>
     969        <IsVisibleTab Value="True"/>
     970        <EditorIndex Value="4"/>
     971        <WindowIndex Value="0"/>
     972        <TopLine Value="77"/>
     973        <CursorPos X="13" Y="86"/>
     974        <UsageCount Value="13"/>
    979975        <Loaded Value="True"/>
    980976      </Unit105>
     
    10381034        <UsageCount Value="10"/>
    10391035      </Unit113>
     1036      <Unit114>
     1037        <Filename Value="..\..\UCDWindowList.pas"/>
     1038        <UnitName Value="UCDWindowList"/>
     1039        <EditorIndex Value="3"/>
     1040        <WindowIndex Value="0"/>
     1041        <TopLine Value="65"/>
     1042        <CursorPos X="51" Y="79"/>
     1043        <UsageCount Value="10"/>
     1044        <Loaded Value="True"/>
     1045      </Unit114>
    10401046    </Units>
    10411047    <JumpHistory Count="30" HistoryIndex="29">
    10421048      <Position1>
    1043         <Filename Value="UMainForm.pas"/>
    1044         <Caret Line="135" Column="14" TopLine="114"/>
     1049        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1050        <Caret Line="389" Column="35" TopLine="381"/>
    10451051      </Position1>
    10461052      <Position2>
    1047         <Filename Value="UMainForm.pas"/>
    1048         <Caret Line="134" Column="14" TopLine="113"/>
     1053        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1054        <Caret Line="46" Column="13" TopLine="20"/>
    10491055      </Position2>
    10501056      <Position3>
    1051         <Filename Value="UMainForm.pas"/>
    1052         <Caret Line="140" Column="3" TopLine="124"/>
     1057        <Filename Value="..\..\UCDManager.pas"/>
     1058        <Caret Line="93" Column="21" TopLine="80"/>
    10531059      </Position3>
    10541060      <Position4>
    10551061        <Filename Value="..\..\UCDManager.pas"/>
    1056         <Caret Line="362" Column="20" TopLine="354"/>
     1062        <Caret Line="151" Column="60" TopLine="130"/>
    10571063      </Position4>
    10581064      <Position5>
    1059         <Filename Value="UMainForm.pas"/>
    1060         <Caret Line="116" Column="1" TopLine="103"/>
     1065        <Filename Value="..\..\UCDManager.pas"/>
     1066        <Caret Line="357" Column="22" TopLine="336"/>
    10611067      </Position5>
    10621068      <Position6>
    1063         <Filename Value="UMainForm.pas"/>
    1064         <Caret Line="118" Column="1" TopLine="103"/>
     1069        <Filename Value="..\..\UCDManager.pas"/>
     1070        <Caret Line="361" Column="16" TopLine="343"/>
    10651071      </Position6>
    10661072      <Position7>
    1067         <Filename Value="UMainForm.pas"/>
    1068         <Caret Line="110" Column="1" TopLine="103"/>
     1073        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1074        <Caret Line="42" Column="37" TopLine="23"/>
    10691075      </Position7>
    10701076      <Position8>
    1071         <Filename Value="UMainForm.pas"/>
    1072         <Caret Line="112" Column="1" TopLine="103"/>
     1077        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1078        <Caret Line="413" Column="40" TopLine="401"/>
    10731079      </Position8>
    10741080      <Position9>
    1075         <Filename Value="UMainForm.pas"/>
    1076         <Caret Line="116" Column="1" TopLine="103"/>
     1081        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1082        <Caret Line="427" Column="49" TopLine="405"/>
    10771083      </Position9>
    10781084      <Position10>
    1079         <Filename Value="UMainForm.pas"/>
    1080         <Caret Line="110" Column="1" TopLine="103"/>
     1085        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1086        <Caret Line="413" Column="1" TopLine="405"/>
    10811087      </Position10>
    10821088      <Position11>
    10831089        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1084         <Caret Line="368" Column="1" TopLine="355"/>
     1090        <Caret Line="414" Column="1" TopLine="405"/>
    10851091      </Position11>
    10861092      <Position12>
    1087         <Filename Value="..\..\UCDManager.pas"/>
    1088         <Caret Line="362" Column="1" TopLine="354"/>
     1093        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1094        <Caret Line="417" Column="1" TopLine="405"/>
    10891095      </Position12>
    10901096      <Position13>
    10911097        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1092         <Caret Line="368" Column="1" TopLine="355"/>
     1098        <Caret Line="419" Column="1" TopLine="405"/>
    10931099      </Position13>
    10941100      <Position14>
    10951101        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1096         <Caret Line="176" Column="1" TopLine="163"/>
     1102        <Caret Line="420" Column="1" TopLine="405"/>
    10971103      </Position14>
    10981104      <Position15>
    1099         <Filename Value="UMainForm.pas"/>
    1100         <Caret Line="116" Column="1" TopLine="103"/>
     1105        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1106        <Caret Line="421" Column="1" TopLine="405"/>
    11011107      </Position15>
    11021108      <Position16>
    1103         <Filename Value="..\..\UCDManager.pas"/>
    1104         <Caret Line="360" Column="1" TopLine="354"/>
     1109        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1110        <Caret Line="422" Column="1" TopLine="405"/>
    11051111      </Position16>
    11061112      <Position17>
    11071113        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1108         <Caret Line="314" Column="1" TopLine="301"/>
     1114        <Caret Line="423" Column="1" TopLine="405"/>
    11091115      </Position17>
    11101116      <Position18>
    1111         <Filename Value="UMainForm.pas"/>
    1112         <Caret Line="108" Column="9" TopLine="103"/>
     1117        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1118        <Caret Line="425" Column="1" TopLine="405"/>
    11131119      </Position18>
    11141120      <Position19>
    1115         <Filename Value="UMainForm.pas"/>
    1116         <Caret Line="115" Column="1" TopLine="103"/>
     1121        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1122        <Caret Line="426" Column="1" TopLine="405"/>
    11171123      </Position19>
    11181124      <Position20>
    1119         <Filename Value="UMainForm.pas"/>
    1120         <Caret Line="116" Column="1" TopLine="103"/>
     1125        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1126        <Caret Line="427" Column="28" TopLine="406"/>
    11211127      </Position20>
    11221128      <Position21>
    1123         <Filename Value="UMainForm.pas"/>
    1124         <Caret Line="109" Column="1" TopLine="103"/>
     1129        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1130        <Caret Line="411" Column="3" TopLine="447"/>
    11251131      </Position21>
    11261132      <Position22>
    1127         <Filename Value="UMainForm.pas"/>
    1128         <Caret Line="110" Column="1" TopLine="103"/>
     1133        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1134        <Caret Line="48" Column="1" TopLine="36"/>
    11291135      </Position22>
    11301136      <Position23>
    1131         <Filename Value="UMainForm.pas"/>
    1132         <Caret Line="115" Column="1" TopLine="103"/>
     1137        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1138        <Caret Line="413" Column="1" TopLine="409"/>
    11331139      </Position23>
    11341140      <Position24>
    1135         <Filename Value="..\..\UCDManager.pas"/>
    1136         <Caret Line="360" Column="1" TopLine="354"/>
     1141        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1142        <Caret Line="427" Column="1" TopLine="409"/>
    11371143      </Position24>
    11381144      <Position25>
    11391145        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1140         <Caret Line="314" Column="1" TopLine="301"/>
     1146        <Caret Line="428" Column="1" TopLine="409"/>
    11411147      </Position25>
    11421148      <Position26>
    1143         <Filename Value="UMainForm.pas"/>
    1144         <Caret Line="109" Column="1" TopLine="103"/>
     1149        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1150        <Caret Line="417" Column="56" TopLine="409"/>
    11451151      </Position26>
    11461152      <Position27>
    1147         <Filename Value="..\..\UCDManager.pas"/>
    1148         <Caret Line="362" Column="1" TopLine="354"/>
     1153        <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
     1154        <Caret Line="84" Column="33" TopLine="71"/>
    11491155      </Position27>
    11501156      <Position28>
    1151         <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1152         <Caret Line="368" Column="1" TopLine="355"/>
     1157        <Filename Value="..\..\UCDManager.pas"/>
     1158        <Caret Line="90" Column="65" TopLine="75"/>
    11531159      </Position28>
    11541160      <Position29>
    11551161        <Filename Value="UMainForm.pas"/>
    1156         <Caret Line="115" Column="1" TopLine="103"/>
     1162        <Caret Line="144" Column="5" TopLine="129"/>
    11571163      </Position29>
    11581164      <Position30>
    1159         <Filename Value="..\..\Managers\UCDManagerRegions.pas"/>
    1160         <Caret Line="314" Column="1" TopLine="301"/>
     1165        <Filename Value="UMainForm.pas"/>
     1166        <Caret Line="109" Column="25" TopLine="107"/>
    11611167      </Position30>
    11621168    </JumpHistory>
  • Docking/CoolDocking/Demo/Testing/UMainForm.pas

    r355 r359  
    99  ComCtrls, ExtCtrls, Buttons, Menus, UCDMaster, UCDCustomize, UCDClient,
    1010  UDockForm, UComponentTree, UCDWindowList, UCDConjoinForm, UCDManager,
    11   UCDCommon;
     11  UCDCommon, UCDManagerRegions;
    1212
    1313type
     
    6969  ConjoinedDockForm2: TCDConjoinForm;
    7070  Form1: TDockForm;
     71  Form2: TDockForm;
     72  Form3: TDockForm;
    7173begin
    72   NewDockForm.ManualDock(Panel1);
    7374  Form1 := NewDockForm;
    74   Form1.ManualDock(Panel1);
    75   NewDockForm.ManualDock(Form1);
    76   TCDManager(Panel1.DockManager).DockStyle := dsTabs;
    77   NewDockForm.ManualDock(Panel1);
     75  Form1.ManualDock(Panel1, nil, alRight);
     76  Form2 := NewDockForm;
     77  Form2.ManualDock(Panel1, nil, alRight);
     78  Form3 := NewDockForm;
     79  Form3.ManualDock(Panel1, nil, alRight);
     80  TCDManagerRegionsItem(TCDPanelHeader(Form2.Parent.Parent).DockItem).SetCenter;
     81
     82  //Form1 := NewDockForm;
     83  //Form1.ManualDock(Panel1);
     84  //NewDockForm.ManualDock(Form1);
     85  //TCDManager(Panel1.DockManager).DockStyle := dsTabs;
     86  //NewDockForm.ManualDock(Panel1);
    7887(*  ConjoinedDockForm1 := TCDManager(Panel1.DockManager).CreateConjoinForm;
    7988  ConjoinedDockForm1.Name := 'Model';;
  • Docking/CoolDocking/Managers/UCDManagerRegions.pas

    r355 r359  
    1515
    1616  TCDManagerRegionsItem = class(TCDManagerItem)
     17  private
     18  public
    1719    PanelHeader: TCDPanelHeader;
    1820    Splitter: TSplitter;
    19     Align: TAlign;
    2021    procedure VisibleChange(Sender: TObject); override;
    2122    procedure Paint(Sender: TObject); override;
     23    procedure PanelResize(Sender: TObject);
    2224    constructor Create;
    2325    destructor Destroy; override;
    2426    procedure SetControl(const AValue: TWinControl); override;
     27    procedure SetCenter;
    2528  end;
    2629
     
    3033  private
    3134    FDockItems: TObjectList; // TList<TCDManagerRegionsItem>
     35    FLastVisibleItemsCount: Integer;
    3236    function GetHeaderPos: THeaderPos; override;
    3337    procedure SetHeaderPos(const AValue: THeaderPos); override;
    3438    function GetDirection(InsertAt: TAlign): TCDDirection;
     39    procedure ResizePanels;
     40    procedure ClearItemsAlignment;
     41    procedure UpdateItemsAlignment;
     42    function PanelsVisible: Integer;
     43  protected
     44    FDockDirection: TCDDirection;
    3545  public
    36     FDockDirection: TCDDirection;
    3746    //Panels: TObjectList; // TObjectList<TCDStyleRegionsPanel>
    3847    function FindControlInPanels(Control: TControl): TCDManagerItem; override;
     
    5968{ TCDManagerRegionsItem }
    6069
     70procedure TCDManagerRegionsItem.SetCenter;
     71begin
     72  TCDManagerRegions(Manager).ClearItemsAlignment;
     73  PanelHeader.Align := alClient;
     74  Manager.Update;
     75end;
     76
    6177procedure TCDManagerRegionsItem.VisibleChange(Sender: TObject);
    6278begin
     
    6682    //  TCDManagerRegionsItem(DockItems[DockItems.IndexOf(FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
    6783    //end;
     84    PanelHeader.Visible := Control.Visible;
    6885    Update;
    6986
     
    91108end;
    92109
     110procedure TCDManagerRegionsItem.PanelResize(Sender: TObject);
     111begin
     112  TCDManagerRegions(Manager).ResizePanels;
     113end;
     114
    93115constructor TCDManagerRegionsItem.Create;
    94116begin
     
    97119  PanelHeader.Header.OnMouseDown := DockPanelMouseDown;
    98120  PanelHeader.Header.Icon.OnMouseDown := DockPanelMouseDown;
     121  PanelHeader.OnResize := PanelResize;
    99122
    100123  Splitter := TSplitter.Create(nil);
     
    113136  Splitter.Parent := nil;
    114137  Splitter.Free;
    115   Control.Parent := nil;
     138  if Assigned(Control) then Control.Parent := nil;
    116139  inherited Destroy;
    117140end;
     
    153176end;
    154177
     178procedure TCDManagerRegions.ResizePanels;
     179var
     180  I: Integer;
     181  CenterPanelSize: TPoint;
     182  Zoom: Real;
     183const
     184  MinSize = 30;
     185begin
     186  I := 0;
     187  while (I < DockItems.Count) and
     188    (TCDManagerRegionsItem(DockItems[I]).PanelHeader.Align <> alClient) do
     189      Inc(I);
     190  if I < DockItems.Count then begin
     191    CenterPanelSize.X := TCDManagerRegionsItem(DockItems[I]).PanelHeader.Width;
     192    CenterPanelSize.Y := TCDManagerRegionsItem(DockItems[I]).PanelHeader.Height;
     193  end else Exit;
     194  if (CenterPanelSize.X < MinSize) and (FDockDirection = ddHorizontal) then begin
     195    Zoom := CenterPanelSize.X / MinSize;
     196    for I := 0 to DockItems.Count - 1 do
     197      with TCDManagerRegionsItem(DockItems[I]).PanelHeader do
     198        if Align <> alClient then Width := Round(Width * Zoom);
     199  end;
     200  if (CenterPanelSize.Y < MinSize) and (FDockDirection = ddVertical) then begin
     201    Zoom := CenterPanelSize.Y / MinSize;
     202    for I := 0 to DockItems.Count - 1 do
     203      with TCDManagerRegionsItem(DockItems[I]).PanelHeader do
     204        if Align <> alClient then Height := Round(Height * Zoom);
     205  end;
     206end;
     207
     208procedure TCDManagerRegions.ClearItemsAlignment;
     209var
     210  I: Integer;
     211begin
     212  for I := 0 to FDockItems.Count - 1 do
     213  with TCDManagerRegionsItem(FDockItems[I]) do begin
     214    PanelHeader.Align := alNone;
     215    Splitter.Align := alNone;
     216  end;
     217end;
     218
     219procedure TCDManagerRegions.UpdateItemsAlignment;
     220var
     221  I: Integer;
     222  ClientPanelIndex: Integer;
     223begin
     224  // Find alClient panel item index
     225  I := 0;
     226  while (I < FDockItems.Count) and
     227    (TCDManagerRegionsItem(FDockItems[I]).PanelHeader.Align <> alClient) do Inc(I);
     228  if I < FDockItems.Count then ClientPanelIndex := I
     229    else ClientPanelIndex := FDockItems.Count div 2;
     230
     231  // Normalize alignment
     232  for I := 0 to FDockItems.Count - 1 do
     233  with TCDManagerRegionsItem(FDockItems[I]) do begin
     234    if FDockDirection = ddHorizontal then begin
     235      if I < ClientPanelIndex then PanelHeader.Align := alLeft
     236        else if I = ClientPanelIndex then PanelHeader.Align := alClient
     237        else if I > ClientPanelIndex then PanelHeader.Align := alRight;
     238    end;
     239    if FDockDirection = ddVertical then begin
     240      if I < ClientPanelIndex then PanelHeader.Align := alTop
     241        else if I = ClientPanelIndex then PanelHeader.Align := alClient
     242        else if I > ClientPanelIndex then PanelHeader.Align := alBottom;
     243    end;
     244  end;
     245end;
     246
     247function TCDManagerRegions.PanelsVisible: Integer;
     248var
     249  I: Integer;
     250begin
     251  Result := 0;
     252  for I := 0 to FDockItems.Count - 1 do
     253  with TCDManagerRegionsItem(FDockItems[I]) do begin
     254    if PanelHeader.Visible then Inc(Result);
     255  end;
     256end;
     257
    155258function TCDManagerRegions.FindControlInPanels(Control: TControl
    156259  ): TCDManagerItem;
     
    172275  NewItem := TCDManagerRegionsItem.Create;
    173276  with NewItem do begin
     277    PanelHeader.DockItem := NewItem;
    174278    PanelHeader.Parent := Self.DockSite;
    175279    Manager := Self;
     
    184288
    185289  NewItem.PanelHeader.Parent := DockSite;
    186 
    187   if DockItems.Count = 0 then NewItem.Align := alClient
    188     else NewItem.Align := InsertAt;
    189290
    190291  NewItem.Control := TWinControl(Control);
     
    302403var
    303404  I: Integer;
    304   SplitterLeft: Integer;
    305   SplitterTop: Integer;
    306   BaseAlign: TAlign;
     405  PositionLeft: Integer;
     406  PositionTop: Integer;
    307407  VisibleControlsCount: Integer;
     408const
     409  MinSize = 30;
    308410begin
    309411  inherited;
    310412  if FUpdateCount = 0 then begin
    311413  DebugLog('TCDManagerRegions.UpdateClientSize');
    312   VisibleControlsCount := DockSite.VisibleDockClientCount;
     414  VisibleControlsCount := PanelsVisible;
    313415  if DockSite is TForm then begin
    314     DockSiteVisible := VisibleControlsCount > 0;
     416    //DockSiteVisible := VisibleControlsCount > 0;
    315417  end;
    316418  if VisibleControlsCount = 0 then VisibleControlsCount := 1;
    317419
     420  PositionLeft := 0;
     421  PositionTop := 0;
     422  UpdateItemsAlignment;
    318423  for I := 0 to DockItems.Count - 1 do
    319424  with TCDManagerRegionsItem(DockItems[I]) do
    320425  begin
    321     PanelHeader.Left := SplitterLeft;
    322     PanelHeader.Top := SplitterTop;
    323     PanelHeader.Height := Self.DockSite.Height div
    324       VisibleControlsCount;
    325     PanelHeader.Width := Self.DockSite.Width div
    326       VisibleControlsCount;
     426    PanelHeader.Left := PositionLeft;
     427    PanelHeader.Top := PositionTop;
     428    if (FLastVisibleItemsCount <> VisibleControlsCount) then begin
     429      PanelHeader.Height := Self.DockSite.Height div
     430        VisibleControlsCount;
     431      PanelHeader.Width := Self.DockSite.Width div
     432        VisibleControlsCount;
     433    end;
     434    if PanelHeader.Height < MinSize then PanelHeader.Height := MinSize;
     435    if PanelHeader.Width < MinSize then PanelHeader.Width := MinSize;
     436
    327437    if Assigned(TWinControl(Control).DockManager) then
    328438      PanelHeader.Header.Visible := TCDManager(TWinControl(Control).DockManager).HeaderVisible;
    329439    PanelHeader.Visible := Control.Visible;
    330440    Paint(Self);
    331     if FDockDirection = ddHorizontal then
    332       BaseAlign := alLeft else BaseAlign := alTop;
    333 
    334     if I < Trunc((DockItems.Count - 1) / 2) then BaseAlign := BaseAlign
    335         else if I = Trunc((DockItems.Count - 1) / 2) then BaseAlign := alClient
    336         else if I > Trunc((DockItems.Count - 1) / 2) then begin
    337           if BaseAlign = alTop then BaseAlign := alBottom
    338           else if BaseAlign = alLeft then BaseAlign := alRight;
    339         end;
    340     PanelHeader.Align := BaseAlign;
    341 
    342     Splitter.Align := BaseAlign;
    343     SplitterLeft := PanelHeader.Left;
    344     SplitterTop := PanelHeader.Top;
    345     Splitter.Left := SplitterLeft;
    346     Splitter.Top := SplitterTop;
     441
     442    //PositionLeft := PanelHeader.Left;
     443    //PositionTop := PanelHeader.Top;
     444    if PanelHeader.Align = alLeft then Splitter.Left := PositionLeft + PanelHeader.Width + 1;
     445    if PanelHeader.Align = alRight then Splitter.Left := PositionLeft - 1;
     446    if PanelHeader.Align = alTop then Splitter.Top := PositionTop + PanelHeader.Height + 1;
     447    if PanelHeader.Align = alBottom then Splitter.Top := PositionTop - 1;
     448    Splitter.Align := PanelHeader.Align;
    347449    Splitter.Parent := Self.DockSite;
    348     Splitter.Visible := I <> (Trunc(DockItems.Count - 1) / 2);
    349     Inc(SplitterLeft, Splitter.Width);
    350     Inc(SplitterTop, Splitter.Height);
     450    Splitter.Visible := PanelHeader.Visible and (PanelHeader.Align <> alClient);
     451    Splitter.Width := 3;
     452    Splitter.Height := 3;
     453    Inc(PositionLeft, Splitter.Width + PanelHeader.Width);
     454    Inc(PositionTop, Splitter.Height + PanelHeader.Height);
    351455
    352456    Paint(Self);
    353     PanelHeader.Align := BaseAlign;
    354   end;
     457    //PanelHeader.Align := BaseAlign;
     458  end;
     459    FLastVisibleItemsCount := VisibleControlsCount;
    355460  end;
    356461end;
     
    362467  inherited;
    363468  //if DockSite.Visible <> AValue then
     469  if DockItems.Count > 0 then
    364470  try
    365471    BeginUpdate;
  • Docking/CoolDocking/UCDClient.pas

    r355 r359  
    9595begin
    9696  inherited Create(AOwner);
    97   FDockable := False;
     97  FDockable := True;
    9898  if not (AOwner is TForm) then
    9999    raise Exception.Create(SWrongOwner);
    100100  with (AOwner as TForm) do begin
    101101    if not (csDesigning in ComponentState) then begin
    102       (*if Dockable then begin
     102      if Dockable then begin
    103103        DragKind := dkDock;
    104104        DragMode := dmAutomatic;
    105105        DockSite := True;
    106106      end;
    107       *)UseDockManager := True;
     107      UseDockManager := True;
    108108      DockManager := TCDManagerRegions.Create(TWinControl(AOwner));
    109109      //FormStyle := fsStayOnTop;
  • Docking/CoolDocking/UCDManager.pas

    r355 r359  
    88  Classes, SysUtils, UCDCommon, Controls, Contnrs, Dialogs,
    99  UCDPopupMenu, LCLType, LCLIntf, LMessages, Graphics, Buttons,
    10   UCDConjoinForm, Menus, StdCtrls, ExtCtrls, Forms;
     10  UCDConjoinForm, Menus, ExtCtrls, Forms;
    1111
    1212const
     
    5757    Header: TCDHeader;
    5858    ControlPanel: TPanel;
     59    DockItem: TCDManagerItem;
    5960    property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos;
    6061    property HeaderVisible: Boolean read GetHeaderVisible write SetHeaderVisible;
     
    357358  FDockSiteVisible := AValue;
    358359  SetVisible(FDockSiteVisible);
    359   if Assigned(FOnDockSiteHide) and not AValue then
     360  if Assigned(FOnDockSiteHide) and (not FDockSiteVisible) then
    360361    FOnDockSiteHide(Self);
    361   if Assigned(FOnDockSiteShow) and AValue then
     362  if Assigned(FOnDockSiteShow) and FDockSiteVisible then
    362363    FOnDockSiteShow(Self);
    363364end;
Note: See TracChangeset for help on using the changeset viewer.