1/*
2 * Copyright 2006-2010 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5#ifndef TRANSPORT_CONTROL_GROUP_H
6#define TRANSPORT_CONTROL_GROUP_H
7
8
9// NOTE: Based on my code in the BeOS interface for the VLC media player
10// that I did during the VLC 0.4.3 - 0.4.6 times. Code not written by me
11// removed. -Stephan Aßmus
12
13
14#include <GroupView.h>
15
16
17class BShape;
18class DurationView;
19class PeakView;
20class PlayPauseButton;
21class PositionToolTip;
22class SeekSlider;
23class SymbolButton;
24class VolumeSlider;
25
26enum {
27	SKIP_BACK_ENABLED		= 1 << 0,
28	SEEK_BACK_ENABLED		= 1 << 1,
29	PLAYBACK_ENABLED		= 1 << 2,
30	SEEK_FORWARD_ENABLED	= 1 << 3,
31	SKIP_FORWARD_ENABLED	= 1 << 4,
32	VOLUME_ENABLED			= 1 << 5,
33	SEEK_ENABLED			= 1 << 6,
34};
35
36
37class TransportControlGroup : public BGroupView {
38public:
39								TransportControlGroup(BRect frame,
40									bool useSkipButtons, bool usePeakView,
41									bool useWindButtons);
42	virtual						~TransportControlGroup();
43
44	// BView interface
45	virtual	void				AttachedToWindow();
46	virtual	void				GetPreferredSize(float* width, float* height);
47	virtual	void				MessageReceived(BMessage* message);
48
49	// TransportControlGroup
50	virtual	uint32				EnabledButtons();
51	virtual	void				TogglePlaying();
52	virtual	void				Stop();
53	virtual	void				Rewind();
54	virtual	void				Forward();
55	virtual	void				SkipBackward();
56	virtual	void				SkipForward();
57	virtual	void				VolumeChanged(float value);
58	virtual	void				ToggleMute();
59	virtual	void				PositionChanged(float value);
60
61			void				SetEnabled(uint32 whichButtons);
62
63			void				SetPlaybackState(uint32 state);
64			void				SetSkippable(bool backward, bool forward);
65
66			void				SetAudioEnabled(bool enable);
67			void				SetMuted(bool mute);
68
69			void				SetVolume(float value);
70			void				SetAudioChannelCount(int32 count);
71			void				SetPosition(float value, bigtime_t position,
72									bigtime_t duration);
73			float				Position() const;
74
75			PeakView*			GetPeakView() const
76									{ return fPeakView; }
77
78			void				SetDisabledString(const char* string);
79			void				SetSymbolScale(float scale);
80
81private:
82			void				_TogglePlaying();
83			void				_Stop();
84			void				_Rewind();
85			void				_Forward();
86			void				_SkipBackward();
87			void				_SkipForward();
88			void				_UpdateVolume();
89			void				_ToggleMute();
90			void				_UpdatePosition();
91
92			float				_LinearToExponential(float db);
93			float				_ExponentialToLinear(float db);
94			float				_DbToGain(float db);
95			float				_GainToDb(float gain);
96
97			BShape*				_CreateSkipBackwardsShape(float height) const;
98			BShape*				_CreateSkipForwardShape(float height) const;
99			BShape*				_CreateRewindShape(float height) const;
100			BShape*				_CreateForwardShape(float height) const;
101			BShape*				_CreatePlayShape(float height) const;
102			BShape*				_CreatePauseShape(float height) const;
103			BShape*				_CreateStopShape(float height) const;
104			BShape*				_CreateSpeakerShape(float height) const;
105
106private:
107			SeekSlider*			fSeekSlider;
108			DurationView*		fDurationView;
109			PositionToolTip*	fPositionToolTip;
110			PeakView*			fPeakView;
111			VolumeSlider*		fVolumeSlider;
112
113			SymbolButton*		fSkipBack;
114			SymbolButton*		fSkipForward;
115			SymbolButton*		fRewind;
116			SymbolButton*		fForward;
117			PlayPauseButton*	fPlayPause;
118			SymbolButton*		fStop;
119			SymbolButton*		fMute;
120
121			BGroupLayout*		fSeekLayout;
122			BGroupLayout*		fControlLayout;
123
124			float				fSymbolScale;
125			uint32				fLastEnabledButtons;
126};
127
128#endif	// TRANSPORT_CONTROL_GROUP_H
129