86b0dd42eed68a599b033536c1d1b89a3ae50e1b
[vlc.git] / modules / gui / beos / MediaControlView.h
1 /*****************************************************************************
2  * MediaControlView.h: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 VideoLAN
5  * $Id: MediaControlView.h,v 1.2 2002/09/30 18:30:27 titer Exp $
6  *
7  * Authors: Tony Castley <tony@castley.net>
8  *          Stephan Aßmus <stippi@yellowbites.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef BEOS_MEDIA_CONTROL_VIEW_H
26 #define BEOS_MEDIA_CONTROL_VIEW_H
27
28 #include <Box.h>
29 #include <Control.h>
30
31 class BBitmap;
32 class PlayPauseButton;
33 class SeekSlider;
34 class TransportButton;
35 class VolumeSlider;
36
37 class MediaControlView : public BBox
38 {
39  public:
40                                                                 MediaControlView( BRect frame );
41         virtual                                         ~MediaControlView();
42
43                                                                 // BBox
44         virtual void                            AttachedToWindow();
45         virtual void                            FrameResized(float width, float height);
46         virtual void                            GetPreferredSize(float* width, float* height);
47         virtual void                            MessageReceived(BMessage* message);
48         virtual void                            Pulse(); // detect stopped stream
49
50                                                                 // MediaControlView
51                         void                            SetProgress(uint64 seek, uint64 size);
52
53                         void                            SetStatus(int status, int rate); 
54                         void                            SetEnabled(bool enable);
55                         void                            SetAudioEnabled(bool enable);
56                         uint32                          GetSeekTo() const;
57                         uint32                          GetVolume() const;
58                         void                            SetSkippable(bool backward,
59                                                                                          bool forward);
60                         void                            SetMuted(bool mute);
61
62                         sem_id                          fScrubSem;
63     
64  private:
65                         void                            _LayoutControls(BRect frame) const;
66                         BRect                           _MinFrame() const;
67                         void                            _LayoutControl(BView* view,
68                                                                                            BRect frame,
69                                                                                            bool resize = false) const;
70
71
72                         VolumeSlider*           fVolumeSlider;
73                         SeekSlider*                     fSeekSlider;
74                         TransportButton*        fSkipBack;
75                         TransportButton*        fSkipForward;
76                         TransportButton*        fRewind;
77                         TransportButton*        fForward;
78                         PlayPauseButton*        fPlayPause;
79                         TransportButton*        fStop;
80                         TransportButton*        fMute;
81
82                         int                                     fCurrentRate;
83                         int                                     fCurrentStatus;
84                         float                           fBottomControlHeight;
85                         BRect                           fOldBounds;
86 };
87
88 class SeekSlider : public BControl
89 {
90  public:
91                                                                 SeekSlider(BRect frame,
92                                                                                    const char* name,
93                                                                                    MediaControlView* owner,
94                                                                                    int32 minValue,
95                                                                                    int32 maxValue);
96
97         virtual                                         ~SeekSlider();
98
99                                                                 // BControl
100         virtual void                            AttachedToWindow();
101         virtual void                            Draw(BRect updateRect);
102         virtual void                            MouseDown(BPoint where);
103         virtual void                            MouseMoved(BPoint where, uint32 transit,
104                                                                                    const BMessage* dragMessage);
105         virtual void                            MouseUp(BPoint where);
106         virtual void                            ResizeToPreferred();
107
108                                                                 // SeekSlider
109                         void                            SetPosition(float position);
110
111 private:
112                         int32                           _ValueFor(float x) const;
113                         void                            _StrokeFrame(BRect frame,
114                                                                                          rgb_color left,
115                                                                                          rgb_color top,
116                                                                                          rgb_color right,
117                                                                                          rgb_color bottom);
118                         void                            _BeginSeek();
119                         void                            _Seek();
120                         void                            _EndSeek();
121
122                         MediaControlView*       fOwner; 
123                         bool                            fTracking;
124                         int32                           fMinValue;
125                         int32                           fMaxValue;
126 };
127
128 class VolumeSlider : public BControl
129 {
130  public:
131                                                                 VolumeSlider(BRect frame,
132                                                                                          const char* name,
133                                                                                          int32 minValue,
134                                                                                          int32 maxValue,
135                                                                                          BMessage* message = NULL,
136                                                                                          BHandler* target = NULL);
137
138         virtual                                         ~VolumeSlider();
139
140                                                                 // BControl
141         virtual void                            AttachedToWindow();
142         virtual void                            SetValue(int32 value);
143         virtual void                            SetEnabled(bool enable);
144         virtual void                            Draw(BRect updateRect);
145         virtual void                            MouseDown(BPoint where);
146         virtual void                            MouseMoved(BPoint where, uint32 transit,
147                                                                                    const BMessage* dragMessage);
148         virtual void                            MouseUp(BPoint where);
149
150                                                                 // VolumeSlider
151                         bool                            IsValid() const;
152                         void                            SetMuted(bool mute);
153
154  private:
155                         void                            _MakeBitmaps();
156                         void                            _DimBitmap(BBitmap* bitmap);
157                         int32                           _ValueFor(float xPos) const;
158
159                         BBitmap*                        fLeftSideBits;
160                         BBitmap*                        fRightSideBits;
161                         BBitmap*                        fKnobBits;
162                         bool                            fTracking;
163                         bool                            fMuted;
164                         int32                           fMinValue;
165                         int32                           fMaxValue;
166 };
167
168 #endif  // BEOS_MEDIA_CONTROL_VIEW_H