//..............................................................................
//
// Ninja UI - layouts
//

import "ui_Label.jnc"

namespace ui {

//! \addtogroup api-ui
//! @{

enum FrameShadow {
	Plain  = 0x10,
	Raised = 0x20,
	Sunken = 0x30,
}

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

opaque class Layout {
	int autoget property m_margin;
	int autoget property m_spacing;

	destruct();

	void clear();
}

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

class BoxLayout: Layout {
	enum Direction {
		LeftToRight,
		RightToLeft,
		TopToBottom,
		BottomToTop
	}

	Direction autoget property m_direction;

	construct(Direction direction);

	void addWidget(
		Widget* widget,
		int stretch = 0,
		Alignment alignment = 0
	);

	void addLayout(
		Layout* layout,
		int stretch = 0
	);

	void addSpacing(int size);
	void addStrut(int size);
	void addStretch(int stretch = 0);
	void addLine(FrameShadow shadow = FrameShadow.Sunken);
}

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

class HBoxLayout: BoxLayout {
	construct() {
		basetype.construct(Direction.LeftToRight)
	}
}

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

class VBoxLayout: BoxLayout {
	construct() {
		basetype.construct(Direction.TopToBottom)
	}
}

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

class FormLayout: Layout {
	construct();

	void addRow(Widget* widget);
	void addRow(Layout* layout);

	void addRow(
		Widget* label,
		Widget* field
	);

	void addRow(
		Widget* label,
		Layout* field
	);

	void addRow(
		string_t label,
		Widget* field
	) {
		addRow(new Label(label), field);
	}

	void addRow(
		string_t label,
		Layout* field
	) {
		addRow(new Label(label), field);
	}

	void addLine(FrameShadow shadow = FrameShadow.Sunken);
}

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

//! @}

} // namespace ui
