Skip to content

Tooltips, add overlay render pass #830

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

Merged
merged 15 commits into from
May 22, 2025
Merged

Tooltips, add overlay render pass #830

merged 15 commits into from
May 22, 2025

Conversation

kushalkolar
Copy link
Member

@kushalkolar kushalkolar commented May 20, 2025

closes #753

  • adds an overlay render pass, I think pygfx plans for a more effiicent overlay render pass later without the depth buffer but I think we can update it to that later when it's available.
  • Tooltip class that can manage displaying tooltips for registered Graphics
    • Figure.tooltip_manager is an Tooltip instance
  • Figure.show_tooltip is a settable property
  • Figure.tooltip_manager.register() is a method than can be used for customizable registration of tooltips.

Usage options:

Auto-register all Graphics that will be added to the figure. Tooltips display the data of the hovered vertex or image array element (either grayscale value or RGB(A) values).

fig = fpl.Figure(..., show_tooltips=True)

# to hide tooltips for all graphics in an existing Figure
# this basically unregisters all graphics
# figure.show_tooltips = False

# to show tooltips for all graphics in an existing Figure
# this basically registers all current graphics in the figure's subplots
# figure.show_tooltips = True

Manually register a tooltip for a Graphic.

fig.tooltip_manager.register(
    graphic=my_graphic,
    appear_event="click",  # any valid pointer event
    disappear_event="double_click",  # any valid pointer event
)

Manually register a tooltip to show custom info by register a function that takes the pointer event and returns a str:

def custom_tooltip_info(ev: PointerEvent):
    index = ev.pick_info["vertex_index"]
    info = custom_metadata_object[index]
    return info

fig.tooltip_manager.register(
    my_graphic,
    custom_info=custom_tooltip_info,
)
tt-2025-05-20_03.50.28.mp4

@@ -7,7 +7,7 @@
from ._rect import RectManager


class UnderlayCamera(pygfx.Camera):
class ScreenSpaceCamera(pygfx.Camera):
"""
Same as pygfx.ScreenCoordsCamera but y-axis is inverted.
Copy link
Member Author

Choose a reason for hiding this comment

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

@almarklein would be useful to have a pygfx Camera that is in screenspace with inverted y, pointer events use (0, 0) as the top left corner so it would be useful to have the option.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something like this? pygfx/pygfx#1092

@kushalkolar kushalkolar marked this pull request as ready for review May 20, 2025 20:45
@kushalkolar kushalkolar requested a review from clewis7 as a code owner May 20, 2025 20:45
@kushalkolar
Copy link
Member Author

@clewis7 ready for review

Screenshot_20250520_164705

Screenshot_20250520_164713

Screenshot_20250520_164720

Screenshot_20250520_164730

Custom tooltips by providing a function that takes the pointer event and outputs a str

Screenshot_20250520_164751

Copy link

github-actions bot commented May 20, 2025

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/tooltips

Comment on lines +533 to +534
# overlay render pass
self.renderer.render(self._overlay_scene, self._overlay_camera, flush=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

@almarklein the overlay render pass without the depth buffer doesn't exist yet right? we'll just keep this here for now and update later I guess.

@kushalkolar kushalkolar changed the title Tooltips Tooltips, add overlay render pass May 21, 2025
Copy link
Member

@clewis7 clewis7 left a comment

Choose a reason for hiding this comment

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

Very nice as always, just a few nitpicky things

Co-authored-by: Caitlin Lewis <69729525+clewis7@users.noreply.github.com>
@clewis7 clewis7 merged commit 5cda159 into main May 22, 2025
52 checks passed
@clewis7 clewis7 deleted the tooltips branch May 22, 2025 12:59
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.

tooltips
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy