controller.hpp 8.21 KB
Newer Older
1
/*****************************************************************************
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 24 25 26 27 28 29 30 31 32 33
 *
 * 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.
 *****************************************************************************/

#ifndef _CONTROLLER_H_
#define _CONTROLLER_H_

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

#include "qt4.hpp"

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

36 37
#define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")

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


45 46
class QPixmap;
class QLabel;
47

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
48
class QGridLayout;
49 50
class QHBoxLayout;
class QBoxLayout;
51

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
52 53
class QAbstractSlider;
class QAbstractButton;
54
class InputSlider;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
55 56

class VolumeClickHandler;
57
class WidgetListing;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
58

59
class QSignalMapper;
60 61
class QTimer;

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
62 63 64 65 66 67 68 69 70 71
typedef enum buttonType_e
{
    PLAY_BUTTON,
    STOP_BUTTON,
    OPEN_BUTTON,
    PREVIOUS_BUTTON,
    NEXT_BUTTON,
    SLOWER_BUTTON,
    FASTER_BUTTON,
    FULLSCREEN_BUTTON,
72
    DEFULLSCREEN_BUTTON,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
73 74 75 76 77 78
    EXTENDED_BUTTON,
    PLAYLIST_BUTTON,
    SNAPSHOT_BUTTON,
    RECORD_BUTTON,
    ATOB_BUTTON,
    FRAME_BUTTON,
79
    REVERSE_BUTTON,
80 81
    SKIP_BACK_BUTTON,
    SKIP_FW_BUTTON,
82 83 84
    BUTTON_MAX,

    SPLITTER = 0x20,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
85
    INPUT_SLIDER,
86
    TIME_LABEL,
87
    VOLUME,
88 89
    MENU_BUTTONS,
    TELETEXT_BUTTONS,
90
    ADVANCED_CONTROLLER,
91 92 93 94 95
    SPECIAL_MAX,

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

98 99 100 101

static const QString nameL[BUTTON_MAX] = { "Play", "Stop", "Open",
    "Previous", "Next", "Slower", "Faster", "Fullscreen", "De-Fullscreen",
    "Extended panel", "Playlist", "Snapshot", "Record", "A->B Loop",
102
    "Frame By Frame", "Reverse", "Skip backward" , "Skip forward" };
103
static const QString tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
Jean-Philippe Andre's avatar
Jean-Philippe Andre committed
104
    _("Stop playback"), _("Open a media"),
105 106 107 108 109
    _("Previous media in the playlist"),
    _("Next media in the playlist"), _("Slower"), _("Faster"),
    _("Toggle the video in fullscreen"), _("Toggle the video out fullscreen"),
    _("Show extended settings" ), _( "Show playlist" ), _( "Take a snapshot" ),
    _( "Record" ), _( "Loop from point A to point B continuously." ),
110 111
    _("Frame by frame"), _("Reverse"), _("Skip backward"), _("Skip forward") };
static const QString iconL[BUTTON_MAX] ={ ":/play_b", ":/stop_b", ":/eject",
112 113
    ":/previous_b", ":/next_b", ":/slower", ":/faster", ":/fullscreen",
    ":/defullscreen", ":/extended", ":/playlist", ":/snapshot", ":/record",
114
    ":/atob_nob", ":/frame", ":/reverse", ":/skip_back", ":/skip_fw" };
115

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
116 117 118 119
typedef enum actionType_e
{
    PLAY_ACTION,
    STOP_ACTION,
120
    OPEN_ACTION,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
121 122 123 124 125 126 127 128 129
    PREVIOUS_ACTION,
    NEXT_ACTION,
    SLOWER_ACTION,
    FASTER_ACTION,
    FULLSCREEN_ACTION,
    EXTENDED_ACTION,
    PLAYLIST_ACTION,
    SNAPSHOT_ACTION,
    RECORD_ACTION,
130
    FRAME_ACTION,
131 132
    ATOB_ACTION,
    REVERSE_ACTION,
133 134
    SKIP_BACK_ACTION,
    SKIP_FW_ACTION,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
135 136
} actionType_e;

137 138 139 140 141 142 143 144
enum
{
   WIDGET_NORMAL = 0x0,
   WIDGET_FLAT   = 0x1,
   WIDGET_BIG    = 0x2,
   WIDGET_SHINY  = 0x4,
};

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

150 151
    Q_OBJECT
public:
152
    AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
153

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
154 155
protected:
    intf_thread_t       *p_intf;
156

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
157
    QSignalMapper       *toolbarActionsMapper;
158 159
    QHBoxLayout         *controlLayout;
    /* Change to BoxLayout if both dir are needed */
160

161 162
    AdvControlsWidget   *advControls;

163 164 165 166
    void parseAndCreate( QString config, QBoxLayout *controlLayout );

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

168
    QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
169
private:
170
    static void setupButton( QAbstractButton * );
171 172
    QFrame *discFrame();
    QFrame *telexFrame();
173

174 175
protected slots:
    virtual void doAction( int );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
176 177 178 179 180 181 182 183 184 185

protected slots:
    void play();
    void stop();
    void prev();
    void next();
    void fullscreen();
    void extSettings();
    void faster();
    void slower();
186
    void reverse();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
187
    void playlist();
188
    void snapshot();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
189
    void record();
190
    void frame();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
191 192

    virtual void setStatus( int );
193 194

signals:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
195 196 197
    void inputExists( bool ); /// This might be usefull in the IM ?
    void inputPlaying( bool ); /// This might be usefull in the IM ?
    void inputIsRecordable( bool ); /// same ?
198 199
};

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

/* Slider Bar */
class InputControlsWidget : public AbstractController
{
    Q_OBJECT
public:
213
    InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
214 215 216 217 218 219 220 221
};

/* Button Bar */
class ControlsWidget : public AbstractController
{
    Q_OBJECT
public:
    /* p_intf, advanced control visible or not, blingbling or not */
222 223
    ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
                    QWidget *_parent = 0 );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
224 225 226 227 228 229 230 231
    virtual ~ControlsWidget();

protected:
    friend class MainInterface;

    bool                 b_advancedVisible;

protected slots:
232
    void toggleAdvanced();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
233

234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
signals:
    void advancedControlsToggled( bool );
};

/* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
   done by trick with setting the opacity of window */
#ifdef WIN32
    #define WIN32TRICK
#endif

/* 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 */
#ifndef WIN32
    #define HAVE_TRANSPARENCY 1
#else
    #define HAVE_TRANSPARENCY 0
#endif

/* Default value of opacity for FS controller */
#define DEFAULT_OPACITY 0.75

/***********************************
 * Fullscreen controller
 ***********************************/
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
259
class FullscreenControllerWidget : public AbstractController
260 261 262
{
    Q_OBJECT
public:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
263
    FullscreenControllerWidget( intf_thread_t * );
264 265
    virtual ~FullscreenControllerWidget();

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
266
    /* Vout */
267
    void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
268
    void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
269

270 271
public slots:
    void setVoutList( vout_thread_t **, int );
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288

protected:
    friend class MainInterface;

    virtual void mouseMoveEvent( QMouseEvent *event );
    virtual void mousePressEvent( QMouseEvent *event );
    virtual void enterEvent( QEvent *event );
    virtual void leaveEvent( QEvent *event );
    virtual void keyPressEvent( QKeyEvent *event );

private slots:
    void showFSC();
    void planHideFSC();
    void hideFSC();
    void slowHideFSC();

private:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
289 290
    virtual void customEvent( QEvent *event );

291 292 293
    QTimer *p_hideTimer;
#if HAVE_TRANSPARENCY
    QTimer *p_slowHideTimer;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
294 295
    bool b_slow_hide_begin;
    int  i_slow_hide_timeout;
296 297
#endif

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
298
    int i_mouse_last_x, i_mouse_last_y;
299
    bool b_mouse_over;
300
    int i_screennumber;
301 302 303 304 305

#ifdef WIN32TRICK
    bool b_fscHidden;
#endif

306 307 308
    /* List of vouts currently tracked */
    QList<vout_thread_t *> vout;

309 310 311 312
    /* 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 */
313 314
    int i_mouse_last_move_x;
    int i_mouse_last_move_y;
315 316 317
};

#endif