yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
item_context_menu.cc
Go to the documentation of this file.
2
4
5namespace yaze {
6namespace gui {
7
8bool ItemContextMenu(const char* id,
9 const std::function<std::vector<MenuItemSpec>()>& build,
10 ImGuiPopupFlags flags) {
11 // Pushed before Begin: a row inside a zero-padding region (a canvas) would
12 // otherwise hand that padding to the popup window.
13 PopupStyleScope popup_style;
14 if (!ImGui::BeginPopupContextItem(id, flags)) {
15 return false;
16 }
17 if (build) {
18 RenderMenuItems(build());
19 }
20 ImGui::EndPopup();
21 return true;
22}
23
24bool ItemContextMenu(const char* id,
25 const std::function<CanvasMenuDefinition()>& build,
26 ImGuiPopupFlags flags) {
27 // Pushed before Begin: a row inside a zero-padding region (a canvas) would
28 // otherwise hand that padding to the popup window.
29 PopupStyleScope popup_style;
30 if (!ImGui::BeginPopupContextItem(id, flags)) {
31 return false;
32 }
33 if (build) {
34 RenderCanvasMenu(build());
35 }
36 ImGui::EndPopup();
37 return true;
38}
39
40void RenderMenuItems(const std::vector<MenuItemSpec>& items) {
41 for (const auto& item : items) {
42 RenderMenuItem(item);
43 }
44}
45
46MenuItemSpec CopyToClipboardItem(const std::string& label,
47 const std::string& text) {
49 [text]() { ImGui::SetClipboardText(text.c_str()); });
50}
51
52} // namespace gui
53} // namespace yaze
Gives one popup the app's normal spacing.
#define ICON_MD_CONTENT_COPY
Definition icons.h:465
void RenderCanvasMenu(const CanvasMenuDefinition &menu, std::function< void(const std::string &, std::function< void()>)> popup_opened_callback)
Render a complete menu definition.
bool ItemContextMenu(const char *id, const std::function< std::vector< MenuItemSpec >()> &build, ImGuiPopupFlags flags)
Right-click menu for the last submitted ImGui item.
CanvasMenuItem MenuItemSpec
Neutral alias for menu items used outside canvases (list rows, tabs, chips). Same type,...
void RenderMenuItem(const CanvasMenuItem &item, std::function< void(const std::string &, std::function< void()>)> popup_opened_callback)
Render a single menu item.
MenuItemSpec CopyToClipboardItem(const std::string &label, const std::string &text)
void RenderMenuItems(const std::vector< MenuItemSpec > &items)
Complete menu definition.
Declarative menu item definition.
Definition canvas_menu.h:64