controller.hpp 9.5 KB
Newer Older
1
/*****************************************************************************
Pere Orga's avatar
Pere Orga committed
2
 * controller.hpp : Controller for the main interface
3
 ****************************************************************************
4
 * Copyright (C) 2006-2008 the VideoLAN team
5 6
 * $Id$
 *
7
 * Authors: Jean-Baptiste Kempf <jb@videolan.org>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

24 25
#ifndef QVLC_CONTROLLER_H_
#define QVLC_CONTROLLER_H_
26 27 28 29 30

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
31
#include "qt.hpp"
32 33

#include <QFrame>
34
#include <QString>
35
#include <QSizeGrip>
36

37
#define MAIN_TB1_DEFAULT "64;39;64;38;65"
38
#define MAIN_TB2_DEFAULT "0-2;64;3;1;4;64;7;9;64;10;20;19;64-4;37;65;35-4"
39
#define ADV_TB_DEFAULT "12;11;13;14"
40
#define INPT_TB_DEFAULT "43;33-4;44"
41
#define FSC_TB_DEFAULT "0-2;64;3;1;4;64;37;64;38;64;8;65;25;35-4;34"
42

43
#define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
44

45
class QBoxLayout;
46
class QHBoxLayout;
47

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
48
class QAbstractButton;
49
class QToolButton;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
50

51
class WidgetListing;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
52

53
class QSignalMapper;
54 55
class QTimer;

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
56 57 58 59 60
typedef enum buttonType_e
{
    PLAY_BUTTON,
    STOP_BUTTON,
    OPEN_BUTTON,
61 62
    PREV_SLOW_BUTTON,
    NEXT_FAST_BUTTON,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
63 64 65
    SLOWER_BUTTON,
    FASTER_BUTTON,
    FULLSCREEN_BUTTON,
66
    DEFULLSCREEN_BUTTON,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
67 68 69 70 71 72
    EXTENDED_BUTTON,
    PLAYLIST_BUTTON,
    SNAPSHOT_BUTTON,
    RECORD_BUTTON,
    ATOB_BUTTON,
    FRAME_BUTTON,
73
    REVERSE_BUTTON,
74 75
    SKIP_BACK_BUTTON,
    SKIP_FW_BUTTON,
76
    QUIT_BUTTON,
77
    RANDOM_BUTTON,
78
    LOOP_BUTTON,
79
    INFO_BUTTON,
80 81
    PREVIOUS_BUTTON,
    NEXT_BUTTON,
82
    OPEN_SUB_BUTTON,
83
    FULLWIDTH_BUTTON,
84 85 86
    BUTTON_MAX,

    SPLITTER = 0x20,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
87
    INPUT_SLIDER,
88
    TIME_LABEL,
89
    VOLUME,
90
    VOLUME_SPECIAL,
91 92
    MENU_BUTTONS,
    TELETEXT_BUTTONS,
93
    ADVANCED_CONTROLLER,
94
    PLAYBACK_BUTTONS,
95
    ASPECT_RATIO_COMBOBOX,
96
    SPEED_LABEL,
97 98
    TIME_LABEL_ELAPSED,
    TIME_LABEL_REMAINING,
99 100 101 102 103
    SPECIAL_MAX,

    WIDGET_SPACER = 0x40,
    WIDGET_SPACER_EXTEND,
    WIDGET_MAX,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
104 105
} buttonType_e;

106

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
107
static const char* const nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
108
    N_("Previous / Backward"), N_("Next / Forward"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
109
    N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
110
    N_("Record"), N_("A→B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
111
    N_("Step backward" ), N_("Step forward"), N_("Quit"), N_("Random"),
112
    N_("Loop / Repeat"), N_("Information"), N_("Previous"), N_("Next"),
113
    N_("Open subtitles"), N_("Dock fullscreen controller")
114
};
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
115
static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
Christophe Mutricy's avatar
Christophe Mutricy committed
116
    N_("Stop playback"), N_("Open a medium"),
117 118
    N_("Previous media in the playlist, skip backward when held"),
    N_("Next media in the playlist, skip forward when held"), N_("Slower"), N_("Faster"),
Christophe Mutricy's avatar
Christophe Mutricy committed
119
    N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
120
    N_("Show extended settings" ), N_( "Toggle playlist" ),
Christophe Mutricy's avatar
Christophe Mutricy committed
121 122
    N_( "Take a snapshot" ), N_( "Record" ),
    N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
123
    N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit"),
124
    N_("Random"), N_("Change the loop and repeat modes"), N_("Information"),
125
    N_("Previous media in the playlist"), N_("Next media in the playlist"),
126
    N_("Open subtitle file"),
127
    N_("Dock/undock fullscreen controller to/from bottom of screen"),
128
};
129 130 131 132 133 134 135 136 137
static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b.svg", ":/toolbar/stop_b.svg",
    ":/toolbar/eject.svg", ":/toolbar/previous_b.svg", ":/toolbar/next_b.svg",
    ":/toolbar/slower.svg", ":/toolbar/faster.svg", ":/toolbar/fullscreen.svg",
    ":/toolbar/defullscreen.svg", ":/toolbar/extended.svg", ":/toolbar/playlist.svg",
    ":/toolbar/snapshot.svg", ":/toolbar/record.svg", ":/toolbar/atob_nob.svg",
    ":/toolbar/frame.svg", ":/toolbar/reverse.svg", ":/toolbar/skip_back.svg",
    ":/toolbar/skip_fw.svg", ":/toolbar/clear.svg", ":/buttons/playlist/shuffle_on.svg",
    ":/buttons/playlist/repeat_all.svg", ":/menu/info.svg",
    ":/toolbar/previous_b.svg", ":/toolbar/next_b.svg", ":/toolbar/eject.svg", ":/toolbar/space.svg"
138
};
139

140 141 142 143 144 145 146 147
enum
{
   WIDGET_NORMAL = 0x0,
   WIDGET_FLAT   = 0x1,
   WIDGET_BIG    = 0x2,
   WIDGET_SHINY  = 0x4,
};

148
class AdvControlsWidget;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
149
class AbstractController : public QFrame
150
{
151 152
    friend class WidgetListing; /* For ToolBar Edition HACKS */

153 154
    Q_OBJECT
public:
155
    AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
156

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
157 158
protected:
    intf_thread_t       *p_intf;
159

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
160
    QSignalMapper       *toolbarActionsMapper;
161
    QBoxLayout          *controlLayout;
162
    /* Change to BoxLayout if both dir are needed */
163

164 165
    AdvControlsWidget   *advControls;

166
    void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
167 168 169

    virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
                                     buttonType_e i_type, int i_option );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
170

171
    QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
172
private:
173
    static void setupButton( QAbstractButton * );
174 175
    QFrame *discFrame();
    QFrame *telexFrame();
176
    void applyAttributes( QToolButton *, bool b_flat, bool b_big );
177 178

    QHBoxLayout         *buttonGroupLayout;
179
protected slots:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
180
    virtual void setStatus( int );
181 182

signals:
Rémi Denis-Courmont's avatar
Typos  
Rémi Denis-Courmont committed
183 184
    void inputExists( bool ); /// This might be useful in the IM ?
    void inputPlaying( bool ); /// This might be useful in the IM ?
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
185
    void inputIsRecordable( bool ); /// same ?
186
    void inputIsTrickPlayable( bool ); /// same ?
187 188
};

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
189 190 191 192 193
/* Advanced Button Bar */
class AdvControlsWidget : public AbstractController
{
    Q_OBJECT
public:
194
    AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
195 196 197 198 199 200 201
};

/* Slider Bar */
class InputControlsWidget : public AbstractController
{
    Q_OBJECT
public:
202
    InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
203 204 205 206 207 208 209 210
};

/* Button Bar */
class ControlsWidget : public AbstractController
{
    Q_OBJECT
public:
    /* p_intf, advanced control visible or not, blingbling or not */
211 212
    ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
                    QWidget *_parent = 0 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
213

214 215 216
    void setGripVisible( bool b_visible )
    { grip->setVisible( b_visible ); }

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
217 218 219
protected:
    friend class MainInterface;

220
    bool b_advancedVisible;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
221

222 223 224
private:
    QSizeGrip *grip;

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
225
protected slots:
226
    void toggleAdvanced();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
227

228 229 230 231 232 233 234 235
signals:
    void advancedControlsToggled( bool );
};


/* to trying transparency with fullscreen controller on windows enable that */
/* it can be enabled on-non windows systems,
   but it will be transparent only with composite manager */
236
#define HAVE_TRANSPARENCY 1
237 238

/* Default value of opacity for FS controller */
239
#define DEFAULT_OPACITY 0.70
240

241 242 243
/* Used to restore the minimum width after a full-width switch */
#define FSC_WIDTH 800

244 245 246
/***********************************
 * Fullscreen controller
 ***********************************/
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
247
class FullscreenControllerWidget : public AbstractController
248 249 250
{
    Q_OBJECT
public:
251
    FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0  );
252 253
    virtual ~FullscreenControllerWidget();

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
254
    /* Vout */
255
    void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
256
    void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
257
    void toggleFullwidth();
258
    void updateFullwidthGeometry( int number );
259
    int targetScreen();
260

261 262 263 264
private:
    static int FullscreenChanged( vlc_object_t *obj,
                    const char *, vlc_value_t, vlc_value_t new_val, void *data );

265 266
signals:
    void keyPressed( QKeyEvent * );
267
    void fullscreenChanged( bool );
268

269 270
public slots:
    void setVoutList( vout_thread_t **, int );
271 272 273 274

protected:
    friend class MainInterface;

275 276 277 278 279 280 281 282
    void mouseMoveEvent( QMouseEvent *event ) Q_DECL_OVERRIDE;
    void mousePressEvent( QMouseEvent *event ) Q_DECL_OVERRIDE;
    void mouseReleaseEvent( QMouseEvent *event ) Q_DECL_OVERRIDE;
    void enterEvent( QEvent *event ) Q_DECL_OVERRIDE;
    void leaveEvent( QEvent *event ) Q_DECL_OVERRIDE;
    void keyPressEvent( QKeyEvent *event ) Q_DECL_OVERRIDE;

    void customEvent( QEvent *event ) Q_DECL_OVERRIDE;
283

284 285 286
private slots:
    void showFSC();
    void planHideFSC();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
287
    void hideFSC() { hide(); }
288
    void slowHideFSC();
289
    void restoreFSC();
290
    void centerFSC( int );
291 292 293 294 295

private:
    QTimer *p_hideTimer;
#if HAVE_TRANSPARENCY
    QTimer *p_slowHideTimer;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
296 297
    bool b_slow_hide_begin;
    int  i_slow_hide_timeout;
298
    float f_opacity;
299 300
#endif

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
301
    int i_mouse_last_x, i_mouse_last_y;
302
    bool b_mouse_over;
303
    int i_screennumber;
304
    QRect screenRes;
305 306
    QRect previousScreenRes;
    QPoint previousPosition;
307

308 309 310
    /* List of vouts currently tracked */
    QList<vout_thread_t *> vout;

311 312 313 314
    /* Shared variable between FSC and VLC (protected by a lock) */
    vlc_mutex_t lock;
    bool        b_fullscreen;
    int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
315 316
    int i_mouse_last_move_x;
    int i_mouse_last_move_y;
317 318

    bool isWideFSC;
319
    int i_sensitivity;
320 321 322
};

#endif