Skip to content

Commit

Permalink
added sound effects and adjusted defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
dagostinelli committed Jun 14, 2017
1 parent 1c35b1c commit fe379af
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Multimedia REQUIRED)

add_executable(prestopalette WIN32 main.cpp mainwindow.cpp resources.qrc visualpalette.cpp circlepalette.cpp clickablelabel.cpp)

target_link_libraries(prestopalette Qt5::Widgets)
target_link_libraries(prestopalette Qt5::Core)
target_link_libraries(prestopalette Qt5::Gui)
target_link_libraries(prestopalette Qt5::Multimedia)

set_property(TARGET prestopalette PROPERTY CXX_STANDARD 11)
set_property(TARGET prestopalette PROPERTY CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -64,10 +66,12 @@ IF(MINGW)
get_target_property(Qt5_Core_Location Qt5::Core LOCATION)
get_target_property(Qt5_Gui_Location Qt5::Gui LOCATION)
get_target_property(Qt5_Widgets_Location Qt5::Widgets LOCATION)
get_target_property(Qt5_Multimedia_Location Qt5::Multimedia LOCATION)

INSTALL(FILES ${Qt5_Core_Location} DESTINATION . COMPONENT Libraries)
INSTALL(FILES ${Qt5_Gui_Location} DESTINATION . COMPONENT Libraries)
INSTALL(FILES ${Qt5_Widgets_Location} DESTINATION . COMPONENT Libraries)
INSTALL(FILES ${Qt5_Multimedia_Location} DESTINATION . COMPONENT Libraries)
ENDIF(MINGW)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Presto Palette")
Expand Down
Binary file added audio/Click_Off_Short.wav
Binary file not shown.
Binary file added audio/Click_On_Short.wav
Binary file not shown.
Binary file added audio/Select.wav
Binary file not shown.
131 changes: 112 additions & 19 deletions circlepalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,14 @@ CirclePalette::CirclePalette(QWidget *parent) : QWidget(parent)
create_gamut_triangle();
create_gamut_square();

/*secondaryTriangle1On = true;
secondaryTriangle2On = true;
secondaryTriangle3On = true;
secondaryQuad1On = true;
secondaryQuad2On = true;
secondaryQuad3On = true;
secondaryQuad4On = true;*/
//centroidLineOn = true;
centroidTriangleOn = true;
centroidQuadOn = true;
centroidTriangleOn = false; // centroids are off by default
centroidQuadOn = false; // centroids are off by default

this->controlOffClick.setSource(QUrl::fromLocalFile(":/main/audio/Click_Off_Short.wav"));
this->controlOffClick.setVolume(0.25f);

this->controlOnClick.setSource(QUrl::fromLocalFile(":/main/audio/Click_On_Short.wav"));
this->controlOnClick.setVolume(0.25f);
}

QPointF CirclePalette::FindIntersectionWithCircle(const QPoint &p1, const QPoint &p2, const qreal radius)
Expand Down Expand Up @@ -358,15 +356,30 @@ bool CirclePalette::eventFilter(QObject* watched, QEvent* event)
if (gamutShape == PrestoPalette::GamutShapeSquare)
{
sortedColors.append(getColorAt((*points)[0]->point));
sortedColors.append(getMidPointColor((*points)[0]->point, (*points)[1]->point));
if ((*points)[0]->secondaryOn)
{
sortedColors.append(getMidPointColor((*points)[0]->point, (*points)[1]->point));
}
sortedColors.append(getColorAt((*points)[1]->point));
sortedColors.append(getMidPointColor((*points)[1]->point, (*points)[2]->point));
if ((*points)[1]->secondaryOn)
{
sortedColors.append(getMidPointColor((*points)[1]->point, (*points)[2]->point));
}
sortedColors.append(getColorAt((*points)[2]->point));
sortedColors.append(getMidPointColor((*points)[2]->point, (*points)[3]->point));
if ((*points)[2]->secondaryOn)
{
sortedColors.append(getMidPointColor((*points)[2]->point, (*points)[3]->point));
}
sortedColors.append(getColorAt((*points)[3]->point));
sortedColors.append(getMidPointColor((*points)[3]->point, (*points)[0]->point));
if ((*points)[3]->secondaryOn)
{
sortedColors.append(getMidPointColor((*points)[3]->point, (*points)[0]->point));
}

sortedColors.append(getColorAt(*this->centroid));
if (centroidQuadOn)
{
sortedColors.append(getColorAt(*this->centroid));
}
}

QVector<QColor> newColors;
Expand Down Expand Up @@ -434,6 +447,14 @@ void CirclePalette::mousePressEvent(QMouseEvent *event)
if (_is_collision(getMidPoint((this->pointsLine[0])->point, (this->pointsLine[1])->point), secondaryRadius, mousePos))
{
(this->pointsLine[0])->secondaryOn = !(this->pointsLine[0])->secondaryOn;
if ((this->pointsLine[0])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
}

Expand All @@ -442,19 +463,51 @@ void CirclePalette::mousePressEvent(QMouseEvent *event)
if (_is_collision(getMidPoint((this->pointsTriangle[0])->point, (this->pointsTriangle[1])->point), secondaryRadius, mousePos))
{
(this->pointsTriangle[0])->secondaryOn = !(this->pointsTriangle[0])->secondaryOn;
if ((this->pointsTriangle[0])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
if (_is_collision(getMidPoint((this->pointsTriangle[1])->point, (this->pointsTriangle[2])->point), secondaryRadius, mousePos))
{
(this->pointsTriangle[1])->secondaryOn = !(this->pointsTriangle[1])->secondaryOn;
if ((this->pointsTriangle[1])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
if (_is_collision(getMidPoint((this->pointsTriangle[2])->point, (this->pointsTriangle[0])->point), secondaryRadius, mousePos))
{
(this->pointsTriangle[2])->secondaryOn = !(this->pointsTriangle[2])->secondaryOn;
if ((this->pointsTriangle[2])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}

if (_is_collision(this->centroidTriangle, centroidRadius, mousePos))
{
this->centroidTriangleOn = !this->centroidTriangleOn;
if (centroidTriangleOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
}

Expand All @@ -463,23 +516,63 @@ void CirclePalette::mousePressEvent(QMouseEvent *event)
if (_is_collision(getMidPoint((this->pointsQuad[0])->point, (this->pointsQuad[1])->point), secondaryRadius, mousePos))
{
(this->pointsQuad[0])->secondaryOn = !(this->pointsQuad[0])->secondaryOn;
if ((this->pointsQuad[0])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
if (_is_collision(getMidPoint((this->pointsQuad[1])->point, (this->pointsQuad[2])->point), secondaryRadius, mousePos))
{
(this->pointsQuad[1])->secondaryOn = !(this->pointsQuad[1])->secondaryOn;
if ((this->pointsQuad[1])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
if (_is_collision(getMidPoint((this->pointsQuad[2])->point, (this->pointsQuad[3])->point), secondaryRadius, mousePos))
{
(this->pointsQuad[2])->secondaryOn = !(this->pointsQuad[2])->secondaryOn;
if ((this->pointsQuad[2])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
if (_is_collision(getMidPoint((this->pointsQuad[3])->point, (this->pointsQuad[0])->point), secondaryRadius, mousePos))
{
(this->pointsQuad[3])->secondaryOn = !(this->pointsQuad[3])->secondaryOn;
if ((this->pointsQuad[3])->secondaryOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}

if (_is_collision(this->centroidQuad, centroidRadius, mousePos))
{
this->centroidQuadOn = !this->centroidQuadOn;
if (centroidQuadOn)
{
this->controlOnClick.play();
}
else
{
this->controlOffClick.play();
}
}
}
}
Expand Down Expand Up @@ -538,10 +631,10 @@ void CirclePalette::create_gamut_triangle()

void CirclePalette::create_gamut_square()
{
ColorPoint *pFirst = new ColorPoint(QPoint(122 - this->geometry().left() - LEFT_SHIFT, 411 - this->geometry().top() - TOP_SHIFT));
ColorPoint *pSecond = new ColorPoint(QPoint(188 - this->geometry().left() - LEFT_SHIFT, 287 - this->geometry().top() - TOP_SHIFT));
ColorPoint *pThird = new ColorPoint(QPoint(362 - this->geometry().left() - LEFT_SHIFT, 220 - this->geometry().top() - TOP_SHIFT));
ColorPoint *pFourth = new ColorPoint(QPoint(495 - this->geometry().left() - LEFT_SHIFT, 419 - this->geometry().top() - TOP_SHIFT));
ColorPoint *pFirst = new ColorPoint(QPoint(204 - this->geometry().left(), 40 - this->geometry().top()));
ColorPoint *pSecond = new ColorPoint(QPoint(410 - this->geometry().left(), 194 - this->geometry().top()));
ColorPoint *pThird = new ColorPoint(QPoint(380 - this->geometry().left(), 318 - this->geometry().top()));
ColorPoint *pFourth = new ColorPoint(QPoint(116 - this->geometry().left(), 355 - this->geometry().top()));

pointsQuad.push_back(pFirst);
pointsQuad.push_back(pSecond);
Expand Down
7 changes: 5 additions & 2 deletions circlepalette.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QLabel>
#include <QPoint>
#include <QSoundEffect>

namespace PrestoPalette
{
Expand Down Expand Up @@ -33,7 +34,7 @@ class ColorPoint
{
this->point = p;
this->angle = 0;
this->secondaryOn = true;
this->secondaryOn = false; // secondaries are off by default
this->color = QColor();
}
};
Expand All @@ -51,6 +52,8 @@ class CirclePalette : public QWidget
QColor lightingColor;
PrestoPalette::GlobalGamutShape gamutShape;
PrestoPalette::GlobalWheelShape wheelShape;
QSoundEffect controlOffClick;
QSoundEffect controlOnClick;

bool enableLighting;

Expand All @@ -68,7 +71,7 @@ private slots:


private:
bool eventFilter( QObject* watched, QEvent* event );
bool eventFilter(QObject* watched, QEvent* event);
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
Expand Down
Loading

0 comments on commit fe379af

Please sign in to comment.