1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-12-02 14:05:27 -05:00
polybar/include/drawtypes/icon.hpp

39 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
#include <string>
#include <vector>
#include <map>
#include <memory>
#include "drawtypes/label.hpp"
namespace drawtypes
{
struct Icon : public Label
{
2016-06-20 21:59:43 -04:00
Icon(std::string icon, int font = 0)
2016-05-19 10:41:06 -04:00
: Label(icon, font){}
2016-06-20 21:59:43 -04:00
Icon(std::string icon, std::string fg, std::string bg = "", std::string ul = "", std::string ol = "", int font = 0, int padding = 0, int margin = 0)
2016-05-19 10:41:06 -04:00
: Label(icon, fg, bg, ul, ol, font, padding, margin){}
std::unique_ptr<Icon> clone();
};
class IconMap
{
std::map<std::string, std::unique_ptr<Icon>> icons;
public:
2016-06-20 21:59:43 -04:00
void add(std::string id, std::unique_ptr<Icon> &&icon);
std::unique_ptr<Icon> &get(std::string id, std::string fallback_id = "");
bool has(std::string id);
2016-05-19 10:41:06 -04:00
operator bool() {
return this->icons.size() > 0;
}
};
2016-06-20 21:59:43 -04:00
std::unique_ptr<Icon> get_config_icon(std::string module_name, std::string icon_name = "icon", bool required = true, std::string def = "");
std::unique_ptr<Icon> get_optional_config_icon(std::string module_name, std::string icon_name = "icon", std::string def = "");
2016-05-19 10:41:06 -04:00
}