vfs: check userland buffers before reading them.
[haiku.git] / src / apps / mediaplayer / interface / TransportControlGroup.h
blobb2eb225eb16ffb096800dc52f12adbb45e0da981
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
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
14 #include <GroupView.h>
17 class BShape;
18 class DurationView;
19 class PeakView;
20 class PlayPauseButton;
21 class PositionToolTip;
22 class SeekSlider;
23 class SymbolButton;
24 class VolumeSlider;
26 enum {
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,
37 class TransportControlGroup : public BGroupView {
38 public:
39 TransportControlGroup(BRect frame,
40 bool useSkipButtons, bool usePeakView,
41 bool useWindButtons);
42 virtual ~TransportControlGroup();
44 // BView interface
45 virtual void AttachedToWindow();
46 virtual void GetPreferredSize(float* width, float* height);
47 virtual void MessageReceived(BMessage* message);
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);
61 void SetEnabled(uint32 whichButtons);
63 void SetPlaybackState(uint32 state);
64 void SetSkippable(bool backward, bool forward);
66 void SetAudioEnabled(bool enable);
67 void SetMuted(bool mute);
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;
75 PeakView* GetPeakView() const
76 { return fPeakView; }
78 void SetDisabledString(const char* string);
79 void SetSymbolScale(float scale);
81 private:
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();
92 float _LinearToExponential(float db);
93 float _ExponentialToLinear(float db);
94 float _DbToGain(float db);
95 float _GainToDb(float gain);
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;
106 private:
107 SeekSlider* fSeekSlider;
108 DurationView* fDurationView;
109 PositionToolTip* fPositionToolTip;
110 PeakView* fPeakView;
111 VolumeSlider* fVolumeSlider;
113 SymbolButton* fSkipBack;
114 SymbolButton* fSkipForward;
115 SymbolButton* fRewind;
116 SymbolButton* fForward;
117 PlayPauseButton* fPlayPause;
118 SymbolButton* fStop;
119 SymbolButton* fMute;
121 BGroupLayout* fSeekLayout;
122 BGroupLayout* fControlLayout;
124 float fSymbolScale;
125 uint32 fLastEnabledButtons;
128 #endif // TRANSPORT_CONTROL_GROUP_H