--User changes

-Give tabs a height of 4px in the qss files. Looks a little large on 4k screens, but just right on HD screens which are much more common.
 -Allow for styling of zero and non-zero variation tree nodes via qss.
 -Allow for toggling whether to interpolate between colors in the palette editor, or to do hard cuts between colors.
 -Allow for adjusting spinner values with the + = or up arrow keys to increase, and - _ or down arrow keys to decrease.
 -Allow for responding to global presses of + = and - _ to cycle up or down to specify which xform is set as the current one.
 -Allow for adding "layers" via xaos which will add a user-specified number of xforms, and set certain xaos values to 0 or 1.
 -Add a new menu item under the Edit menu to copy the OpenCL iteration kernel source to the clipboard.
 -Show text on the status bar which indicates that an OpenCL kernel compilation is taking place.
 -Show xform name on xform combo box when expanded. Adjust size to fit all names.
 -Draw post affine circles using dashed lines.
 -Prevent QSS dialog from styling its editor, which makes it easier to see text when creating styles which have custom colors for text boxes.

--Bug fixes
 -Fix up some table layouts which seemed to have regressed/decayed over time for reasons unknown.
 -Using undo/redo would create a new flame in the library every time.
 -Solo was not being preserved when using undo/redo.

--Code changes
 -Make the solo flag be a part of the flame data now.
 -Fix some tabification in the OpenCL code for EllipticVariation.
 -Fix tabification in the varState code for OpenCL.
 -Add an event called m_CompileBegun to RendererCL that is called right before an OpenCL compile is begun.
 --This required making RendererCLBase not a pure virtual base class. Member functions just return defaults.
 -Filter key presses on main window to only process the third one. This is due to Qt triggering three events for every key press.
 -The palette preview table was installing an event filter for seemingly no reason. Remove it.
 -Mark certain virtual functions as override in SpinBox and DoubleSpinBox.
This commit is contained in:
Person
2018-07-30 21:39:41 -07:00
parent 0deabd45b8
commit 26c558a2f5
37 changed files with 708 additions and 201 deletions

View File

@ -36,6 +36,24 @@ GradientColorsView::GradientColorsView(QWidget* p)
ResetToDefault();
}
/// <summary>
/// Get whether to interpolate color keys.
/// </summary>
/// <returns>True to interpolate (blend), false to do hard cuts.</returns>
bool GradientColorsView::Blend()
{
return m_Blend;
}
/// <summary>
/// Set whether to interpolate color keys.
/// </summary>
/// <param name="blend">rue to interpolate (blend), false to do hard cuts.</param>
void GradientColorsView::Blend(bool blend)
{
m_Blend = blend;
}
/// <summary>
/// Set the focus to the arrow at the given normalized position.
/// </summary>
@ -374,23 +392,37 @@ Palette<float>& GradientColorsView::GetPalette(int size)
{
if (!m_Arrows.empty())
{
QPainter p;
QSize imageSize(size, 1);
QImage image(imageSize, QImage::Format_ARGB32_Premultiplied);
QLinearGradient grad(QPoint(0, 0), QPoint(imageSize.width(), imageSize.height()));
m_Palette.m_SourceColors.clear();
QPainter painter(&image);
float start = 0;
for (auto& it : m_Arrows)
if (Blend())
{
auto pos = it.first;
auto col = it.second.Color();
m_Palette.m_SourceColors[pos] = v4F(col.red() / 255.0f, col.green() / 255.0f, col.blue() / 255.0f, 1.0f);
grad.setColorAt(pos, col);
QLinearGradient grad(QPoint(0, 0), QPoint(imageSize.width(), imageSize.height()));
for (auto& it : m_Arrows)
{
auto col = it.second.Color();
m_Palette.m_SourceColors[it.first] = v4F(col.red() / 255.0f, col.green() / 255.0f, col.blue() / 255.0f, 1.0f);
grad.setColorAt(it.first, col);
}
painter.fillRect(image.rect(), grad);
}
else
{
for (auto& it : m_Arrows)
{
auto col = it.second.Color();
m_Palette.m_SourceColors[it.first] = v4F(col.red() / 255.0f, col.green() / 255.0f, col.blue() / 255.0f, 1.0f);
painter.setBrush(col);
painter.fillRect(start, 0, imageSize.width(), imageSize.height(), col);
start = std::ceil(it.first * imageSize.width());
}
}
p.begin(&image);
p.fillRect(image.rect(), grad);
p.end();
m_Palette.m_Entries.reserve(image.width());
for (int i = 0; i < image.width(); i++)
@ -493,13 +525,25 @@ void GradientColorsView::paintEvent(QPaintEvent*)
QPoint gradStart = QPoint(m_ViewRect.topLeft().x(), m_ViewRect.bottomLeft().y() / 2);
QPoint gradStop = QPoint(m_ViewRect.topRight().x(), m_ViewRect.bottomRight().y() / 2);
QLinearGradient grad(gradStart, gradStop);
float start = m_ViewRect.x();
for (auto& it : m_Arrows)
{
GradientArrow& arrow = it.second;
grad.setColorAt(it.first, arrow.Color());
auto offset = std::ceil(it.first * RectWidth());
if (Blend())
{
grad.setColorAt(it.first, arrow.Color());
}
else
{
painter.fillRect(start, m_ViewRect.y(), m_ViewRect.right() - start, m_ViewRect.height(), arrow.Color());
start = m_ViewRect.x() + offset;
}
QPolygon arrowPolygon = arrow.Area();
int iPosX = it.first * RectWidth(),
int iPosX = offset,
iPosY = m_ViewRect.height() + m_ViewRect.top() + 3;
arrowPolygon.translate(iPosX, iPosY);
QPainterPath paintPath;
@ -513,8 +557,11 @@ void GradientColorsView::paintEvent(QPaintEvent*)
painter.setBrush(QBrush(Qt::NoBrush));
}
QBrush brush(grad);
painter.fillRect(m_ViewRect, brush);
if (Blend())
{
painter.fillRect(m_ViewRect, grad);
}
painter.drawRect(m_ViewRect);
}
else
@ -534,8 +581,6 @@ void GradientColorsView::paintEvent(QPaintEvent*)
//Draw text inside of the arrow.
painter.drawText(topArrowRect.x() + (topArrowRect.width() - (topArrow.Width() - 5)) / 2.0, topArrowRect.y() + (topArrowRect.height() - 5), topArrow.Text());
}
painter.end();
}
/// <summary>

View File

@ -35,6 +35,8 @@ class GradientColorsView : public QWidget
public:
explicit GradientColorsView(QWidget* p = nullptr);
bool Blend();
void Blend(bool blend);
void SetFocus(float position);
void SetFocus(size_t position);
void SetFocusColor(const QColor& col);
@ -74,6 +76,7 @@ private:
int RectHeight();
bool m_ArrowMoving = false;
bool m_ColorIndexArrowMoving = false;
bool m_Blend = true;
QPoint m_ViewRectSize;
QPoint m_ViewRectOffset = QPoint(5, 15);
QPoint m_ViewRectTranslate = QPoint(5, 5);

View File

@ -34,9 +34,10 @@ PaletteEditor::PaletteEditor(QWidget* p) :
connect(ui->RemoveColorButton, SIGNAL(clicked()), this, SLOT(OnRemoveColorButtonClicked()));
connect(ui->InvertColorsButton, SIGNAL(clicked()), this, SLOT(OnInvertColorsButtonClicked()));
connect(ui->ResetColorsButton, SIGNAL(clicked()), this, SLOT(OnResetToDefaultButtonClicked()));
connect(ui->DistributeColorsButton, SIGNAL(clicked()), this, SLOT(OnDistributeColorsButtonClicked()));
connect(ui->RandomColorsButton, SIGNAL(clicked()), this, SLOT(OnRandomColorsButtonClicked()));
connect(ui->DistributeColorsButton, SIGNAL(clicked()), this, SLOT(OnDistributeColorsButtonClicked()));
connect(ui->SyncCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSyncCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui->BlendCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnBlendCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui->PaletteFilenameCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(OnPaletteFilenameComboChanged(const QString&)), Qt::QueuedConnection);
connect(ui->PaletteListTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnPaletteCellClicked(int, int)), Qt::QueuedConnection);
connect(ui->PaletteListTable, SIGNAL(cellChanged(int, int)), this, SLOT(OnPaletteCellChanged(int, int)), Qt::QueuedConnection);
@ -290,6 +291,18 @@ void PaletteEditor::OnSyncCheckBoxStateChanged(int state)
EmitColorIndexChanged(std::numeric_limits<size_t>::max(), 0);//Pass special value to update all.
}
/// <summary>
/// Change whether palette colors are blended between points, or instead do hard cuts.
/// Called when the Blend checkbox is checked/unchecked.
/// </summary>
/// <param name="state">Ignored</param>
void PaletteEditor::OnBlendCheckBoxStateChanged(int state)
{
m_GradientColorView->Blend((bool)state);
m_GradientColorView->update();
EmitPaletteChanged();
}
/// <summary>
/// Load the palette file based on the currently selected index in the combo box.
/// Called when the index of the palette filename combo box changes.
@ -607,6 +620,7 @@ void PaletteEditor::EnablePaletteControls()
ui->AddColorButton->setEnabled(b);
ui->DistributeColorsButton->setEnabled(b);
ui->AutoDistributeCheckBox->setEnabled(b);
ui->BlendCheckBox->setEnabled(b);
ui->RandomColorsButton->setEnabled(b);
ui->RemoveColorButton->setEnabled(b);
ui->ResetColorsButton->setEnabled(b);

View File

@ -54,6 +54,7 @@ private Q_SLOTS:
void OnColorPickerColorChanged(const QColor& col);
void OnArrowDoubleClicked(const GradientArrow& arrow);
void OnSyncCheckBoxStateChanged(int state);
void OnBlendCheckBoxStateChanged(int state);
void OnArrowMoved(qreal lastPos, const GradientArrow& arrow);
void OnColorIndexMove(size_t index, float value);
void OnPaletteFilenameComboChanged(const QString& text);