/*****************************************************************************
 *
 *  confvidmpeg1mencoderdialog.h -- Input the lavc_mpeg1video codec parameters.
 *
 *  Copyright (C) 2010 Starbuck <starbuck@labdv.com>
 *  All rights reserved.
 *
 *  This file is part of the Gui4 module of the DVDx 4 application.
 *
 *  GNU Lesser General Public License Usage
 *  This file may be used under the terms of the GNU Lesser General
 *  Public License version 2.1 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.LGPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU Lesser General Public License version 2.1 requirements
 *  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 *
 *  GNU General Public License Usage
 *  Alternatively, this file may be used under the terms of the GNU
 *  General Public License version 3.0 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.GPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU General Public License version 3.0 requirements will be
 *  met: http://www.gnu.org/copyleft/gpl.html.
 *
 *****************************************************************************/

#ifndef VIDEOSETTINGSMPEG1DIALOG_H
#define VIDEOSETTINGSMPEG1DIALOG_H

#include "../video/video_struct.h"

#include <QtCore/QLocale>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QDialog>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QGroupBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtGui/QSlider>
#include <QtGui/QSpacerItem>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>


class ConfVidMpeg1MEncoderDialog : public QDialog
{
	Q_OBJECT

public:
	ConfVidMpeg1MEncoderDialog(encoder_video_settings_t *settings, 
		video_t *track,
		QWidget *parent = 0);

private slots:
	void accept();
	void bitrateSliderChanged(const int);
	void bitrateLineEditChanged(const QString &);
	void vbr_nomSliderChanged(const int);
	void vbr_nomLineEditChanged(const QString &);
	void vbr_minSliderChanged(const int);
	void vbr_minSliderReleased();
	void vbr_minLineEditChanged(const QString &);
	void vbr_maxSliderChanged(const int);
	void vbr_maxSliderReleased();
	void vbr_maxLineEditChanged(const QString &);
	void gop_sizeLineEditChanged(const QString &);
	void closed_gopCheckBoxClicked();
	void standardVcdCheckBoxClicked();
	void letterBoxCheckBoxClicked();
	void selectRez(const int);
	void selectFps(const int);
	void selectTv();
	void selectBrAllocation(const int);
	void selectFormat();
	void updateMpegMuxerSettings();
	void muxerDefaultPushButtonClicked();

private:
	void setToolTip();
	QString labelToolTip( const QString &defaults, const QString &details );
	QString editToolTip( const QString &name, const QString &range = tr("") );
	QString boxToolTip( const QString &name, const QString &defaults, const QString &range, const QString &details );

	void setWhatsThis();

	void enterUserDefinedSize();
	void updateControls();
	void populateFps();
	void populateRez();
	void populateBrAllocation();

	// Tabs
	QTabWidget *tabWidget;
	QDialogButtonBox *buttonBox;
	QVBoxLayout *verticalLayout;
	QWidget *mainTab;
	QWidget *advancedTab;
	QWidget *muxerTab;

	// Main tab
	QVBoxLayout *mainTabVLayout;
	QGroupBox *frameGroupBox;
	QHBoxLayout *horizontalLayout;
	QComboBox *rezComboBox;
	QComboBox *fpsComboBox;
	QGroupBox *bitrateGroupBox;
	QVBoxLayout *bitrateVLayout;
	QHBoxLayout *bitrateHLayout;
	QSlider *bitrateSlider;
	QLineEdit *bitrateLineEdit;
	QGroupBox *tvGroupBox;
	QVBoxLayout *tvVLayout;
	QRadioButton *tvNtscRadioButton;
	QRadioButton *tvPalRadioButton;
	QRadioButton *tvFreeRadioButton;
	QGroupBox *formatGroupBox;
	QVBoxLayout *formatVLayout;
	QRadioButton *formatMpeg1RadioButton;
	QRadioButton *formatVcdRadioButton;
	QHBoxLayout *standardVcdHLayout;
	QCheckBox *standardVcdCheckBox;
	QSpacerItem *standardVcdHSpacer;
	QSpacerItem *verticalSpacer;

	// Advanced tab
	QVBoxLayout *advancedTabVLayout;
	QGroupBox *br_allocGroupBox;
	QVBoxLayout *br_allocVLayout;
	QComboBox *br_allocComboBox;
	QGridLayout *vbrGLayout;
	QLabel *vbr_nomLabel;
	QSlider *vbr_nomSlider;
	QLineEdit *vbr_nomLineEdit;
	QLabel *vbr_minLabel;
	QSlider *vbr_minSlider;
	QLineEdit *vbr_minLineEdit;
	QLabel *vbr_maxLabel;
	QSlider *vbr_maxSlider;
	QLineEdit *vbr_maxLineEdit;
	QHBoxLayout *letterBoxHLayout;
	QCheckBox *letterBoxCheckBox;
	QSpacerItem *letterBoxHSpacer;
	QGroupBox *gopGroupBox;
	QVBoxLayout *gopVLayout;
	QLineEdit *gop_sizeLineEdit;
	QLabel *gop_sizeLabel;
	QSpacerItem *gop_sizeHSpacer;
	QHBoxLayout *gop_sizeHLayout;
	QCheckBox *closed_gopCheckBox;
	QSpacerItem *advancedTabSpacer;

	// Muxer tab
	QVBoxLayout *muxerTabVLayout;
	QGroupBox *muxerGroupBox;
	QVBoxLayout *muxerVLayout;
	QHBoxLayout *pack_sizeHLayout;
	QLineEdit *pack_sizeLineEdit;
	QLabel *pack_sizeLabel;
	QSpacerItem *pack_sizeSpacer;
	QHBoxLayout *muxrateHLayout;
	QLineEdit *muxrateLineEdit;
	QLabel *muxrateLabel;
	QSpacerItem *muxrateSpacer;
	QHBoxLayout *vdelayHLayout;
	QLineEdit *vdelayLineEdit;
	QLabel *vdelayLabel;
	QSpacerItem *vdelaySpacer;
	QHBoxLayout *adelayHLayout;
	QLineEdit *adelayLineEdit;
	QLabel *adelayLabel;
	QSpacerItem *adelaySpacer;
	QHBoxLayout *vbuf_sizeHLayout;
	QLineEdit *vbuf_sizeLineEdit;
	QLabel *vbuf_sizeLabel;
	QSpacerItem *vbuf_sizeSpacer;
	QHBoxLayout *abuf_sizeHLayout;
	QLineEdit *abuf_sizeLineEdit;
	QLabel *abuf_sizeLabel;
	QSpacerItem *abuf_sizeSpacer;
	QHBoxLayout *interleaving2HLayout;
	QCheckBox *interleaving2CheckBox;
	QSpacerItem *interleaving2Spacer;
	QHBoxLayout *dropHLayout;
	QCheckBox *dropCheckBox;
	QSpacerItem *dropSpacer;
	QSpacerItem *muxerVSpacer;
	QHBoxLayout *muxerDefaultHLayout;
	QPushButton *muxerDefaultPushButton;
	QSpacerItem *muxerDefaultHSpacer;

	bool suspendMuxerSettingsUpdate;

	encoder_video_settings_t *callerSettings;  // settings to modify
	encoder_video_settings_t *encSettings;  // local copy
	video_t *videoSource;  // for recommended stuff (rez, fps)

	QIntValidator *bitrateValidator;
	QIntValidator *vbr_nomValidator;
	QIntValidator *vbr_minValidator;
	QIntValidator *vbr_maxValidator;

	enum Size { widthMin = 192, widthMax = 768,
		heightMin = 144, heightMax = 576 };

	enum BitrateAllocation { CBR = 0, VBR };

	int bitrateMin;
	int bitrateMax;
};

#endif
