Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed return type of all color changing methods (*bar touch changes… #1

Merged
merged 1 commit into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -628,24 +628,26 @@ else if (Math.sqrt(x*x + y*y) <= mColorWheelRadius + mColorPointerHaloRadius
mAngle = (float) Math.atan2(y - mSlopY, x - mSlopX);
mPointerColor.setColor(calculateColor(mAngle));

setNewCenterColor(mCenterNewColor = calculateColor(mAngle));
mCenterNewColor = calculateColor(mAngle);

if (mOpacityBar != null) {
mOpacityBar.setColor(mColor);
mColor = mOpacityBar.setColor(mColor);
}

if (mValueBar != null) {
mValueBar.setColor(mColor);
mColor = mValueBar.setColor(mColor);
}

if (mSaturationBar != null) {
mSaturationBar.setColor(mColor);
mColor = mSaturationBar.setColor(mColor);
}

if (mSVbar != null) {
mSVbar.setColor(mColor);
mColor = mSVbar.setColor(mColor);
}

setNewCenterColor(mColor);

invalidate();
}
// If user did not press pointer or center, report event not handled
Expand Down Expand Up @@ -781,10 +783,11 @@ public boolean getShowOldCenterColor() {
*
* @param color int of the color used to change the opacity bar color.
*/
public void changeOpacityBarColor(int color) {
public int changeOpacityBarColor(int color) {
if (mOpacityBar != null) {
mOpacityBar.setColor(color);
return mOpacityBar.setColor(color);
}
return color;
}

/**
Expand All @@ -793,21 +796,23 @@ public void changeOpacityBarColor(int color) {
* @param color
* int of the color used to change the opacity bar color.
*/
public void changeSaturationBarColor(int color) {
public int changeSaturationBarColor(int color) {
if (mSaturationBar != null) {
mSaturationBar.setColor(color);
return mSaturationBar.setColor(color);
}
return color;
}

/**
* Used to change the color of the {@code ValueBar}.
*
* @param color int of the color used to change the opacity bar color.
*/
public void changeValueBarColor(int color) {
public int changeValueBarColor(int color) {
if (mValueBar != null) {
mValueBar.setColor(color);
return mValueBar.setColor(color);
}
return color;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,12 @@ public boolean onTouchEvent(MotionEvent event) {
*
* @param color
*/
public void setColor(int color) {
public int setColor(int color) {
int x1, y1;
if(mOrientation == ORIENTATION_HORIZONTAL) {
if(mOrientation) {
x1 = (mBarLength + mBarPointerHaloRadius);
y1 = mBarThickness;
}
else {
} else {
x1 = mBarThickness;
y1 = (mBarLength + mBarPointerHaloRadius);
}
Expand All @@ -428,10 +427,11 @@ public void setColor(int color) {
mBarPaint.setShader(shader);
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mPicker.setNewCenterColor(mColor);
}
// if (mPicker != null) {
// mPicker.setNewCenterColor(mColor);
// }
invalidate();
return mColor;
}

/**
Expand Down
20 changes: 8 additions & 12 deletions libary/src/main/java/com/larswerkman/holocolorpicker/SVBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,26 +350,26 @@ public boolean onTouchEvent(MotionEvent event) {
calculateColor(Math.round(dimen));
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
} else if (dimen < mBarPointerHaloRadius) {
mBarPointerPosition = mBarPointerHaloRadius;
mColor = Color.WHITE;
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
} else if (dimen > (mBarPointerHaloRadius + mBarLength)) {
mBarPointerPosition = mBarPointerHaloRadius + mBarLength;
mColor = Color.BLACK;
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand All @@ -395,8 +395,8 @@ public void setSaturation(float saturation) {
// Check whether the Saturation/Value bar is added to the ColorPicker
// wheel
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand All @@ -414,8 +414,8 @@ public void setValue(float value) {
// Check whether the Saturation/Value bar is added to the ColorPicker
// wheel
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand All @@ -427,7 +427,7 @@ public void setValue(float value) {
*
* @param color
*/
public void setColor(int color) {
public int setColor(int color) {
int x1, y1;
if(mOrientation) {
x1 = (mBarLength + mBarPointerHaloRadius);
Expand All @@ -442,14 +442,10 @@ public void setColor(int color) {
x1, y1, new int[] {Color.WHITE, color, Color.BLACK}, null,
Shader.TileMode.CLAMP);
mBarPaint.setShader(shader);
calculateColor(mBarPointerPosition);
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mPicker.setNewCenterColor(mColor);
if(mPicker.hasOpacityBar())
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
return mColor;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,29 +369,29 @@ public boolean onTouchEvent(MotionEvent event) {
calculateColor(Math.round(dimen));
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeValueBarColor(mColor);
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeValueBarColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
} else if (dimen < mBarPointerHaloRadius) {
mBarPointerPosition = mBarPointerHaloRadius;
mColor = Color.WHITE;
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeValueBarColor(mColor);
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeValueBarColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
} else if (dimen > (mBarPointerHaloRadius + mBarLength)) {
mBarPointerPosition = mBarPointerHaloRadius + mBarLength;
mColor = Color.HSVToColor(mHSVColor);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeValueBarColor(mColor);
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeValueBarColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand All @@ -415,9 +415,9 @@ public boolean onTouchEvent(MotionEvent event) {
*
* @param color
*/
public void setColor(int color) {
public int setColor(int color) {
int x1, y1;
if(mOrientation == ORIENTATION_HORIZONTAL) {
if(mOrientation) {
x1 = (mBarLength + mBarPointerHaloRadius);
y1 = mBarThickness;
}
Expand All @@ -434,14 +434,8 @@ public void setColor(int color) {
mBarPaint.setShader(shader);
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mPicker.setNewCenterColor(mColor);
if(mPicker.hasValueBar())
mPicker.changeValueBarColor(mColor);
else if(mPicker.hasOpacityBar())
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
return mColor;
}

/**
Expand All @@ -454,10 +448,11 @@ public void setSaturation(float saturation) {
+ mBarPointerHaloRadius;
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);

if (mPicker != null) {
mColor = mPicker.changeValueBarColor(mColor);
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeValueBarColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand Down
21 changes: 8 additions & 13 deletions libary/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,26 +370,26 @@ public boolean onTouchEvent(MotionEvent event) {
calculateColor(Math.round(dimen));
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
} else if (dimen < mBarPointerHaloRadius) {
mBarPointerPosition = mBarPointerHaloRadius;
mColor = Color.HSVToColor(mHSVColor);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
} else if (dimen > (mBarPointerHaloRadius + mBarLength)) {
mBarPointerPosition = mBarPointerHaloRadius + mBarLength;
mColor = Color.BLACK;
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand All @@ -413,13 +413,12 @@ public boolean onTouchEvent(MotionEvent event) {
*
* @param color
*/
public void setColor(int color) {
public int setColor(int color) {
int x1, y1;
if(mOrientation == ORIENTATION_HORIZONTAL) {
if(mOrientation) {
x1 = (mBarLength + mBarPointerHaloRadius);
y1 = mBarThickness;
}
else {
} else {
x1 = mBarThickness;
y1 = (mBarLength + mBarPointerHaloRadius);
}
Expand All @@ -431,12 +430,8 @@ public void setColor(int color) {
mBarPaint.setShader(shader);
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mPicker.setNewCenterColor(mColor);
if(mPicker.hasOpacityBar())
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
return mColor;
}

/**
Expand All @@ -451,8 +446,8 @@ public void setValue(float value) {
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mColor = mPicker.changeOpacityBarColor(mColor);
mPicker.setNewCenterColor(mColor);
mPicker.changeOpacityBarColor(mColor);
}
invalidate();
}
Expand Down