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