コード例 #1
0
ファイル: UIComponentImage.cpp プロジェクト: YurieCo/Nephilim
void UIComponentImage::onRender(GraphicsDevice* renderer, UIView* view)
{
	RectangleShape backgroundRect;
	backgroundRect.setRect(view->getBounds());
	if(mTexture) backgroundRect.setTexture(mTexture);
	renderer->draw(backgroundRect);
}
コード例 #2
0
void UIComponentTreeView::onRender(Renderer* renderer, UIView* view)
{
	// Draw a black background on the ROOT tree view
	if(mSubTreeLevel == 0)
	{
		RectangleShape back;
		back.setRect(view->getBounds());
		back.setColor(Color(36,36,36));
		renderer->draw(back);
	}
	/*else if(mSubTreeLevel == 1)
	{
		RectangleShape back;
		back.setRect(view->getBounds());
		back.setColor(Color::Grass);
		renderer->draw(back);
	}
	else if(mSubTreeLevel == 2)
	{
		RectangleShape back;
		back.setRect(view->getBounds());
		back.setColor(Color::Bittersweet);
		renderer->draw(back);
	}
	else if(mSubTreeLevel == 3)
	{
		RectangleShape back;
		back.setRect(view->getBounds());
		back.setColor(Color::Lavender);
		renderer->draw(back);
	}*/
}
コード例 #3
0
ファイル: UIComponentButton.cpp プロジェクト: faktis/Nephilim
void UIComponentButton::onRender(Renderer* renderer, UIView* view)
{
	if(hovering)
	{
		RectangleShape hoverRect;
		hoverRect.setRect(view->getBounds());
		hoverRect.setColor(mHoverColor);
		if(mTexture)
		{
			hoverRect.setTexture(mHoverTexture);
		}
		renderer->draw(hoverRect);
	}
	else
	{
		RectangleShape hoverRect;
		hoverRect.setRect(view->getBounds());
		hoverRect.setColor(mNormalColor);
		if(mTexture)
		{
			hoverRect.setTexture(mTexture);
		}
		renderer->draw(hoverRect);
	}

	// -- Label
	Text buttonLabel;
	buttonLabel.setFont(*view->mCore->m_defaultFont);
	buttonLabel.setString(mString);
	buttonLabel.setCharacterSize(view->mRect.height / 2);
	buttonLabel.setOrigin(static_cast<int>((buttonLabel.getLocalBounds().width / 2.f ) + 0.5f), static_cast<int>((buttonLabel.getLocalBounds().height / 2.f) + 0.5f));
	buttonLabel.setPosition(static_cast<int>((view->mRect.left + view->mRect.width / 2.f ) + 0.5f), static_cast<int>((view->mRect.top +  view->mRect.height / 2.f) + 0.5f));
	if(buttonLabel.getLocalBounds().width > view->getSize().x * 0.9f)
	{
		// The text is too big and passes the 90% of the button's width
		float diminishRatio = (view->getSize().x * 0.9f) / buttonLabel.getLocalBounds().width;
		buttonLabel.setCharacterSize(static_cast<unsigned int>(static_cast<float>(buttonLabel.getCharacterSize()) * diminishRatio));
		buttonLabel.setOrigin(static_cast<int>((buttonLabel.getLocalBounds().width / 2.f ) + 0.5f), static_cast<int>((buttonLabel.getLocalBounds().height / 2.f) + 0.5f));
	}
	renderer->draw(buttonLabel);
}
コード例 #4
0
void UIComponentTreeViewItem::onRender(Renderer* renderer, UIView* view)
{
	// Render this item full size

	/*RectangleShape back;
	back.setRect(view->getBounds());
	back.setColor(Color::Red);
	renderer->draw(back);*/

	// Render a little expandable flag if it applies
	if(mParent->getChildCount() > 0)
	{
		RectangleShape back;
		back.setRect(mParent->getChild(0)->getBounds());
		back.setSize(5.f, back.getSize().y);
		back.setColor(Color::Red);
		renderer->draw(back);
	}
}