Repository navigation
Adds an inner fill to the pointer and the ability to stroke inside the pointer #49
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
Open
jonathan-livly
wants to merge
18
commits into
tankery:master
Choose a base branch
from
jonathan-livly:feature/03-adds-fill-to-pointer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
01dc498
Adds Kotlin to project
jonathan-livly 73c2206
Updates AndroidManifest.xml with required exported attribute
jonathan-livly e64c58c
Converts MainActivity to Kotlin using stale branch's changes
jonathan-livly 198e919
Converts CircularSeekBar to Kotlin as CircularSeekBarV2.kt
jonathan-livly d931014
Deletes old CircularSeekBar.java
jonathan-livly d6f7673
Removes Hungarian notation. Should now be backwards compatible with o…
jonathan-livly 2ebc504
Adds the ability to have an inner fill color on the pointer and speci…
jonathan-livly 901972d
Merge branch 'master' of https://github.com/tankery/CircularSeekBar i…
jonathan-livly 1da0714
Removes fill from square pointer example
jonathan-livly 097d674
Reverts changes to to api names
jonathan-livly 07060b7
Ensures `pointerFillInnerStrokeWidth` is never negative
jonathan-livly 0d7c056
Adds name space to README.md
jonathan-livly ff29588
Reverts name change for DEFAULT_POINTER_STROKE_WIDTH
jonathan-livly 725f951
Renames pointer fill properties to the much clearer name pointer overlay
jonathan-livly c0634f7
Fixes bug related to using `Paint.Style.FILL_AND_STROKE` instead of `…
jonathan-livly 402a987
Removes * from imports
jonathan-livly ef92ce3
Adjust imports order
jonathan-livly 7c3e0cc
Saves instance state of pointerOverlayBorderWidth
jonathan-livly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,14 +29,14 @@ package me.tankery.lib.circularseekbar | |
|
|
||
| import android.content.Context | ||
| import android.content.res.TypedArray | ||
| import android.graphics.BlurMaskFilter | ||
| import android.graphics.Canvas | ||
| import android.graphics.Color | ||
| import android.graphics.Paint | ||
| import android.graphics.Path | ||
| import android.graphics.Paint.Cap | ||
| import android.graphics.RectF | ||
| import android.graphics.Color | ||
| import android.graphics.BlurMaskFilter | ||
| import android.graphics.Path | ||
| import android.graphics.PathMeasure | ||
| import android.graphics.Canvas | ||
| import android.graphics.RectF | ||
| import android.os.Build | ||
| import android.os.Bundle | ||
| import android.os.Parcelable | ||
|
|
@@ -85,11 +85,17 @@ class CircularSeekBar @JvmOverloads constructor( | |
| private val circleProgressGlowPaint: Paint = Paint() | ||
|
|
||
| /** | ||
| * `Paint` instance used to draw the center of the pointer. | ||
| * `Paint` instance used to draw the pointer. | ||
| * Note: This is broken on 4.0+, as BlurMasks do not work with hardware acceleration. | ||
| */ | ||
| private val pointerPaint: Paint = Paint() | ||
|
|
||
| /** | ||
| * `Paint` instance used to draw an overlay over [pointerPaint]. | ||
| * Will effectively use [pointerPaint] as stroke. | ||
| */ | ||
| private val pointerOverlayPaint: Paint = Paint() | ||
|
|
||
| /** | ||
| * `Paint` instance used to draw the halo of the pointer. | ||
| * Note: The halo is the part that changes transparency. | ||
|
|
@@ -148,7 +154,7 @@ class CircularSeekBar @JvmOverloads constructor( | |
| /** | ||
| * The radius of the pointer (in pixels). | ||
| * | ||
| * Sets the pointer pointer stroke width. | ||
| * Sets the pointer stroke width. | ||
| * @param width the width of the pointer | ||
| */ | ||
| var pointerStrokeWidth = 0f | ||
|
|
@@ -159,6 +165,24 @@ class CircularSeekBar @JvmOverloads constructor( | |
| invalidate() | ||
| } | ||
|
|
||
| /** | ||
| * The border width between the pointer and [pointerOverlayPaint] | ||
| * Can not be less than zero, if the border is larger than [pointerStrokeWidth] this will not display | ||
| * | ||
| * @param width the width of the pointer stroke. Must be a positive number | ||
| */ | ||
| var pointerOverlayBorderWidth = DEFAULT_POINTER_OVERLAY_BORDER_WIDTH | ||
| set(width) { | ||
| field = if (width < 0) { | ||
| 0f | ||
| } else { | ||
| width | ||
| } | ||
| initPaints() | ||
| recalculateAll() | ||
| invalidate() | ||
| } | ||
|
|
||
| /** | ||
| * The width of the pointer halo (in pixels). | ||
| */ | ||
|
|
@@ -245,6 +269,13 @@ class CircularSeekBar @JvmOverloads constructor( | |
| invalidate() | ||
| } | ||
|
|
||
| var pointerOverlayColor = DEFAULT_POINTER_OVERLAY_COLOR | ||
| set(color) { | ||
| field = color | ||
| pointerOverlayPaint.color = color | ||
| invalidate() | ||
| } | ||
|
|
||
| /** | ||
| * Holds the color value for `mPointerHaloPaint` before the `Paint` instance is created. | ||
| * | ||
|
|
@@ -545,6 +576,7 @@ class CircularSeekBar @JvmOverloads constructor( | |
| R.styleable.cs_CircularSeekBar_cs_circle_y_radius, | ||
| DEFAULT_CIRCLE_Y_RADIUS | ||
| ) | ||
|
|
||
| pointerStrokeWidth = attrArray.getDimension( | ||
| R.styleable.cs_CircularSeekBar_cs_pointer_stroke_width, | ||
| DEFAULT_POINTER_STROKE_WIDTH | ||
|
|
@@ -568,6 +600,16 @@ class CircularSeekBar @JvmOverloads constructor( | |
| R.styleable.cs_CircularSeekBar_cs_pointer_color, | ||
| DEFAULT_POINTER_COLOR | ||
| ) | ||
| pointerOverlayColor = attrArray.getColor( | ||
| R.styleable.cs_CircularSeekBar_cs_pointer_overlay_color, | ||
| DEFAULT_POINTER_OVERLAY_COLOR | ||
| ) | ||
|
|
||
| pointerOverlayBorderWidth = attrArray.getDimension( | ||
| R.styleable.cs_CircularSeekBar_cs_pointer_overlay_border_width, | ||
| DEFAULT_POINTER_OVERLAY_BORDER_WIDTH | ||
| ) | ||
|
|
||
| pointerHaloColor = attrArray.getColor( | ||
| R.styleable.cs_CircularSeekBar_cs_pointer_halo_color, | ||
| DEFAULT_POINTER_HALO_COLOR | ||
|
|
@@ -660,6 +702,7 @@ class CircularSeekBar @JvmOverloads constructor( | |
| } | ||
| if (disablePointer) { | ||
| pointerStrokeWidth = 0f | ||
| pointerOverlayBorderWidth = 0f | ||
| pointerHaloWidth = 0f | ||
| pointerHaloBorderWidth = 0f | ||
| } | ||
|
|
@@ -705,6 +748,12 @@ class CircularSeekBar @JvmOverloads constructor( | |
| pointerPaint.strokeJoin = Paint.Join.ROUND | ||
| pointerPaint.strokeCap = circleStyle | ||
|
|
||
| pointerOverlayPaint.set(pointerPaint) | ||
| pointerOverlayPaint.color = pointerOverlayColor | ||
| pointerOverlayPaint.style = Paint.Style.STROKE | ||
| pointerOverlayPaint.strokeWidth = | ||
| (pointerStrokeWidth - pointerOverlayBorderWidth).coerceAtLeast(0f) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use the concept of "overlay", than the border width of this overlay looks more like it's own width (circle diameter). So at here we may directly set the |
||
|
|
||
| pointerHaloPaint.set(pointerPaint) | ||
| pointerHaloPaint.color = pointerHaloColor | ||
| pointerHaloPaint.alpha = pointerAlpha | ||
|
|
@@ -825,6 +874,7 @@ class CircularSeekBar @JvmOverloads constructor( | |
| canvas.drawPath(circlePointerPath, pointerHaloPaint) | ||
| } | ||
| canvas.drawPath(circlePointerPath, pointerPaint) | ||
| canvas.drawPath(circlePointerPath, pointerOverlayPaint) | ||
| // TODO, find a good way to draw halo border. | ||
| // if (mUserIsMovingPointer) { | ||
| // canvas.drawCircle(mPointerPositionXY[0], mPointerPositionXY[1], | ||
|
|
@@ -1104,6 +1154,8 @@ class CircularSeekBar @JvmOverloads constructor( | |
| state.putInt("circleColor", circleColor) | ||
| state.putInt("circleProgressColor", circleProgressColor) | ||
| state.putInt("pointerColor", pointerColor) | ||
| state.putInt("pointerOverlayColor", pointerOverlayColor) | ||
| state.putFloat("pointerOverlayBorderWidth", pointerOverlayBorderWidth) | ||
| state.putInt("pointerHaloColor", pointerHaloColor) | ||
| state.putInt("pointerHaloColorOnTouch", pointerHaloColorOnTouch) | ||
| state.putInt("pointerAlpha", pointerAlpha) | ||
|
|
@@ -1128,6 +1180,8 @@ class CircularSeekBar @JvmOverloads constructor( | |
| circleColor = savedState.getInt("circleColor") | ||
| circleProgressColor = savedState.getInt("circleProgressColor") | ||
| pointerColor = savedState.getInt("pointerColor") | ||
| pointerOverlayColor = savedState.getInt("pointerOverlayColor") | ||
|
jonathan-livly marked this conversation as resolved.
|
||
| pointerOverlayBorderWidth = savedState.getFloat("pointerOverlayBorderWidth") | ||
| pointerHaloColor = savedState.getInt("pointerHaloColor") | ||
| pointerHaloColorOnTouch = savedState.getInt("pointerHaloColorOnTouch") | ||
| pointerAlpha = savedState.getInt("pointerAlpha") | ||
|
|
@@ -1194,6 +1248,8 @@ class CircularSeekBar @JvmOverloads constructor( | |
| private const val DEFAULT_CIRCLE_COLOR = Color.DKGRAY | ||
| private val DEFAULT_CIRCLE_PROGRESS_COLOR = Color.argb(235, 74, 138, 255) | ||
| private val DEFAULT_POINTER_COLOR = Color.argb(235, 74, 138, 255) | ||
| private const val DEFAULT_POINTER_OVERLAY_COLOR = Color.TRANSPARENT | ||
| private val DEFAULT_POINTER_OVERLAY_BORDER_WIDTH = 0f | ||
| private val DEFAULT_POINTER_HALO_COLOR = Color.argb(135, 74, 138, 255) | ||
| private val DEFAULT_POINTER_HALO_COLOR_ONTOUCH = Color.argb(135, 74, 138, 255) | ||
| private const val DEFAULT_CIRCLE_FILL_COLOR = Color.TRANSPARENT | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.