]> git.sesse.net Git - vlc/blob - modules/gui/beos/VideoWindow.h
Attempt to port new BeOS features from the stable branch.
[vlc] / modules / gui / beos / VideoWindow.h
1 /*****************************************************************************
2  * VideoWindow.h: BeOS video window class prototype
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 VideoLAN
5  * $Id: VideoWindow.h,v 1.2 2002/09/30 18:30:27 titer Exp $
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., 59 Temple Place - Suite 330, Boston, MA  02111, 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         u32 chroma;
42         int planes;
43         int pixel_bytes;
44 } colorcombo;
45
46 colorcombo colspace[]=
47 {
48         {B_YCbCr420, "B_YCbCr420", VLC_FOURCC('I','4','2','0'), 3, 2},
49         {B_YUV422,   "B_YUV422",   VLC_FOURCC('Y','4','2','2'), 3, 2},
50         {B_YCbCr422, "B_YCbCr422", VLC_FOURCC('Y','U','Y','2'), 3, 2},
51         {B_RGB32,    "B_RGB32",    VLC_FOURCC('R','V','3','2'), 1, 4},
52         {B_RGB16,    "B_RGB16",    VLC_FOURCC('R','V','1','6'), 1, 2}
53 };
54
55 #define COLOR_COUNT 5
56 #define DEFAULT_COL 4
57
58
59 class VLCView : public BView
60 {
61  public:
62                                                         VLCView( BRect bounds);
63         virtual                                 ~VLCView();
64
65         virtual void                    AttachedToWindow();
66         virtual void                    MouseDown(BPoint where);
67         virtual void                    MouseMoved(BPoint where, uint32 transit,
68                                                                            const BMessage* dragMessage);
69         virtual void                    Pulse();
70         virtual void                    Draw(BRect updateRect);
71         virtual void                    KeyDown(const char* bytes, int32 numBytes);
72
73  private:
74                         bigtime_t               fLastMouseMovedTime;
75                         bool                    fCursorHidden;
76                         bool                    fCursorInside;
77                         bool                    fIgnoreDoubleClick;
78 };
79
80
81 class VideoWindow : public BWindow
82 {
83 public:
84                                                         VideoWindow(int v_width, 
85                                                                                 int v_height,
86                                                                                 BRect frame); 
87         virtual                                 ~VideoWindow();
88
89                                                         // BWindow    
90         virtual void                    MessageReceived(BMessage* message);
91         virtual void                    Zoom(BPoint origin,
92                                                                  float width, float height);
93         virtual void                    FrameResized(float width, float height);
94         virtual void                    FrameMoved(BPoint origin);
95         virtual void                    ScreenChanged(BRect frame,
96                                                                                   color_space mode);
97         virtual void                    WindowActivated(bool active);
98
99                                                         // VideoWindow
100                         void                    drawBuffer(int bufferIndex);
101
102                         void                    ToggleInterfaceShowing();
103                         void                    SetInterfaceShowing(bool showIt);
104
105                         void                    SetCorrectAspectRatio(bool doIt);
106         inline  bool                    CorrectAspectRatio() const
107                                                                 { return fCorrectAspect; }
108         inline  status_t                InitCheck() const
109                                                                 { return fInitStatus; }
110
111
112     // this is the hook controling direct screen connection
113     int32           i_width;     // aspect corrected bitmap size 
114     int32           i_height;
115     BRect           winSize;     // current window size
116     bool            is_zoomed, vsync;
117     BBitmap             *bitmap[3];
118     BBitmap         *overlaybitmap;
119     VLCView             *view;
120     int             i_buffer;
121         volatile bool   teardownwindow;
122     thread_id       fDrawThreadID;
123     int             mode;
124     int             colspace_index;
125
126 private:
127                         status_t                _AllocateBuffers(int width,
128                                                                                          int height,
129                                                                                          int* mode);
130                         void                    _FreeBuffers();
131                         void                    _BlankBitmap(BBitmap* bitmap) const;
132                         void                    _SetVideoSize(uint32 mode);
133
134                         void                    _SaveScreenShot( BBitmap* bitmap,
135                                                                                          char* path,
136                                                                                          uint32 translatorID ) const;
137         static  int32                   _save_screen_shot( void* cookie );
138
139         struct screen_shot_info
140         {
141                 BBitmap*        bitmap;
142                 char*           path;
143                 uint32          translatorID;
144                 int32           width;
145                 int32           height;
146         };
147
148     struct vout_thread_s   *p_vout;
149
150                         int32                   fTrueWidth;     // incomming bitmap size 
151                         int32                   fTrueHeight;
152                         bool                    fCorrectAspect;
153                         window_feel             fCachedFeel;
154                         bool                    fInterfaceShowing;
155                         status_t                fInitStatus;
156 };
157
158 #endif  // BEOS_VIDEO_WINDOW_H
159