Skip to content

Commit

Permalink
*Optimized performance into Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
carloBarazzetta committed Sep 10, 2020
1 parent 6b50fb2 commit 81f7be2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Demo/Source/UMainNew.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object MainForm: TMainForm
Font.Style = []
OldCreateOrder = False
ShowHint = True
OnAfterMonitorDpiChanged = FormAfterMonitorDpiChanged
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
Expand Down Expand Up @@ -227,7 +228,6 @@ object MainForm: TMainForm
ImageIndex = 100
Align = alBottom
OnMouseDown = SVGIconImageMouseDown
ExplicitLeft = 0
end
object DeleteButton: TButton
Left = 3
Expand Down
37 changes: 19 additions & 18 deletions Demo/Source/UMainNew.pas
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ TMainForm = class(TForm)
NewFormButton: TButton;
NewFormAction: TAction;
tmrTrackbar: TTimer;
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
procedure ChangeIconActionExecute(Sender: TObject);
procedure SelectThemeRadioGroupClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
Expand All @@ -104,11 +105,8 @@ TMainForm = class(TForm)
procedure tmrTrackbarTimer(Sender: TObject);
private
FUpdating: Boolean;
{$IFDEF HiDPISupport}
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
{$ENDIF}
procedure UpdateButtons;
procedure UpdateGUI;
procedure UpdateGUI(UpdateIcons: Boolean = True);
procedure UpdateListView;
procedure UpdateTreeView;
public
Expand Down Expand Up @@ -197,12 +195,10 @@ procedure TMainForm.DeleteIconActionExecute(Sender: TObject);
end;
end;

{$IFDEF HiDPISupport}
procedure TMainForm.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
begin
UpdateGUI;
UpdateGUI(False);
end;
{$ENDIF}

procedure TMainForm.FixedColorComboBoxSelect(Sender: TObject);
begin
Expand Down Expand Up @@ -275,7 +271,7 @@ procedure TMainForm.SelectThemeRadioGroupClick(Sender: TObject);
if TStyleManager.ActiveStyle.Name <> LStyleName then
TStyleManager.TrySetStyle(LStyleName);
//UpdateIconFontsColorByStyle(IconFontsImageList); TODO
UpdateGUI;
UpdateGUI(False);
finally
Screen.Cursor := crDefault;
end;
Expand Down Expand Up @@ -322,29 +318,34 @@ procedure TMainForm.tmrTrackbarTimer(Sender: TObject);
tmrTrackbar.Enabled := false;
//Resize all icons into ImageList
VirtualImageList.SetSize(TrackBar.Position, TrackBar.Position);
UpdateGUI;
UpdateGUI(False);
finally
TrackBar.Enabled := true;
end;
end;

procedure TMainForm.updateGUI;
procedure TMainForm.updateGUI(UpdateIcons: Boolean = True);
var
LSize: Integer;
begin
if FUpdating then
Exit;
FUpdating := True;
try
LSize := VirtualImageList.Height;
//Fill VirtualImageList with all icons in the collection of SVGIconVirtualImageList
VirtualImageList.BeginUpdate;
try
VirtualImageList.Clear;
VirtualImageList.Add('', 0, ImageDataModule.SVGIconImageCollection.Count-1 );
finally
VirtualImageList.EndUpdate;
if UpdateIcons then
begin
//Fill VirtualImageList with all icons in the collection of SVGIconVirtualImageList
//it's only a demo: normally a VirtualImageList contains only the icons needed for
//the Form
VirtualImageList.BeginUpdate;
try
VirtualImageList.Clear;
VirtualImageList.Add('', 0, ImageDataModule.SVGIconImageCollection.Count-1 );
finally
VirtualImageList.EndUpdate;
end;
end;
LSize := VirtualImageList.Height;
IconSizeLabel.Caption := Format('Icons size: %d',[LSize]);
TopToolBar.ButtonHeight := LSize + 2;
TopToolBar.ButtonWidth := LSize + 2;
Expand Down

0 comments on commit 81f7be2

Please sign in to comment.