unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Ani, FMX.Layouts, FMX.Gestures,
FMX.StdCtrls;
type
TScrollBox =
class (FMX.Layouts.TScrollBox)
end;
TForm1 =
class(TForm)
StyleBook1: TStyleBook;
ToolbarHolder: TLayout;
ToolbarPopup: TPopup;
ToolbarPopupAnimation: TFloatAnimation;
ToolBar1: TToolBar;
ToolbarApplyButton: TButton;
ToolbarCloseButton: TButton;
ToolbarAddButton: TButton;
ScrollBox1: TScrollBox;
Panel1: TPanel;
GestureManager1: TGestureManager;
procedure ToolbarCloseButtonClick(Sender: TObject);
procedure FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
var KeyChar: Char;
Shift: TShiftState);
procedure ScrollBox1Gesture(Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
private
FGestureOrigin: TPointF;
FGestureInProgress: Boolean;
{ Private-Deklarationen }
procedure ShowToolbar(AShow: Boolean);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
if Key = vkEscape
then
ShowToolbar(
not ToolbarPopup.IsOpen);
end;
procedure TForm1.ToolbarCloseButtonClick(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
var
DX, DY : Single;
begin
showmessage('
Hello World');
if EventInfo.GestureID = igiPan
then
begin
if (TInteractiveGestureFlag.gfBegin
in EventInfo.Flags)
and ((Sender = ToolbarPopup)
or (EventInfo.Location.Y > (ClientHeight - 70)))
then
begin
FGestureOrigin := EventInfo.Location;
FGestureInProgress := True;
end;
if FGestureInProgress
and (TInteractiveGestureFlag.gfEnd
in EventInfo.Flags)
then
begin
FGestureInProgress := False;
DX := EventInfo.Location.X - FGestureOrigin.X;
DY := EventInfo.Location.Y - FGestureOrigin.Y;
if (Abs(DY) > Abs(DX))
then
ShowToolbar(DY < 0);
end;
end
end;
procedure TForm1.ScrollBox1Gesture(Sender: TObject;
const EventInfo: TGestureEventInfo;
var Handled: Boolean);
begin
showmessage('
Hello World');
case EventInfo.GestureID
of
sgiDown : ScrollBox1.ScrollTo (0, -40);
sgiLeft : ScrollBox1.ScrollTo (-40, 0);
sgiRight : ScrollBox1.ScrollTo (40, 0);
sgiUp : ScrollBox1.ScrollTo (0, 40);
end;
end;
procedure TForm1.ShowToolbar(AShow: Boolean);
begin
ToolbarPopup.Width := ClientWidth;
ToolbarPopup.PlacementRectangle.Rect := TRectF.Create(0, ClientHeight-ToolbarPopup.Height, ClientWidth-1, ClientHeight-1);
ToolbarPopupAnimation.StartValue := ToolbarPopup.Height;
ToolbarPopupAnimation.StopValue := 0;
ToolbarPopup.IsOpen := AShow;
end;
end.