2014-03-01 21:02:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "NinePatchComponent.h"
|
|
|
|
#include "ComponentList.h"
|
|
|
|
#include "TextComponent.h"
|
2014-03-12 03:00:08 +00:00
|
|
|
#include "ComponentGrid.h"
|
2014-03-12 23:24:34 +00:00
|
|
|
#include "../Util.h"
|
2014-03-12 03:00:08 +00:00
|
|
|
|
|
|
|
class ButtonComponent;
|
2014-03-01 21:02:44 +00:00
|
|
|
|
|
|
|
class MenuComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MenuComponent(Window* window, const char* title);
|
|
|
|
|
|
|
|
void onSizeChanged() override;
|
|
|
|
|
2014-03-12 23:24:34 +00:00
|
|
|
inline void addRow(const ComponentListRow& row, bool setCursorHere = false) { mList->addRow(row, setCursorHere); updateSize(); }
|
2014-03-01 21:02:44 +00:00
|
|
|
|
2014-03-08 18:19:21 +00:00
|
|
|
inline void addWithLabel(const std::string& label, const std::shared_ptr<GuiComponent>& comp, bool setCursorHere = false)
|
|
|
|
{
|
|
|
|
ComponentListRow row;
|
2014-03-12 23:24:34 +00:00
|
|
|
row.addElement(std::make_shared<TextComponent>(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
2014-03-08 18:19:21 +00:00
|
|
|
row.addElement(comp, false);
|
|
|
|
addRow(row, setCursorHere);
|
|
|
|
}
|
|
|
|
|
2014-03-12 03:00:08 +00:00
|
|
|
void addButton(const std::string& label, const std::string& helpText, const std::function<void()>& callback);
|
|
|
|
|
|
|
|
inline void setCursorToList() { mGrid.setCursorTo(mList); }
|
|
|
|
inline void setCursorToButtons() { assert(mButtonGrid); mGrid.setCursorTo(mButtonGrid); }
|
|
|
|
|
2014-03-01 21:02:44 +00:00
|
|
|
private:
|
2014-03-12 23:24:34 +00:00
|
|
|
void updateSize();
|
2014-03-12 03:00:08 +00:00
|
|
|
void updateGrid();
|
|
|
|
|
2014-03-01 21:02:44 +00:00
|
|
|
NinePatchComponent mBackground;
|
2014-03-12 03:00:08 +00:00
|
|
|
ComponentGrid mGrid;
|
|
|
|
|
|
|
|
std::shared_ptr<TextComponent> mTitle;
|
|
|
|
std::shared_ptr<ComponentList> mList;
|
|
|
|
std::shared_ptr<ComponentGrid> mButtonGrid;
|
|
|
|
std::vector< std::shared_ptr<ButtonComponent> > mButtons;
|
2014-03-01 21:02:44 +00:00
|
|
|
};
|