]> git.sesse.net Git - vlc/blob - modules/gui/beos/MediaControlView.h
- Added LCD info view from 0.4.x
[vlc] / 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.3 2002/10/28 19:42:24 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(uint64 seek, uint64 size);
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                         
90                         intf_thread_t *     p_intf;
91 };
92
93 class SeekSlider : public BControl
94 {
95  public:
96                                                                 SeekSlider(BRect frame,
97                                                                                    const char* name,
98                                                                                    MediaControlView* owner,
99                                                                                    int32 minValue,
100                                                                                    int32 maxValue);
101
102         virtual                                         ~SeekSlider();
103
104                                                                 // BControl
105         virtual void                            AttachedToWindow();
106         virtual void                            Draw(BRect updateRect);
107         virtual void                            MouseDown(BPoint where);
108         virtual void                            MouseMoved(BPoint where, uint32 transit,
109                                                                                    const BMessage* dragMessage);
110         virtual void                            MouseUp(BPoint where);
111         virtual void                            ResizeToPreferred();
112
113                                                                 // SeekSlider
114                         void                            SetPosition(float position);
115
116 private:
117                         int32                           _ValueFor(float x) const;
118                         void                            _StrokeFrame(BRect frame,
119                                                                                          rgb_color left,
120                                                                                          rgb_color top,
121                                                                                          rgb_color right,
122                                                                                          rgb_color bottom);
123                         void                            _BeginSeek();
124                         void                            _Seek();
125                         void                            _EndSeek();
126
127                         MediaControlView*       fOwner; 
128                         bool                            fTracking;
129                         int32                           fMinValue;
130                         int32                           fMaxValue;
131 };
132
133 class VolumeSlider : public BControl
134 {
135  public:
136                                                                 VolumeSlider(BRect frame,
137                                                                                          const char* name,
138                                                                                          int32 minValue,
139                                                                                          int32 maxValue,
140                                                                                          BMessage* message = NULL,
141                                                                                          BHandler* target = NULL);
142
143         virtual                                         ~VolumeSlider();
144
145                                                                 // BControl
146         virtual void                            AttachedToWindow();
147         virtual void                            SetValue(int32 value);
148         virtual void                            SetEnabled(bool enable);
149         virtual void                            Draw(BRect updateRect);
150         virtual void                            MouseDown(BPoint where);
151         virtual void                            MouseMoved(BPoint where, uint32 transit,
152                                                                                    const BMessage* dragMessage);
153         virtual void                            MouseUp(BPoint where);
154
155                                                                 // VolumeSlider
156                         bool                            IsValid() const;
157                         void                            SetMuted(bool mute);
158
159  private:
160                         void                            _MakeBitmaps();
161                         void                            _DimBitmap(BBitmap* bitmap);
162                         int32                           _ValueFor(float xPos) const;
163
164                         BBitmap*                        fLeftSideBits;
165                         BBitmap*                        fRightSideBits;
166                         BBitmap*                        fKnobBits;
167                         bool                            fTracking;
168                         bool                            fMuted;
169                         int32                           fMinValue;
170                         int32                           fMaxValue;
171 };
172
173 class PositionInfoView : public BView
174 {
175  public:
176                                                                 PositionInfoView( BRect frame,
177                                                                                                   const char* name,
178                                                                                                   intf_thread_t *p_intf );
179         virtual                                         ~PositionInfoView();
180
181                                                                 // BView
182         virtual void                            Draw( BRect updateRect );
183         virtual void                            ResizeToPreferred();
184         virtual void                            GetPreferredSize( float* width,
185                                                                                                   float* height );
186         virtual void                            Pulse();
187
188                                                                 // PositionInfoView
189         enum
190         {
191                 MODE_SMALL,
192                 MODE_BIG,
193         };
194
195                         void                            SetMode( uint32 mode );
196                         void                            GetBigPreferredSize( float* width,
197                                                                                                          float* height );
198
199                         void                            SetFile( int32 index, int32 size );
200                         void                            SetTitle( int32 index, int32 size );
201                         void                            SetChapter( int32 index, int32 size );
202                         void                            SetTime( int32 seconds );
203                         void                            SetTime( const char* string );
204  private:
205                         void                            _InvalidateContents( uint32 which = 0 );
206                         void                            _MakeString( BString& into,
207                                                                                          int32 index,
208                                                                                          int32 maxIndex ) const;
209 //                      void                            _DrawAlignedString( const char* string,
210 //                                                                                                      BRect frame,
211 //                                                                                                      alignment mode = B_ALIGN_LEFT );
212
213                         uint32                          fMode;
214                         int32                           fCurrentFileIndex;
215                         int32                           fCurrentFileSize;
216                         int32                           fCurrentTitleIndex;
217                         int32                           fCurrentTitleSize;
218                         int32                           fCurrentChapterIndex;
219                         int32                           fCurrentChapterSize;
220
221                         int32                           fSeconds;
222                         BString                         fTimeString;
223                         bigtime_t                       fLastPulseUpdate;
224                         float                           fStackedWidthCache;
225                         float                           fStackedHeightCache;
226                         
227                         intf_thread_t *     p_intf;
228                         
229 };
230
231 #endif  // BEOS_MEDIA_CONTROL_VIEW_H