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

Last change on this file since 176 was 176, checked in by Silvan Scherrer, 9 years ago

smplayer: update trunk to version 16.4

  • Property svn:eol-style set to LF
File size: 5.9 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2016 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
45// Number of pixels the window has to be dragged at least before dragging starts
46#define DRAG_THRESHOLD 4
47
48enum TDragState {NOT_DRAGGING, START_DRAGGING, DRAGGING};
49
50//! Screen is a widget that hides the mouse cursor after some seconds if not moved.
51
52class Screen : public QWidget
53{
54 Q_OBJECT
55
56public:
57 Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
58 ~Screen();
59
60 void setAutoHideCursor(bool b);
61 bool autoHideCursor() { return autohide_cursor; };
62
63 void setAutoHideInterval(int milliseconds) { autohide_interval = milliseconds; };
64 int autoHideInterval() { return autohide_interval; };
65
66public slots:
67 //! Should be called when a file has started.
68 virtual void playingStarted();
69
70 //! Should be called when a file has stopped.
71 virtual void playingStopped();
72
73signals:
74 void mouseMoved(QPoint);
75
76protected:
77 virtual void mouseMoveEvent( QMouseEvent * e );
78
79protected slots:
80 virtual void checkMousePos();
81
82private:
83 QTimer * check_mouse_timer;
84 QPoint mouse_last_position;
85 bool autohide_cursor;
86 int autohide_interval;
87};
88
89//! MplayerLayer can be instructed to not delete the background.
90
91class MplayerLayer : public Screen
92{
93 Q_OBJECT
94
95public:
96 MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
97 ~MplayerLayer();
98
99#if REPAINT_BACKGROUND_OPTION
100 //! If b is true, the background of the widget will be repainted as usual.
101 /*! Otherwise the background will not repainted when a video is playing. */
102 void setRepaintBackground(bool b);
103
104 //! Return true if repainting the background is allowed.
105 bool repaintBackground() { return repaint_background; };
106#endif
107
108public slots:
109 //! Should be called when a file has started.
110 /*! It's needed to know if the background has to be cleared or not. */
111 virtual void playingStarted();
112 //! Should be called when a file has stopped.
113 virtual void playingStopped();
114
115#if REPAINT_BACKGROUND_OPTION
116protected:
117 virtual void paintEvent ( QPaintEvent * e );
118#endif
119
120private:
121#if REPAINT_BACKGROUND_OPTION
122 bool repaint_background;
123#endif
124 bool playing;
125};
126
127
128class MplayerWindow : public Screen
129{
130 Q_OBJECT
131
132public:
133 MplayerWindow(QWidget* parent = 0, Qt::WindowFlags f = 0);
134 ~MplayerWindow();
135
136 MplayerLayer * videoLayer() { return mplayerlayer; };
137
138 void setResolution( int w, int h);
139 void setAspect( double asp);
140 void setMonitorAspect(double asp);
141 void updateVideoWindow();
142
143#if USE_COLORKEY
144 void setColorKey(QColor c);
145#endif
146
147 void setOffsetX( int );
148 int offsetX();
149
150 void setOffsetY( int );
151 int offsetY();
152
153 void setZoom( double );
154 double zoom();
155
156 void allowVideoMovement(bool b) { allow_video_movement = b; };
157 bool isVideoMovementAllowed() { return allow_video_movement; };
158
159 void delayLeftClick(bool b) { delay_left_click = b; };
160 bool isLeftClickDelayed() { return delay_left_click; };
161
162 virtual QSize sizeHint () const;
163 virtual QSize minimumSizeHint() const;
164
165 virtual bool eventFilter(QObject *, QEvent *);
166
167#if LOGO_ANIMATION
168 bool animatedLogo() { return animated_logo; }
169#endif
170
171 void setCornerWidget(QWidget * w);
172 QWidget * cornerWidget() { return corner_widget; };
173
174public slots:
175 void setLogoVisible(bool b);
176 void showLogo() { setLogoVisible(true); };
177 void hideLogo() { setLogoVisible(false); };
178
179#if LOGO_ANIMATION
180 void setAnimatedLogo(bool b) { animated_logo = b; };
181#endif
182
183 void moveLeft();
184 void moveRight();
185 void moveUp();
186 void moveDown();
187 void incZoom();
188 void decZoom();
189
190 void activateMouseDragTracking(bool active) { mouse_drag_tracking = active; }
191
192#if DELAYED_RESIZE
193protected slots:
194 void resizeLater();
195#endif
196
197protected:
198 virtual void retranslateStrings();
199 virtual void changeEvent ( QEvent * event ) ;
200
201 virtual void resizeEvent( QResizeEvent * e);
202 virtual void mouseReleaseEvent( QMouseEvent * e);
203 virtual void mouseDoubleClickEvent( QMouseEvent * e );
204 virtual void wheelEvent( QWheelEvent * e );
205 void moveLayer( int offset_x, int offset_y );
206
207signals:
208 //void rightButtonReleased( QPoint p );
209 void doubleClicked();
210 void leftClicked();
211 void rightClicked();
212 void middleClicked();
213 void xbutton1Clicked(); // first X button
214 void xbutton2Clicked(); // second X button
215 void keyPressed(QKeyEvent * e);
216 void wheelUp();
217 void wheelDown();
218 void mouseMovedDiff(QPoint);
219
220protected:
221 int video_width, video_height;
222 double aspect;
223 double monitoraspect;
224
225 MplayerLayer * mplayerlayer;
226 QLabel * logo;
227
228 // Zoom and moving
229 int offset_x, offset_y;
230 double zoom_factor;
231
232 // Original pos and dimensions of the mplayerlayer
233 // before zooming or moving
234 int orig_x, orig_y;
235 int orig_width, orig_height;
236
237 bool allow_video_movement;
238
239#if DELAYED_RESIZE
240 QTimer * resize_timer;
241#endif
242
243 // Delay left click event
244 bool delay_left_click;
245 QTimer * left_click_timer;
246 bool double_clicked;
247
248#if LOGO_ANIMATION
249 bool animated_logo;
250#endif
251
252 QWidget * corner_widget;
253
254private:
255 TDragState drag_state;
256 QPoint start_drag;
257 bool mouse_drag_tracking;
258};
259
260#endif
261
Note: See TracBrowser for help on using the repository browser.