//..............................................................................
//
// Ninja UI - toolbars
//

import "ui_Action.jnc"
import "ui_Label.jnc"
import "ui_ComboBox.jnc"

namespace ui {

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

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

enum ToolButtonStyle {
	IconOnly,
	TextOnly,
	TextBesideIcon,
	TextUnderIcon,
	FollowStyle,
}


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

opaque class ToolBar: Widget {
	enum {
		Def_Spacing = 6,
	}

	ToolButtonStyle autoget property m_toolButtonStyle;

	construct();
	destruct();

	void setIconSize(
		int width,
		int height
	);

	void addAction(Action* action);
	void addWidget(Widget* widget);
	void addSpacing(int size = Def_Spacing);
	void addStretch(int stretch = 0);
	void addSeparator();

	Label* addLabel(
		char const* text,
		int spacing = Def_Spacing
	);

	ComboBox* addComboBox(uint_t width = 0);  // 0 = default, -1 = stretch

	ComboBox* addComboBox(
		const char* labelText,
		ComboItem const* itemArray,
		size_t itemCount
	);
}

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

Label* ToolBar.addLabel(
	char const* text,
	int spacing
) {
	Label* label = new Label(text);
	addWidget(label);

	if (spacing)
		addSpacing(spacing);

	return label;
}

ComboBox* ToolBar.addComboBox(uint_t width) {
	ComboBox* comboBox = new ComboBox;
	if (width == -1)
		comboBox.m_horizontalSizePolicy = SizePolicy.Expanding;
	else if (width > 0)
		comboBox.m_minimumWidth = width;

	addWidget(comboBox);
	return comboBox;
}

ComboBox* ToolBar.addComboBox(
	const char* labelText,
	ComboItem const* itemArray,
	size_t itemCount
) {
	addLabel(labelText);
	ComboBox* comboBox = new ComboBox(itemArray, itemCount);
	comboBox.adjustSizeToContents();
	addWidget(comboBox);
	return comboBox;
}

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

//! @}

} // namespace ui
