2018-10-10 01:06:03 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_MENU
|
|
|
|
#define FTXUI_COMPONENT_MENU
|
|
|
|
|
|
|
|
#include "ftxui/component/component.hpp"
|
2019-01-03 07:35:59 +08:00
|
|
|
#include "ftxui/dom/elements.hpp"
|
2018-10-10 01:06:03 +08:00
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
namespace ftxui {
|
|
|
|
namespace component {
|
|
|
|
|
|
|
|
class Menu : public Component {
|
|
|
|
public:
|
|
|
|
// Constructor.
|
|
|
|
Menu(Delegate*);
|
|
|
|
|
|
|
|
// State.
|
|
|
|
std::vector<std::wstring> entries = {};
|
|
|
|
int selected = 0;
|
|
|
|
|
2019-01-03 07:35:59 +08:00
|
|
|
dom::Decorator active_style = dom::inverted;
|
|
|
|
dom::Decorator selected_style = dom::bold;
|
|
|
|
dom::Decorator normal_style = dom::nothing;
|
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
// State update callback.
|
|
|
|
std::function<void()> on_change = [](){};
|
|
|
|
std::function<void()> on_enter = [](){};
|
|
|
|
|
|
|
|
// Component implementation.
|
|
|
|
dom::Element Render() override;
|
2019-01-06 23:10:57 +08:00
|
|
|
bool OnEvent(Event) override;
|
2018-10-10 01:06:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace component
|
|
|
|
} // namespace ftxui
|
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_MENU */
|