Skip to content

Commit

Permalink
Merge pull request #502 from scribblemaniac/color-wheel-alpha-fix-2
Browse files Browse the repository at this point in the history
Stopped color wheel changes from resetting alpha
  • Loading branch information
chchwy committed May 22, 2016
2 parents cfa0ac9 + 7b5ac71 commit d2994bf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
29 changes: 27 additions & 2 deletions app/colorwheel.cpp
Expand Up @@ -40,6 +40,11 @@ void ColorWheel::changeColor(const QColor &color)
{
svChanged(color);
}

if(color.alpha() != m_currentColor.alpha())
{
alphaChanged(color.alpha());
}
//emit colorChanged(color);
update();
}
Expand All @@ -61,6 +66,11 @@ void ColorWheel::setColor(const QColor &color)
svChanged(color);
}

if ( color.alpha() != m_currentColor.alpha() )
{
alphaChanged(color.alpha());
}

update();
emit colorSelected(color);
}
Expand Down Expand Up @@ -360,8 +370,9 @@ void ColorWheel::hueChanged(const int &hue)
}
int s = m_currentColor.saturation();
int v = m_currentColor.value();
int a = m_currentColor.alpha();

m_currentColor.setHsv(hue, s, v);
m_currentColor.setHsv(hue, s, v, a);

if(!isVisible())
{
Expand All @@ -377,9 +388,11 @@ void ColorWheel::hueChanged(const int &hue)
void ColorWheel::svChanged(const QColor &newcolor)
{
int hue = m_currentColor.hue();
int alpha = m_currentColor.alpha();
m_currentColor.setHsv(hue,
newcolor.saturation(),
newcolor.value());
newcolor.value(),
alpha);
if( !isVisible() )
{
return;
Expand All @@ -388,3 +401,15 @@ void ColorWheel::svChanged(const QColor &newcolor)
repaint();
emit colorChanged(m_currentColor);
}

void ColorWheel::alphaChanged(const int &alpha)
{
m_currentColor.setAlpha(alpha);

if(!isVisible())
{
return;
}

emit colorChanged(m_currentColor);
}
1 change: 1 addition & 0 deletions app/colorwheel.h
Expand Up @@ -33,6 +33,7 @@ public slots:
void changeColor(const QColor &color);
void hueChanged(const int &hue);
void svChanged(const QColor &newcolor);
void alphaChanged(const int &alpha);

QColor pickColor(const QPoint &point);

Expand Down

0 comments on commit d2994bf

Please sign in to comment.