2014-03-01 21:02:44 +00:00
|
|
|
#include "MenuComponent.h"
|
|
|
|
|
|
|
|
MenuComponent::MenuComponent(Window* window, const char* title) : GuiComponent(window),
|
|
|
|
mBackground(window), mTitle(window), mList(window)
|
|
|
|
{
|
|
|
|
mBackground.setImagePath(":/frame.png");
|
|
|
|
|
2014-03-02 16:41:02 +00:00
|
|
|
mTitle.setFont(Font::get(FONT_SIZE_LARGE));
|
2014-03-01 21:02:44 +00:00
|
|
|
mTitle.setText(title);
|
2014-03-04 22:48:33 +00:00
|
|
|
mTitle.setColor(0x555555FF);
|
2014-03-01 21:02:44 +00:00
|
|
|
mTitle.setCentered(true);
|
|
|
|
|
|
|
|
addChild(&mBackground);
|
|
|
|
addChild(&mTitle);
|
|
|
|
addChild(&mList);
|
|
|
|
|
2014-03-04 22:48:33 +00:00
|
|
|
setSize(Renderer::getScreenWidth() * 0.5f, Renderer::getScreenHeight() * 0.75f);
|
2014-03-01 21:02:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MenuComponent::onSizeChanged()
|
|
|
|
{
|
2014-03-04 22:48:33 +00:00
|
|
|
mBackground.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(-32, -32));
|
|
|
|
|
|
|
|
const float titlePadding = mTitle.getFont()->getHeight() * 0.2f;
|
2014-03-01 21:02:44 +00:00
|
|
|
|
|
|
|
mTitle.setSize(mSize.x(), (float)mTitle.getFont()->getHeight());
|
2014-03-04 22:48:33 +00:00
|
|
|
mTitle.setPosition(0, titlePadding / 2);
|
2014-03-01 21:02:44 +00:00
|
|
|
|
2014-03-04 22:48:33 +00:00
|
|
|
mList.setPosition(0, mTitle.getSize().y() + titlePadding);
|
|
|
|
mList.setSize(mSize.x(), mSize.y() - mTitle.getSize().y() - titlePadding);
|
2014-03-01 21:02:44 +00:00
|
|
|
}
|