summaryrefslogtreecommitdiff
path: root/src/config/ConfigDataValues.hpp
diff options
context:
space:
mode:
authorM Matthew Hydock <mhydock@yahoo.com>2025-04-24 14:48:08 -0400
committerGitHub <noreply@github.com>2025-04-24 20:48:08 +0200
commitbe6268a7ecea2ad50cdb78fb661884811a8a28e8 (patch)
treeac5846bc109796f84c1d0abe095286de96a5967d /src/config/ConfigDataValues.hpp
parenta9549dbca060b65ae6ec50f9bc68cdf1823d6cbe (diff)
groupbar: Add options for setting group bar title font weight (and indicator gap) (#9617)
Diffstat (limited to 'src/config/ConfigDataValues.hpp')
-rw-r--r--src/config/ConfigDataValues.hpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/config/ConfigDataValues.hpp b/src/config/ConfigDataValues.hpp
index 270f6880..2fad9277 100644
--- a/src/config/ConfigDataValues.hpp
+++ b/src/config/ConfigDataValues.hpp
@@ -2,11 +2,13 @@
#include "../defines.hpp"
#include "../helpers/varlist/VarList.hpp"
#include <vector>
+#include <map>
enum eConfigValueDataTypes : int8_t {
- CVD_TYPE_INVALID = -1,
- CVD_TYPE_GRADIENT = 0,
- CVD_TYPE_CSS_VALUE = 1
+ CVD_TYPE_INVALID = -1,
+ CVD_TYPE_GRADIENT = 0,
+ CVD_TYPE_CSS_VALUE = 1,
+ CVD_TYPE_FONT_WEIGHT = 2,
};
class ICustomConfigValueData {
@@ -136,3 +138,41 @@ class CCssGapData : public ICustomConfigValueData {
return std::format("{} {} {} {}", m_top, m_right, m_bottom, m_left);
}
};
+
+class CFontWeightConfigValueData : public ICustomConfigValueData {
+ public:
+ CFontWeightConfigValueData() = default;
+ CFontWeightConfigValueData(const char* weight) {
+ parseWeight(weight);
+ }
+
+ int64_t m_value = 400; // default to normal weight
+
+ virtual eConfigValueDataTypes getDataType() {
+ return CVD_TYPE_FONT_WEIGHT;
+ }
+
+ virtual std::string toString() {
+ return std::format("{}", m_value);
+ }
+
+ void parseWeight(const std::string& strWeight) {
+ auto lcWeight{strWeight};
+ transform(strWeight.begin(), strWeight.end(), lcWeight.begin(), ::tolower);
+
+ // values taken from Pango weight enums
+ const auto WEIGHTS = std::map<std::string, int>{
+ {"thin", 100}, {"ultralight", 200}, {"light", 300}, {"semilight", 350}, {"book", 380}, {"normal", 400},
+ {"medium", 500}, {"semibold", 600}, {"bold", 700}, {"ultrabold", 800}, {"heavy", 900}, {"ultraheavy", 1000},
+ };
+
+ auto weight = WEIGHTS.find(lcWeight);
+ if (weight != WEIGHTS.end())
+ m_value = weight->second;
+ else {
+ int w_i = std::stoi(strWeight);
+ if (w_i < 100 || w_i > 1000)
+ m_value = 400;
+ }
+ }
+};