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

Introduce a proper ZoomModel #150

Open
bric3 opened this issue Jan 26, 2023 · 1 comment
Open

Introduce a proper ZoomModel #150

bric3 opened this issue Jan 26, 2023 · 1 comment
Labels
enhancement New feature or request flamegraph
Milestone

Comments

@bric3
Copy link
Owner

bric3 commented Jan 26, 2023

Using the bounds as a mean to zoom causes some complications. It was introduced to animate the zoom. But the various computation makes the factor not stable.

See #46

Using a ZoomModel, the code can control the actual zoom factor, the model should be able to perform the necessary checks (scale to low, too high).

@bric3 bric3 added the enhancement New feature or request label Jan 26, 2023
@bric3 bric3 added this to the 0.0.1 milestone Jan 29, 2023
@bric3
Copy link
Owner Author

bric3 commented Jan 29, 2023

Actually the fix introduced in #149 to fix #46 doesn't work properly and introduce flickering when the flamegraph is not zoomed.

The issue is due to the ScrollPaneLayout that is checking before ViewPortLayout if an horizontal bar is needed. Since the container is shrinking the width is getting narrower than the "out of date" canvas.
Note that layout is called on the ScrollPane first then on the view port.

To fix that there's two options (guassing from the ScrollPaneLayout code:

        boolean viewTracksViewportWidth = false;
        ...
        if (!isEmpty && view instanceof Scrollable) {
            sv = (Scrollable)view;
            viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();
            viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();
        }
        else {

        ...

        if (hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) {
            hsbNeeded = true;
        }
        else if (hsbPolicy == HORIZONTAL_SCROLLBAR_NEVER) {
            hsbNeeded = false;
        }
        else {  // hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
            hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width);
        }
  1. Implements Scrollable interface as in Investigate Scrollable use for the canvas #92 and to toggle viewTracksViewportWidth.
  2. In the canvas identify when being zoomed and set the HSB policy via setHorizontalScrollBarPolicy.

Either way the code needs to know when it's zoomed or not. The current approach is a bit hacky as it requires to deal with boundaries (width / height) to trigger the zoom. This approach is more and more problematic especially when it comes to layout.
Even #149 had some issues with scale factor stability.

Introducing a proper Zoom or scale model will be likely helping. Doing so maybe an opportunity to revisit #92.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flamegraph
Projects
None yet
Development

No branches or pull requests

1 participant