/*
 * Copyright (C) 2012 by
 *   MetraLabs GmbH (MLAB), GERMANY
 *  and
 *   Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
 * All rights reserved.
 *
 * Redistribution and modification of this code is strictly prohibited.
 *
 * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
 * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
 * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
 */

/**
 * @file QColor
 *    Serialization/Deserialization of Qt QColor.
 *
 *    The filename was chosen to match the Qt standard.
 *    Instead of
 *      #include <QColor>
 *    use
 *      #include <serialization/adapters/Qt/QColor>
 *
 * @author Tim Langner, Erik Einhorn
 * @date   2011/01/05
 */

#ifndef _MIRA_QCOLOR_H_
#define _MIRA_QCOLOR_H_

#include <QColor>

#include <serialization/SplitReflect.h>

namespace mira {

//////////////////////////////////////////////////////////////////////////////

MIRA_SPLIT_REFLECT(QColor)

template<typename Reflector>
void reflectRead(Reflector& re, QColor& color)
{
	qreal r,g,b,a;
	color.getRgbF(&r,&g,&b,&a);
	re.property("Red", r, "Red component (0-1)");
	re.property("Green", g, "Green component (0-1)");
	re.property("Blue", b, "Blue component (0-1)");
	re.property("Alpha", a, "Alpha (0=transparent, 1=opaque)");
}

template<typename Reflector>
void reflectWrite(Reflector& re, QColor& color)
{
	qreal r,g,b,a;
	re.property("Red", r, "Red component (0-1)");
	re.property("Green", g, "Green component (0-1)");
	re.property("Blue", b, "Blue component (0-1)");
	re.property("Alpha", a, "Alpha (0=transparent, 1=opaque)");
	color.setRgbF(r,g,b,a);
}

//////////////////////////////////////////////////////////////////////////////

}

#endif
