mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-28 17:03:07 +02:00
lcl: move Dock Image handling from the drag manager to the TDragDockObject (part of issue #0013427)
git-svn-id: trunk@19202 -
This commit is contained in:
parent
7180ac0e84
commit
f7577be51b
@ -418,6 +418,12 @@ type
|
|||||||
procedure AdjustDockRect(ARect: TRect); virtual;
|
procedure AdjustDockRect(ARect: TRect); virtual;
|
||||||
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
|
function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
|
||||||
procedure EndDrag(Target: TObject; X, Y: Integer); override;
|
procedure EndDrag(Target: TObject; X, Y: Integer); override;
|
||||||
|
|
||||||
|
// dock image drawing
|
||||||
|
procedure InitDock(APosition: TPoint); virtual;
|
||||||
|
procedure ShowDockImage; virtual;
|
||||||
|
procedure HideDockImage; virtual;
|
||||||
|
procedure MoveDockImage; virtual;
|
||||||
public
|
public
|
||||||
property DockOffset: TPoint read FDockOffset write FDockOffset;
|
property DockOffset: TPoint read FDockOffset write FDockOffset;
|
||||||
property DockRect: TRect read FDockRect write FDockRect;
|
property DockRect: TRect read FDockRect write FDockRect;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* *
|
* *
|
||||||
* This file is part of the Lazarus Component Library (LCL) *
|
* This file is part of the Lazarus Component Library (LCL) *
|
||||||
* *
|
* *
|
||||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||||||
* for details about the copyright. *
|
* for details about the copyright. *
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, *
|
* This program is distributed in the hope that it will be useful, *
|
||||||
@ -59,7 +59,6 @@ type
|
|||||||
TDockPerformer = class(TDragDockCommon)
|
TDockPerformer = class(TDragDockCommon)
|
||||||
private
|
private
|
||||||
FDockObject: TDragDockObject;
|
FDockObject: TDragDockObject;
|
||||||
procedure DefaultDockImage(AOldRect, ANewRect: TRect; AOperation: TDockImageOperation);
|
|
||||||
protected
|
protected
|
||||||
function Dragging(AControl: TControl): boolean; override;
|
function Dragging(AControl: TControl): boolean; override;
|
||||||
procedure DragStarted(APosition: TPoint); override;
|
procedure DragStarted(APosition: TPoint); override;
|
||||||
@ -264,27 +263,15 @@ end;
|
|||||||
constructor TDockPerformer.Create(AManager: TDragManagerDefault; AControl: TControl);
|
constructor TDockPerformer.Create(AManager: TDragManagerDefault; AControl: TControl);
|
||||||
//Start a drag operation, if not already running
|
//Start a drag operation, if not already running
|
||||||
var
|
var
|
||||||
p, cp: TPoint;
|
APoint: TPoint;
|
||||||
begin
|
begin
|
||||||
inherited Create(AManager, AControl);
|
inherited Create(AManager, AControl);
|
||||||
AControl.DoStartDock(FDockObject);
|
AControl.DoStartDock(FDockObject);
|
||||||
if FDockObject = nil then
|
if FDockObject = nil then
|
||||||
FDockObject := TDragDockObject.AutoCreate(AControl);
|
FDockObject := TDragDockObject.AutoCreate(AControl);
|
||||||
|
|
||||||
// we should handle somehow difference between
|
GetCursorPos(APoint);
|
||||||
// Control.BoundsRect.LeftTop and CursorPos
|
FDockObject.InitDock(APoint);
|
||||||
|
|
||||||
GetCursorPos(p);
|
|
||||||
FDockObject.DragPos := p;
|
|
||||||
// mouse click offset from control TopLeft in screen coordinates
|
|
||||||
cp := AControl.BoundsRect.TopLeft;
|
|
||||||
if AControl.Parent <> nil then
|
|
||||||
cp := AControl.Parent.ClientToScreen(cp);
|
|
||||||
FDockObject.DockOffset := Point(p.x - cp.x, p.y - cp.y);
|
|
||||||
AControl.CalculateDockSizes;
|
|
||||||
FDockObject.DockRect := Rect(p.x, p.y, p.x + AControl.Width, p.y + AControl.Height);
|
|
||||||
FDockObject.EraseDockRect := Rect(MaxInt, 0, MaxInt, 0);
|
|
||||||
|
|
||||||
// we are tracking capture change to stop drag/dock is happen
|
// we are tracking capture change to stop drag/dock is happen
|
||||||
SetCaptureControl(AControl);
|
SetCaptureControl(AControl);
|
||||||
end;
|
end;
|
||||||
@ -301,15 +288,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDockPerformer.DragStarted(APosition: TPoint);
|
procedure TDockPerformer.DragStarted(APosition: TPoint);
|
||||||
//Imput device has moved beyond tresholt (or immediate docking)
|
// Input device has moved beyond threshold (or immediate docking)
|
||||||
begin
|
begin
|
||||||
if FDockObject = nil then
|
if FDockObject = nil then
|
||||||
Exit;
|
Exit;
|
||||||
FDragImageList := FDockObject.GetDragImages;
|
FDragImageList := FDockObject.GetDragImages;
|
||||||
if FDragImageList <> nil then
|
if FDragImageList <> nil then
|
||||||
FDragImageList.BeginDrag(0, APosition.X, APosition.Y);
|
FDragImageList.BeginDrag(0, APosition.X, APosition.Y);
|
||||||
DefaultDockImage(FDockObject.EraseDockRect, FDockObject.DockRect, disShow);
|
FDockObject.ShowDockImage;
|
||||||
FDockObject.EraseDockRect := FDockObject.DockRect;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDockPerformer.DragMove(APosition: TPoint);
|
procedure TDockPerformer.DragMove(APosition: TPoint);
|
||||||
@ -468,12 +454,7 @@ begin
|
|||||||
DropAlign := DropOnControl.GetDockEdge(DropOnControl.ScreenToClient(APosition));
|
DropAlign := DropOnControl.GetDockEdge(DropOnControl.ScreenToClient(APosition));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//Draw the form outlines when the position has changed
|
MoveDockImage;
|
||||||
if not CompareMem(@DockRect, @EraseDockRect, SizeOf(TRect)) then
|
|
||||||
begin
|
|
||||||
DefaultDockImage(FDockObject.EraseDockRect, FDockObject.DockRect, disMove);
|
|
||||||
EraseDockRect := DockRect;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -491,7 +472,7 @@ begin
|
|||||||
FDockObject := nil;
|
FDockObject := nil;
|
||||||
SetCaptureControl(nil);
|
SetCaptureControl(nil);
|
||||||
|
|
||||||
DefaultDockImage(ADockObjectCopy.EraseDockRect, ADockObjectCopy.DockRect, disHide);
|
ADockObjectCopy.HideDockImage;
|
||||||
ADockObjectCopy.Floating := ADockObjectCopy.DragTarget = nil;
|
ADockObjectCopy.Floating := ADockObjectCopy.DragTarget = nil;
|
||||||
|
|
||||||
Accepted := ADockObjectCopy.DragTarget <> nil;
|
Accepted := ADockObjectCopy.DragTarget <> nil;
|
||||||
@ -547,11 +528,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TDockPerformer.DefaultDockImage(AOldRect, ANewRect: TRect; AOperation: TDockImageOperation);
|
|
||||||
begin
|
|
||||||
WidgetSet.DrawDefaultDockImage(AOldRect, ANewRect, AOperation);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDragManagerDefault }
|
{ TDragManagerDefault }
|
||||||
|
|
||||||
destructor TDragManagerDefault.Destroy;
|
destructor TDragManagerDefault.Destroy;
|
||||||
|
@ -112,6 +112,49 @@ begin
|
|||||||
FControl.DoEndDock(Target, X, Y);
|
FControl.DoEndDock(Target, X, Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDragDockObject.InitDock(APosition: TPoint);
|
||||||
|
begin
|
||||||
|
// Determine hotspot scale for adjusting the undocked rectangle.
|
||||||
|
// Since the undocked extent of the control doesn't change, we fix the hotspot offset.
|
||||||
|
// Usage: OffsetRect(DockRect, FDockOffset);
|
||||||
|
|
||||||
|
DragPos := APosition; //should have been done before
|
||||||
|
Control.CalculateDockSizes;
|
||||||
|
// mouse click offset from control TopLeft in screen coordinates
|
||||||
|
FDockRect.TopLeft := Control.ClientToScreen(Point(0, 0));
|
||||||
|
if Control.Width > 0 then
|
||||||
|
FDockOffset.x := Round((APosition.x - FDockRect.Left) / Control.Width * Control.UndockWidth)
|
||||||
|
else
|
||||||
|
FDockOffset.X := 0;
|
||||||
|
if Control.Height > 0 then
|
||||||
|
FDockOffset.Y := Round((APosition.y - FDockRect.Top) / Control.Height * Control.UndockHeight)
|
||||||
|
else
|
||||||
|
FDockOffset.Y := 0;
|
||||||
|
FEraseDockRect := Rect(MaxInt, 0, MaxInt, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDragDockObject.ShowDockImage;
|
||||||
|
begin
|
||||||
|
WidgetSet.DrawDefaultDockImage(EraseDockRect, DockRect, disShow);
|
||||||
|
EraseDockRect := DockRect;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDragDockObject.HideDockImage;
|
||||||
|
begin
|
||||||
|
WidgetSet.DrawDefaultDockImage(EraseDockRect, DockRect, disHide);
|
||||||
|
FEraseDockRect := Rect(MaxInt, 0, MaxInt, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDragDockObject.MoveDockImage;
|
||||||
|
begin
|
||||||
|
//Draw the form outlines when the position has changed
|
||||||
|
if not CompareMem(@DockRect, @EraseDockRect, SizeOf(TRect)) then
|
||||||
|
begin
|
||||||
|
WidgetSet.DrawDefaultDockImage(EraseDockRect, DockRect, disMove);
|
||||||
|
EraseDockRect := DockRect;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TDragDockObjectEx }
|
{ TDragDockObjectEx }
|
||||||
|
|
||||||
constructor TDragDockObjectEx.Create(AControl: TControl);
|
constructor TDragDockObjectEx.Create(AControl: TControl);
|
||||||
|
Loading…
Reference in New Issue
Block a user