Utilisateur anonyme
-
21 avril 2008 à 21:51
cs_MAURICIO
Messages postés2106Date d'inscriptionmardi 10 décembre 2002StatutModérateurDernière intervention15 décembre 2014
-
22 avril 2008 à 18:17
Salut la compagnie
J'ai réalisé un petit composant : Celui fonctionne très bien sauf qu'il est terriblement lent ce qui fait que le refresh de la fiche que j'utilise mais du temps à se faire. Je pense que c'est une question d'optimisation mais je ne vois pas trop ce que je pourrais améliorer. Donc je m'en remet à vos lumières
Procedure TBrowser.Add_SoundFont(Value:String);
Begin
SetLength(SoundFontList,High(SoundFontList)+2);
With SoundFontList[High(SoundFontList)] Do
Begin
FileName:=Value;
Bank:=0;
Panel:=TPanel.Create(Self);
Panel.Parent:=Self;
Panel.OnClick:=SoundFontsOnClick;
Panel.Tag:=High(SoundFontList)+1;
Selected:=False;
Font.Color:=Clwhite;
Panel.Caption:=ExtractFileName(FileName);
End;
Self.Invalidate;
End;
Procedure TBrowser.Add_Asio(Value:String);
Begin
SetLength(AsioList,High(AsioList)+2);
With AsioList[High(AsioList)] Do
Begin
FileName:=Value;
Panel:=TPanel.Create(Self);
Panel.Parent:=Self;
Panel.OnClick:=AsiosOnClick;
Panel.Tag:=High(AsioList)+1;
Selected:=False;
Font.Color:=Clwhite;
Panel.Caption:=ExtractFileName(FileName);
End;
Self.Invalidate;
End;
Procedure TBrowser.Add_VSTInstr(Value:String);
Begin
SetLength(VSTInstrList,High(VSTInstrList)+2);
With VSTInstrList[High(VSTInstrList)] Do
Begin
FileName:=Value;
Panel:=TPanel.Create(Self);
Panel.Parent:=Self;
Panel.OnClick:=VSTInstrsOnClick;
Panel.Tag:=High(VSTInstrList)+1;
Selected:=False;
Font.Color:=Clwhite;
Panel.Caption:=ExtractFileName(FileName);
End;
Self.Invalidate;
End;
Procedure TBrowser.InstrumentsOnClick(Sender:TObject);
Var
Number,Index:Cardinal;
Begin
InstrumentSelected:=0;
Number:=1;
If (Sender is TPanel) Then
Number:=(Sender As TPanel).Tag;
For Index:=1 To 128 Do
InstrumentList[Index].Selected:=False;
InstrumentList[Number].Selected:=True;
InstrumentSelected:=Number;
Self.Invalidate;
If Assigned(fOnInstrument_Event) Then Self.fOnInstrument_Event(Sender);
End;
Procedure TBrowser.SoundFontsOnClick(Sender:TObject);
Var
Number,Index:Cardinal;
Begin
SoundFontSelected:=0;
Number:=1;
If (Sender is TPanel) Then
Number:=(Sender As TPanel).Tag;
For Index:=Low(SoundFontList) To High(SoundFontList) Do
SoundFontList[Index].Selected:=False;
SoundFontList[Number-1].Selected:=Not SoundFontList[Number-1].Selected;
If SoundFontList[Number-1].Selected Then SoundFontSelected:=Number;
Self.Invalidate;
If Assigned(fOnSoundFont_Event) Then Self.fOnSoundFont_Event(Sender);
End;
Procedure TBrowser.AsiosOnClick(Sender:TObject);
Var
Number,Index:Cardinal;
Begin
Number:=1;
If (Sender is TPanel) Then
Number:=(Sender As TPanel).Tag;
For Index:=Low(AsioList) To High(AsioList) Do
If Number-1<>Index Then AsioList[Index].Selected:=False;
AsioList[Number-1].Selected:=Not AsioList[Number-1].Selected;
If AsioList[Number-1].Selected Then AsioSelected:=Number;
Self.Invalidate;
If Assigned(fOnAsio_Event) Then Self.fOnAsio_Event(Sender);
End;
Procedure TBrowser.VSTInstrsOnClick(Sender:TObject);
Var
Number,Index:Cardinal;
Begin
Number:=1;
VSTISelected:=0;
If (Sender is TPanel) Then
Number:=(Sender As TPanel).Tag;
For Index:=Low(VSTInstrList) To High(VSTInstrList) Do
If Number-1<>Index Then VSTInstrList[Index].Selected:=False;
VSTInstrList[Number-1].Selected:=Not VSTInstrList[Number-1].Selected;
If VSTInstrList[Number-1].Selected Then VSTISelected:=Number;
Self.Invalidate;
If Assigned(fOnVSTInstr_Event) Then Self.fOnVSTInstr_Event(Sender);
End;
Procedure TBrowser.Paint;
Var
Index, IndexTop:Cardinal;
Begin
Gen_Grad_Panel;
IndexTop:=0;
With fInstrumentPanel Do
Begin
Width:=Self.Width-4;
Height:=30;
Top:=IndexTop*32;
Left:=2;
Color:=Self.fColorPanel;
Caption:='INSTRUMENT';
End;
For Index:=1 To 128 Do
With InstrumentList[Index] Do
Begin
Panel.Width:=Round(Self.Width*0.90)-2;
Panel.Height:=30;
Panel.Top:=32*IndexTop+32;
Panel.Left:=Round(Self.Width*0.1);
If Not Selected Then Panel.Color:=Self.fColorPanel Else
Panel.Color:=Self.fSelectColor;
Panel.Visible:=Self.fInstrumentsVisible;
If Panel.Visible Then Inc(IndexTop);
End;
With fSoundFontPanel Do
Begin
Width:=Self.Width-4;
Height:=30;
Top:=32*IndexTop+32;
Left:=2;
Color:=Self.fColorPanel;
Caption:='SOUNDFONT';
Inc(IndexTop);
End;
If High(SoundFontList)>-1 Then
For Index:=Low(SoundFontList) To High(SoundFontList) Do
With SoundFontList[Index] Do
Begin
Panel.Width:=Round(Self.Width*0.90)-2;
Panel.Height:=30;
Panel.Top:=32*IndexTop+32;
Panel.Left:=Round(Self.Width*0.1);
If Not Selected Then Panel.Color:=Self.fColorPanel Else
Panel.Color:=Self.fSelectColor;
Panel.Visible:=Self.fSoundFontsVisible;
If Panel.Visible Then Inc(IndexTop);
End;
With fAsioPanel Do
Begin
Inc(IndexTop);
Width:=Self.Width-4;
Height:=30;
Top:=IndexTop*32;
Left:=2;
Color:=Self.fColorPanel;
Caption:='ASIO';
End;
If High(AsioList)>-1 Then
For Index:=Low(AsioList) To High(AsioList) Do
With AsioList[Index] Do
Begin
Panel.Width:=Round(Self.Width*0.90)-2;
Panel.Height:=30;
Panel.Top:=32*IndexTop+32;
Panel.Left:=Round(Self.Width*0.1);
If Not Selected Then Panel.Color:=Self.fColorPanel Else
Panel.Color:=Self.fSelectColor;
Panel.Visible:=Self.fAsiosVisible;
If Panel.Visible Then Inc(IndexTop);
End;
With fVSTInstrPanel Do
Begin
Inc(IndexTop);
Width:=Self.Width-4;
Height:=30;
Top:=IndexTop*32;
Left:=2;
Color:=Self.fColorPanel;
Caption:='VST INSTRUMENT';
End;
If High(VSTInstrList)>-1 Then
For Index:=Low(VSTInstrList) To High(VSTInstrList) Do
With VSTInstrList[Index] Do
Begin
Panel.Width:=Round(Self.Width*0.90)-2;
Panel.Height:=30;
Panel.Top:=32*IndexTop+32;
Panel.Left:=Round(Self.Width*0.1);
If Not Selected Then Panel.Color:=Self.fColorPanel Else
Panel.Color:=Self.fSelectColor;
Panel.Visible:=Self.fVSTInstrsVisible;
If Panel.Visible Then Inc(IndexTop);
End;
Self.Height:=(IndexTop+1)*32;
End;
destructor TBrowser.Destroy;
Var
Index:Cardinal;
begin
fInstrumentPanel.Free;
fSoundFontPanel.Free;
fASioPanel.Free;
If High(SoundFontList)>-1 Then
For Index:=0 To High(SoundFontList) Do Self.SoundFontList[Index].Panel.Free;
If High(AsioList)>-1 Then
For Index:=0 To High(AsioList) Do Self.AsioList[Index].Panel.Free;
If High(VSTInstrList)>-1 Then
For Index:=0 To High(VSTInstrList) Do Self.VSTInstrList[Index].Panel.Free;
Finalize(SoundFontList);
Finalize(AsioList);
Finalize(VSTInstrList);
inherited;
end;
procedure TBrowser.MouseDown(Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
Begin
Inherited;
If (Assigned(fPopupMenu)) And (Shift=[ssRight]) Then
fPopupMenu.Popup(ClientOrigin.X+x,ClientOrigin.Y+y);
End;