1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
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.
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.
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
20
#ifndef MPLAYERWINDOW_H
21
#define MPLAYERWINDOW_H
27
#include <QResizeEvent>
28
#include <QWheelEvent>
29
#include <QMouseEvent>
31
#include <QPaintEvent>
39
#define ZOOM_STEP 0.05
43
//! Screen is a widget that hides the mouse cursor after some seconds if not moved.
45
class Screen : public QWidget
50
Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
54
virtual void mouseMoveEvent( QMouseEvent * e );
55
virtual void paintEvent ( QPaintEvent * e );
58
virtual void checkMousePos();
61
QPoint cursor_pos, last_cursor_pos;
64
//! MplayerLayer can be instructed to not delete the background.
66
class MplayerLayer : public Screen
71
MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
74
//! If b is true, the background of the widget will be repainted as usual.
75
/*! Otherwise the background will not repainted when a video is playing. */
76
void allowClearingBackground(bool b);
78
//! Return true if repainting the background is allowed.
79
bool isClearingBackgroundAllowed() { return allow_clearing; };
82
//! Should be called when a file has started.
83
/*! It's needed to know if the background has to be cleared or not. */
84
void playingStarted();
85
//! Should be called when a file has stopped.
86
void playingStopped();
89
virtual void paintEvent ( QPaintEvent * e );
97
class MplayerWindow : public Screen
102
MplayerWindow( QWidget* parent = 0, Qt::WindowFlags f = 0);
105
void showLogo( bool b);
107
MplayerLayer * videoLayer() { return mplayerlayer; };
109
void setResolution( int w, int h);
110
void setAspect( double asp);
111
void setMonitorAspect(double asp);
112
void updateVideoWindow();
115
void setColorKey(QColor c);
118
void setOffsetX( int );
121
void setOffsetY( int );
124
void setZoom( double );
127
void allowVideoMovement(bool b) { allow_video_movement = b; };
128
bool isVideoMovementAllowed() { return allow_video_movement; };
130
QPoint mousePosition() { return mouse_position; };
132
virtual QSize sizeHint () const;
133
virtual QSize minimumSizeHint() const;
135
virtual bool eventFilter( QObject * watched, QEvent * event );
146
virtual void retranslateStrings();
147
virtual void changeEvent ( QEvent * event ) ;
149
virtual void resizeEvent( QResizeEvent * e);
150
virtual void mouseReleaseEvent( QMouseEvent * e);
151
virtual void mouseDoubleClickEvent( QMouseEvent * e );
152
virtual void wheelEvent( QWheelEvent * e );
153
void moveLayer( int offset_x, int offset_y );
156
//void rightButtonReleased( QPoint p );
157
void doubleClicked();
160
void middleClicked();
161
void xbutton1Clicked(); // first X button
162
void xbutton2Clicked(); // second X button
163
void keyPressed(QKeyEvent * e);
166
void mouseMoved(QPoint);
169
int video_width, video_height;
171
double monitoraspect;
173
MplayerLayer * mplayerlayer;
177
int offset_x, offset_y;
180
// Original pos and dimensions of the mplayerlayer
181
// before zooming or moving
183
int orig_width, orig_height;
185
bool allow_video_movement;
187
QPoint mouse_position;