You've already forked lazarus-ccr
tvplanit: Activate sound being played in NavBar when selecting a folder.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5006 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -13,7 +13,7 @@ object Form1: TForm1
|
|||||||
Height = 370
|
Height = 370
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 128
|
Width = 128
|
||||||
ActiveFolder = 3
|
ActiveFolder = 0
|
||||||
AllowInplaceEdit = True
|
AllowInplaceEdit = True
|
||||||
AllowRearrange = True
|
AllowRearrange = True
|
||||||
BackgroundColor = clInactiveCaption
|
BackgroundColor = clInactiveCaption
|
||||||
@@ -128,25 +128,26 @@ object Form1: TForm1
|
|||||||
Images = Images
|
Images = Images
|
||||||
ItemFont.Color = clWhite
|
ItemFont.Color = clWhite
|
||||||
ItemSpacing = 5
|
ItemSpacing = 5
|
||||||
PlaySounds = False
|
PlaySounds = True
|
||||||
SelectedItem = -1
|
SelectedItem = -1
|
||||||
SelectedItemFont.Color = clYellow
|
SelectedItemFont.Color = clYellow
|
||||||
SelectedItemFont.Style = [fsBold]
|
SelectedItemFont.Style = [fsBold]
|
||||||
ShowButtons = True
|
ShowButtons = True
|
||||||
SoundAlias = 'MenuCommand'
|
SoundAlias = 'c:\windows\media\tada.wav'
|
||||||
OnItemClick = VpNavBar1ItemClick
|
OnItemClick = VpNavBar1ItemClick
|
||||||
OnFolderChanged = VpNavBar1FolderChanged
|
OnFolderChanged = VpNavBar1FolderChanged
|
||||||
Align = alLeft
|
Align = alLeft
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
object Container0: TVpFolderContainer
|
object Container0: TVpFolderContainer
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 290
|
Height = 0
|
||||||
Top = 80
|
Top = 80
|
||||||
Width = 128
|
Width = 0
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
Color = clInactiveCaption
|
Color = clInactiveCaption
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
Visible = False
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object RgDrawingStyle: TRadioGroup
|
object RgDrawingStyle: TRadioGroup
|
||||||
@@ -393,6 +394,39 @@ object Form1: TForm1
|
|||||||
OnClick = RgBorderStyleClick
|
OnClick = RgBorderStyleClick
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
|
object GroupBox2: TGroupBox
|
||||||
|
Left = 292
|
||||||
|
Height = 66
|
||||||
|
Top = 288
|
||||||
|
Width = 259
|
||||||
|
Caption = 'Sounds'
|
||||||
|
ClientHeight = 46
|
||||||
|
ClientWidth = 255
|
||||||
|
TabOrder = 8
|
||||||
|
object CbPlaySounds: TCheckBox
|
||||||
|
Left = 9
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 83
|
||||||
|
Caption = 'Play sounds'
|
||||||
|
OnChange = CbPlaySoundsChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object EdSoundFile: TFileNameEdit
|
||||||
|
Left = 9
|
||||||
|
Height = 23
|
||||||
|
Top = 23
|
||||||
|
Width = 239
|
||||||
|
OnAcceptFileName = EdSoundFileAcceptFileName
|
||||||
|
FilterIndex = 0
|
||||||
|
HideDirectories = False
|
||||||
|
ButtonWidth = 23
|
||||||
|
NumGlyphs = 1
|
||||||
|
MaxLength = 0
|
||||||
|
TabOrder = 1
|
||||||
|
OnEditingDone = EdSoundFileEditingDone
|
||||||
|
end
|
||||||
|
end
|
||||||
object Images: TImageList
|
object Images: TImageList
|
||||||
Height = 32
|
Height = 32
|
||||||
Width = 32
|
Width = 32
|
||||||
|
@@ -18,8 +18,11 @@ type
|
|||||||
BtnAddItem: TButton;
|
BtnAddItem: TButton;
|
||||||
BkColor: TColorBox;
|
BkColor: TColorBox;
|
||||||
BtnLoadBkImage: TButton;
|
BtnLoadBkImage: TButton;
|
||||||
|
CbPlaySounds: TCheckBox;
|
||||||
EdBkImage: TFileNameEdit;
|
EdBkImage: TFileNameEdit;
|
||||||
|
EdSoundFile: TFileNameEdit;
|
||||||
GroupBox1: TGroupBox;
|
GroupBox1: TGroupBox;
|
||||||
|
GroupBox2: TGroupBox;
|
||||||
IconsLbl: TLabel;
|
IconsLbl: TLabel;
|
||||||
IconsLink: TLabel;
|
IconsLink: TLabel;
|
||||||
Panel2: TPanel;
|
Panel2: TPanel;
|
||||||
@@ -39,6 +42,9 @@ type
|
|||||||
procedure BtnAddFolderClick(Sender: TObject);
|
procedure BtnAddFolderClick(Sender: TObject);
|
||||||
procedure BtnAddItemClick(Sender: TObject);
|
procedure BtnAddItemClick(Sender: TObject);
|
||||||
procedure BtnLoadBkImageClick(Sender: TObject);
|
procedure BtnLoadBkImageClick(Sender: TObject);
|
||||||
|
procedure CbPlaySoundsChange(Sender: TObject);
|
||||||
|
procedure EdSoundFileAcceptFileName(Sender: TObject; var Value: String);
|
||||||
|
procedure EdSoundFileEditingDone(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure IconsLinkClick(Sender: TObject);
|
procedure IconsLinkClick(Sender: TObject);
|
||||||
procedure IconsLinkMouseEnter(Sender: TObject);
|
procedure IconsLinkMouseEnter(Sender: TObject);
|
||||||
@@ -64,7 +70,8 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LCLIntf;
|
LCLIntf,
|
||||||
|
VpMisc;
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
@@ -150,10 +157,25 @@ begin
|
|||||||
}
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CbPlaySoundsChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
VpNavBar1.PlaySounds := CbPlaySounds.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.EdSoundFileAcceptFileName(Sender: TObject; var Value: String);
|
||||||
|
begin
|
||||||
|
VpNavBar1.SoundAlias := ExpandFilename(Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.EdSoundFileEditingDone(Sender: TObject);
|
||||||
|
begin
|
||||||
|
VpNavBar1.SoundAlias := EdSoundFile.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
RandSeed := 1;
|
RandSeed := 1;
|
||||||
IconsLink.Left := IconsLbl.Left + IconsLbl.Width;
|
IconsLink.Left := IconsLbl.Left + GetLabelWidth(IconsLbl);
|
||||||
RgDrawingStyle.ItemIndex := ord(VpNavBar1.DrawingStyle);
|
RgDrawingStyle.ItemIndex := ord(VpNavBar1.DrawingStyle);
|
||||||
RgBorderStyle.ItemIndex := ord(VpNavBar1.BorderStyle);
|
RgBorderStyle.ItemIndex := ord(VpNavBar1.BorderStyle);
|
||||||
BkColor.Selected := VpNavBar1.BackgroundColor;
|
BkColor.Selected := VpNavBar1.BackgroundColor;
|
||||||
@@ -178,6 +200,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
BtnLoadBkImageClick(nil);
|
BtnLoadBkImageClick(nil);
|
||||||
|
|
||||||
|
EdSoundFile.InitialDir := ExtractFileDir(VpNavBar1.SoundAlias);
|
||||||
|
EdSoundFile.FileName := VpNavBar1.SoundAlias;
|
||||||
|
CbPlaySounds.Checked := VpNavBar1.PlaySounds;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.IconsLinkClick(Sender: TObject);
|
procedure TForm1.IconsLinkClick(Sender: TObject);
|
||||||
|
@@ -218,6 +218,7 @@ type
|
|||||||
FOnFolderClick: TVpFolderClickEvent;
|
FOnFolderClick: TVpFolderClickEvent;
|
||||||
FOnItemClick: TVpItemClickEvent;
|
FOnItemClick: TVpItemClickEvent;
|
||||||
FOnMouseOverItem: TVpMouseOverItemEvent;
|
FOnMouseOverItem: TVpMouseOverItemEvent;
|
||||||
|
FOnPlaySound: TVpPlaySoundEvent;
|
||||||
|
|
||||||
{internal variables}
|
{internal variables}
|
||||||
nabChanging: Boolean;
|
nabChanging: Boolean;
|
||||||
@@ -358,6 +359,7 @@ type
|
|||||||
property OnFolderChange: TVpFolderChangeEvent read FOnFolderChange write FOnFolderChange;
|
property OnFolderChange: TVpFolderChangeEvent read FOnFolderChange write FOnFolderChange;
|
||||||
property OnFolderChanged: TVpFolderChangedEvent read FOnFolderChanged write FOnFolderChanged;
|
property OnFolderChanged: TVpFolderChangedEvent read FOnFolderChanged write FOnFolderChanged;
|
||||||
property OnMouseOverItem: TVpMouseOverItemEvent read FOnMouseOverItem write FOnMouseOverItem;
|
property OnMouseOverItem: TVpMouseOverItemEvent read FOnMouseOverItem write FOnMouseOverItem;
|
||||||
|
property OnPlaySound: TVpPlaySoundEvent read FOnPlaySound write FOnPlaySound;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
@@ -382,6 +384,7 @@ type
|
|||||||
procedure InvalidateItem(FolderIndex, ItemIndex: Integer);
|
procedure InvalidateItem(FolderIndex, ItemIndex: Integer);
|
||||||
procedure RemoveItem(AFolderIndex, AItemIndex: Integer);
|
procedure RemoveItem(AFolderIndex, AItemIndex: Integer);
|
||||||
procedure RenameItem(AFolderIndex, AItemIndex: Integer);
|
procedure RenameItem(AFolderIndex, AItemIndex: Integer);
|
||||||
|
procedure PlaySound(const AWavFile: String; APlaySoundMode: TVpPlaySoundMode);
|
||||||
property ActiveItem: Integer read FActiveItem;
|
property ActiveItem: Integer read FActiveItem;
|
||||||
property Containers[Index: Integer]: TVpFolderContainer read GetContainer;
|
property Containers[Index: Integer]: TVpFolderContainer read GetContainer;
|
||||||
property Folders[Index: Integer]: TVpNavFolder read GetFolder;
|
property Folders[Index: Integer]: TVpNavFolder read GetFolder;
|
||||||
@@ -461,6 +464,9 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
mmSystem,
|
||||||
|
{$ENDIF}
|
||||||
Themes,
|
Themes,
|
||||||
VpNavBarPainter;
|
VpNavBarPainter;
|
||||||
|
|
||||||
@@ -2693,13 +2699,28 @@ end;
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
|
procedure TVpCustomNavBar.PlaySound(const AWavFile: String;
|
||||||
|
APlaySoundMode: TVpPlaySoundMode);
|
||||||
|
begin
|
||||||
|
if Assigned(FOnPlaySound) then
|
||||||
|
FOnPlaySound(Self, AWavFile, APlaySoundMode)
|
||||||
|
else begin
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
case APlaySoundMode of
|
||||||
|
psmSync : SndPlaySound(PChar(AWavFile), SND_SYNC);
|
||||||
|
psmAsync : SndPlaySound(PChar(AWavFile), SND_ASYNC);
|
||||||
|
psmStop : SndPlaySound(nil, 0);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpCustomNavBar.SetActiveFolder(Value: Integer);
|
procedure TVpCustomNavBar.SetActiveFolder(Value: Integer);
|
||||||
var
|
var
|
||||||
Y: Integer;
|
Y: Integer;
|
||||||
YDelta: Integer;
|
YDelta: Integer;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
R2: TRect;
|
R2: TRect;
|
||||||
Buf: array[0..1023] of Char;
|
|
||||||
AllowChange: Boolean;
|
AllowChange: Boolean;
|
||||||
begin
|
begin
|
||||||
if Value <> FActiveFolder then begin
|
if Value <> FActiveFolder then begin
|
||||||
@@ -2721,12 +2742,16 @@ begin
|
|||||||
{animated scroll}
|
{animated scroll}
|
||||||
if FActiveFolder > -1 then begin
|
if FActiveFolder > -1 then begin
|
||||||
{play sound}
|
{play sound}
|
||||||
|
if FPlaySounds and (FSoundAlias <> '') and FileExists(FSoundAlias) then
|
||||||
|
PlaySound(FSoundAlias, psmAsync);
|
||||||
|
(*
|
||||||
if FPlaySounds and (FSoundAlias > '') then begin
|
if FPlaySounds and (FSoundAlias > '') then begin
|
||||||
StrPLCopy(Buf, FSoundAlias, SizeOf(Buf)-1);
|
StrPLCopy(Buf, FSoundAlias, SizeOf(Buf)-1);
|
||||||
{$IFNDEF LCL}
|
{$IFNDEF LCL}
|
||||||
FPlaySounds := PlaySound(@Buf, 0, SND_ASYNC);
|
FPlaySounds := PlaySound(@Buf, 0, SND_ASYNC);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
if Parent <> nil then begin
|
if Parent <> nil then begin
|
||||||
{scroll selection}
|
{scroll selection}
|
||||||
|
Reference in New Issue
Block a user