Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
popup_menu.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <functional>
6#include <optional>
7
8namespace pulp::platform {
9
10// Native popup/context menu
11class PopupMenu {
12public:
13 struct Item {
14 int id = 0;
15 std::string label;
16 bool enabled = true;
17 bool checked = false;
18 bool is_separator = false;
19
20 static Item separator() { return {0, "", true, false, true}; }
21 };
22
23 PopupMenu() = default;
24
25 void add_item(int id, const std::string& label, bool enabled = true, bool checked = false) {
26 items_.push_back({id, label, enabled, checked, false});
27 }
28
30 items_.push_back(Item::separator());
31 }
32
33 const std::vector<Item>& items() const { return items_; }
34
35 // Show at screen coordinates. Returns selected item ID or nullopt.
36 std::optional<int> show(float x, float y) const;
37
38 // Show attached to a view (uses view's screen position)
39 std::optional<int> show_at_view(void* native_view_handle) const;
40
41private:
42 std::vector<Item> items_;
43};
44
45} // namespace pulp::platform
std::optional< int > show(float x, float y) const
void add_separator()
Definition popup_menu.hpp:29
std::optional< int > show_at_view(void *native_view_handle) const
void add_item(int id, const std::string &label, bool enabled=true, bool checked=false)
Definition popup_menu.hpp:25
const std::vector< Item > & items() const
Definition popup_menu.hpp:33
Device capability vocabulary: one tier ladder, one thermal ladder, and the projection from observed i...
Definition child_process.hpp:15
Definition popup_menu.hpp:13
bool checked
Definition popup_menu.hpp:17
bool is_separator
Definition popup_menu.hpp:18
static Item separator()
Definition popup_menu.hpp:20
bool enabled
Definition popup_menu.hpp:16
std::string label
Definition popup_menu.hpp:15