1 #pragma once 2 3 #include "modules/meta/static_module.hpp" 4 5 POLYBAR_NS 6 7 namespace modules { 8 class menu_module : public static_module<menu_module> { 9 public: 10 struct menu_tree_item { 11 string exec; 12 label_t label; 13 }; 14 15 struct menu_tree { 16 vector<unique_ptr<menu_tree_item>> items; 17 }; 18 19 public: 20 explicit menu_module(const bar_settings&, string); 21 22 bool build(builder* builder, const string& tag) const; update()23 void update() {} 24 25 static constexpr auto TYPE = "custom/menu"; 26 27 static constexpr auto EVENT_OPEN = "open"; 28 static constexpr auto EVENT_CLOSE = "close"; 29 static constexpr auto EVENT_EXEC = "exec"; 30 31 protected: 32 bool input(const string& action, const string& data); 33 34 private: 35 static constexpr auto TAG_LABEL_TOGGLE = "<label-toggle>"; 36 static constexpr auto TAG_MENU = "<menu>"; 37 38 bool m_expand_right{true}; 39 40 label_t m_labelopen; 41 label_t m_labelclose; 42 label_t m_labelseparator; 43 44 vector<unique_ptr<menu_tree>> m_levels; 45 46 std::atomic<int> m_level{-1}; 47 }; 48 } // namespace modules 49 50 POLYBAR_NS_END 51