/*****************************************************************************
 *
 *  x264partitionsdialog.h -- Control to select x264 partiions parameter.
 *
 *  Copyright (C) 2010 Starbuck <starbuck@labdv.com>
 *  All rights reserved.
 *
 *  This file is part of the Encoder 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 X264PARTITIONSDIALOG_H
#define X264PARTITIONSDIALOG_H

#include <QRadioButton>
#include <QCheckBox>
#include <QString>
#include <QDialogButtonBox>
#include <QDialog>

class x264PartitionsDialog : public QDialog
{
	Q_OBJECT

	struct mb_t
	{
		bool i8x8;
		bool i4x4;
		bool p8x8;
		bool p4x4;
		bool b8x8;

		void clear() {
			i8x8 = false;
			i4x4 = false;
			p8x8 = false;
			p4x4 = false;
			b8x8 = false;
		}

		void all() {
			i8x8 = true;
			i4x4 = true;
			p8x8 = true;
			p4x4 = true;
			b8x8 = true;
		}
	};

public:
	x264PartitionsDialog(QString *partitions, const QString &defaults, QWidget *parent = 0);

	static void stringToBlocks(const QString &, mb_t *);
	static void blocksToString(const mb_t &, QString *);

private slots:
	void accept();
	void checkASplit();
	void checkAChoice();
	void defaultPushButtonClicked();
	
private:
    QCheckBox *p8x8CheckBox;
    QCheckBox *b8x8CheckBox;
    QCheckBox *i8x8CheckBox;
    QCheckBox *i4x4CheckBox;
    QCheckBox *p4x4CheckBox;

    QRadioButton *allRadioButton;
    QRadioButton *customRadioButton;
    QRadioButton *noneRadioButton;

    QDialogButtonBox *buttonBox;

	void updateControls();

	mb_t blkPartitions;  // the state member

	QString *strPartitions;  // to fill in with result
	QString strDefaults;
};

#endif
