//..............................................................................
//
// 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 GroupProperty: Property
{
	construct (char const* name);

	addProperty (
		Property* prop,
		Property* beforeProp = null
		);

	removeProperty (Property* prop);
}

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

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 ();
}

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

struct FlagPropertyOption
{
	char const* m_text;
	uint_t m_value;
}

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

opaque class FlagProperty: Property
{
	uint_t autoget bindable property m_value;

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

	setOptions (
		FlagPropertyOption const* optionArray,
		size_t count
		);
}

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

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

	uint_t autoget bindable property m_value;
}

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

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

	function* m_onAction ();
}

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

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

	char const* autoget bindable property m_value;
	char const* autoget property m_fileDialogCaption;
	char const* autoget property m_initialDirectory;
	char const* autoget property m_filter;
}

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

opaque class PropertyGrid
{
	addProperty (
		Property* prop,
		Property* beforeProp = null
		);

	removeProperty (Property* prop);

	GroupProperty* createGroupProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

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

	BoolProperty* createBoolProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

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

	IntProperty* createIntProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

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

	StringProperty* createStringProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

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

	EnumProperty* createEnumProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		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 (,, name, toolTipText, optionArray, count);
	}

	FlagProperty* createFlagProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText,
		FlagPropertyOption const* optionArray,
		size_t count
		);

	FlagProperty* createFlagProperty (
		char const* name,
		char const* toolTipText,
		FlagPropertyOption const* optionArray,
		size_t count
		)
	{
		return createFlagProperty (,, name, toolTipText, optionArray, count);
	}

	ColorProperty* createColorProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

	ColorProperty* createColorProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createColorProperty (,, name, toolTipText);
	}

	ActionProperty* createActionProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

	ActionProperty* createActionProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createActionProperty (,, name, toolTipText);
	}

	FileProperty* createFileProperty (
		GroupProperty* group = null,
		Property* beforeProp = null,
		char const* name,
		char const* toolTipText
		);

	FileProperty* createFileProperty (
		char const* name,
		char const* toolTipText
		)
	{
		return createFileProperty (,, name, toolTipText);
	}
}

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

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

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

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

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

EnumProperty* PropertyGrid.createEnumProperty (
	GroupProperty* group,
	Property* beforeProp,
	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, beforeProp);
	else
		addProperty (prop, beforeProp);
	return prop;
}

FlagProperty* PropertyGrid.createFlagProperty (
	GroupProperty* group,
	Property* beforeProp,
	char const* name,
	char const* toolTipText,
	FlagPropertyOption const* optionArray,
	size_t count
	)
{
	FlagProperty* prop = new FlagProperty (name);
	prop.m_toolTipText = toolTipText;
	prop.setOptions (optionArray, count);
	if (group)
		group.addProperty (prop, beforeProp);
	else
		addProperty (prop, beforeProp);
	return prop;
}

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

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

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

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

} // namespace gui {
