2014-03-01 21:02:44 +00:00
|
|
|
#pragma once
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_COMPONENTS_MENU_COMPONENT_H
|
|
|
|
#define ES_CORE_COMPONENTS_MENU_COMPONENT_H
|
2014-03-01 21:02:44 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "components/ComponentGrid.h"
|
2014-06-20 01:30:09 +00:00
|
|
|
#include "components/ComponentList.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "components/NinePatchComponent.h"
|
2014-06-20 01:30:09 +00:00
|
|
|
#include "components/TextComponent.h"
|
2018-01-27 17:04:28 +00:00
|
|
|
#include "utils/StringUtil.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Renderer.h"
|
2014-03-12 03:00:08 +00:00
|
|
|
|
|
|
|
class ButtonComponent;
|
2014-03-22 21:02:25 +00:00
|
|
|
class ImageComponent;
|
2014-03-01 21:02:44 +00:00
|
|
|
|
2014-03-15 17:18:50 +00:00
|
|
|
std::shared_ptr<ComponentGrid> makeButtonGrid(Window* window, const std::vector< std::shared_ptr<ButtonComponent> >& buttons);
|
2014-03-22 21:02:25 +00:00
|
|
|
std::shared_ptr<ImageComponent> makeArrow(Window* window);
|
2014-03-15 17:18:50 +00:00
|
|
|
|
2014-04-19 20:21:15 +00:00
|
|
|
#define TITLE_VERT_PADDING (Renderer::getScreenHeight()*0.0637f)
|
|
|
|
|
2014-03-01 21:02:44 +00:00
|
|
|
class MenuComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2014-04-19 19:15:44 +00:00
|
|
|
MenuComponent(Window* window, const char* title, const std::shared_ptr<Font>& titleFont = Font::get(FONT_SIZE_LARGE));
|
2014-03-01 21:02:44 +00:00
|
|
|
|
|
|
|
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-21 19:51:25 +00:00
|
|
|
inline void addWithLabel(const std::string& label, const std::shared_ptr<GuiComponent>& comp, bool setCursorHere = false, bool invert_when_selected = true)
|
2014-03-08 18:19:21 +00:00
|
|
|
{
|
|
|
|
ComponentListRow row;
|
2018-01-27 17:04:28 +00:00
|
|
|
row.addElement(std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
2014-03-21 19:51:25 +00:00
|
|
|
row.addElement(comp, false, invert_when_selected);
|
2014-03-08 18:19:21 +00:00
|
|
|
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);
|
|
|
|
|
2014-04-19 19:15:44 +00:00
|
|
|
void setTitle(const char* title, const std::shared_ptr<Font>& font);
|
|
|
|
|
2014-03-12 03:00:08 +00:00
|
|
|
inline void setCursorToList() { mGrid.setCursorTo(mList); }
|
|
|
|
inline void setCursorToButtons() { assert(mButtonGrid); mGrid.setCursorTo(mButtonGrid); }
|
|
|
|
|
2014-03-13 19:09:50 +00:00
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
|
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-21 16:54:48 +00:00
|
|
|
float getButtonGridHeight() const;
|
2014-03-12 03:00:08 +00:00
|
|
|
|
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
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_COMPONENTS_MENU_COMPONENT_H
|