mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-04 10:17:43 +02:00
TAChart: Add TPanDragTool.Directions to allow panning in specified directions only.
* This finishes issue #16109 git-svn-id: trunk@24339 -
This commit is contained in:
parent
a4cc8f74aa
commit
fff9fbf31a
@ -113,16 +113,27 @@ type
|
|||||||
read FZoomFactor write FZoomFactor stored ZoomFactorIsStored;
|
read FZoomFactor write FZoomFactor stored ZoomFactorIsStored;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TPanDirection = (pdLeft, pdUp, pdRight, pdDown);
|
||||||
|
TPanDirectionSet = set of TPanDirection;
|
||||||
|
|
||||||
|
const
|
||||||
|
PAN_DIRECTIONS_ALL = [Low(TPanDirection) .. High(TPanDirection)];
|
||||||
|
|
||||||
|
type
|
||||||
{ TPanDragTool }
|
{ TPanDragTool }
|
||||||
|
|
||||||
TPanDragTool = class(TChartTool)
|
TPanDragTool = class(TChartTool)
|
||||||
private
|
private
|
||||||
|
FDirections: TPanDirectionSet;
|
||||||
FOrigin: TPoint;
|
FOrigin: TPoint;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure MouseDown(APoint: TPoint); override;
|
procedure MouseDown(APoint: TPoint); override;
|
||||||
procedure MouseMove(APoint: TPoint); override;
|
procedure MouseMove(APoint: TPoint); override;
|
||||||
procedure MouseUp(APoint: TPoint); override;
|
procedure MouseUp(APoint: TPoint); override;
|
||||||
|
published
|
||||||
|
property Directions: TPanDirectionSet
|
||||||
|
read FDirections write FDirections default PAN_DIRECTIONS_ALL;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TReticuleTool }
|
{ TReticuleTool }
|
||||||
@ -543,6 +554,7 @@ end;
|
|||||||
constructor TPanDragTool.Create(AOwner: TComponent);
|
constructor TPanDragTool.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
|
FDirections := PAN_DIRECTIONS_ALL;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TPanDragTool }
|
{ TPanDragTool }
|
||||||
@ -554,8 +566,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPanDragTool.MouseMove(APoint: TPoint);
|
procedure TPanDragTool.MouseMove(APoint: TPoint);
|
||||||
|
var
|
||||||
|
d: TPoint;
|
||||||
begin
|
begin
|
||||||
FChart.Pan(APoint - FOrigin);
|
d := APoint - FOrigin;
|
||||||
|
if not (pdLeft in Directions) then d.X := Max(d.X, 0);
|
||||||
|
if not (pdRight in Directions) then d.X := Min(d.X, 0);
|
||||||
|
if not (pdUp in Directions) then d.Y := Max(d.Y, 0);
|
||||||
|
if not (pdDown in Directions) then d.Y := Min(d.Y, 0);
|
||||||
|
FChart.Pan(d);
|
||||||
FOrigin := APoint;
|
FOrigin := APoint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user