* store windows sizes in the vlc configuration file
[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.5 2003/01/25 01:03:44 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 PositionInfoView;
34 class SeekSlider;
35 class TransportButton;
36 class VolumeSlider;
37
38 class MediaControlView : public BBox
39 {
40  public:
41                                                                 MediaControlView( BRect frame, intf_thread_t *p_intf );
42         virtual                                         ~MediaControlView();
43
44                                                                 // BBox
45         virtual void                            AttachedToWindow();
46         virtual void                            FrameResized(float width, float height);
47         virtual void                            GetPreferredSize(float* width, float* height);
48         virtual void                            MessageReceived(BMessage* message);
49         virtual void                            Pulse(); // detect stopped stream
50
51                                                                 // MediaControlView
52                         void                            SetProgress( float position );
53
54                         void                            SetStatus(int status, int rate); 
55                         void                            SetEnabled(bool enable);
56                         void                            SetAudioEnabled(bool enable);
57                         uint32                          GetSeekTo() const;
58                         uint32                          GetVolume() const;
59                         void                            SetSkippable(bool backward,
60                                                                                          bool forward);
61                         void                            SetMuted(bool mute);
62
63                         sem_id                          fScrubSem;
64     
65  private:
66                         void                            _LayoutControls(BRect frame) const;
67                         BRect                           _MinFrame() const;
68                         void                            _LayoutControl(BView* view,
69                                                                                            BRect frame,
70                                                                                            bool resizeWidth = false,
71                                                                                            bool resizeHeight = false) const;
72
73
74                         VolumeSlider*           fVolumeSlider;
75                         SeekSlider*                     fSeekSlider;
76                         TransportButton*        fSkipBack;
77                         TransportButton*        fSkipForward;
78                         TransportButton*        fRewind;
79                         TransportButton*        fForward;
80                         PlayPauseButton*        fPlayPause;
81                         TransportButton*        fStop;
82                         TransportButton*        fMute;
83                         PositionInfoView*   fPositionInfo;
84
85                         int                                     fCurrentRate;
86                         int                                     fCurrentStatus;
87                         float                           fBottomControlHeight;
88                         BRect                           fOldBounds;
89                         bool                fIsEnabled;
90                         
91                         intf_thread_t *     p_intf;
92 };
93
94 class SeekSlider : public BControl
95 {
96  public:
97                                                                 SeekSlider(BRect frame,
98                                                                                    const char* name,
99                                                                                    MediaControlView* owner,
100                                                                                    int32 minValue,
101                                                                                    int32 maxValue);
102
103         virtual                                         ~SeekSlider();
104
105                                                                 // BControl
106         virtual void                            AttachedToWindow();
107         virtual void                            Draw(BRect updateRect);
108         virtual void                            MouseDown(BPoint where);
109         virtual void                            MouseMoved(BPoint where, uint32 transit,
110                                                                                    const BMessage* dragMessage);
111         virtual void                            MouseUp(BPoint where);
112         virtual void                            ResizeToPreferred();
113
114                                                                 // SeekSlider
115                         void                            SetPosition(float position);
116
117 private:
118                         int32                           _ValueFor(float x) const;
119                         void                            _StrokeFrame(BRect frame,
120                                                                                          rgb_color left,
121                                                                                          rgb_color top,
122                                                                                          rgb_color right,
123                                                                                          rgb_color bottom);
124                         void                            _BeginSeek();
125                         void                            _Seek();
126                         void                            _EndSeek();
127
128                         MediaControlView*       fOwner; 
129                         bool                            fTracking;
130                         int32                           fMinValue;
131                         int32                           fMaxValue;
132 };
133
134 class VolumeSlider : public BControl
135 {
136  public:
137                                                                 VolumeSlider(BRect frame,
138                                                                                          const char* name,
139                                                                                          int32 minValue,
140                                                                                          int32 maxValue,
141                                                                                          BMessage* message = NULL,
142                                                                                          BHandler* target = NULL);
143
144         virtual                                         ~VolumeSlider();
145
146                                                                 // BControl
147         virtual void                            AttachedToWindow();
148         virtual void                            SetValue(int32 value);
149         virtual void                            SetEnabled(bool enable);
150         virtual void                            Draw(BRect updateRect);
151         virtual void                            MouseDown(BPoint where);
152         virtual void                            MouseMoved(BPoint where, uint32 transit,
153                                                                                    const BMessage* dragMessage);
154         virtual void                            MouseUp(BPoint where);
155
156                                                                 // VolumeSlider
157                         bool                            IsValid() const;
158                         void                            SetMuted(bool mute);
159
160  private:
161                         void                            _MakeBitmaps();
162                         void                            _DimBitmap(BBitmap* bitmap);
163                         int32                           _ValueFor(float xPos) const;
164
165                         BBitmap*                        fLeftSideBits;
166                         BBitmap*                        fRightSideBits;
167                         BBitmap*                        fKnobBits;
168                         bool                            fTracking;
169                         bool                            fMuted;
170                         int32                           fMinValue;
171                         int32                           fMaxValue;
172 };
173
174 class PositionInfoView : public BView
175 {
176  public:
177                                                                 PositionInfoView( BRect frame,
178                                                                                                   const char* name,
179                                                                                                   intf_thread_t *p_intf );
180         virtual                                         ~PositionInfoView();
181
182                                                                 // BView
183         virtual void                            Draw( BRect updateRect );
184         virtual void                            ResizeToPreferred();
185         virtual void                            GetPreferredSize( float* width,
186                                                                                                   float* height );
187         virtual void                            Pulse();
188
189                                                                 // PositionInfoView
190         enum
191         {
192                 MODE_SMALL,
193                 MODE_BIG,
194         };
195
196                         void                            SetMode( uint32 mode );
197                         void                            GetBigPreferredSize( float* width,
198                                                                                                          float* height );
199
200                         void                            SetFile( int32 index, int32 size );
201                         void                            SetTitle( int32 index, int32 size );
202                         void                            SetChapter( int32 index, int32 size );
203                         void                            SetTime( int32 seconds );
204                         void                            SetTime( const char* string );
205  private:
206                         void                            _InvalidateContents( uint32 which = 0 );
207                         void                            _MakeString( BString& into,
208                                                                                          int32 index,
209                                                                                          int32 maxIndex ) const;
210 //                      void                            _DrawAlignedString( const char* string,
211 //                                                                                                      BRect frame,
212 //                                                                                                      alignment mode = B_ALIGN_LEFT );
213
214                         uint32                          fMode;
215                         int32                           fCurrentFileIndex;
216                         int32                           fCurrentFileSize;
217                         int32                           fCurrentTitleIndex;
218                         int32                           fCurrentTitleSize;
219                         int32                           fCurrentChapterIndex;
220                         int32                           fCurrentChapterSize;
221
222                         int32                           fSeconds;
223                         BString                         fTimeString;
224                         bigtime_t                       fLastPulseUpdate;
225                         float                           fStackedWidthCache;
226                         float                           fStackedHeightCache;
227                         
228                         intf_thread_t *     p_intf;
229                         
230 };
231
232 #endif  // BEOS_MEDIA_CONTROL_VIEW_H