polybar-dwm/include/components/builder.hpp

76 lines
2.0 KiB
C++
Raw Normal View History

2016-06-15 03:32:35 +00:00
#pragma once
#include <map>
2016-06-15 03:32:35 +00:00
#include "common.hpp"
2016-12-26 16:06:28 +00:00
#include "components/types.hpp"
#include "tags/types.hpp"
2016-11-19 05:22:44 +00:00
POLYBAR_NS
2016-06-15 03:32:35 +00:00
using std::map;
// fwd decl
2016-06-15 03:32:35 +00:00
using namespace drawtypes;
namespace modules {
struct module_interface;
}
2016-06-15 03:32:35 +00:00
class builder {
public:
2016-12-31 03:32:11 +00:00
explicit builder(const bar_settings& bar);
2016-06-15 03:32:35 +00:00
void reset();
2016-11-02 19:22:45 +00:00
string flush();
2016-12-26 16:06:28 +00:00
void append(string text);
void node(string str);
void node(string str, int font_index);
void node(const label_t& label);
void node_repeat(const string& str, size_t n);
void node_repeat(const label_t& label, size_t n);
void offset(int pixels);
2016-12-26 16:06:28 +00:00
void space(size_t width);
void space();
void remove_trailing_space(size_t len);
void remove_trailing_space();
2016-11-02 19:22:45 +00:00
void font(int index);
void font_close();
void background(rgba color);
void background_close();
void color(rgba color);
void color_close();
void line_color(const rgba& color);
void line_color_close();
void overline_color(rgba color);
void overline_color_close();
void underline_color(rgba color);
void underline_color_close();
void overline(const rgba& color = rgba{});
void overline_close();
void underline(const rgba& color = rgba{});
void underline_close();
void control(tags::controltag tag);
void action(mousebtn index, string action);
void action(mousebtn btn, const modules::module_interface& module, string action, string data);
void action(mousebtn index, string action, const label_t& label);
void action(mousebtn btn, const modules::module_interface& module, string action, string data, const label_t& label);
void action_close();
2016-06-15 03:32:35 +00:00
protected:
void tag_open(tags::syntaxtag tag, const string& value);
void tag_open(tags::attribute attr);
void tag_close(tags::syntaxtag tag);
void tag_close(tags::attribute attr);
2016-06-15 03:32:35 +00:00
private:
2016-12-26 16:06:28 +00:00
const bar_settings m_bar;
2016-12-26 09:37:14 +00:00
string m_output;
map<tags::syntaxtag, int> m_tags{};
map<tags::syntaxtag, string> m_colors{};
map<tags::attribute, bool> m_attrs{};
2016-12-26 09:37:14 +00:00
2017-01-19 10:11:28 +00:00
int m_fontindex{0};
2016-06-15 03:32:35 +00:00
};
2016-11-19 05:22:44 +00:00
POLYBAR_NS_END