refactor: Remove all mentions of icon_t
Is exactly the same label_t
This commit is contained in:
parent
148d46b65b
commit
0ab9fcdc38
@ -13,8 +13,6 @@ using std::map;
|
||||
namespace drawtypes {
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
using icon = label;
|
||||
using icon_t = label_t;
|
||||
}
|
||||
using namespace drawtypes;
|
||||
|
||||
|
@ -15,21 +15,21 @@ namespace drawtypes {
|
||||
class animation : public non_copyable_mixin<animation> {
|
||||
public:
|
||||
explicit animation(int framerate_ms) : m_framerate_ms(framerate_ms) {}
|
||||
explicit animation(vector<icon_t>&& frames, int framerate_ms)
|
||||
explicit animation(vector<label_t>&& frames, int framerate_ms)
|
||||
: m_frames(forward<decltype(frames)>(frames))
|
||||
, m_framerate_ms(framerate_ms)
|
||||
, m_framecount(m_frames.size())
|
||||
, m_lastupdate(chrono::system_clock::now()) {}
|
||||
|
||||
void add(icon_t&& frame);
|
||||
icon_t get();
|
||||
void add(label_t&& frame);
|
||||
label_t get();
|
||||
int framerate();
|
||||
operator bool();
|
||||
|
||||
protected:
|
||||
void tick();
|
||||
|
||||
vector<icon_t> m_frames;
|
||||
vector<label_t> m_frames;
|
||||
int m_framerate_ms = 1000;
|
||||
int m_frame = 0;
|
||||
int m_framecount = 0;
|
||||
|
@ -11,13 +11,13 @@ POLYBAR_NS
|
||||
namespace drawtypes {
|
||||
class iconset : public non_copyable_mixin<iconset> {
|
||||
public:
|
||||
void add(string id, icon_t&& icon);
|
||||
void add(string id, label_t&& icon);
|
||||
bool has(const string& id);
|
||||
icon_t get(const string& id, const string& fallback_id = "", bool fuzzy_match = false);
|
||||
label_t get(const string& id, const string& fallback_id = "", bool fuzzy_match = false);
|
||||
operator bool();
|
||||
|
||||
protected:
|
||||
std::map<string, icon_t> m_icons;
|
||||
std::map<string, label_t> m_icons;
|
||||
};
|
||||
|
||||
using iconset_t = shared_ptr<iconset>;
|
||||
|
@ -9,10 +9,6 @@
|
||||
|
||||
POLYBAR_NS
|
||||
|
||||
/**
|
||||
* TODO: Remove icon_t
|
||||
*/
|
||||
|
||||
namespace drawtypes {
|
||||
struct token {
|
||||
string token;
|
||||
@ -25,12 +21,6 @@ namespace drawtypes {
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
|
||||
/**
|
||||
* \deprecated use label
|
||||
*/
|
||||
using icon = label;
|
||||
using icon_t = label_t;
|
||||
|
||||
class label : public non_copyable_mixin<label> {
|
||||
public:
|
||||
string m_foreground{};
|
||||
@ -89,9 +79,6 @@ namespace drawtypes {
|
||||
|
||||
label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = ""s);
|
||||
label_t load_optional_label(const config& conf, string section, string name, string def = ""s);
|
||||
|
||||
icon_t load_icon(const config& conf, string section, string name, bool required = true, string def = ""s);
|
||||
icon_t load_optional_icon(const config& conf, string section, string name, string def = ""s);
|
||||
}
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
@ -12,16 +12,14 @@ namespace drawtypes {
|
||||
// fwd
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
using icon = label;
|
||||
using icon_t = label_t;
|
||||
|
||||
class progressbar : public non_copyable_mixin<progressbar> {
|
||||
public:
|
||||
explicit progressbar(const bar_settings& bar, int width, string format);
|
||||
|
||||
void set_fill(icon_t&& fill);
|
||||
void set_empty(icon_t&& empty);
|
||||
void set_indicator(icon_t&& indicator);
|
||||
void set_fill(label_t&& fill);
|
||||
void set_empty(label_t&& empty);
|
||||
void set_indicator(label_t&& indicator);
|
||||
void set_gradient(bool mode);
|
||||
void set_colors(vector<string>&& colors);
|
||||
|
||||
@ -38,9 +36,9 @@ namespace drawtypes {
|
||||
unsigned int m_colorstep = 1;
|
||||
bool m_gradient = false;
|
||||
|
||||
icon_t m_fill;
|
||||
icon_t m_empty;
|
||||
icon_t m_indicator;
|
||||
label_t m_fill;
|
||||
label_t m_empty;
|
||||
label_t m_indicator;
|
||||
};
|
||||
|
||||
using progressbar_t = shared_ptr<progressbar>;
|
||||
|
@ -11,15 +11,15 @@ namespace drawtypes {
|
||||
class ramp : public non_copyable_mixin<ramp> {
|
||||
public:
|
||||
explicit ramp() = default;
|
||||
explicit ramp(vector<icon_t>&& icons) : m_icons(forward<decltype(icons)>(icons)) {}
|
||||
explicit ramp(vector<label_t>&& icons) : m_icons(forward<decltype(icons)>(icons)) {}
|
||||
|
||||
void add(icon_t&& icon);
|
||||
icon_t get(size_t index);
|
||||
icon_t get_by_percentage(float percentage);
|
||||
void add(label_t&& icon);
|
||||
label_t get(size_t index);
|
||||
label_t get_by_percentage(float percentage);
|
||||
operator bool();
|
||||
|
||||
protected:
|
||||
vector<icon_t> m_icons;
|
||||
vector<label_t> m_icons;
|
||||
};
|
||||
|
||||
using ramp_t = shared_ptr<ramp>;
|
||||
|
@ -37,8 +37,6 @@ namespace drawtypes {
|
||||
using progressbar_t = shared_ptr<progressbar>;
|
||||
class animation;
|
||||
using animation_t = shared_ptr<animation>;
|
||||
using icon = label;
|
||||
using icon_t = label_t;
|
||||
class iconset;
|
||||
using iconset_t = shared_ptr<iconset>;
|
||||
}
|
||||
|
@ -5,12 +5,12 @@
|
||||
POLYBAR_NS
|
||||
|
||||
namespace drawtypes {
|
||||
void animation::add(icon_t&& frame) {
|
||||
void animation::add(label_t&& frame) {
|
||||
m_frames.emplace_back(forward<decltype(frame)>(frame));
|
||||
m_framecount = m_frames.size();
|
||||
}
|
||||
|
||||
icon_t animation::get() {
|
||||
label_t animation::get() {
|
||||
tick();
|
||||
return m_frames[m_frame];
|
||||
}
|
||||
@ -42,12 +42,12 @@ namespace drawtypes {
|
||||
* from the configuration
|
||||
*/
|
||||
animation_t load_animation(const config& conf, const string& section, string name, bool required) {
|
||||
vector<icon_t> vec;
|
||||
vector<label_t> vec;
|
||||
vector<string> frames;
|
||||
|
||||
name = string_util::ltrim(string_util::rtrim(move(name), '>'), '<');
|
||||
|
||||
auto anim_defaults = load_optional_icon(conf, section, name);
|
||||
auto anim_defaults = load_optional_label(conf, section, name);
|
||||
|
||||
if (required) {
|
||||
frames = conf.get_list(section, name);
|
||||
@ -56,7 +56,7 @@ namespace drawtypes {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < frames.size(); i++) {
|
||||
vec.emplace_back(forward<icon_t>(load_optional_icon(conf, section, name + "-" + to_string(i), frames[i])));
|
||||
vec.emplace_back(forward<label_t>(load_optional_label(conf, section, name + "-" + to_string(i), frames[i])));
|
||||
vec.back()->copy_undefined(anim_defaults);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
POLYBAR_NS
|
||||
|
||||
namespace drawtypes {
|
||||
void iconset::add(string id, icon_t&& icon) {
|
||||
void iconset::add(string id, label_t&& icon) {
|
||||
m_icons.emplace(id, forward<decltype(icon)>(icon));
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ namespace drawtypes {
|
||||
return m_icons.find(id) != m_icons.end();
|
||||
}
|
||||
|
||||
icon_t iconset::get(const string& id, const string& fallback_id, bool fuzzy_match) {
|
||||
label_t iconset::get(const string& id, const string& fallback_id, bool fuzzy_match) {
|
||||
if (fuzzy_match) {
|
||||
for (auto const& ent1 : m_icons) {
|
||||
if (id.find(ent1.first) != std::string::npos) {
|
||||
|
@ -249,19 +249,6 @@ namespace drawtypes {
|
||||
return load_label(conf, move(section), move(name), false, move(def));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an icon by loading values from the configuration
|
||||
*/
|
||||
icon_t load_icon(const config& conf, string section, string name, bool required, string def) {
|
||||
return load_label(conf, move(section), move(name), required, move(def));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an icon by loading optional values from the configuration
|
||||
*/
|
||||
icon_t load_optional_icon(const config& conf, string section, string name, string def) {
|
||||
return load_icon(conf, move(section), move(name), false, move(def));
|
||||
}
|
||||
}
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
@ -12,15 +12,15 @@ namespace drawtypes {
|
||||
progressbar::progressbar(const bar_settings& bar, int width, string format)
|
||||
: m_builder(factory_util::unique<builder>(bar)), m_format(move(format)), m_width(width) {}
|
||||
|
||||
void progressbar::set_fill(icon_t&& fill) {
|
||||
void progressbar::set_fill(label_t&& fill) {
|
||||
m_fill = forward<decltype(fill)>(fill);
|
||||
}
|
||||
|
||||
void progressbar::set_empty(icon_t&& empty) {
|
||||
void progressbar::set_empty(label_t&& empty) {
|
||||
m_empty = forward<decltype(empty)>(empty);
|
||||
}
|
||||
|
||||
void progressbar::set_indicator(icon_t&& indicator) {
|
||||
void progressbar::set_indicator(label_t&& indicator) {
|
||||
if (!m_indicator && indicator.get()) {
|
||||
m_width--;
|
||||
}
|
||||
@ -100,18 +100,18 @@ namespace drawtypes {
|
||||
pbar->set_gradient(conf.get(section, name + "-gradient", true));
|
||||
pbar->set_colors(conf.get_list(section, name + "-foreground", {}));
|
||||
|
||||
icon_t icon_empty;
|
||||
icon_t icon_fill;
|
||||
icon_t icon_indicator;
|
||||
label_t icon_empty;
|
||||
label_t icon_fill;
|
||||
label_t icon_indicator;
|
||||
|
||||
if (format.find("%empty%") != string::npos) {
|
||||
icon_empty = load_icon(conf, section, name + "-empty");
|
||||
icon_empty = load_label(conf, section, name + "-empty");
|
||||
}
|
||||
if (format.find("%fill%") != string::npos) {
|
||||
icon_fill = load_icon(conf, section, name + "-fill");
|
||||
icon_fill = load_label(conf, section, name + "-fill");
|
||||
}
|
||||
if (format.find("%indicator%") != string::npos) {
|
||||
icon_indicator = load_icon(conf, section, name + "-indicator");
|
||||
icon_indicator = load_label(conf, section, name + "-indicator");
|
||||
}
|
||||
|
||||
// If a foreground/background color is defined for the indicator
|
||||
|
@ -5,15 +5,15 @@
|
||||
POLYBAR_NS
|
||||
|
||||
namespace drawtypes {
|
||||
void ramp::add(icon_t&& icon) {
|
||||
void ramp::add(label_t&& icon) {
|
||||
m_icons.emplace_back(forward<decltype(icon)>(icon));
|
||||
}
|
||||
|
||||
icon_t ramp::get(size_t index) {
|
||||
label_t ramp::get(size_t index) {
|
||||
return m_icons[index];
|
||||
}
|
||||
|
||||
icon_t ramp::get_by_percentage(float percentage) {
|
||||
label_t ramp::get_by_percentage(float percentage) {
|
||||
size_t index = percentage * m_icons.size() / 100.0f;
|
||||
return m_icons[math_util::cap<size_t>(index, 0, m_icons.size() - 1)];
|
||||
}
|
||||
@ -29,9 +29,9 @@ namespace drawtypes {
|
||||
ramp_t load_ramp(const config& conf, const string& section, string name, bool required) {
|
||||
name = string_util::ltrim(string_util::rtrim(move(name), '>'), '<');
|
||||
|
||||
auto ramp_defaults = load_optional_icon(conf, section, name);
|
||||
auto ramp_defaults = load_optional_label(conf, section, name);
|
||||
|
||||
vector<icon_t> vec;
|
||||
vector<label_t> vec;
|
||||
vector<string> icons;
|
||||
|
||||
if (required) {
|
||||
@ -41,7 +41,7 @@ namespace drawtypes {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < icons.size(); i++) {
|
||||
auto icon = load_optional_icon(conf, section, name + "-" + to_string(i), icons[i]);
|
||||
auto icon = load_optional_label(conf, section, name + "-" + to_string(i), icons[i]);
|
||||
icon->copy_undefined(ramp_defaults);
|
||||
vec.emplace_back(move(icon));
|
||||
}
|
||||
|
@ -59,45 +59,45 @@ namespace modules {
|
||||
m_icons = factory_util::shared<iconset>();
|
||||
|
||||
if (m_formatter->has(TAG_ICON_PLAY) || m_formatter->has(TAG_TOGGLE) || m_formatter->has(TAG_TOGGLE_STOP)) {
|
||||
m_icons->add("play", load_icon(m_conf, name(), TAG_ICON_PLAY));
|
||||
m_icons->add("play", load_label(m_conf, name(), TAG_ICON_PLAY));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_PAUSE) || m_formatter->has(TAG_TOGGLE)) {
|
||||
m_icons->add("pause", load_icon(m_conf, name(), TAG_ICON_PAUSE));
|
||||
m_icons->add("pause", load_label(m_conf, name(), TAG_ICON_PAUSE));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_STOP) || m_formatter->has(TAG_TOGGLE_STOP)) {
|
||||
m_icons->add("stop", load_icon(m_conf, name(), TAG_ICON_STOP));
|
||||
m_icons->add("stop", load_label(m_conf, name(), TAG_ICON_STOP));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_PREV)) {
|
||||
m_icons->add("prev", load_icon(m_conf, name(), TAG_ICON_PREV));
|
||||
m_icons->add("prev", load_label(m_conf, name(), TAG_ICON_PREV));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_NEXT)) {
|
||||
m_icons->add("next", load_icon(m_conf, name(), TAG_ICON_NEXT));
|
||||
m_icons->add("next", load_label(m_conf, name(), TAG_ICON_NEXT));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_SEEKB)) {
|
||||
m_icons->add("seekb", load_icon(m_conf, name(), TAG_ICON_SEEKB));
|
||||
m_icons->add("seekb", load_label(m_conf, name(), TAG_ICON_SEEKB));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_SEEKF)) {
|
||||
m_icons->add("seekf", load_icon(m_conf, name(), TAG_ICON_SEEKF));
|
||||
m_icons->add("seekf", load_label(m_conf, name(), TAG_ICON_SEEKF));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_RANDOM)) {
|
||||
m_icons->add("random", load_icon(m_conf, name(), TAG_ICON_RANDOM));
|
||||
m_icons->add("random", load_label(m_conf, name(), TAG_ICON_RANDOM));
|
||||
}
|
||||
if (m_formatter->has(TAG_ICON_REPEAT)) {
|
||||
m_icons->add("repeat", load_icon(m_conf, name(), TAG_ICON_REPEAT));
|
||||
m_icons->add("repeat", load_label(m_conf, name(), TAG_ICON_REPEAT));
|
||||
}
|
||||
|
||||
if (m_formatter->has(TAG_ICON_SINGLE)) {
|
||||
m_icons->add("single", load_icon(m_conf, name(), TAG_ICON_SINGLE));
|
||||
m_icons->add("single", load_label(m_conf, name(), TAG_ICON_SINGLE));
|
||||
}
|
||||
else if(m_formatter->has(TAG_ICON_REPEAT_ONE)){
|
||||
|
||||
m_conf.warn_deprecated(name(), "icon-repeatone", "icon-single");
|
||||
|
||||
m_icons->add("single", load_icon(m_conf, name(), TAG_ICON_REPEAT_ONE));
|
||||
m_icons->add("single", load_label(m_conf, name(), TAG_ICON_REPEAT_ONE));
|
||||
}
|
||||
|
||||
if (m_formatter->has(TAG_ICON_CONSUME)) {
|
||||
m_icons->add("consume", load_icon(m_conf, name(), TAG_ICON_CONSUME));
|
||||
m_icons->add("consume", load_label(m_conf, name(), TAG_ICON_CONSUME));
|
||||
}
|
||||
|
||||
if (m_formatter->has(TAG_LABEL_SONG)) {
|
||||
|
Loading…
Reference in New Issue
Block a user