core: move colorspace handling to oklab (#8635)
* Meson: add hyprgraphics * Nix: add hyprgraphics * CI/setup_base: get hyprgraphics-git --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
92186898c0
commit
320144ae72
40 changed files with 492 additions and 173 deletions
|
|
@ -21,8 +21,9 @@ class ICustomConfigValueData {
|
|||
class CGradientValueData : public ICustomConfigValueData {
|
||||
public:
|
||||
CGradientValueData() {};
|
||||
CGradientValueData(CColor col) {
|
||||
CGradientValueData(CHyprColor col) {
|
||||
m_vColors.push_back(col);
|
||||
updateColorsOk();
|
||||
};
|
||||
virtual ~CGradientValueData() {};
|
||||
|
||||
|
|
@ -30,14 +31,29 @@ class CGradientValueData : public ICustomConfigValueData {
|
|||
return CVD_TYPE_GRADIENT;
|
||||
}
|
||||
|
||||
void reset(CColor col) {
|
||||
void reset(CHyprColor col) {
|
||||
m_vColors.clear();
|
||||
m_vColors.emplace_back(col);
|
||||
m_fAngle = 0;
|
||||
updateColorsOk();
|
||||
}
|
||||
|
||||
void updateColorsOk() {
|
||||
m_vColorsOkLabA.clear();
|
||||
for (auto& c : m_vColors) {
|
||||
const auto OKLAB = c.asOkLab();
|
||||
m_vColorsOkLabA.emplace_back(OKLAB.l);
|
||||
m_vColorsOkLabA.emplace_back(OKLAB.a);
|
||||
m_vColorsOkLabA.emplace_back(OKLAB.b);
|
||||
m_vColorsOkLabA.emplace_back(c.a);
|
||||
}
|
||||
}
|
||||
|
||||
/* Vector containing the colors */
|
||||
std::vector<CColor> m_vColors;
|
||||
std::vector<CHyprColor> m_vColors;
|
||||
|
||||
/* Vector containing pure colors for shoving into opengl */
|
||||
std::vector<float> m_vColorsOkLabA;
|
||||
|
||||
/* Float corresponding to the angle (rad) */
|
||||
float m_fAngle = 0;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
|
|||
const auto COL = configStringToInt(var);
|
||||
if (!COL)
|
||||
throw std::runtime_error(std::format("failed to parse {} as a color", var));
|
||||
DATA->m_vColors.push_back(CColor(COL.value()));
|
||||
DATA->m_vColors.push_back(CHyprColor(COL.value()));
|
||||
} catch (std::exception& e) {
|
||||
Debug::log(WARN, "Error parsing gradient {}", V);
|
||||
parseError = "Error parsing gradient " + V + ": " + e.what();
|
||||
|
|
@ -85,6 +85,8 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
|
|||
DATA->m_vColors.push_back(0); // transparent
|
||||
}
|
||||
|
||||
DATA->updateColorsOk();
|
||||
|
||||
Hyprlang::CParseResult result;
|
||||
if (!parseError.empty())
|
||||
result.setError(parseError.c_str());
|
||||
|
|
@ -676,7 +678,7 @@ CConfigManager::CConfigManager() {
|
|||
Debug::disableTime = reinterpret_cast<int64_t* const*>(m_pConfig->getConfigValuePtr("debug:disable_time")->getDataStaticPtr());
|
||||
|
||||
if (ERR.has_value())
|
||||
g_pHyprError->queueCreate(ERR.value(), CColor{1.0, 0.1, 0.1, 1.0});
|
||||
g_pHyprError->queueCreate(ERR.value(), CHyprColor{1.0, 0.1, 0.1, 1.0});
|
||||
}
|
||||
|
||||
std::optional<std::string> CConfigManager::generateConfig(std::string configPath) {
|
||||
|
|
@ -883,14 +885,14 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
|
|||
m_szConfigErrors = "";
|
||||
|
||||
if (result.error && !std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:suppress_errors")))
|
||||
g_pHyprError->queueCreate(result.getError(), CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
g_pHyprError->queueCreate(result.getError(), CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
else if (std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("autogenerated")) == 1)
|
||||
g_pHyprError->queueCreate(
|
||||
"Warning: You're using an autogenerated config! (config file: " + getMainConfigPath() +
|
||||
" )\nSUPER+Q -> kitty (if it doesn't launch, make sure it's installed or choose a different terminal in the config)\nSUPER+M -> exit Hyprland",
|
||||
CColor(1.0, 1.0, 70.0 / 255.0, 1.0));
|
||||
CHyprColor(1.0, 1.0, 70.0 / 255.0, 1.0));
|
||||
else if (*PENABLEEXPLICIT != prevEnabledExplicit)
|
||||
g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CColor(0.9, 0.76, 0.221, 1.0));
|
||||
g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CHyprColor(0.9, 0.76, 0.221, 1.0));
|
||||
else
|
||||
g_pHyprError->destroy();
|
||||
|
||||
|
|
@ -948,7 +950,8 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
|
|||
// manual crash
|
||||
if (std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash")) && !m_bManualCrashInitiated) {
|
||||
m_bManualCrashInitiated = true;
|
||||
g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CColor(0), 5000, ICON_INFO);
|
||||
g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CHyprColor(0), 5000,
|
||||
ICON_INFO);
|
||||
} else if (m_bManualCrashInitiated && !std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash"))) {
|
||||
// cowabunga it is
|
||||
g_pHyprRenderer->initiateManualCrash();
|
||||
|
|
@ -1015,7 +1018,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
|||
|
||||
if (COMMAND.contains("explicit")) {
|
||||
if (*PENABLEEXPLICIT != prevEnabledExplicit)
|
||||
g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CColor(0.9, 0.76, 0.221, 1.0));
|
||||
g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CHyprColor(0.9, 0.76, 0.221, 1.0));
|
||||
else
|
||||
g_pHyprError->destroy();
|
||||
}
|
||||
|
|
@ -1027,7 +1030,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
|||
if (std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash")) && !m_bManualCrashInitiated) {
|
||||
m_bManualCrashInitiated = true;
|
||||
if (g_pHyprNotificationOverlay) {
|
||||
g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CColor(0), 5000,
|
||||
g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CHyprColor(0), 5000,
|
||||
ICON_INFO);
|
||||
}
|
||||
} else if (m_bManualCrashInitiated && !std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash"))) {
|
||||
|
|
@ -1671,7 +1674,7 @@ SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std::
|
|||
}
|
||||
|
||||
void CConfigManager::addParseError(const std::string& err) {
|
||||
g_pHyprError->queueCreate(err + "\nHyprland may not work correctly.", CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
g_pHyprError->queueCreate(err + "\nHyprland may not work correctly.", CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
}
|
||||
|
||||
PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
|
||||
|
|
@ -1716,7 +1719,7 @@ void CConfigManager::handlePluginLoads() {
|
|||
error << "\n" << path;
|
||||
}
|
||||
|
||||
g_pHyprError->queueCreate(error.str(), CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
g_pHyprError->queueCreate(error.str(), CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
|
||||
}
|
||||
|
||||
if (pluginsChanged) {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ struct SConfigOptionDescription {
|
|||
};
|
||||
|
||||
struct SColorData {
|
||||
CColor color;
|
||||
CHyprColor color;
|
||||
};
|
||||
|
||||
struct SChoiceData {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue