Add Paragraph and ClickableText functions; implement MapKeyToImGuiKey for key mapping
This commit is contained in:
@@ -37,6 +37,10 @@ IMGUI_API bool InputHexByte(const char *label, uint8_t *data,
|
||||
IMGUI_API bool InputHexByte(const char *label, uint8_t *data, uint8_t max_value,
|
||||
float input_width = 50.f, bool no_step = false);
|
||||
|
||||
IMGUI_API void Paragraph(const std::string &text);
|
||||
|
||||
IMGUI_API bool ClickableText(const std::string &text);
|
||||
|
||||
IMGUI_API bool ListBox(const char *label, int *current_item,
|
||||
const std::vector<std::string> &items,
|
||||
int height_in_items = -1);
|
||||
@@ -53,6 +57,8 @@ IMGUI_API void ItemLabel(absl::string_view title, ItemLabelFlags flags);
|
||||
|
||||
IMGUI_API ImGuiID GetID(const std::string &id);
|
||||
|
||||
ImGuiKey MapKeyToImGuiKey(char key);
|
||||
|
||||
using GuiElement = std::variant<std::function<void()>, std::string>;
|
||||
|
||||
struct Table {
|
||||
@@ -77,58 +83,12 @@ struct MenuItem {
|
||||
std::function<bool()> enabled_condition = kDefaultEnabledCondition;
|
||||
std::vector<MenuItem> subitems;
|
||||
};
|
||||
using Menu = std::array<MenuItem, 5>;
|
||||
using Menu = std::vector<MenuItem>;
|
||||
|
||||
void DrawMenu(Menu ¶ms);
|
||||
|
||||
enum MenuType {
|
||||
kFile,
|
||||
kEdit,
|
||||
kView,
|
||||
kTools,
|
||||
kHelp,
|
||||
};
|
||||
|
||||
static Menu kMainMenu;
|
||||
|
||||
inline void AddToMenu(const std::string &label, const char *icon,
|
||||
MenuType type) {
|
||||
if (icon) {
|
||||
kMainMenu[type].subitems.emplace_back(absl::StrCat(icon, " ", label), "",
|
||||
nullptr);
|
||||
} else {
|
||||
kMainMenu[type].subitems.emplace_back(label, "", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
inline void AddToFileMenu(const std::string &label, const std::string &shortcut,
|
||||
std::function<void()> callback) {
|
||||
kMainMenu[MenuType::kFile].subitems.emplace_back(label, shortcut, callback);
|
||||
}
|
||||
|
||||
inline void AddToFileMenu(const std::string &label, const std::string &shortcut,
|
||||
std::function<void()> callback,
|
||||
std::function<bool()> enabled_condition,
|
||||
std::vector<MenuItem> subitems) {
|
||||
kMainMenu[MenuType::kFile].subitems.emplace_back(label, shortcut, callback,
|
||||
enabled_condition, subitems);
|
||||
}
|
||||
|
||||
inline void AddToEditMenu(const std::string &label, const std::string &shortcut,
|
||||
std::function<void()> callback) {
|
||||
kMainMenu[MenuType::kEdit].subitems.emplace_back(label, shortcut, callback);
|
||||
}
|
||||
|
||||
inline void AddToViewMenu(const std::string &label, const std::string &shortcut,
|
||||
std::function<void()> callback) {
|
||||
kMainMenu[MenuType::kView].subitems.emplace_back(label, shortcut, callback);
|
||||
}
|
||||
|
||||
inline void AddToHelpMenu(const std::string &label, const std::string &shortcut,
|
||||
std::function<void()> callback) {
|
||||
kMainMenu[MenuType::kHelp].subitems.emplace_back(label, shortcut, callback);
|
||||
}
|
||||
|
||||
} // namespace gui
|
||||
} // namespace yaze
|
||||
|
||||
|
||||
Reference in New Issue
Block a user