//..............................................................................
//
// Ninja property grid
//

namespace gui {

//..............................................................................

opaque class Property
{
	char const* autoget property m_name;
	char const* autoget property m_toolTipText;
	bool autoget property m_isEnabled;
}

//..............................................................................

opaque class BoolProperty: Property
{
	construct (char const* name);

	bool autoget bindable property m_value;
}

//..............................................................................

opaque class IntProperty: Property
{
	construct (char const* name);

	int autoget bindable property m_value;
	int autoget property m_minValue;
	int autoget property m_maxValue;
	int autoget property m_spinBoxStep;
}

//..............................................................................

opaque class StringProperty: Property
{
	construct (char const* name);

	char const* autoget bindable property m_value;
	bool autoget property m_isPassword;
}

//..............................................................................

struct EnumPropertyOption
{
	char const* m_text;
	variant m_value;
}

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

opaque class EnumProperty: Property
{
	property m_value
	{
		variant autoget m_value;
		set (variant value);
		bindable alias m_onPropChanged = m_onChanged;
	}

	property m_currentIndex
	{
		size_t autoget m_value;
		set (size_t value);
		bindable alias m_onPropChanged = m_onChanged;
	}

	construct (char const* name);
	destruct ();

	setOptions (
		EnumPropertyOption const* optionArray,
		size_t count
		);

	event m_onChanged ();
}

//..............................................................................

opaque class GroupProperty: Property
{
	construct (char const* name);

	addProperty (Property* prop);
}

//..............................................................................

opaque class PropertyGrid
{
	addProperty (Property* prop);

	GroupProperty* createGroupProperty (
		GroupProperty* group,
		char const* name,
		char const* toolTipText
		);

	GroupProperty* createGroupProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createGroupProperty (null, name, toolTipText);
	}

	BoolProperty* createBoolProperty (
		GroupProperty* group,
		char const* name,
		char const* toolTipText
		);

	BoolProperty* createBoolProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createBoolProperty (null, name, toolTipText);
	}

	IntProperty* createIntProperty (
		GroupProperty* group,
		char const* name,
		char const* toolTipText
		);

	IntProperty* createIntProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createIntProperty (null, name, toolTipText);
	}

	StringProperty* createStringProperty (
		GroupProperty* group,
		char const* name,
		char const* toolTipText
		);

	StringProperty* createStringProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createStringProperty (null, name, toolTipText);
	}

	EnumProperty* createEnumProperty (
		GroupProperty* group,
		char const* name,
		char const* toolTipText,
		EnumPropertyOption const* optionArray,
		size_t count
		);

	EnumProperty* createEnumProperty (
		char const* name,
		char const* toolTipText,
		EnumPropertyOption const* optionArray,
		size_t count
		)
	{
		return createEnumProperty (null, name, toolTipText, optionArray, count);
	}
}

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

GroupProperty* PropertyGrid.createGroupProperty (
	GroupProperty* group,
	char const* name,
	char const* toolTipText
	)
{
	GroupProperty* prop = new GroupProperty (name);
	prop.m_toolTipText = toolTipText;
	if (group)
		group.addProperty (prop);
	else
		addProperty (prop);
	return prop;
}

BoolProperty* PropertyGrid.createBoolProperty (
	GroupProperty* group,
	char const* name,
	char const* toolTipText
	)
{
	BoolProperty* prop = new BoolProperty (name);
	prop.m_toolTipText = toolTipText;
	if (group)
		group.addProperty (prop);
	else
		addProperty (prop);
	return prop;
}

IntProperty* PropertyGrid.createIntProperty (
	GroupProperty* group,
	char const* name,
	char const* toolTipText
	)
{
	IntProperty* prop = new IntProperty (name);
	prop.m_toolTipText = toolTipText;
	if (group)
		group.addProperty (prop);
	else
		addProperty (prop);
	return prop;
}

StringProperty* PropertyGrid.createStringProperty (
	GroupProperty* group,
	char const* name,
	char const* toolTipText
	)
{
	StringProperty* prop = new StringProperty (name);
	prop.m_toolTipText = toolTipText;
	if (group)
		group.addProperty (prop);
	else
		addProperty (prop);
	return prop;
}

EnumProperty* PropertyGrid.createEnumProperty (
	GroupProperty* group,
	char const* name,
	char const* toolTipText,
	EnumPropertyOption const* optionArray,
	size_t count
	)
{
	EnumProperty* prop = new EnumProperty (name);
	prop.m_toolTipText = toolTipText;
	prop.setOptions (optionArray, count);
	if (group)
		group.addProperty (prop);
	else
		addProperty (prop);
	return prop;
}

//..............................................................................

} // namespace gui {
