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

add aligned viewbox widget #2513

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

Conversation

matthiasverstraete
Copy link
Contributor

For a project I was working on, I needed to show a logo in the right top corner of my vispy canvas.
Surprisingly, I found that there was no functionality in vipsy to support this.

Therefore, I implemented this simple AlignedViewBox class which provides this functionality. Please let me know if you find that this would be a useful addition to your repository.

Thanks for your feedback.

Note: As the changes are very simple, it could also be implemented as an extra argument to the standard ViewBox

@djhoese
Copy link
Member

djhoese commented Jul 27, 2023

Hhhmmm this is very interesting. Thanks for making the pull request. The way we've told people to do this in the past is to set the parent of their "overlay" widgets not to the viewbox's subscene (view.scene off the top of my head), but to the Canvas itself or something like that. I was recently corrected on how this is actually done, but I don't remember what the correct way is...Regardless, the point is you basically make it so the parent of your widgets/visuals is not the camera-based view, but rather the canvas widget itself. This allows you to specify coordinate for your widgets in pixel space I think. Obviously I've never done it myself, but it is supposed to work. I have no idea if doing it this way automatically adjusts things that are "aligned" on the edges to still be on the edges when things are resized.

Do you have any experience doing it this way? Does the on_resize of this new viewbox handle these cases that would otherwise be annoying to deal with in user code? I guess what I'm asking is, how does your viewbox differ from this type of workflow? How much easier is a user's life using your viewbox rather than doing it themselves?

What happens to your viewbox if you attach a camera to it?

@brisvag
Copy link
Collaborator

brisvag commented Jul 31, 2023

I agree that this seems overkill if all you need is a static logo. However, the viewbox has the advantage that it will be a whole new separate subcanvas, so it can itself have scenes and cameras and mouse interactions. Not sure this is the use case, though :)

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.

None yet

3 participants