commit
e730105950
|
@ -31,7 +31,7 @@ class ALabel : public IModule {
|
||||||
|
|
||||||
virtual bool handleToggle(GdkEventButton *const &ev);
|
virtual bool handleToggle(GdkEventButton *const &ev);
|
||||||
virtual bool handleScroll(GdkEventScroll *);
|
virtual bool handleScroll(GdkEventScroll *);
|
||||||
virtual std::string getState(uint8_t value, bool reverse = false);
|
virtual std::string getState(uint8_t value, bool lesser = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> pid_;
|
std::vector<int> pid_;
|
||||||
|
|
|
@ -129,7 +129,7 @@ std::string waybar::ALabel::getIcon(uint16_t percentage, const std::string& alt,
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string waybar::ALabel::getState(uint8_t value, bool reverse) {
|
std::string waybar::ALabel::getState(uint8_t value, bool lesser) {
|
||||||
if (!config_["states"].isObject()) {
|
if (!config_["states"].isObject()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -143,12 +143,12 @@ std::string waybar::ALabel::getState(uint8_t value, bool reverse) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort states
|
// Sort states
|
||||||
std::sort(states.begin(), states.end(), [&reverse](auto& a, auto& b) {
|
std::sort(states.begin(), states.end(), [&lesser](auto& a, auto& b) {
|
||||||
return reverse ? a.second < b.second : a.second > b.second;
|
return lesser ? a.second < b.second : a.second > b.second;
|
||||||
});
|
});
|
||||||
std::string valid_state;
|
std::string valid_state;
|
||||||
for (auto const& state : states) {
|
for (auto const& state : states) {
|
||||||
if (value <= state.second && valid_state.empty()) {
|
if ((lesser ? value <= state.second : value >= state.second) && valid_state.empty()) {
|
||||||
label_.get_style_context()->add_class(state.first);
|
label_.get_style_context()->add_class(state.first);
|
||||||
valid_state = state.first;
|
valid_state = state.first;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue