2022-11-26 18:56:43 +01:00
|
|
|
#pragma once
|
|
|
|
#include "../defines.hpp"
|
2024-06-11 17:17:45 +02:00
|
|
|
#include "../helpers/varlist/VarList.hpp"
|
2022-12-16 18:17:31 +01:00
|
|
|
#include <vector>
|
2022-11-26 18:56:43 +01:00
|
|
|
|
2023-05-31 15:55:54 +02:00
|
|
|
enum eConfigValueDataTypes {
|
2024-02-21 12:07:39 +01:00
|
|
|
CVD_TYPE_INVALID = -1,
|
|
|
|
CVD_TYPE_GRADIENT = 0,
|
|
|
|
CVD_TYPE_CSS_VALUE = 1
|
2022-11-26 18:56:43 +01:00
|
|
|
};
|
|
|
|
|
2023-08-07 13:35:19 +02:00
|
|
|
class ICustomConfigValueData {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-11-26 18:56:43 +01:00
|
|
|
virtual ~ICustomConfigValueData() = 0;
|
|
|
|
|
|
|
|
virtual eConfigValueDataTypes getDataType() = 0;
|
2024-03-04 11:36:32 +01:00
|
|
|
|
|
|
|
virtual std::string toString() = 0;
|
2022-11-26 18:56:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGradientValueData : public ICustomConfigValueData {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2024-07-13 12:36:29 +02:00
|
|
|
CGradientValueData() {};
|
2022-11-26 18:56:43 +01:00
|
|
|
CGradientValueData(CColor col) {
|
2023-01-05 19:25:45 +01:00
|
|
|
m_vColors.push_back(col);
|
2022-11-26 18:56:43 +01:00
|
|
|
};
|
2024-07-13 12:36:29 +02:00
|
|
|
virtual ~CGradientValueData() {};
|
2022-11-26 18:56:43 +01:00
|
|
|
|
|
|
|
virtual eConfigValueDataTypes getDataType() {
|
|
|
|
return CVD_TYPE_GRADIENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset(CColor col) {
|
|
|
|
m_vColors.clear();
|
2023-01-05 19:25:45 +01:00
|
|
|
m_vColors.emplace_back(col);
|
2022-11-26 18:56:43 +01:00
|
|
|
m_fAngle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vector containing the colors */
|
|
|
|
std::vector<CColor> m_vColors;
|
|
|
|
|
|
|
|
/* Float corresponding to the angle (rad) */
|
2022-12-16 18:17:31 +01:00
|
|
|
float m_fAngle = 0;
|
2022-11-26 18:56:43 +01:00
|
|
|
|
2023-05-31 15:55:54 +02:00
|
|
|
//
|
|
|
|
bool operator==(const CGradientValueData& other) const {
|
2023-02-01 22:06:01 +01:00
|
|
|
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
|
2022-11-26 18:56:43 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < m_vColors.size(); ++i)
|
2022-12-16 18:17:31 +01:00
|
|
|
if (m_vColors[i] != other.m_vColors[i])
|
|
|
|
return false;
|
2022-11-26 18:56:43 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2024-03-04 11:36:32 +01:00
|
|
|
|
|
|
|
virtual std::string toString() {
|
|
|
|
std::string result;
|
|
|
|
for (auto& c : m_vColors) {
|
|
|
|
result += std::format("{:x} ", c.getAsHex());
|
|
|
|
}
|
|
|
|
|
|
|
|
result += std::format("{}deg", (int)(m_fAngle * 180.0 / M_PI));
|
2024-03-22 18:34:51 +01:00
|
|
|
return result;
|
2024-03-04 11:36:32 +01:00
|
|
|
}
|
2023-02-01 22:06:01 +01:00
|
|
|
};
|
2024-02-21 12:07:39 +01:00
|
|
|
|
|
|
|
class CCssGapData : public ICustomConfigValueData {
|
|
|
|
public:
|
2024-07-13 12:36:29 +02:00
|
|
|
CCssGapData() : top(0), right(0), bottom(0), left(0) {};
|
|
|
|
CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global) {};
|
|
|
|
CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal) {};
|
|
|
|
CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal) {};
|
|
|
|
CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left) {};
|
2024-02-21 12:07:39 +01:00
|
|
|
|
|
|
|
/* Css like directions */
|
|
|
|
int64_t top;
|
|
|
|
int64_t right;
|
|
|
|
int64_t bottom;
|
|
|
|
int64_t left;
|
|
|
|
|
|
|
|
void parseGapData(CVarList varlist) {
|
|
|
|
switch (varlist.size()) {
|
|
|
|
case 1: {
|
|
|
|
*this = CCssGapData(std::stoi(varlist[0]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
|
|
|
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]), std::stoi(varlist[2]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4: {
|
|
|
|
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]), std::stoi(varlist[2]), std::stoi(varlist[3]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
Debug::log(WARN, "Too many arguments provided for gaps.");
|
|
|
|
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]), std::stoi(varlist[2]), std::stoi(varlist[3]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset(int64_t global) {
|
|
|
|
top = global;
|
|
|
|
right = global;
|
|
|
|
bottom = global;
|
|
|
|
left = global;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual eConfigValueDataTypes getDataType() {
|
|
|
|
return CVD_TYPE_CSS_VALUE;
|
|
|
|
}
|
2024-03-04 11:36:32 +01:00
|
|
|
|
|
|
|
virtual std::string toString() {
|
|
|
|
return std::format("{} {} {} {}", top, right, bottom, left);
|
|
|
|
}
|
2024-02-21 12:07:39 +01:00
|
|
|
};
|