--User changes

-Add new preset dimensions to the right click menu of the width and height fields in the editor.
-Change QSS stylesheets to properly handle tabs.
-Make tabs rectangular by default. For some reason, they had always been triangular.

--Bug fixes
 -Incremental rendering times in the editor were wrong.

--Code changes
 -Migrate to Qt6. There is probably more work to be done here.
-Migrate to VS2022.
-Migrate to Wix 4 installer.
-Change installer to install to program files for all users.
-Fix many VS2022 code analysis warnings.
-No longer use byte typedef, because std::byte is now a type. Revert all back to unsigned char.
-Upgrade OpenCL headers to version 3.0 and keep locally now rather than trying to look for system files.
-No longer link to Nvidia or AMD specific OpenCL libraries. Use the generic installer located at OCL_ROOT too.
-Add the ability to change OpenCL grid dimensions. This was attempted for investigating possible performance improvments, but made no difference.

This has not been verified on Linux or Mac yet.
This commit is contained in:
Person
2023-04-25 17:59:54 -06:00
parent 64d4470b12
commit 1dfbd4eff2
306 changed files with 514515 additions and 491207 deletions

View File

@ -1,79 +1,79 @@
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FractoriumPch.h"
#include "ColorPanel.h"
/// <summary>
/// Constructor which passes parent widget to the base and initializes the minimum size.
/// </summary>
/// <param name="p">The parent widget</param>
ColorPanel::ColorPanel(QWidget* p)
: QPushButton(p)
{
setMinimumSize(10, 10);
}
/// <summary>
/// Derived paint event which paints the entire button surface with m_Color.
/// </summary>
void ColorPanel::paintEvent(QPaintEvent*)
{
QPainter p(this);
p.setPen(m_Pen);
p.setBrush(QBrush(m_Color));
p.drawRect(QRect(2, 2, width() - 6, height() - 6));
}
/// <summary>
/// Set the pen object used to paint the button.
/// </summary>
/// <param name="pen">The pen object used to paint the button</param>
void ColorPanel::Pen(const QPen& pen)
{
m_Pen = pen;
update();
}
/// <summary>
/// Get the pen object used to paint the button.
/// </summary>
/// <returns>QPen</returns>
QPen ColorPanel::Pen() const
{
return m_Pen;
}
/// <summary>
/// Set the color used to paint the button.
/// </summary>
/// <param name="color">The color used to paint the button</param>
void ColorPanel::Color(const QColor& color)
{
m_Color = color;
update();
}
/// <summary>
/// Get the color used to paint the button.
/// </summary>
/// <returns>QColor</returns>
QColor ColorPanel::Color() const
{
return m_Color;
}
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FractoriumPch.h"
#include "ColorPanel.h"
/// <summary>
/// Constructor which passes parent widget to the base and initializes the minimum size.
/// </summary>
/// <param name="p">The parent widget</param>
ColorPanel::ColorPanel(QWidget* p)
: QPushButton(p)
{
setMinimumSize(10, 10);
}
/// <summary>
/// Derived paint event which paints the entire button surface with m_Color.
/// </summary>
void ColorPanel::paintEvent(QPaintEvent*)
{
QPainter p(this);
p.setPen(m_Pen);
p.setBrush(QBrush(m_Color));
p.drawRect(QRect(2, 2, width() - 6, height() - 6));
}
/// <summary>
/// Set the pen object used to paint the button.
/// </summary>
/// <param name="pen">The pen object used to paint the button</param>
void ColorPanel::Pen(const QPen& pen)
{
m_Pen = pen;
update();
}
/// <summary>
/// Get the pen object used to paint the button.
/// </summary>
/// <returns>QPen</returns>
QPen ColorPanel::Pen() const
{
return m_Pen;
}
/// <summary>
/// Set the color used to paint the button.
/// </summary>
/// <param name="color">The color used to paint the button</param>
void ColorPanel::Color(const QColor& color)
{
m_Color = color;
update();
}
/// <summary>
/// Get the color used to paint the button.
/// </summary>
/// <returns>QColor</returns>
QColor ColorPanel::Color() const
{
return m_Color;
}

View File

@ -1,47 +1,47 @@
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "FractoriumPch.h"
/// <summary>
/// A derivation of a QPushButton which makes a large, clickable panel
/// which custom paints the button based on a user specified color.
/// </summary>
class ColorPanel : public QPushButton
{
Q_OBJECT
public:
ColorPanel(QWidget* p = nullptr);
void Pen(const QPen& pen);
QPen Pen() const;
void Color(const QColor& color);
QColor Color() const;
protected:
void paintEvent(QPaintEvent* event) override;
private:
QPen m_Pen;
QColor m_Color;
};
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "FractoriumPch.h"
/// <summary>
/// A derivation of a QPushButton which makes a large, clickable panel
/// which custom paints the button based on a user specified color.
/// </summary>
class ColorPanel : public QPushButton
{
Q_OBJECT
public:
ColorPanel(QWidget* p = nullptr);
void Pen(const QPen& pen);
QPen Pen() const;
void Color(const QColor& color);
QColor Color() const;
protected:
void paintEvent(QPaintEvent* event) override;
private:
QPen m_Pen;
QColor m_Color;
};

View File

@ -1,97 +1,97 @@
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FractoriumPch.h"
#include "ColorPickerWidget.h"
/// <summary>
/// Constructor which passes parent widget to the base and initializes the member controls
/// on a grid layout.
/// </summary>
/// <param name="p">The parent widget</param>
ColorPickerWidget::ColorPickerWidget(QWidget* p)
: QWidget(p)
{
m_ColorTriangle = new ColorTriangle(this);
m_ColorPanel = new ColorPanel(this);
m_ColorDialog = new QColorDialog(this);
m_ColorPanel->Color(m_ColorTriangle->Color());
connect(m_ColorTriangle, SIGNAL(ColorChanged(const QColor&)), this, SLOT(OnTriangleColorChanged(const QColor&)));
connect(m_ColorPanel, SIGNAL(clicked()), this, SLOT(OnColorViewerClicked()));
auto layout = new QGridLayout(this);
layout->setMargin(4);
layout->addWidget(m_ColorTriangle, 0, 0, 3, 1);
layout->addWidget(m_ColorPanel, 0, 1, 3, 1);
setLayout(layout);
}
/// <summary>
/// Get the color used to paint the color panel.
/// </summary>
/// <returns>QColor</returns>
QColor ColorPickerWidget::Color() const
{
return m_ColorPanel->Color();
}
/// <summary>
/// Set the current color for the triangle.
/// </summary>
/// <param name="col">The parent widget</param>
void ColorPickerWidget::SetColorPanelColor(const QColor& col)
{
if (col.isValid())
m_ColorTriangle->Color(col);//Internally emits ColorChanged() which will call OnTriangleColorChanged(), which will call m_ColorPanel->Color().
}
/// <summary>
/// Overridden resize event to set the color panel height slightly
/// smaller than the container it's in.
/// </summary>
/// <param name="col">The resize event</param>
void ColorPickerWidget::resizeEvent(QResizeEvent* event)
{
m_ColorPanel->setMinimumHeight(event->size().height() - 22);
m_ColorPanel->setMaximumHeight(event->size().height() - 22);
}
/// <summary>
/// Slot called when the color panel is clicked, which will show the color
/// picker dialog.
/// </summary>
void ColorPickerWidget::OnColorViewerClicked()
{
m_ColorDialog->setCurrentColor(m_ColorPanel->Color());
const auto newColor = m_ColorDialog->getColor(m_ColorPanel->Color(), this);
SetColorPanelColor(newColor);
}
/// <summary>
/// Slot called when the color on the triangle changes for any reason,
/// either user initiated or programatically called.
/// </summary>
/// <param name="col">The new color on the triangle</param>
void ColorPickerWidget::OnTriangleColorChanged(const QColor& col)
{
if (col.isValid())
{
m_ColorPanel->Color(col);
emit ColorChanged(col);
}
}
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "FractoriumPch.h"
#include "ColorPickerWidget.h"
/// <summary>
/// Constructor which passes parent widget to the base and initializes the member controls
/// on a grid layout.
/// </summary>
/// <param name="p">The parent widget</param>
ColorPickerWidget::ColorPickerWidget(QWidget* p)
: QWidget(p)
{
m_ColorTriangle = new ColorTriangle(this);
m_ColorPanel = new ColorPanel(this);
m_ColorDialog = new QColorDialog(this);
m_ColorPanel->Color(m_ColorTriangle->Color());
connect(m_ColorTriangle, SIGNAL(ColorChanged(const QColor&)), this, SLOT(OnTriangleColorChanged(const QColor&)));
connect(m_ColorPanel, SIGNAL(clicked()), this, SLOT(OnColorViewerClicked()));
auto layout = new QGridLayout(this);
layout->setContentsMargins(4, 4, 4, 4);
layout->addWidget(m_ColorTriangle, 0, 0, 3, 1);
layout->addWidget(m_ColorPanel, 0, 1, 3, 1);
setLayout(layout);
}
/// <summary>
/// Get the color used to paint the color panel.
/// </summary>
/// <returns>QColor</returns>
QColor ColorPickerWidget::Color() const
{
return m_ColorPanel->Color();
}
/// <summary>
/// Set the current color for the triangle.
/// </summary>
/// <param name="col">The parent widget</param>
void ColorPickerWidget::SetColorPanelColor(const QColor& col)
{
if (col.isValid())
m_ColorTriangle->Color(col);//Internally emits ColorChanged() which will call OnTriangleColorChanged(), which will call m_ColorPanel->Color().
}
/// <summary>
/// Overridden resize event to set the color panel height slightly
/// smaller than the container it's in.
/// </summary>
/// <param name="col">The resize event</param>
void ColorPickerWidget::resizeEvent(QResizeEvent* event)
{
m_ColorPanel->setMinimumHeight(event->size().height() - 22);
m_ColorPanel->setMaximumHeight(event->size().height() - 22);
}
/// <summary>
/// Slot called when the color panel is clicked, which will show the color
/// picker dialog.
/// </summary>
void ColorPickerWidget::OnColorViewerClicked()
{
m_ColorDialog->setCurrentColor(m_ColorPanel->Color());
const auto newColor = m_ColorDialog->getColor(m_ColorPanel->Color(), this);
SetColorPanelColor(newColor);
}
/// <summary>
/// Slot called when the color on the triangle changes for any reason,
/// either user initiated or programatically called.
/// </summary>
/// <param name="col">The new color on the triangle</param>
void ColorPickerWidget::OnTriangleColorChanged(const QColor& col)
{
if (col.isValid())
{
m_ColorPanel->Color(col);
emit ColorChanged(col);
}
}

View File

@ -1,54 +1,54 @@
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "FractoriumPch.h"
#include "ColorTriangle.h"
#include "ColorPanel.h"
/// <summary>
/// Aggregator class to package a color triangle, color panel, and color dialog
/// all together on a layout.
/// </summary>
class ColorPickerWidget : public QWidget
{
Q_OBJECT
public:
ColorPickerWidget(QWidget* p = nullptr);
QColor Color() const;
void SetColorPanelColor(const QColor& col);
Q_SIGNALS:
void ColorChanged(const QColor& col);
protected:
void resizeEvent(QResizeEvent* event) override;
private Q_SLOTS:
void OnColorViewerClicked();
void OnTriangleColorChanged(const QColor& col);
private:
ColorTriangle* m_ColorTriangle;
ColorPanel* m_ColorPanel;
QColorDialog* m_ColorDialog;
};
/*
Copyright (C) 2009, Etienne Moutot <e.moutot@gmail.com>
This file is part of colorPickerWidget.
colorPickerWidget is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
colorPickerWidget is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "FractoriumPch.h"
#include "ColorTriangle.h"
#include "ColorPanel.h"
/// <summary>
/// Aggregator class to package a color triangle, color panel, and color dialog
/// all together on a layout.
/// </summary>
class ColorPickerWidget : public QWidget
{
Q_OBJECT
public:
ColorPickerWidget(QWidget* p = nullptr);
QColor Color() const;
void SetColorPanelColor(const QColor& col);
Q_SIGNALS:
void ColorChanged(const QColor& col);
protected:
void resizeEvent(QResizeEvent* event) override;
private Q_SLOTS:
void OnColorViewerClicked();
void OnTriangleColorChanged(const QColor& col);
private:
ColorTriangle* m_ColorTriangle;
ColorPanel* m_ColorPanel;
QColorDialog* m_ColorDialog;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,138 +1,138 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#pragma once
#include "FractoriumPch.h"
/// <summary>
/// DoubleColor, Vertex and ColorTriangle classes.
/// </summary>
/// <summary>
/// Used to store color values in the range 0..255 as doubles.
/// </summary>
struct DoubleColor
{
double r, g, b;
DoubleColor() : r(0.0), g(0.0), b(0.0) {}
DoubleColor(double red, double green, double blue) : r(red), g(green), b(blue) {}
DoubleColor(const DoubleColor& c) : r(c.r), g(c.g), b(c.b) {}
};
/// <summary>
/// Used to store pairs of DoubleColor and DoublePoint in one structure.
/// </summary>
struct Vertex
{
DoubleColor color;
QPointF point;
Vertex(const DoubleColor& c, const QPointF& p) : color(c), point(p) {}
Vertex(const QColor& c, const QPointF& p)
: color(DoubleColor(static_cast<double>(c.red()), static_cast<double>(c.green()),
static_cast<double>(c.blue()))), point(p) {}
};
/// <summary>
/// Widget for drawing a color triangle which allows users to select colors
/// in a manner more intuitive than the usual color picker dialog.
/// This class was taken from an open source project named Chaos Helper, which took
/// it from the Qt examples, so it mostly remains as-is.
/// </summary>
class ColorTriangle : public QWidget
{
Q_OBJECT
public:
ColorTriangle(QWidget* parent = nullptr);
void Polish();
QColor Color() const;
void Color(const QColor& col);
int heightForWidth(int w) const override;
QSize sizeHint() const override;
Q_SIGNALS:
void ColorChanged(const QColor& col);
protected:
void paintEvent(QPaintEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void keyPressEvent(QKeyEvent* e) override;
void resizeEvent(QResizeEvent*) override;
private:
void GenBackground();
void DrawTrigon(QImage* p, const QPointF& a, const QPointF& b, const QPointF& c, const QColor& color);
double CalcOuterRadius() const;
double RadiusAt(const QPointF& pos, const QRect& rect) const;
double AngleAt(const QPointF& pos, const QRect& rect) const;
QColor ColorFromPoint(const QPointF& p) const;
QPointF PointFromColor(const QColor& col) const;
QPointF MovePointToTriangle(double x, double y, const Vertex& a, const Vertex& b, const Vertex& c) const;
bool mustGenerateBackground;
int curHue;
int penWidth;
int ellipseSize;
int outerRadius;
double a, b, c;
QImage bg;
QColor curColor;
QPointF pa, pb, pc, pd;
QPointF selectorPos;
enum SelectionMode
{
Idle,
SelectingHue,
SelectingSatValue
} selMode;
};
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#pragma once
#include "FractoriumPch.h"
/// <summary>
/// DoubleColor, Vertex and ColorTriangle classes.
/// </summary>
/// <summary>
/// Used to store color values in the range 0..255 as doubles.
/// </summary>
struct DoubleColor
{
double r, g, b;
DoubleColor() : r(0.0), g(0.0), b(0.0) {}
DoubleColor(double red, double green, double blue) : r(red), g(green), b(blue) {}
DoubleColor(const DoubleColor& c) : r(c.r), g(c.g), b(c.b) {}
};
/// <summary>
/// Used to store pairs of DoubleColor and DoublePoint in one structure.
/// </summary>
struct Vertex
{
DoubleColor color;
QPointF point;
Vertex(const DoubleColor& c, const QPointF& p) : color(c), point(p) {}
Vertex(const QColor& c, const QPointF& p)
: color(DoubleColor(static_cast<double>(c.red()), static_cast<double>(c.green()),
static_cast<double>(c.blue()))), point(p) {}
};
/// <summary>
/// Widget for drawing a color triangle which allows users to select colors
/// in a manner more intuitive than the usual color picker dialog.
/// This class was taken from an open source project named Chaos Helper, which took
/// it from the Qt examples, so it mostly remains as-is.
/// </summary>
class ColorTriangle : public QWidget
{
Q_OBJECT
public:
ColorTriangle(QWidget* parent = nullptr);
void Polish();
QColor Color() const;
void Color(const QColor& col);
int heightForWidth(int w) const override;
QSize sizeHint() const override;
Q_SIGNALS:
void ColorChanged(const QColor& col);
protected:
void paintEvent(QPaintEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void keyPressEvent(QKeyEvent* e) override;
void resizeEvent(QResizeEvent*) override;
private:
void GenBackground();
void DrawTrigon(QImage* p, const QPointF& a, const QPointF& b, const QPointF& c, const QColor& color);
double CalcOuterRadius() const;
double RadiusAt(const QPointF& pos, const QRect& rect) const;
double AngleAt(const QPointF& pos, const QRect& rect) const;
QColor ColorFromPoint(const QPointF& p) const;
QPointF PointFromColor(const QColor& col) const;
QPointF MovePointToTriangle(double x, double y, const Vertex& a, const Vertex& b, const Vertex& c) const;
bool mustGenerateBackground;
int curHue;
int penWidth;
int ellipseSize;
int outerRadius;
double a, b, c;
QImage bg;
QColor curColor;
QPointF pa, pb, pc, pd;
QPointF selectorPos;
enum SelectionMode
{
Idle,
SelectingHue,
SelectingSatValue
} selMode;
};

View File

@ -1,127 +1,127 @@
/****************************************************************************/
// This file is part of the gradLib library originally made by Stian Broen
//
// For more free libraries, please visit <http://broentech.no>
//
// gradLib is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library. If not, see <http://www.gnu.org/licenses/>
/****************************************************************************/
#pragma once
#include "FractoriumPch.h"
/// <summary>
/// Class for drawing the small arrows below the gradient in the palette editor.
/// The drawing is accomplished via a QPolygon object.
/// </summary>
class GradientArrow
{
public:
/// <summary>
/// Default constructor which sets up the size of the arrow.
/// </summary>
explicit GradientArrow()
{
QPolygon area;
area << QPoint(5, 5) << QPoint(10, 0) << QPoint(15, 5) << QPoint(15, 15) << QPoint(5, 15) << QPoint(5, 5);
Area(area);
}
/// <summary>
/// Constructor which takes the color and focus state of the arrow.
/// </summary>
/// <param name="col">The color of the arrow</param>
/// <param name="focus">Whether the arrow is focused</param>
explicit GradientArrow(QColor col, bool focus)
: GradientArrow()
{
m_Color = col;
m_Focus = focus;
}
/// <summary>
/// Copy constructor to copy another GradientArrow.
/// </summary>
/// <param name="other">The GradientArrow object to copy</param>
GradientArrow(const GradientArrow& other)
: m_Focus(other.Focus()),
m_Area(other.Area()),
m_Color(other.Color())
{
}
/// <summary>
/// Getters and setters.
/// </summary>
inline bool Focus() const { return m_Focus; }
inline void Focus(bool val) { m_Focus = val; }
inline const QPolygon Area() const { return m_Area; }
inline void Area(const QPolygon& val) {m_Area = val; }
inline const QColor Color() const { return m_Color; }
inline void Color(const QColor& val) { m_Color = val; }
private:
bool m_Focus;
QPolygon m_Area;
QColor m_Color;
};
/// <summary>
/// Thin derivation to handle drawing arrows at the top of the gradient area to
/// represent the color indices of each xform.
/// </summary>
class TopArrow : public GradientArrow
{
public:
/// <summary>
/// Default constructor which is only present so this class can be used with containers.
/// This should never be used by a caller.
/// </summary>
TopArrow()
: TopArrow(10, 0)
{
}
/// <summary>
/// Constructor which takes the width used to draw the arrow and the xform index
/// this arrow represents.
/// </summary>
/// <param name="width">The width used to draw the arrow</param>
/// <param name="index">The xform index this arrow represents</param>
TopArrow(int width, size_t index)
{
QPolygon area;
constexpr int center = 10;
const auto mid = width / 2;
const auto left = center - mid;
const auto right = center + mid;
area << QPoint(left, 0) << QPoint(right, 0) << QPoint(right, 10) << QPoint(center, 15) << QPoint(left, 10) << QPoint(left, 0);
Area(area);
m_Index = index;
m_Width = width;
m_Text = QString::number(index + 1);
}
/// <summary>
/// Getters.
/// </summary>
int Width() { return m_Width; }
size_t Index() { return m_Index; }
QString Text() { return m_Text; }
private:
int m_Width;
size_t m_Index;
QString m_Text;
/****************************************************************************/
// This file is part of the gradLib library originally made by Stian Broen
//
// For more free libraries, please visit <http://broentech.no>
//
// gradLib is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library. If not, see <http://www.gnu.org/licenses/>
/****************************************************************************/
#pragma once
#include "FractoriumPch.h"
/// <summary>
/// Class for drawing the small arrows below the gradient in the palette editor.
/// The drawing is accomplished via a QPolygon object.
/// </summary>
class GradientArrow
{
public:
/// <summary>
/// Default constructor which sets up the size of the arrow.
/// </summary>
explicit GradientArrow()
{
QPolygon area;
area << QPoint(5, 5) << QPoint(10, 0) << QPoint(15, 5) << QPoint(15, 15) << QPoint(5, 15) << QPoint(5, 5);
Area(area);
}
/// <summary>
/// Constructor which takes the color and focus state of the arrow.
/// </summary>
/// <param name="col">The color of the arrow</param>
/// <param name="focus">Whether the arrow is focused</param>
explicit GradientArrow(QColor col, bool focus)
: GradientArrow()
{
m_Color = col;
m_Focus = focus;
}
/// <summary>
/// Copy constructor to copy another GradientArrow.
/// </summary>
/// <param name="other">The GradientArrow object to copy</param>
GradientArrow(const GradientArrow& other)
: m_Focus(other.Focus()),
m_Area(other.Area()),
m_Color(other.Color())
{
}
/// <summary>
/// Getters and setters.
/// </summary>
inline bool Focus() const { return m_Focus; }
inline void Focus(bool val) { m_Focus = val; }
inline const QPolygon Area() const { return m_Area; }
inline void Area(const QPolygon& val) {m_Area = val; }
inline const QColor Color() const { return m_Color; }
inline void Color(const QColor& val) { m_Color = val; }
private:
bool m_Focus;
QPolygon m_Area;
QColor m_Color;
};
/// <summary>
/// Thin derivation to handle drawing arrows at the top of the gradient area to
/// represent the color indices of each xform.
/// </summary>
class TopArrow : public GradientArrow
{
public:
/// <summary>
/// Default constructor which is only present so this class can be used with containers.
/// This should never be used by a caller.
/// </summary>
TopArrow()
: TopArrow(10, 0)
{
}
/// <summary>
/// Constructor which takes the width used to draw the arrow and the xform index
/// this arrow represents.
/// </summary>
/// <param name="width">The width used to draw the arrow</param>
/// <param name="index">The xform index this arrow represents</param>
TopArrow(int width, size_t index)
{
QPolygon area;
constexpr int center = 10;
const auto mid = width / 2;
const auto left = center - mid;
const auto right = center + mid;
area << QPoint(left, 0) << QPoint(right, 0) << QPoint(right, 10) << QPoint(center, 15) << QPoint(left, 10) << QPoint(left, 0);
Area(area);
m_Index = index;
m_Width = width;
m_Text = QString::number(index + 1);
}
/// <summary>
/// Getters.
/// </summary>
int Width() { return m_Width; }
size_t Index() { return m_Index; }
QString Text() { return m_Text; }
private:
int m_Width;
size_t m_Index;
QString m_Text;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +1,89 @@
/****************************************************************************/
// This file is part of the gradLib library originally made by Stian Broen
//
// For more free libraries, please visit <http://broentech.no>
//
// gradLib is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library. If not, see <http://www.gnu.org/licenses/>
/****************************************************************************/
#pragma once
#include "FractoriumPch.h"
#include "GradientArrow.h"
/// <summary>
/// Class for drawing the resulting palette created by interpolating the key colors
/// as well as the arrows underneath the palette.
/// The arrows are held in a sorted map whose key is the normalized index of the arrow,
/// between 0 and 1 inclusive. They value is the arrow itself.
/// The resulting palette is always stored in the m_Palette member.
/// </summary>
class GradientColorsView : public QWidget
{
Q_OBJECT
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);
void AddArrow(const QColor& color);
void AddArrow(float position, const QColor& color);
void DeleteFocusedArrow();
void InvertColors();
void RandomColors();
void DistributeColors();
void ResetToDefault();
void ClearArrows();
void NewFocusColor(const QColor& col, int index);
void SetArrows(map<float, GradientArrow>& newArrows);
int ArrowCount();
int GetFocusedIndex();
map<float, GradientArrow>& GetArrows();
Palette<float>& GetPalette(int size);
void SetPalette(const Palette<float>& palette);
map<size_t, float> GetColorIndices() const;
void SetColorIndices(const map<size_t, float>& indices);
Q_SIGNALS:
void ArrowMove(qreal lastPos, const GradientArrow& arrow);
void ArrowDoubleClicked(const GradientArrow& arrow);
void ColorIndexMove(size_t index, float value);
protected:
void paintEvent(QPaintEvent* e) override;
void mousePressEvent(QMouseEvent* e) override;
void mouseDoubleClickEvent(QMouseEvent* e) override;
void mouseMoveEvent(QMouseEvent* e) override;
void mouseReleaseEvent(QMouseEvent* e) override;
void resizeEvent(QResizeEvent*) override;
private:
int RectWidth();
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);
QRect m_ViewRect;
QPoint m_DragStart;
map<float, GradientArrow> m_Arrows;
map<size_t, pair<float, TopArrow>> m_ColorIndicesArrows;
Palette<float> m_Palette;
QPixmap m_FinalFixedPixmap;
};
/****************************************************************************/
// This file is part of the gradLib library originally made by Stian Broen
//
// For more free libraries, please visit <http://broentech.no>
//
// gradLib is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library. If not, see <http://www.gnu.org/licenses/>
/****************************************************************************/
#pragma once
#include "FractoriumPch.h"
#include "GradientArrow.h"
/// <summary>
/// Class for drawing the resulting palette created by interpolating the key colors
/// as well as the arrows underneath the palette.
/// The arrows are held in a sorted map whose key is the normalized index of the arrow,
/// between 0 and 1 inclusive. They value is the arrow itself.
/// The resulting palette is always stored in the m_Palette member.
/// </summary>
class GradientColorsView : public QWidget
{
Q_OBJECT
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);
void AddArrow(const QColor& color);
void AddArrow(float position, const QColor& color);
void DeleteFocusedArrow();
void InvertColors();
void RandomColors();
void DistributeColors();
void ResetToDefault();
void ClearArrows();
void NewFocusColor(const QColor& col, int index);
void SetArrows(map<float, GradientArrow>& newArrows);
int ArrowCount();
int GetFocusedIndex();
map<float, GradientArrow>& GetArrows();
Palette<float>& GetPalette(int size);
void SetPalette(const Palette<float>& palette);
map<size_t, float> GetColorIndices() const;
void SetColorIndices(const map<size_t, float>& indices);
Q_SIGNALS:
void ArrowMove(qreal lastPos, const GradientArrow& arrow);
void ArrowDoubleClicked(const GradientArrow& arrow);
void ColorIndexMove(size_t index, float value);
protected:
void paintEvent(QPaintEvent* e) override;
void mousePressEvent(QMouseEvent* e) override;
void mouseDoubleClickEvent(QMouseEvent* e) override;
void mouseMoveEvent(QMouseEvent* e) override;
void mouseReleaseEvent(QMouseEvent* e) override;
void resizeEvent(QResizeEvent*) override;
private:
int RectWidth();
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);
QRect m_ViewRect;
QPoint m_DragStart;
map<float, GradientArrow> m_Arrows;
map<size_t, pair<float, TopArrow>> m_ColorIndicesArrows;
Palette<float> m_Palette;
QPixmap m_FinalFixedPixmap;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +1,93 @@
#pragma once
#include "FractoriumPch.h"
#include "Fractorium.h"
#include "ColorPickerWidget.h"
#include "GradientColorsView.h"
#include "EmberFile.h"
#include "ui_PaletteEditor.h"
namespace Ui
{
class PaletteEditor;
}
/// <summary>
/// Dialog for editing user created palettes.
/// This will load with all available user created palettes populated in the combo
/// box. As the user changes the selected index, the palettes for that file
/// are shown in the list box. The user can click on those and then edit them and either
/// save it back to the same position in the file, or append it to the end.
/// They can also click in the name column to set/rename the palette name.
/// Any changes on this dialog can be "synced". That is, when the Sync checkbox is checked
/// any changes result in a signal being sent back to the main window.
/// </summary>
class PaletteEditor : public QDialog
{
Q_OBJECT
public:
explicit PaletteEditor(QWidget* p = nullptr);
public:
bool Sync();
Palette<float>& GetPalette(int size);
void SetPalette(const Palette<float>& palette);
map<size_t, float> GetColorIndices() const;
map<size_t, float> GetPreviousColorIndices() const;
void SetColorIndices(const map<size_t, float>& indices);
void SetPreviousColorIndices(const map<size_t, float>& indices);
string GetPaletteFile() const;
void SetPaletteFile(const string& filename);
Q_SIGNALS:
void PaletteChanged();
void PaletteFileChanged();
void ColorIndexChanged(size_t index, float value);
private Q_SLOTS:
void OnAddColorButtonClicked();
void OnRemoveColorButtonClicked();
void OnInvertColorsButtonClicked();
void OnRandomColorsButtonClicked();
void OnDistributeColorsButtonClicked();
void OnResetToDefaultButtonClicked();
void OnCreatePaletteFromImageButtonClicked();
void OnCreatePaletteAgainFromImageButton();
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);
void OnPaletteCellClicked(int row, int col);
void OnPaletteCellChanged(int row, int col);
void OnNewPaletteFileButtonClicked();
void OnCopyPaletteFileButtonClicked();
void OnAppendPaletteButtonClicked();
void OnOverwritePaletteButtonClicked();
void OnDeletePaletteButtonClicked();
private:
void EmitPaletteChanged();
void EmitColorIndexChanged(size_t index, float value);
QStringList SetupOpenImagesDialog();
void AddArrow(const QColor& color);
map<float, GradientArrow> GetRandomColorsFromImage(QString filename, int numPoints);
void EnablePaletteFileControls();
void EnablePaletteControls();
bool IsCurrentPaletteAndFileEditable();
bool m_PaletteFileChanged = false;
int m_PaletteIndex = 0;
map<size_t, float> m_PreviousColorIndices;
QString m_Filename;
string m_CurrentPaletteFilePath;
ColorPickerWidget* m_ColorPicker = nullptr;
GradientColorsView* m_GradientColorView = nullptr;
#ifndef __APPLE__
QFileDialog* m_FileDialog = nullptr;
#endif
shared_ptr<PaletteList<float>> m_PaletteList;
std::unique_ptr<Ui::PaletteEditor> ui;
};
#pragma once
#include "FractoriumPch.h"
#include "Fractorium.h"
#include "ColorPickerWidget.h"
#include "GradientColorsView.h"
#include "EmberFile.h"
#include "ui_PaletteEditor.h"
namespace Ui
{
class PaletteEditor;
}
/// <summary>
/// Dialog for editing user created palettes.
/// This will load with all available user created palettes populated in the combo
/// box. As the user changes the selected index, the palettes for that file
/// are shown in the list box. The user can click on those and then edit them and either
/// save it back to the same position in the file, or append it to the end.
/// They can also click in the name column to set/rename the palette name.
/// Any changes on this dialog can be "synced". That is, when the Sync checkbox is checked
/// any changes result in a signal being sent back to the main window.
/// </summary>
class PaletteEditor : public QDialog
{
Q_OBJECT
public:
explicit PaletteEditor(QWidget* p = nullptr);
public:
bool Sync();
Palette<float>& GetPalette(int size);
void SetPalette(const Palette<float>& palette);
map<size_t, float> GetColorIndices() const;
map<size_t, float> GetPreviousColorIndices() const;
void SetColorIndices(const map<size_t, float>& indices);
void SetPreviousColorIndices(const map<size_t, float>& indices);
string GetPaletteFile() const;
void SetPaletteFile(const string& filename);
Q_SIGNALS:
void PaletteChanged();
void PaletteFileChanged();
void ColorIndexChanged(size_t index, float value);
private Q_SLOTS:
void OnAddColorButtonClicked();
void OnRemoveColorButtonClicked();
void OnInvertColorsButtonClicked();
void OnRandomColorsButtonClicked();
void OnDistributeColorsButtonClicked();
void OnResetToDefaultButtonClicked();
void OnCreatePaletteFromImageButtonClicked();
void OnCreatePaletteAgainFromImageButton();
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);
void OnPaletteCellClicked(int row, int col);
void OnPaletteCellChanged(int row, int col);
void OnNewPaletteFileButtonClicked();
void OnCopyPaletteFileButtonClicked();
void OnAppendPaletteButtonClicked();
void OnOverwritePaletteButtonClicked();
void OnDeletePaletteButtonClicked();
private:
void EmitPaletteChanged();
void EmitColorIndexChanged(size_t index, float value);
QStringList SetupOpenImagesDialog();
void AddArrow(const QColor& color);
map<float, GradientArrow> GetRandomColorsFromImage(QString filename, int numPoints);
void EnablePaletteFileControls();
void EnablePaletteControls();
bool IsCurrentPaletteAndFileEditable();
bool m_PaletteFileChanged = false;
int m_PaletteIndex = 0;
map<size_t, float> m_PreviousColorIndices;
QString m_Filename;
string m_CurrentPaletteFilePath;
ColorPickerWidget* m_ColorPicker = nullptr;
GradientColorsView* m_GradientColorView = nullptr;
#ifndef __APPLE__
QFileDialog* m_FileDialog = nullptr;
#endif
shared_ptr<PaletteList<float>> m_PaletteList;
std::unique_ptr<Ui::PaletteEditor> ui;
};