]> git.sesse.net Git - vlc/blob - modules/gui/beos/VideoWindow.h
Merge branch 1.0-bugfix
[vlc] / modules / gui / beos / VideoWindow.h
1 /*****************************************************************************
2  * VideoWindow.h: BeOS video window class prototype
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8  *          Tony Castley <tcastley@mail.powerup.com.au>
9  *          Richard Shepherd <richard@rshepherd.demon.co.uk>
10  *          Stephan Aßmus <stippi@yellowbites.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifndef BEOS_VIDEO_WINDOW_H
28 #define BEOS_VIDEO_WINDOW_H
29
30 #include <View.h>
31 #include <Window.h>
32
33 #define BITMAP  0
34 #define OVERLAY 1
35 #define OPENGL  2
36
37 typedef struct colorcombo
38 {
39     color_space colspace;
40     const char *name;
41     uint32_t chroma;
42     int planes;
43     int pixel_bytes;
44 } colorcombo;
45
46 colorcombo colspace[]=
47 {
48     {B_YCbCr420, "B_YCbCr420", VLC_CODEC_I420, 3, 2},
49     {B_YUV422,   "B_YUV422",   VLC_FOURCC('Y','4','2','2'), 3, 2},
50     {B_YCbCr422, "B_YCbCr422", VLC_CODEC_YUYV, 3, 2},
51     {B_RGB32,    "B_RGB32",    VLC_CODEC_RGB32, 1, 4},
52     {B_RGB16,    "B_RGB16",    VLC_CODEC_RGB16, 1, 2}
53 };
54
55 #define COLOR_COUNT 5
56 #define DEFAULT_COL 3
57
58 class VideoSettings
59 {
60  public:
61                             VideoSettings( const VideoSettings& clone );
62     virtual                    ~VideoSettings();
63
64     static    VideoSettings*    DefaultSettings();
65
66     enum
67     {
68         SIZE_OTHER            = 0,
69         SIZE_50                = 1,
70         SIZE_100            = 2,
71         SIZE_200            = 3,
72     };
73
74             void            SetVideoSize( uint32_t mode );
75     inline    uint32_t            VideoSize() const
76                                 { return fVideoSize; }
77     enum
78     {
79         FLAG_CORRECT_RATIO    = 0x0001,
80         FLAG_SYNC_RETRACE    = 0x0002,
81         FLAG_ON_TOP_ALL        = 0x0004,
82         FLAG_FULL_SCREEN    = 0x0008,
83     };
84
85     inline    void            SetFlags( uint32_t flags )
86                                 { fFlags = flags; }
87     inline    void            AddFlags( uint32_t flags )
88                                 { fFlags |= flags; }
89     inline    void            ClearFlags( uint32_t flags )
90                                 { fFlags &= ~flags; }
91     inline    bool            HasFlags( uint32_t flags ) const
92                                 { return fFlags & flags; }
93     inline    uint32_t            Flags() const
94                                 { return fFlags; }
95
96  private:
97                             VideoSettings(); // reserved for default settings
98
99     static    VideoSettings    fDefaultSettings;
100
101             uint32_t            fVideoSize;
102             uint32_t            fFlags;
103             BMessage*        fSettings;
104 };
105
106
107 class VLCView : public BView
108 {
109  public:
110                             VLCView( BRect bounds, vout_thread_t *p_vout );
111     virtual                    ~VLCView();
112
113     virtual    void            AttachedToWindow();
114     virtual    void            MouseDown(BPoint where);
115     virtual    void            MouseUp(BPoint where);
116     virtual    void            MouseMoved(BPoint where, uint32 transit,
117                                        const BMessage* dragMessage);
118     virtual    void            Pulse();
119     virtual    void            Draw(BRect updateRect);
120
121  private:
122             vout_thread_t   *p_vout;
123
124             bigtime_t        fLastMouseMovedTime;
125             int             fMouseHideTimeout;
126             bool            fCursorHidden;
127             bool            fCursorInside;
128             bool            fIgnoreDoubleClick;
129 };
130
131
132 class VideoWindow : public BWindow
133 {
134 public:
135                             VideoWindow(int v_width,
136                                         int v_height,
137                                         BRect frame,
138                                         vout_thread_t *p_vout);
139     virtual                    ~VideoWindow();
140
141                             // BWindow
142     virtual    void            MessageReceived(BMessage* message);
143     virtual    void            Zoom(BPoint origin,
144                                  float width, float height);
145     virtual    void            FrameResized(float width, float height);
146     virtual    void            FrameMoved(BPoint origin);
147     virtual    void            ScreenChanged(BRect frame,
148                                           color_space mode);
149     virtual    void            WindowActivated(bool active);
150
151                             // VideoWindow
152             void            drawBuffer(int bufferIndex);
153
154             void            ToggleInterfaceShowing();
155             void            SetInterfaceShowing(bool showIt);
156
157             void            SetCorrectAspectRatio(bool doIt);
158             bool            CorrectAspectRatio() const;
159             void            ToggleFullScreen();
160             void            SetFullScreen(bool doIt);
161             bool            IsFullScreen() const;
162             void            SetOnTop(bool doIt);
163             bool            IsOnTop() const;
164             void            SetSyncToRetrace(bool doIt);
165             bool            IsSyncedToRetrace() const;
166     inline    status_t        InitCheck() const
167                                 { return fInitStatus; }
168
169
170     // this is the hook controling direct screen connection
171     int32_t         i_width;     // aspect corrected bitmap size
172     int32_t         i_height;
173     BRect           winSize;     // current window size
174     BBitmap            *bitmap[3];
175 //    BBitmap         *overlaybitmap;
176     VLCView            *view;
177     int             i_buffer;
178     volatile bool    teardownwindow;
179     thread_id       fDrawThreadID;
180     int             mode;
181     int             bitmap_count;
182     int             colspace_index;
183
184 private:
185             status_t        _AllocateBuffers(int width,
186                                              int height,
187                                              int* mode);
188             void            _FreeBuffers();
189             void            _BlankBitmap(BBitmap* bitmap) const;
190             void            _SetVideoSize(uint32_t mode);
191             void            _SetToSettings();
192
193     vout_thread_t   *p_vout;
194
195     int32_t            fTrueWidth;     // incomming bitmap size
196     int32_t            fTrueHeight;
197     window_feel        fCachedFeel;
198     bool            fInterfaceShowing;
199     status_t        fInitStatus;
200     VideoSettings*    fSettings;
201 };
202
203 #endif    // BEOS_VIDEO_WINDOW_H
204