diff --git a/common/lc_application.cpp b/common/lc_application.cpp index b3a735ae..f406f68c 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -624,7 +624,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions() { if (ParseColor(Options.StudCylinderColor)) { - if (Options.StudStyle < lcStudStyle::HighContrast) + if (!lcIsHighContrast(Options.StudStyle)) { Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option); Options.ParseOK = false; @@ -635,7 +635,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions() { if (ParseColor(Options.PartEdgeColor)) { - if (Options.StudStyle < lcStudStyle::HighContrast) + if (!lcIsHighContrast(Options.StudStyle)) { Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option); Options.ParseOK = false; @@ -646,7 +646,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions() { if (ParseColor(Options.BlackEdgeColor)) { - if (Options.StudStyle < lcStudStyle::HighContrast) + if (!lcIsHighContrast(Options.StudStyle)) { Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option); Options.ParseOK = false; @@ -657,7 +657,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions() { if (ParseColor(Options.DarkEdgeColor)) { - if (Options.StudStyle < lcStudStyle::HighContrast) + if (!lcIsHighContrast(Options.StudStyle)) { Options.StdErr += tr("High contrast stud style is required for the '%1' option but is not enabled.\n").arg(Option); Options.ParseOK = false; @@ -834,7 +834,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions() } } - if (Options.AutomateEdgeColor && Options.StudStyle > lcStudStyle::FlattenedLogo) + if (Options.AutomateEdgeColor && lcIsHighContrast(Options.StudStyle)) { Options.StdErr += tr("Automate edge color and high contrast stud style cannot be enabled at the same time.\n"); Options.ParseOK = false; diff --git a/common/lc_colors.cpp b/common/lc_colors.cpp index 175a4ba0..3244fd80 100644 --- a/common/lc_colors.cpp +++ b/common/lc_colors.cpp @@ -213,7 +213,8 @@ int lcGetBrickLinkColor(int ColorIndex) static void lcAdjustStudStyleColors(std::vector& Colors, lcStudStyle StudStyle) { const lcPreferences& Preferences = lcGetPreferences(); - if (!Preferences.mAutomateEdgeColor && StudStyle != lcStudStyle::HighContrast && StudStyle != lcStudStyle::HighContrastLogo) + + if (!Preferences.mAutomateEdgeColor && !lcIsHighContrast(StudStyle)) return; const float LDIndex = LC_SRGB_TO_LINEAR(Preferences.mPartColorValueLDIndex); @@ -223,7 +224,7 @@ static void lcAdjustStudStyleColors(std::vector& Colors, lcStudStyle St for (lcColor& Color : Colors) { - float ValueLuminescence = lcLuminescenceFromRGBA(Color.Value); + float ValueLuminescence = lcLuminescenceFromSRGB(Color.Value); if (Preferences.mAutomateEdgeColor) { diff --git a/common/lc_library.h b/common/lc_library.h index 47716b57..670dd3cd 100644 --- a/common/lc_library.h +++ b/common/lc_library.h @@ -23,6 +23,11 @@ enum class lcStudStyle Count }; +inline bool lcIsHighContrast(lcStudStyle StudStyle) +{ + return StudStyle == lcStudStyle::HighContrast || StudStyle == lcStudStyle::HighContrastLogo; +} + enum class lcZipFileType { Official, diff --git a/common/lc_math.h b/common/lc_math.h index 3fd0f977..2dfddea4 100644 --- a/common/lc_math.h +++ b/common/lc_math.h @@ -651,7 +651,7 @@ inline quint32 lcColorFromVector3(const lcVector3& Color) return LC_RGB(Color[0] * 255, Color[1] * 255, Color[2] * 255); } -inline float lcLuminescenceFromRGBA(lcVector4& Value) +inline float lcLuminescenceFromSRGB(lcVector4& Value) { float r = LC_SRGB_TO_LINEAR(Value[0]); float g = LC_SRGB_TO_LINEAR(Value[1]); diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index 786fa5df..6814e552 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -561,7 +561,7 @@ void lcQPreferencesDialog::on_AutomateEdgeColor_toggled() void lcQPreferencesDialog::on_studStyleCombo_currentIndexChanged(int index) { - ui->HighContrastButton->setEnabled(index > static_cast(lcStudStyle::FlattenedLogo)); + ui->HighContrastButton->setEnabled(lcIsHighContrast(static_cast(index))); } void lcQPreferencesDialog::AutomateEdgeColor()