1 /*****************************************************************************
2 * interface_widgets.hpp : Custom widgets for the main interface
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Rafaël Carré <funman@videolanorg>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #ifndef _CONTROLLER_H_
27 #define _CONTROLLER_H_
33 #include <vlc_common.h>
34 #include <vlc_interface.h>
37 #include "main_interface.hpp"
38 #include "input_manager.hpp"
42 #include <QToolButton>
44 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")
51 class QAbstractSlider;
53 class QAbstractButton;
55 class VolumeClickHandler;
61 typedef enum buttonType_e
97 static const QString nameL[BUTTON_MAX] = { "Play", "Stop", "Open",
98 "Previous", "Next", "Slower", "Faster", "Fullscreen", "De-Fullscreen",
99 "Extended panel", "Playlist", "Snapshot", "Record", "A->B Loop",
100 "Frame By Frame", "Reverse" };
101 static const QString tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
103 _("Previous media in the playlist"),
104 _("Next media in the playlist"), _("Slower"), _("Faster"),
105 _("Toggle the video in fullscreen"), _("Toggle the video out fullscreen"),
106 _("Show extended settings" ), _( "Show playlist" ), _( "Take a snapshot" ),
107 _( "Record" ), _( "Loop from point A to point B continuously." ),
108 _("Frame by frame"), _("Reverse") };
109 static const QString iconL[BUTTON_MAX] ={ ":/play_b", ":/stop_b", "",
110 ":/previous_b", ":/next_b", ":/slower", ":/faster", ":/fullscreen",
111 ":/defullscreen", ":/extended", ":/playlist", ":/snapshot", ":/record",
112 ":/atob_nob", ":/frame", ":/reverse" };
114 typedef enum actionType_e
140 class AbstractController : public QFrame
142 friend class WidgetListing; /* For ToolBar Edition HACKS */
146 AbstractController( intf_thread_t *_p_i );
149 intf_thread_t *p_intf;
151 QSignalMapper *toolbarActionsMapper;
152 QHBoxLayout *controlLayout;
153 /* Change to BoxLayout if both dir are needed */
155 AdvControlsWidget *advControls;
157 void parseAndCreate( QString config, QBoxLayout *controlLayout );
159 virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
160 buttonType_e i_type, int i_option );
162 QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
164 static void setupButton( QAbstractButton * );
165 QWidget *discFrame();
166 QWidget *telexFrame();
169 virtual void doAction( int );
186 virtual void setStatus( int );
189 void inputExists( bool ); /// This might be usefull in the IM ?
190 void inputPlaying( bool ); /// This might be usefull in the IM ?
191 void inputIsRecordable( bool ); /// same ?
195 * SPECIAL Widgets that are a bit more than just a ToolButton
196 * and have an icon/behaviour that changes depending on the context:
199 * - Teletext group buttons
200 * - Sound Widget group
202 class PlayButton : public QToolButton
206 void updateButton( bool );
209 class AtoB_Button : public QToolButton
213 void setIcons( bool, bool );
216 class TeletextController : public QWidget
219 friend class AbstractController;
221 QToolButton *telexTransparent, *telexOn;
225 void enableTeletextButtons( bool );
226 void toggleTeletextTransparency( bool );
229 class SoundWidget : public QWidget
232 friend class VolumeClickHandler;
235 SoundWidget( QWidget *parent, intf_thread_t *_p_i, bool );
238 intf_thread_t *p_intf;
239 QLabel *volMuteLabel;
240 QAbstractSlider *volumeSlider;
241 VolumeClickHandler *hVolLabel;
245 void updateVolume( int );
246 void updateVolume( void );
249 /* Advanced Button Bar */
250 class AdvControlsWidget : public AbstractController
254 AdvControlsWidget( intf_thread_t * );
258 class InputControlsWidget : public AbstractController
262 InputControlsWidget( intf_thread_t * );
266 class ControlsWidget : public AbstractController
270 /* p_intf, advanced control visible or not, blingbling or not */
271 ControlsWidget( intf_thread_t *_p_i, bool b_advControls );
272 virtual ~ControlsWidget();
275 friend class MainInterface;
277 bool b_advancedVisible;
280 void toggleAdvanced();
283 void advancedControlsToggled( bool );
286 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
287 done by trick with setting the opacity of window */
292 /* to trying transparency with fullscreen controller on windows enable that */
293 /* it can be enabled on-non windows systems,
294 but it will be transparent only with composite manager */
296 #define HAVE_TRANSPARENCY 1
298 #define HAVE_TRANSPARENCY 0
301 /* Default value of opacity for FS controller */
302 #define DEFAULT_OPACITY 0.75
304 /***********************************
305 * Fullscreen controller
306 ***********************************/
307 class FullscreenControllerWidget : public AbstractController
311 FullscreenControllerWidget( intf_thread_t * );
312 virtual ~FullscreenControllerWidget();
315 vout_thread_t *p_vout;
316 void attachVout( vout_thread_t *p_vout );
318 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
320 int i_mouse_last_move_x;
321 int i_mouse_last_move_y;
324 friend class MainInterface;
326 virtual void mouseMoveEvent( QMouseEvent *event );
327 virtual void mousePressEvent( QMouseEvent *event );
328 virtual void enterEvent( QEvent *event );
329 virtual void leaveEvent( QEvent *event );
330 virtual void keyPressEvent( QKeyEvent *event );
339 virtual void customEvent( QEvent *event );
342 #if HAVE_TRANSPARENCY
343 QTimer *p_slowHideTimer;
344 bool b_slow_hide_begin;
345 int i_slow_hide_timeout;
348 int i_mouse_last_x, i_mouse_last_y;
356 /* Shared variable between FSC and VLC (protected by a lock) */
359 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */