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

Variant drawing styles #1502

Merged
merged 6 commits into from
May 20, 2022
Merged

Conversation

dariogf
Copy link
Contributor

@dariogf dariogf commented May 4, 2022

There are two new options to review, the strokecolor property that can be used to change only the stroke color in a similar way to the color property, and the context_hook that pass a complete drawing context that can be used to customize the drawing at any level.

@jrobinso
Copy link
Contributor

jrobinso commented May 4, 2022

Thanks this is an interesting PR, and could potentially be generalized for other track types. I won't be able to concentrate on this until next week, busy with some IGV desktop work at the moment.

@jrobinso
Copy link
Contributor

jrobinso commented May 4, 2022

In the meantime, it looks like I also made some variantTrack changes, if you could resolve the conflicts that would be helpful. Not essential though.

@dariogf
Copy link
Contributor Author

dariogf commented May 4, 2022 via email

@jrobinso
Copy link
Contributor

jrobinso commented May 4, 2022

OK if it takes much time don't worry about it I can do it while reviewing.

@dariogf
Copy link
Contributor Author

dariogf commented May 6, 2022

I have resolved the conflicts, and separated the example to a new file.

@jrobinso
Copy link
Contributor

I'll be looking at this this week.

@jrobinso
Copy link
Contributor

@dariogf I had an initial look, looks great, I am confused about 1 point. The "context_hook" is used to customize the drawing of the variant, however the default drawing (a rectangle) is drawn first whether a "context_hook" is defined or not. In your draw implementations you sometimes clear this previously drawn rect, however I think logic like the following would be clearer and more flexible

if(this._context_hook) {
   ... draw with the provided function
} else {
   ... do the default draw. (fill rectangle)
}

Another minor comment, I think we might rename "context_hook" to something more explicit, it wasn't clear to me until looking at the code what it actually does. However I don't have a suggestion at this point, just noting it. Also, I think I will extend this to allow a hook for genotype drawing as well, however I can do that post merge.

@dariogf
Copy link
Contributor Author

dariogf commented May 18, 2022 via email

@jrobinso
Copy link
Contributor

WRT optionally doing the default draw, I think I'll implement that if function explicitly returns false, in other words no return value (=> undefined) will be converted to true, because I think the general expectation would be the custom draw overrides the default one.

@dariogf
Copy link
Contributor Author

dariogf commented May 19, 2022 via email

jrobinso added a commit that referenced this pull request May 19, 2022
@jrobinso
Copy link
Contributor

OK I've made the changes discussed, and to my surprise I was able to push them to this branch. If I had thought that would succeed I would have added more comments. Here are the changes:

  • strokecolor property renamed to "borderColor", easier to explain
  • context_hook renamed to "customDraw"
  • If custom draw function explicitly returns false the default variant representation is drawn. I think this only makes sense to use if the customDraw function does nothing, since the default draw will overwrite it.

@dariogf
Copy link
Contributor Author

dariogf commented May 19, 2022 via email

@jrobinso jrobinso merged commit dba763e into igvteam:master May 20, 2022
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.

2 participants