Permalink
Browse files

Animate "Open" button on session manager while connecting

  • Loading branch information...
ansgarbecker committed Jan 9, 2019
1 parent fb081d3 commit 6918f066804ae56d73710287f8963d8099d9dd0f
Showing with 30 additions and 0 deletions.
  1. +7 −0 source/connections.dfm
  2. +23 −0 source/connections.pas
@@ -977,4 +977,11 @@ object connform: Tconnform
Action = MainForm.actAboutBox
end
end
object TimerButtonAnimation: TTimer
Enabled = False
Interval = 200
OnTimer = TimerButtonAnimationTimer
Left = 112
Top = 144
end
end
@@ -117,6 +117,7 @@ Tconnform = class(TFormWithSizeGrip)
pnlDpiHelperSettings: TPanel;
pnlDpiHelperSshTunnel: TPanel;
pnlDpiHelperAdvanced: TPanel;
TimerButtonAnimation: TTimer;
procedure FormCreate(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
procedure FormShow(Sender: TObject);
@@ -165,6 +166,7 @@ Tconnform = class(TFormWithSizeGrip)
Pt: TPoint; var Effect: Integer; Mode: TDropMode);
procedure btnMoreClick(Sender: TObject);
procedure menuRenameClick(Sender: TObject);
procedure TimerButtonAnimationTimer(Sender: TObject);
private
{ Private declarations }
FLoaded: Boolean;
@@ -173,6 +175,7 @@ Tconnform = class(TFormWithSizeGrip)
FSessionColor: TColor;
FSettingsImportWaitTime: Cardinal;
FPopupDatabases: TPopupMenu;
FButtonAnimationStep: Integer;
procedure RefreshSessions(ParentNode: PVirtualNode);
function SelectedSessionPath: String;
function CurrentParams: TConnectionParameters;
@@ -344,13 +347,19 @@ procedure Tconnform.btnOpenClick(Sender: TObject);
// Connect to selected session
if not btnOpen.Enabled then
Exit;
btnOpen.Enabled := False;
FButtonAnimationStep := 0;
TimerButtonAnimation.Enabled := True;
Screen.Cursor := crHourglass;
if Mainform.InitConnection(CurrentParams, True, Connection) then
ModalResult := mrOK
else begin
TimerStatistics.OnTimer(Sender);
ModalResult := mrNone;
end;
TimerButtonAnimation.Enabled := False;
btnOpen.Enabled := True;
btnOpen.Caption := _('Open');
Screen.Cursor := crDefault;
end;

@@ -1215,6 +1224,20 @@ procedure Tconnform.splitterMainMoved(Sender: TObject);
end;


procedure Tconnform.TimerButtonAnimationTimer(Sender: TObject);
const
MaxAnimationSteps = 3;
begin
// Animate "Open" button
btnOpen.Caption := _('Open') + StringOfChar(' ', FButtonAnimationStep) +
'.' +
StringOfChar(' ', MaxAnimationSteps-FButtonAnimationStep);
btnOpen.Repaint;
Inc(FButtonAnimationStep);
if FButtonAnimationStep >= MaxAnimationSteps then
FButtonAnimationStep := 0;
end;

procedure Tconnform.PickFile(Sender: TObject);
var
Selector: TOpenDialog;

0 comments on commit 6918f06

Please sign in to comment.