Simple ftxui menu for selecting an example program to run
This commit is contained in:
@@ -8,12 +8,39 @@
|
|||||||
#include "ExampleApps/CubesExampleApp.hpp"
|
#include "ExampleApps/CubesExampleApp.hpp"
|
||||||
#include "ExampleApps/MovingCubeApp.hpp"
|
#include "ExampleApps/MovingCubeApp.hpp"
|
||||||
|
|
||||||
|
#include <ftxui/component/captured_mouse.hpp>
|
||||||
|
#include <ftxui/component/component.hpp>
|
||||||
|
#include <ftxui/component/component_options.hpp>
|
||||||
|
#include <ftxui/component/screen_interactive.hpp>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace OpenVulkano;
|
using namespace OpenVulkano;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::unique_ptr<IGraphicsApp> app = CubesExampleApp::CreateUnique();
|
std::vector<std::string> examples = {
|
||||||
// std::unique_ptr<IGraphicsApp> app = MovingCubeApp::CreateUnique();
|
"Cubes Example App",
|
||||||
|
"Moving Cube Example App",
|
||||||
|
};
|
||||||
|
|
||||||
|
int selectedExample = 0;
|
||||||
|
ftxui::MenuOption option;
|
||||||
|
auto screen = ftxui::ScreenInteractive::TerminalOutput();
|
||||||
|
option.on_enter = screen.ExitLoopClosure();
|
||||||
|
auto menu = ftxui::Menu(&examples, &selectedExample, option);
|
||||||
|
|
||||||
|
screen.Loop(menu);
|
||||||
|
|
||||||
|
std::unique_ptr<IGraphicsApp> app;
|
||||||
|
switch (selectedExample)
|
||||||
|
{
|
||||||
|
case 0: app = CubesExampleApp::CreateUnique(); break;
|
||||||
|
case 1: app = MovingCubeApp::CreateUnique(); break;
|
||||||
|
default: throw std::runtime_error("Invalid menu selection!"); break;
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsAppManager manager(app.get());
|
GraphicsAppManager manager(app.get());
|
||||||
manager.Run();
|
manager.Run();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user