mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00

TextComponent now has a proper "alignment" setting (left, center, and right). Did some more styling on GuiMetaDataEd.
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "NinePatchComponent.h"
|
|
#include "ComponentList.h"
|
|
#include "TextComponent.h"
|
|
#include "ComponentGrid.h"
|
|
#include "../Util.h"
|
|
|
|
class ButtonComponent;
|
|
|
|
std::shared_ptr<ComponentGrid> makeButtonGrid(Window* window, const std::vector< std::shared_ptr<ButtonComponent> >& buttons);
|
|
|
|
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<GuiComponent>& comp, bool setCursorHere = false, bool invert_when_selected = true)
|
|
{
|
|
ComponentListRow row;
|
|
row.addElement(std::make_shared<TextComponent>(mWindow, strToUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF), TextComponent::ALIGN_CENTER);
|
|
row.addElement(comp, false, invert_when_selected);
|
|
addRow(row, setCursorHere);
|
|
}
|
|
|
|
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); }
|
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
private:
|
|
void updateSize();
|
|
void updateGrid();
|
|
float getButtonGridHeight() const;
|
|
|
|
NinePatchComponent mBackground;
|
|
ComponentGrid mGrid;
|
|
|
|
std::shared_ptr<TextComponent> mTitle;
|
|
std::shared_ptr<ComponentList> mList;
|
|
std::shared_ptr<ComponentGrid> mButtonGrid;
|
|
std::vector< std::shared_ptr<ButtonComponent> > mButtons;
|
|
};
|