2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
#include "modules/base.hpp"
|
|
|
|
|
|
|
|
namespace modules
|
|
|
|
{
|
|
|
|
struct MenuTreeItem {
|
|
|
|
std::string exec;
|
|
|
|
std::unique_ptr<drawtypes::Label> label;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MenuTree {
|
|
|
|
std::vector<std::unique_ptr<MenuTreeItem>> items;
|
|
|
|
};
|
|
|
|
|
|
|
|
DefineModule(MenuModule, StaticModule)
|
|
|
|
{
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto TAG_LABEL_TOGGLE = "<label-toggle>";
|
2016-05-31 03:58:58 +00:00
|
|
|
static constexpr auto TAG_MENU = "<menu>";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto EVENT_MENU_OPEN = "menu_open-";
|
2016-05-31 03:58:58 +00:00
|
|
|
static constexpr auto EVENT_MENU_CLOSE = "menu_close";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
std::mutex output_mtx;
|
|
|
|
std::mutex cmd_mtx;
|
|
|
|
|
|
|
|
int current_level = -1;
|
|
|
|
std::vector<std::unique_ptr<MenuTree>> levels;
|
|
|
|
|
|
|
|
std::unique_ptr<drawtypes::Label> label_open;
|
|
|
|
std::unique_ptr<drawtypes::Label> label_close;
|
|
|
|
|
|
|
|
public:
|
2016-06-21 01:59:43 +00:00
|
|
|
explicit MenuModule(std::string name);
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-31 03:58:58 +00:00
|
|
|
std::string get_output();
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-21 01:59:43 +00:00
|
|
|
bool build(Builder *builder, std::string tag);
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-21 01:59:43 +00:00
|
|
|
bool handle_command(std::string cmd);
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|