Ignore:
Timestamp:
Mar 17, 2011, 11:11:36 AM (14 years ago)
Author:
george
Message:
  • Modified: Better tabs popup animation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/Managers/UCDManagerTabsPopup.pas

    r199 r204  
    77uses
    88  Classes, Controls, SysUtils, ComCtrls, ExtCtrls, UCDCommon, UCDManager,
    9   UCDManagerTabs, Forms;
     9  UCDManagerTabs, Forms, URectangle;
    1010
    1111type
     
    1717    FStepCount: Integer;
    1818    FTabPosition: TTabPosition;
    19     StartBounds: TRect;
     19    ControlBounds: TRectangle;
     20    HideBounds: TRectangle;
     21    ShowBounds: TRectangle;
    2022    procedure SetDuration(const AValue: Real);
    2123    procedure SetStepCount(const AValue: Integer);
     
    2931    Control: TControl;
    3032    ControlVisible: Boolean;
     33    DoShow: Boolean;
    3134    procedure Hide;
    3235    procedure Show;
     
    8184begin
    8285  case TabPosition of
     86    tpTop: begin
     87      Control.SetBounds(ControlBounds.Left, ControlBounds.Top,
     88        ControlBounds.Width, Round(ControlBounds.Height * Position));
     89    end;
     90    tpLeft: begin
     91      Control.SetBounds(ControlBounds.Left, ControlBounds.Top,
     92        Round(ControlBounds.Width * Position), ControlBounds.Height);
     93    end;
     94    tpRight: begin
     95      Control.SetBounds(ControlBounds.Right -
     96        Round(ControlBounds.Width * Position), ControlBounds.Top,
     97        Round(ControlBounds.Width * Position), ControlBounds.Height);
     98    end;
    8399    tpBottom: begin
    84       Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);
    85       Control.Top := StartBounds.Bottom - Control.Height;
    86     end;
    87     tpTop: begin
    88       Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);
    89     end;
    90     tpLeft: begin
    91       Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);
    92     end;
    93     tpRight: begin
    94       Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);
    95       Control.Left := StartBounds.Right - Control.Width;
     100      Control.SetBounds(ControlBounds.Left,
     101        ControlBounds.Bottom - Round(ControlBounds.Height * Position),
     102        ControlBounds.Width, Round(ControlBounds.Height * Position));
    96103    end;
    97104  end;
     
    119126procedure TCDAutoHide.Hide;
    120127begin
    121   StartBounds := Control.BoundsRect;
     128  HideBounds.AsTRect := Control.BoundsRect;
     129  ControlBounds.Assign(HideBounds);
    122130  Control.Show;
    123131  Control.BringToFront;
     132  Application.ProcessMessages;
    124133  Direction := -1;
    125134  Position := 1;
     
    130139procedure TCDAutoHide.Show;
    131140begin
    132   StartBounds := Control.BoundsRect;
    133   //StartBounds := Bounds(0, 0, Control.UndockWidth, Control.UndockHeight);
    134   Control.Show;
    135   Control.BringToFront;
    136   Control.Align := alClient;
    137   Direction := 1;
    138   Position := 0;
    139   Timer.Enabled := True;
    140   UpdateBounds;
     141  ShowBounds.AsTRect := Control.BoundsRect;
     142  ControlBounds.Assign(HideBounds);
     143  if Position > 0 then begin
     144    DoShow := True;
     145    Hide;
     146  end else begin
     147    //StartBounds := Bounds(0, 0, Control.UndockWidth, Control.UndockHeight);
     148    Control.Show;
     149    Control.BringToFront;
     150    //Control.Align := alClient;
     151    Direction := 1;
     152    Position := 0;
     153    Timer.Enabled := True;
     154    UpdateBounds;
     155  end;
    141156end;
    142157
     
    144159begin
    145160  inherited;
     161  ShowBounds := TRectangle.Create;
     162  HideBounds := TRectangle.Create;
     163  ControlBounds := TRectangle.Create;
    146164  Timer := TTimer.Create(nil);
    147165  Timer.Enabled := False;
     
    149167  StepCount := 10;
    150168  Duration := 0.05;
     169  ShowBounds := TRectangle.Create;
    151170end;
    152171
    153172destructor TCDAutoHide.Destroy;
    154173begin
     174  ShowBounds.Free;
     175  HideBounds.Free;
     176  ControlBounds.Free;
    155177  Timer.Free;
    156178  inherited Destroy;
     
    165187      Timer.Enabled := False;
    166188      ControlVisible := True;
     189      DoShow := False;
     190      HideBounds := ShowBounds;
    167191    end;
    168192  end else
     
    171195    if Position < 0 then begin
    172196      Position := 0;
    173       Timer.Enabled := False;
    174       ControlVisible := False;
     197      if DoShow then begin
     198        Direction := 1;
     199        ControlBounds.Assign(ShowBounds);
     200      end else begin
     201        Timer.Enabled := False;
     202        ControlVisible := False;
     203      end;
    175204    end;
    176205  end;
     
    194223  Pos: TPoint;
    195224  C: TControl;
     225  TopParent: TWinControl;
    196226begin
    197227  inherited TabControlChange(Sender);
    198228  MouseDownSkip := True;
    199   if PopupForm.ControlCount > 0 then
    200     PopupForm.Controls[0].Parent := nil;
    201   AutoHide.Hide;
    202   while AutoHide.Position > 0 do begin
    203     Application.ProcessMessages;
    204     Sleep(1);
    205   end;
     229
    206230  if PageControl.TabIndex >= 0 then begin
    207231    C := TCDManagerTabsPopupItem(DockItems[PageControl.TabIndex]).Control;
     232    C.Align := alClient;
    208233    C.Parent := PopupForm;
     234    Pos := Point(PageControl.Left, PageControl.Top);
     235
     236    TopParent := DockSite;
     237    while Assigned(TopParent.Parent) do begin
     238      Pos.X := Pos.X + TopParent.Left;;
     239      Pos.Y := Pos.Y + TopParent.Top;
     240      TopParent := TopParent.Parent;
     241    end;
     242    PopupForm.Parent := TopParent;
    209243    //AutoHide.Control.Align := alCustom;
    210     Pos := Point(PageControl.Left, PageControl.Top);
    211     Pos := DockSite.ClientToScreen(Pos);
     244    //Pos := DockSite.ClientToScreen(Pos);
     245    C.TBDockHeight := 100;
     246    C.LRDockWidth := 100;
    212247    with AutoHide.Control do
    213248    case AutoHide.TabPosition of
     
    243278  PopupForm.DockManager := TCDManagerRegions.Create(PopupForm);
    244279  PopupForm.Visible := True;
    245   //PopupForm.Parent := ADockSite;
    246280  PopupForm.BorderStyle := bsNone;
    247281  AutoHide := TCDAutoHide.Create;
Note: See TracChangeset for help on using the changeset viewer.