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

"Horizontal Clipping" #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EnricoMonese
Copy link
Contributor

@EnricoMonese EnricoMonese commented Mar 8, 2018

This is something we needed for our project, if you want to add it to the original codebase here it is!
The change allows to clip the spark-line horizontally and draws a grey line under it.
The gif sums it up pretty well.

public void setClipAmount(float amount) to set a value between 0 and 1. If value is 1 clipping gets automatically disabled. (Passed value get clipped between 0 and 1)
There's also a public boolean clipOnScrub to automatically use it when scrubbing.

clip

@naturalwarren
Copy link
Contributor

This looks neat! Thanks for sharing!

If this is going to get added it might make sense to have this as a stylable attribute as well as a programatic API. Also, perhaps we would want to make the color configurable instead of always using grey?

Lets see what @danh32 thinks :)

private Paint sparkFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint baseLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint scrubLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private OnScrubListener scrubListener;
private ScrubGestureDetector scrubGestureDetector;
private Animator pathAnimator;
private final RectF contentRect = new RectF();
private float clipAmount = 1f;
private RectF clippedRect = new RectF();
public boolean clipOnScrub;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd likely want this to a public API instead of something that can be directly set on the view.

@naturalwarren
Copy link
Contributor

naturalwarren commented Mar 10, 2018

I'd love to better understand the use case here; it feels a little awkward to leave the graph in the last scrubbed state (part green, part grey) after the scrub bar is gone. Where did you find yourself wanting this behavior?

@EnricoMonese
Copy link
Contributor Author

Yeah I also wan't sure what to do when finishing scrubbing. I though to use a `keepClipAfterScrub but it was getting too convoluted and too many parameters for a relatively small feature.
We use it synced with a video, while the video plays the graph progresses. It gets set by code, we're not using the scrubbing. That's why that part is not so polished

@danh32
Copy link
Contributor

danh32 commented Apr 21, 2018

Similarly to #54, I think this is a bit too specific for Spark 1.0. I also agree with @naturalwarren on the public boolean needing a bit of polish.

@EnricoMonese
Copy link
Contributor Author

EnricoMonese commented Apr 21, 2018

Yeah I agree, this is kinda specific. It would also need a better name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants