Make high contrast colours configurable and split preferences dialogue

This commit is contained in:
Trevor SANDY 2021-01-25 13:35:04 +01:00
parent 512785de36
commit feeb034ff9
10 changed files with 150 additions and 41 deletions

View file

@ -60,6 +60,8 @@ void lcPreferences::LoadDefaults()
mDrawPreviewAxis = lcGetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES);
mStudColor = lcGetProfileInt(LC_PROFILE_STUD_COLOR);
mStudEdgeColor = lcGetProfileInt(LC_PROFILE_STUD_EDGE_COLOR);
mBlackEdgeColor = lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR);
mDarkEdgeColor = lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR);
mPartEdgeContrast = lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST);
mPartEdgeGamma = lcGetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA);
mPartColorValueLDIndex = lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX);
@ -111,6 +113,8 @@ void lcPreferences::SaveDefaults()
lcSetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES, mDrawPreviewAxis);
lcSetProfileInt(LC_PROFILE_STUD_COLOR, mStudColor);
lcSetProfileInt(LC_PROFILE_STUD_EDGE_COLOR, mStudEdgeColor);
lcSetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR, mBlackEdgeColor);
lcSetProfileInt(LC_PROFILE_DARK_EDGE_COLOR, mDarkEdgeColor);
lcSetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST, mPartEdgeContrast);
lcSetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA, mPartEdgeGamma);
lcSetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX, mPartColorValueLDIndex);
@ -1161,11 +1165,14 @@ void lcApplication::ShowPreferencesDialog()
bool AutomateEdgeColorChanged = Options.Preferences.mAutomateEdgeColor != bool(lcGetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR));
bool StudColorChanged = Options.Preferences.mStudColor != quint32(lcGetProfileInt(LC_PROFILE_STUD_COLOR));
bool StudEdgeColorChanged = Options.Preferences.mStudEdgeColor != quint32(lcGetProfileInt(LC_PROFILE_STUD_EDGE_COLOR));
bool BlackEdgeColorChanged = Options.Preferences.mBlackEdgeColor != quint32(lcGetProfileInt(LC_PROFILE_BLACK_EDGE_COLOR));
bool DarkEdgeColorChanged = Options.Preferences.mDarkEdgeColor != quint32(lcGetProfileInt(LC_PROFILE_DARK_EDGE_COLOR));
bool PartEdgeContrastChanged = Options.Preferences.mPartEdgeContrast != lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST);
bool PartEdgeGammaChanged = Options.Preferences.mPartEdgeGamma != lcGetProfileFloat(LC_PROFILE_PART_EDGE_GAMMA);
bool PartColorValueLDIndexChanged = Options.Preferences.mPartColorValueLDIndex != lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX);
if (!AutomateEdgeColorChanged)
AutomateEdgeColorChanged = (StudColorChanged || StudEdgeColorChanged || PartEdgeContrastChanged || PartEdgeGammaChanged || PartColorValueLDIndexChanged);
AutomateEdgeColorChanged = (StudColorChanged || StudEdgeColorChanged || BlackEdgeColorChanged || DarkEdgeColorChanged || PartEdgeContrastChanged || PartEdgeGammaChanged || PartColorValueLDIndexChanged);
mPreferences = Options.Preferences;

View file

@ -75,6 +75,8 @@ public:
quint32 mStudColor;
quint32 mStudEdgeColor;
quint32 mBlackEdgeColor;
quint32 mDarkEdgeColor;
float mPartEdgeContrast;
float mPartEdgeGamma;
float mPartColorValueLDIndex;

View file

@ -240,17 +240,28 @@ static void lcAdjustStudStyleColors(std::vector<lcColor>& Colors, lcStudStyle St
else if (StudStyle != lcStudStyle::HighContrast && StudStyle != lcStudStyle::HighContrastLogo)
return;
const lcVector4 Edge(LC_RGBA_RED(lcGetPreferences().mStudEdgeColor),
LC_RGBA_GREEN(lcGetPreferences().mStudEdgeColor),
LC_RGBA_BLUE(lcGetPreferences().mStudEdgeColor),
LC_RGBA_ALPHA(lcGetPreferences().mStudEdgeColor));
const lcVector4 DarkEdge(LC_RGBA_RED(lcGetPreferences().mDarkEdgeColor),
LC_RGBA_GREEN(lcGetPreferences().mDarkEdgeColor),
LC_RGBA_BLUE(lcGetPreferences().mDarkEdgeColor),
LC_RGBA_ALPHA(lcGetPreferences().mDarkEdgeColor));
const lcVector4 BlackEdge(LC_RGBA_RED(lcGetPreferences().mBlackEdgeColor),
LC_RGBA_GREEN(lcGetPreferences().mBlackEdgeColor),
LC_RGBA_BLUE(lcGetPreferences().mBlackEdgeColor),
LC_RGBA_ALPHA(lcGetPreferences().mBlackEdgeColor));
for (lcColor& Color : Colors)
{
const lcVector4 FillColor = Color.Value * 255.0f;
lcVector4 EdgeColor(0.0f, 0.0f, 0.0f, 255.0f);
if (30.0f * FillColor[0] + 59.0f * FillColor[1] + 11.0f * FillColor[2] <= 3600.0f)
EdgeColor = lcVector4(27.0f, 42.0f, 52.0f, 255.0f);
Color.Edge = DarkEdge / 255.0f;
else if (Color.Code == 0)
EdgeColor = lcVector4(255.0f, 255.0f, 255.0f, 255.0f);
Color.Edge = EdgeColor / 255.0f;
Color.Edge = BlackEdge / 255.0f;
else
Color.Edge = Edge / 255.0f;
}
}

View file

@ -3,11 +3,14 @@
#define MIN_GAMMA 1.0f
lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent, bool ShowHighContrastDialog)
:QDialog(Parent)
{
mStudColor = lcGetPreferences().mStudColor;
mStudEdgeColor = lcGetPreferences().mStudEdgeColor;
mBlackEdgeColor = lcGetPreferences().mBlackEdgeColor;
mDarkEdgeColor = lcGetPreferences().mDarkEdgeColor;
mPartEdgeContrast = lcGetPreferences().mPartEdgeContrast;
mPartEdgeGamma = lcGetPreferences().mPartEdgeGamma;
mPartColorValueLDIndex = lcGetPreferences().mPartColorValueLDIndex;
@ -16,6 +19,7 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
QVBoxLayout* MainLayout = new QVBoxLayout(this);
QGroupBox* EdgeSettingsBox = new QGroupBox(tr("Edge Colors"), this);
EdgeSettingsBox->setVisible(!ShowHighContrastDialog);
MainLayout->addWidget(EdgeSettingsBox);
QGridLayout* EdgeSettingsLayout = new QGridLayout(EdgeSettingsBox);
EdgeSettingsBox->setLayout(EdgeSettingsLayout);
@ -60,6 +64,7 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
EdgeSettingsLayout->addWidget(PartColorValueLDIndex,2,2);
QGroupBox* StudColorBox = new QGroupBox(tr("High Contrast Studs"), this);
StudColorBox->setVisible(ShowHighContrastDialog);
MainLayout->addWidget(StudColorBox);
QGridLayout* StudColorLayout = new QGridLayout(StudColorBox);
StudColorBox->setLayout(StudColorLayout);
@ -101,6 +106,34 @@ lcAutomateEdgeColorDialog::lcAutomateEdgeColorDialog(QWidget* Parent)
StudColorLayout->addWidget(StudEdgeColorButton,1,1);
StudColorLayout->addWidget(ResetStudEdgeColorButton,1,2);
QLabel* BlackEdgeColorLabel = new QLabel(tr("Black Parts Edge Color:"), this);
BlackEdgeColorButton = new QToolButton(this);
SetButtonPixmap(mBlackEdgeColor, BlackEdgeColorButton);
connect(BlackEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetBlackEdgeColorButton = new QToolButton(this);
ResetBlackEdgeColorButton->setText(tr("..."));
ResetBlackEdgeColorButton->setToolTip(tr("Reset"));
connect(ResetBlackEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
StudColorLayout->addWidget(BlackEdgeColorLabel,2,0);
StudColorLayout->addWidget(BlackEdgeColorButton,2,1);
StudColorLayout->addWidget(ResetBlackEdgeColorButton,2,2);
QLabel* DarkEdgeColorLabel = new QLabel(tr("Dark Parts Edge Color:"), this);
DarkEdgeColorButton = new QToolButton(this);
SetButtonPixmap(mDarkEdgeColor, DarkEdgeColorButton);
connect(DarkEdgeColorButton, SIGNAL(clicked()), this, SLOT(ColorButtonClicked()));
ResetDarkEdgeColorButton = new QToolButton(this);
ResetDarkEdgeColorButton->setText(tr("..."));
ResetDarkEdgeColorButton->setToolTip(tr("Reset"));
connect(ResetDarkEdgeColorButton, SIGNAL(clicked()), this, SLOT(ResetColorButtonClicked()));
StudColorLayout->addWidget(DarkEdgeColorLabel,3,0);
StudColorLayout->addWidget(DarkEdgeColorButton,3,1);
StudColorLayout->addWidget(ResetDarkEdgeColorButton,3,2);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
MainLayout->addWidget(buttonBox);
QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
@ -145,6 +178,16 @@ void lcAutomateEdgeColorDialog::ColorButtonClicked()
Title = tr("Select Stud Edge Color");
Color = &mStudEdgeColor;
}
else if (Button == BlackEdgeColorButton)
{
Title = tr("Select Black Edge Color");
Color = &mBlackEdgeColor;
}
else if (Button == DarkEdgeColorButton)
{
Title = tr("Select Dark Edge Color");
Color = &mDarkEdgeColor;
}
else
return;
@ -172,7 +215,7 @@ void lcAutomateEdgeColorDialog::ResetColorButtonClicked()
if (sender() == StudColorButton)
{
Color = &mStudColor;
*Color = LC_RGBA(27, 42, 52, 255);
*Color = LC_RGBA(27, 42, 52, 255);
ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
Pix.fill(ResetColor);
StudColorButton->setIcon(Pix);
@ -181,10 +224,28 @@ void lcAutomateEdgeColorDialog::ResetColorButtonClicked()
else if (sender() == StudEdgeColorButton)
{
Color = &mStudEdgeColor;
*Color = LC_RGBA(0, 0, 0, 255);
*Color = LC_RGBA(0, 0, 0, 255);
ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
Pix.fill(ResetColor);
StudEdgeColorButton->setIcon(Pix);
StudEdgeColorButton->setToolTip(ResetColor.name().toUpper());
}
else if (sender() == BlackEdgeColorButton)
{
Color = &mBlackEdgeColor;
*Color = LC_RGBA(0, 0, 0, 255);
ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
Pix.fill(ResetColor);
BlackEdgeColorButton->setIcon(Pix);
BlackEdgeColorButton->setToolTip(ResetColor.name().toUpper());
}
else if (sender() == DarkEdgeColorButton)
{
Color = &mDarkEdgeColor;
*Color = LC_RGBA(27, 42, 52, 255);
ResetColor = QColor(LC_RGBA_RED(*Color), LC_RGBA_GREEN(*Color), LC_RGBA_BLUE(*Color), LC_RGBA_ALPHA(*Color));
Pix.fill(ResetColor);
DarkEdgeColorButton->setIcon(Pix);
DarkEdgeColorButton->setToolTip(ResetColor.name().toUpper());
}
}

View file

@ -6,9 +6,11 @@ class lcAutomateEdgeColorDialog : public QDialog
{
Q_OBJECT
public:
lcAutomateEdgeColorDialog(QWidget *Parent);
lcAutomateEdgeColorDialog(QWidget *Parent, bool ShowHighContrastDialog);
quint32 mStudColor;
quint32 mStudEdgeColor;
quint32 mDarkEdgeColor;
quint32 mBlackEdgeColor;
float mPartEdgeContrast;
float mPartEdgeGamma;
float mPartColorValueLDIndex;
@ -23,13 +25,18 @@ protected:
QSlider* PartColorValueLDIndexSlider;
QSlider* PartEdgeContrastSlider;
QToolButton* StudColorButton;
QToolButton* StudEdgeColorButton;
QToolButton* ResetStudColorButton;
QToolButton* ResetStudEdgeColorButton;
QLabel* PartEdgeContrast;
QLabel* PartEdgeGamma;
QLabel* PartColorValueLDIndex;
QToolButton* StudColorButton;
QToolButton* StudEdgeColorButton;
QToolButton* BlackEdgeColorButton;
QToolButton* DarkEdgeColorButton;
QToolButton* ResetStudColorButton;
QToolButton* ResetStudEdgeColorButton;
QToolButton* ResetBlackEdgeColorButton;
QToolButton* ResetDarkEdgeColorButton;
};

View file

@ -142,9 +142,11 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
lcProfileEntry("Settings", "StudColor", LC_RGBA(27, 42, 52, 255)), // LC_PROFILE_STUD_COLOR
lcProfileEntry("Settings", "StudEdgeColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_STUD_EDGE_COLOR
lcProfileEntry("Settings", "PartEdgeContrast", 0.50f), // LC_PROFILE_PART_EDGE_CONTRAST
lcProfileEntry("Settings", "PartEdgeGamma", 2.20f), // LC_PROFILE_PART_EDGE_GAMMA
lcProfileEntry("Settings", "PartColorValueLDIndex", 0.50f), // LC_PROFILE_PART_COLOR_VALUE_LD_INDEX
lcProfileEntry("Settings", "BlackEdgeColor", LC_RGBA(255, 255, 255, 255)), // LC_PROFILE_BLACK_EDGE_COLOR
lcProfileEntry("Settings", "DarkEdgeColor", LC_RGBA(27, 42, 52, 255)), // LC_PROFILE_DARK_EDGE_COLOR
lcProfileEntry("Settings", "PartEdgeContrast", 0.5f), // LC_PROFILE_PART_EDGE_CONTRAST
lcProfileEntry("Settings", "PartEdgeGamma", 1.8f), // LC_PROFILE_PART_EDGE_GAMMA
lcProfileEntry("Settings", "mPartColorValueLDIndex", 0.5f), // LC_PROFILE_PART_COLOR_VALUE_LD_INDEX
lcProfileEntry("Settings", "AutomateEdgeColor", 0) // LC_PROFILE_AUTOMATE_EDGE_COLOR
};

View file

@ -90,6 +90,8 @@ enum LC_PROFILE_KEY
LC_PROFILE_STUD_COLOR,
LC_PROFILE_STUD_EDGE_COLOR,
LC_PROFILE_BLACK_EDGE_COLOR,
LC_PROFILE_DARK_EDGE_COLOR,
LC_PROFILE_PART_EDGE_CONTRAST,
LC_PROFILE_PART_EDGE_GAMMA,
LC_PROFILE_PART_COLOR_VALUE_LD_INDEX,

View file

@ -47,6 +47,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
ui->shortcutEdit->installEventFilter(this);
connect(ui->commandList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(commandChanged(QTreeWidgetItem*)));
connect(ui->mouseTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(MouseTreeItemChanged(QTreeWidgetItem*)));
connect(ui->HighContrastButton, SIGNAL(clicked()), this, SLOT(AutomateEdgeColor()));
connect(ui->AutomateEdgeColorButton, SIGNAL(clicked()), this, SLOT(AutomateEdgeColor()));
ui->partsLibrary->setText(mOptions->LibraryPath);
@ -557,13 +558,20 @@ void lcQPreferencesDialog::on_AutomateEdgeColor_toggled()
ui->AutomateEdgeColorButton->setEnabled(ui->AutomateEdgeColor->isChecked());
}
void lcQPreferencesDialog::on_studStyleCombo_currentIndexChanged(int index)
{
ui->HighContrastButton->setEnabled(index > static_cast<int>(lcStudStyle::FlattenedLogo));
}
void lcQPreferencesDialog::AutomateEdgeColor()
{
lcAutomateEdgeColorDialog Dialog(this);
lcAutomateEdgeColorDialog Dialog(this, sender() == ui->HighContrastButton);
if (Dialog.exec() == QDialog::Accepted)
{
mOptions->Preferences.mStudColor = Dialog.mStudColor;
mOptions->Preferences.mStudEdgeColor = Dialog.mStudEdgeColor;
mOptions->Preferences.mBlackEdgeColor = Dialog.mBlackEdgeColor;
mOptions->Preferences.mDarkEdgeColor = Dialog.mDarkEdgeColor;
mOptions->Preferences.mPartEdgeContrast = Dialog.mPartEdgeContrast;
mOptions->Preferences.mPartEdgeGamma = Dialog.mPartEdgeGamma;
mOptions->Preferences.mPartColorValueLDIndex = Dialog.mPartColorValueLDIndex;

View file

@ -67,6 +67,7 @@ public slots:
void ColorButtonClicked();
void AutomateEdgeColor();
void on_AutomateEdgeColor_toggled();
void on_studStyleCombo_currentIndexChanged(int index);
void on_antiAliasing_toggled();
void on_edgeLines_toggled();
void on_LineWidthSlider_valueChanged();

View file

@ -402,25 +402,6 @@
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<widget class="QComboBox" name="ShadingMode">
<item>
<property name="text">
<string>Wireframe</string>
</property>
</item>
<item>
<property name="text">
<string>Flat Shading</string>
</property>
</item>
<item>
<property name="text">
<string>Default Lights</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="MeshLODSlider">
<property name="sizePolicy">
@ -547,10 +528,36 @@
<item row="7" column="0">
<widget class="QCheckBox" name="AutomateEdgeColor">
<property name="text">
<string>Automate edge color:</string>
<string>Automate edge color</string>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QToolButton" name="HighContrastButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QComboBox" name="ShadingMode">
<item>
<property name="text">
<string>Wireframe</string>
</property>
</item>
<item>
<property name="text">
<string>Flat Shading</string>
</property>
</item>
<item>
<property name="text">
<string>Default Lights</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
@ -1733,6 +1740,7 @@
<tabstop>HighlightNewParts</tabstop>
<tabstop>HighlightNewPartsColor</tabstop>
<tabstop>studStyleCombo</tabstop>
<tabstop>HighContrastButton</tabstop>
<tabstop>ShadingMode</tabstop>
<tabstop>ViewSphereSizeCombo</tabstop>
<tabstop>ViewSphereLocationCombo</tabstop>
@ -1745,8 +1753,8 @@
<tabstop>PreviewViewSphereLocationCombo</tabstop>
<tabstop>PreviewAxisIconCheckBox</tabstop>
<tabstop>BackgroundSolidRadio</tabstop>
<tabstop>BackgroundGradientRadio</tabstop>
<tabstop>BackgroundSolidColorButton</tabstop>
<tabstop>BackgroundGradientRadio</tabstop>
<tabstop>BackgroundGradient1ColorButton</tabstop>
<tabstop>BackgroundGradient2ColorButton</tabstop>
<tabstop>ActiveViewColorButton</tabstop>