diff --git a/libary/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java b/libary/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java index ee1fd3e..2309c95 100644 --- a/libary/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java +++ b/libary/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java @@ -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 @@ -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; } /** @@ -793,10 +796,11 @@ 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; } /** @@ -804,10 +808,11 @@ public void changeSaturationBarColor(int color) { * * @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; } /** diff --git a/libary/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java b/libary/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java index fccac9a..64aa2b9 100644 --- a/libary/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java +++ b/libary/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java @@ -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); } @@ -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; } /** diff --git a/libary/src/main/java/com/larswerkman/holocolorpicker/SVBar.java b/libary/src/main/java/com/larswerkman/holocolorpicker/SVBar.java index 352159f..32690c4 100644 --- a/libary/src/main/java/com/larswerkman/holocolorpicker/SVBar.java +++ b/libary/src/main/java/com/larswerkman/holocolorpicker/SVBar.java @@ -350,8 +350,8 @@ 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) { @@ -359,8 +359,8 @@ public boolean onTouchEvent(MotionEvent event) { 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)) { @@ -368,8 +368,8 @@ public boolean onTouchEvent(MotionEvent event) { mColor = Color.BLACK; mBarPointerPaint.setColor(mColor); if (mPicker != null) { + mColor = mPicker.changeOpacityBarColor(mColor); mPicker.setNewCenterColor(mColor); - mPicker.changeOpacityBarColor(mColor); } invalidate(); } @@ -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(); } @@ -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(); } @@ -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); @@ -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; } /** diff --git a/libary/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java b/libary/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java index fd736ea..cfc2d5b 100644 --- a/libary/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java +++ b/libary/src/main/java/com/larswerkman/holocolorpicker/SaturationBar.java @@ -369,9 +369,9 @@ 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) { @@ -379,9 +379,9 @@ public boolean onTouchEvent(MotionEvent event) { 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)) { @@ -389,9 +389,9 @@ public boolean onTouchEvent(MotionEvent event) { 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(); } @@ -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; } @@ -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; } /** @@ -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(); } diff --git a/libary/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java b/libary/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java index 93e337e..0837dd7 100644 --- a/libary/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java +++ b/libary/src/main/java/com/larswerkman/holocolorpicker/ValueBar.java @@ -370,8 +370,8 @@ 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) { @@ -379,8 +379,8 @@ public boolean onTouchEvent(MotionEvent event) { 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)) { @@ -388,8 +388,8 @@ public boolean onTouchEvent(MotionEvent event) { mColor = Color.BLACK; mBarPointerPaint.setColor(mColor); if (mPicker != null) { + mColor = mPicker.changeOpacityBarColor(mColor); mPicker.setNewCenterColor(mColor); - mPicker.changeOpacityBarColor(mColor); } invalidate(); } @@ -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); } @@ -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; } /** @@ -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(); }