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
|
||||
Top = 0
|
||||
Width = 128
|
||||
ActiveFolder = 3
|
||||
ActiveFolder = 0
|
||||
AllowInplaceEdit = True
|
||||
AllowRearrange = True
|
||||
BackgroundColor = clInactiveCaption
|
||||
@@ -128,25 +128,26 @@ object Form1: TForm1
|
||||
Images = Images
|
||||
ItemFont.Color = clWhite
|
||||
ItemSpacing = 5
|
||||
PlaySounds = False
|
||||
PlaySounds = True
|
||||
SelectedItem = -1
|
||||
SelectedItemFont.Color = clYellow
|
||||
SelectedItemFont.Style = [fsBold]
|
||||
ShowButtons = True
|
||||
SoundAlias = 'MenuCommand'
|
||||
SoundAlias = 'c:\windows\media\tada.wav'
|
||||
OnItemClick = VpNavBar1ItemClick
|
||||
OnFolderChanged = VpNavBar1FolderChanged
|
||||
Align = alLeft
|
||||
ParentColor = False
|
||||
object Container0: TVpFolderContainer
|
||||
Left = 0
|
||||
Height = 290
|
||||
Height = 0
|
||||
Top = 80
|
||||
Width = 128
|
||||
Width = 0
|
||||
BevelOuter = bvNone
|
||||
Color = clInactiveCaption
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
Visible = False
|
||||
end
|
||||
end
|
||||
object RgDrawingStyle: TRadioGroup
|
||||
@@ -393,6 +394,39 @@ object Form1: TForm1
|
||||
OnClick = RgBorderStyleClick
|
||||
TabOrder = 7
|
||||
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
|
||||
Height = 32
|
||||
Width = 32
|
||||
|
@@ -18,8 +18,11 @@ type
|
||||
BtnAddItem: TButton;
|
||||
BkColor: TColorBox;
|
||||
BtnLoadBkImage: TButton;
|
||||
CbPlaySounds: TCheckBox;
|
||||
EdBkImage: TFileNameEdit;
|
||||
EdSoundFile: TFileNameEdit;
|
||||
GroupBox1: TGroupBox;
|
||||
GroupBox2: TGroupBox;
|
||||
IconsLbl: TLabel;
|
||||
IconsLink: TLabel;
|
||||
Panel2: TPanel;
|
||||
@@ -39,6 +42,9 @@ type
|
||||
procedure BtnAddFolderClick(Sender: TObject);
|
||||
procedure BtnAddItemClick(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 IconsLinkClick(Sender: TObject);
|
||||
procedure IconsLinkMouseEnter(Sender: TObject);
|
||||
@@ -64,7 +70,8 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLIntf;
|
||||
LCLIntf,
|
||||
VpMisc;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
@@ -150,10 +157,25 @@ begin
|
||||
}
|
||||
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);
|
||||
begin
|
||||
RandSeed := 1;
|
||||
IconsLink.Left := IconsLbl.Left + IconsLbl.Width;
|
||||
IconsLink.Left := IconsLbl.Left + GetLabelWidth(IconsLbl);
|
||||
RgDrawingStyle.ItemIndex := ord(VpNavBar1.DrawingStyle);
|
||||
RgBorderStyle.ItemIndex := ord(VpNavBar1.BorderStyle);
|
||||
BkColor.Selected := VpNavBar1.BackgroundColor;
|
||||
@@ -178,6 +200,9 @@ begin
|
||||
end;
|
||||
BtnLoadBkImageClick(nil);
|
||||
|
||||
EdSoundFile.InitialDir := ExtractFileDir(VpNavBar1.SoundAlias);
|
||||
EdSoundFile.FileName := VpNavBar1.SoundAlias;
|
||||
CbPlaySounds.Checked := VpNavBar1.PlaySounds;
|
||||
end;
|
||||
|
||||
procedure TForm1.IconsLinkClick(Sender: TObject);
|
||||
|
@@ -218,6 +218,7 @@ type
|
||||
FOnFolderClick: TVpFolderClickEvent;
|
||||
FOnItemClick: TVpItemClickEvent;
|
||||
FOnMouseOverItem: TVpMouseOverItemEvent;
|
||||
FOnPlaySound: TVpPlaySoundEvent;
|
||||
|
||||
{internal variables}
|
||||
nabChanging: Boolean;
|
||||
@@ -358,6 +359,7 @@ type
|
||||
property OnFolderChange: TVpFolderChangeEvent read FOnFolderChange write FOnFolderChange;
|
||||
property OnFolderChanged: TVpFolderChangedEvent read FOnFolderChanged write FOnFolderChanged;
|
||||
property OnMouseOverItem: TVpMouseOverItemEvent read FOnMouseOverItem write FOnMouseOverItem;
|
||||
property OnPlaySound: TVpPlaySoundEvent read FOnPlaySound write FOnPlaySound;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@@ -382,6 +384,7 @@ type
|
||||
procedure InvalidateItem(FolderIndex, ItemIndex: Integer);
|
||||
procedure RemoveItem(AFolderIndex, AItemIndex: Integer);
|
||||
procedure RenameItem(AFolderIndex, AItemIndex: Integer);
|
||||
procedure PlaySound(const AWavFile: String; APlaySoundMode: TVpPlaySoundMode);
|
||||
property ActiveItem: Integer read FActiveItem;
|
||||
property Containers[Index: Integer]: TVpFolderContainer read GetContainer;
|
||||
property Folders[Index: Integer]: TVpNavFolder read GetFolder;
|
||||
@@ -461,6 +464,9 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF WINDOWS}
|
||||
mmSystem,
|
||||
{$ENDIF}
|
||||
Themes,
|
||||
VpNavBarPainter;
|
||||
|
||||
@@ -2693,13 +2699,28 @@ end;
|
||||
{$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);
|
||||
var
|
||||
Y: Integer;
|
||||
YDelta: Integer;
|
||||
R: TRect;
|
||||
R2: TRect;
|
||||
Buf: array[0..1023] of Char;
|
||||
AllowChange: Boolean;
|
||||
begin
|
||||
if Value <> FActiveFolder then begin
|
||||
@@ -2721,12 +2742,16 @@ begin
|
||||
{animated scroll}
|
||||
if FActiveFolder > -1 then begin
|
||||
{play sound}
|
||||
if FPlaySounds and (FSoundAlias <> '') and FileExists(FSoundAlias) then
|
||||
PlaySound(FSoundAlias, psmAsync);
|
||||
(*
|
||||
if FPlaySounds and (FSoundAlias > '') then begin
|
||||
StrPLCopy(Buf, FSoundAlias, SizeOf(Buf)-1);
|
||||
{$IFNDEF LCL}
|
||||
FPlaySounds := PlaySound(@Buf, 0, SND_ASYNC);
|
||||
{$ENDIF}
|
||||
end;
|
||||
*)
|
||||
|
||||
if Parent <> nil then begin
|
||||
{scroll selection}
|
||||
|
Reference in New Issue
Block a user