]> git.sesse.net Git - vlc/blob - modules/gui/beos/VideoWindow.h
* added mouse management in the BeOS video output.
[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.4 2002/12/03 02:00:38 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, vout_thread_t *p_vout );
63         virtual                                 ~VLCView();
64
65         virtual void                    AttachedToWindow();
66         virtual void                    MouseDown(BPoint where);
67         virtual void                    MouseUp(BPoint where);
68         virtual void                    MouseMoved(BPoint where, uint32 transit,
69                                                                            const BMessage* dragMessage);
70         virtual void                    Pulse();
71         virtual void                    Draw(BRect updateRect);
72         virtual void                    KeyDown(const char* bytes, int32 numBytes);
73
74  private:
75             vout_thread_t   *p_vout;
76             
77                         bigtime_t               fLastMouseMovedTime;
78                         bool                    fCursorHidden;
79                         bool                    fCursorInside;
80                         bool                    fIgnoreDoubleClick;
81 };
82
83
84 class VideoWindow : public BWindow
85 {
86 public:
87                                                         VideoWindow(int v_width, 
88                                                                                 int v_height,
89                                                                                 BRect frame,
90                                                                                 vout_thread_t *p_vout); 
91         virtual                                 ~VideoWindow();
92
93                                                         // BWindow    
94         virtual void                    MessageReceived(BMessage* message);
95         virtual void                    Zoom(BPoint origin,
96                                                                  float width, float height);
97         virtual void                    FrameResized(float width, float height);
98         virtual void                    FrameMoved(BPoint origin);
99         virtual void                    ScreenChanged(BRect frame,
100                                                                                   color_space mode);
101         virtual void                    WindowActivated(bool active);
102
103                                                         // VideoWindow
104                         void                    drawBuffer(int bufferIndex);
105
106                         void                    ToggleInterfaceShowing();
107                         void                    SetInterfaceShowing(bool showIt);
108
109                         void                    SetCorrectAspectRatio(bool doIt);
110         inline  bool                    CorrectAspectRatio() const
111                                                                 { return fCorrectAspect; }
112         inline  status_t                InitCheck() const
113                                                                 { return fInitStatus; }
114
115
116     // this is the hook controling direct screen connection
117     int32           i_width;     // aspect corrected bitmap size 
118     int32           i_height;
119     BRect           winSize;     // current window size
120     bool            is_zoomed, vsync;
121     BBitmap             *bitmap[3];
122     BBitmap         *overlaybitmap;
123     VLCView             *view;
124     int             i_buffer;
125         volatile bool   teardownwindow;
126     thread_id       fDrawThreadID;
127     int             mode;
128     int             colspace_index;
129
130 private:
131                         status_t                _AllocateBuffers(int width,
132                                                                                          int height,
133                                                                                          int* mode);
134                         void                    _FreeBuffers();
135                         void                    _BlankBitmap(BBitmap* bitmap) const;
136                         void                    _SetVideoSize(uint32 mode);
137
138                         void                    _SaveScreenShot( BBitmap* bitmap,
139                                                                                          char* path,
140                                                                                          uint32 translatorID ) const;
141         static  int32                   _save_screen_shot( void* cookie );
142
143         struct screen_shot_info
144         {
145                 BBitmap*        bitmap;
146                 char*           path;
147                 uint32          translatorID;
148                 int32           width;
149                 int32           height;
150         };
151
152     vout_thread_t   *p_vout;
153
154         int32                   fTrueWidth;     // incomming bitmap size 
155         int32                   fTrueHeight;
156         bool                    fCorrectAspect;
157         window_feel             fCachedFeel;
158         bool                    fInterfaceShowing;
159         status_t                fInitStatus;
160 };
161
162 #endif  // BEOS_VIDEO_WINDOW_H
163