source: smplayer/trunk/src/mplayerwindow.h@ 135

Last change on this file since 135 was 135, checked in by Silvan Scherrer, 13 years ago

SMplayer: update trunk to 0.8.1

  • Property svn:eol-style set to LF
File size: 5.5 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2012 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19
20#ifndef MPLAYERWINDOW_H
21#define MPLAYERWINDOW_H
22
23#include <QWidget>
24#include <QSize>
25#include <QPoint>
26
27#include <QResizeEvent>
28#include <QWheelEvent>
29#include <QMouseEvent>
30#include <QKeyEvent>
31#include <QPaintEvent>
32
33#include "config.h"
34
35class QWidget;
36class QLabel;
37class QKeyEvent;
38class QTimer;
39
40#define ZOOM_STEP 0.05
41#define ZOOM_MIN 0.5
42
43#define DELAYED_RESIZE 0
44#define NEW_MOUSE_CHECK_POS 1
45
46//! Screen is a widget that hides the mouse cursor after some seconds if not moved.
47
48class Screen : public QWidget
49{
50 Q_OBJECT
51
52public:
53 Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
54 ~Screen();
55
56#if NEW_MOUSE_CHECK_POS
57 void setAutoHideCursor(bool b);
58 bool autoHideCursor() { return autohide_cursor; };
59
60 void setAutoHideInterval(int milliseconds) { autohide_interval = milliseconds; };
61 int autoHideInterval() { return autohide_interval; };
62#endif
63
64public slots:
65 //! Should be called when a file has started.
66 virtual void playingStarted();
67
68 //! Should be called when a file has stopped.
69 virtual void playingStopped();
70
71protected:
72#if !NEW_MOUSE_CHECK_POS
73 virtual void mouseMoveEvent( QMouseEvent * e );
74#endif
75 virtual void paintEvent ( QPaintEvent * e );
76
77protected slots:
78 virtual void checkMousePos();
79
80private:
81 QTimer * check_mouse_timer;
82#if NEW_MOUSE_CHECK_POS
83 QPoint mouse_last_position;
84 bool autohide_cursor;
85 int autohide_interval;
86#else
87 QPoint cursor_pos, last_cursor_pos;
88#endif
89};
90
91//! MplayerLayer can be instructed to not delete the background.
92
93class MplayerLayer : public Screen
94{
95 Q_OBJECT
96
97public:
98 MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
99 ~MplayerLayer();
100
101#if REPAINT_BACKGROUND_OPTION
102 //! If b is true, the background of the widget will be repainted as usual.
103 /*! Otherwise the background will not repainted when a video is playing. */
104 void setRepaintBackground(bool b);
105
106 //! Return true if repainting the background is allowed.
107 bool repaintBackground() { return repaint_background; };
108#endif
109
110public slots:
111 //! Should be called when a file has started.
112 /*! It's needed to know if the background has to be cleared or not. */
113 virtual void playingStarted();
114 //! Should be called when a file has stopped.
115 virtual void playingStopped();
116
117#if REPAINT_BACKGROUND_OPTION
118protected:
119 virtual void paintEvent ( QPaintEvent * e );
120#endif
121
122private:
123#if REPAINT_BACKGROUND_OPTION
124 bool repaint_background;
125#endif
126 bool playing;
127};
128
129
130class MplayerWindow : public Screen
131{
132 Q_OBJECT
133
134public:
135 MplayerWindow( QWidget* parent = 0, Qt::WindowFlags f = 0);
136 ~MplayerWindow();
137
138 MplayerLayer * videoLayer() { return mplayerlayer; };
139
140 void setResolution( int w, int h);
141 void setAspect( double asp);
142 void setMonitorAspect(double asp);
143 void updateVideoWindow();
144
145#if USE_COLORKEY
146 void setColorKey(QColor c);
147#endif
148
149 void setOffsetX( int );
150 int offsetX();
151
152 void setOffsetY( int );
153 int offsetY();
154
155 void setZoom( double );
156 double zoom();
157
158 void allowVideoMovement(bool b) { allow_video_movement = b; };
159 bool isVideoMovementAllowed() { return allow_video_movement; };
160
161 virtual QSize sizeHint () const;
162 virtual QSize minimumSizeHint() const;
163
164 virtual bool eventFilter( QObject * watched, QEvent * event );
165
166#if LOGO_ANIMATION
167 bool animatedLogo() { return animated_logo; }
168#endif
169
170public slots:
171 void setLogoVisible(bool b);
172 void showLogo() { setLogoVisible(true); };
173 void hideLogo() { setLogoVisible(false); };
174
175#if LOGO_ANIMATION
176 void setAnimatedLogo(bool b) { animated_logo = b; };
177#endif
178
179 void moveLeft();
180 void moveRight();
181 void moveUp();
182 void moveDown();
183 void incZoom();
184 void decZoom();
185
186#if DELAYED_RESIZE
187protected slots:
188 void resizeLater();
189#endif
190
191protected:
192 virtual void retranslateStrings();
193 virtual void changeEvent ( QEvent * event ) ;
194
195 virtual void resizeEvent( QResizeEvent * e);
196 virtual void mouseReleaseEvent( QMouseEvent * e);
197 virtual void mouseDoubleClickEvent( QMouseEvent * e );
198 virtual void wheelEvent( QWheelEvent * e );
199 void moveLayer( int offset_x, int offset_y );
200
201signals:
202 //void rightButtonReleased( QPoint p );
203 void doubleClicked();
204 void leftClicked();
205 void rightClicked();
206 void middleClicked();
207 void xbutton1Clicked(); // first X button
208 void xbutton2Clicked(); // second X button
209 void keyPressed(QKeyEvent * e);
210 void wheelUp();
211 void wheelDown();
212 void mouseMoved(QPoint);
213
214protected:
215 int video_width, video_height;
216 double aspect;
217 double monitoraspect;
218
219 MplayerLayer * mplayerlayer;
220 QLabel * logo;
221
222 // Zoom and moving
223 int offset_x, offset_y;
224 double zoom_factor;
225
226 // Original pos and dimensions of the mplayerlayer
227 // before zooming or moving
228 int orig_x, orig_y;
229 int orig_width, orig_height;
230
231 bool allow_video_movement;
232
233#if DELAYED_RESIZE
234 QTimer * resize_timer;
235#endif
236
237#if LOGO_ANIMATION
238 bool animated_logo;
239#endif
240};
241
242
243#endif
244
Note: See TracBrowser for help on using the repository browser.