Esempio n. 1
0
void UIHBoxLayout::layout (UINode* parent)
{
	float currentSize = 2.0f * parent->getPadding();
	float minHeight = 0.0f;

	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* node = *i;
		currentSize += node->getWidth() + _spacing;
		minHeight = std::max(node->getHeight() + 2.0f * parent->getPadding(), minHeight);
	}

	float size = currentSize - _spacing;
	parent->setSize(size, minHeight);

	// the size might change the alignment and thus the position of the parent
	float currentPos = parent->getPadding();
	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* node = *i;
		if (_expandChildren)
			node->setSize(node->getWidth(), parent->getHeight() - 2.0f * parent->getPadding());

		if (_align & NODE_ALIGN_MIDDLE) {
			node->setPos(currentPos, parent->getHeight() / 2.0f - node->getHeight() / 2.0f);
		} else if (_align & NODE_ALIGN_BOTTOM) {
			node->setPos(currentPos, parent->getHeight() - node->getHeight());
		} else {
			node->setPos(currentPos, node->getY());
		}

		currentPos += node->getWidth() + _spacing;
	}
}
Esempio n. 2
0
Intro::Intro(const std::string& name, IFrontend* frontend) :
		UIWindow(name, frontend, WINDOW_FLAG_MODAL) {
	_onPop = CMD_START;

	_background = new UINodeIntroBackground(frontend);
	UINode *overlay = new UINode(frontend);
	overlay->setBackgroundColor(colorWhiteAlpha80);
	const float padding = 4.0f / std::max(_frontend->getWidth(), _frontend->getHeight());
	overlay->setSize(_background->getWidth() - 2.0f * padding, _background->getHeight() - 2.0f * padding);
	overlay->setPos(padding, padding);
	_background->add(overlay);
	add(_background);

	UINodeButton* close = new UINodeButton(_frontend);
	close->setImage("icon-close");
	close->setOnActivate(CMD_UI_POP);
	close->alignTo(_background, NODE_ALIGN_RIGHT | NODE_ALIGN_TOP, 0.01f);
	add(close);

	_panel = new UINode(frontend);
	_panel->setStandardPadding();
	_panel->setPos(0.0f, _background->getTop());
	_panel->setSize(_background->getWidth(), _background->getHeight());
	_panel->setAlignment(NODE_ALIGN_CENTER | NODE_ALIGN_TOP);
	UIVBoxLayout *layout = new UIVBoxLayout(0.01f, true, NODE_ALIGN_CENTER);
	_panel->setLayout(layout);
	setInactiveAfterPush(1000L);
}
Esempio n. 3
0
UINode* UIWindow::addTextureNode (const std::string& texture, float x, float y, float w, float h)
{
	UINode* imageNode = new UINode(_frontend);
	imageNode->setImage(texture);
	imageNode->setPos(x, y);
	imageNode->setSize(w, h);
	add(imageNode);
	return imageNode;
}
void UIMapWindow::initHudNodes ()
{
	UINode* panel = new UINode(_frontend);
	panel->setImage("bones");
	panel->setStandardPadding();
	panel->setAlignment(NODE_ALIGN_TOP | NODE_ALIGN_CENTER);
	add(panel);

	UINode *innerPanel = new UINode(_frontend);
	innerPanel->setLayout(new UIHBoxLayout(0.01f));
	innerPanel->setPos(panel->getX() + 0.07f, panel->getY());
	_points = new UICavePackerNodePoint(_frontend, 30);
	_points->setFont(HUGE_FONT);
	_points->setId(UINODE_POINTS);
	innerPanel->add(_points);
	add(innerPanel);
}