unit Form.Main;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Layouts, FMX.ListBox;
type
TMainForm =
class( TForm )
ZoomPanel: TPanel;
Label1: TLabel;
procedure FormGesture( Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean );
private
FLastDistance: Integer;
FZoomWidth, FZoomHeight: Single;
public
procedure AfterConstruction;
override;
end;
var
MainForm: TMainForm;
implementation
{$R *.fmx}
procedure TMainForm.AfterConstruction;
begin
inherited;
Label1.Text := '
Ich kann größer werden';
// ZoomPanel-Werte sichern
FZoomWidth := ZoomPanel.Width;
FZoomHeight := ZoomPanel.Height;
// Gesten-Behandlung
Self.OnGesture := FormGesture;
Self.Touch.InteractiveGestures := [TInteractiveGesture.Zoom];
end;
procedure TMainForm.FormGesture( Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean );
var
LScale, Direction: Single;
begin
if EventInfo.GestureID = igiZoom
then
begin
if not( TInteractiveGestureFlag.gfBegin
in EventInfo.Flags )
and not( TInteractiveGestureFlag.gfEnd
in EventInfo.Flags )
then
begin
Direction := EventInfo.Distance / FLastDistance;
LScale := ZoomPanel.Scale.X * Direction;
if LScale < 1
then
LScale := 1;
ZoomPanel.Scale.X := LScale;
ZoomPanel.Scale.Y := LScale;
ZoomPanel.Width := FZoomWidth * LScale;
ZoomPanel.Height := FZoomHeight * LScale;
end;
FLastDistance := EventInfo.Distance;
end;
end;
end.