GoogleCodeArchive / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

PScrollPane does not use setInteracting() on the canvas #131

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use the ScrollingExemple class from teh official samples
2. click/drag the canvas : when moving, PDragSequenceEventHandler changes
the rendering quality as expected
3. click/drag either the vertical or the horizontal scrollbar : the
redering quality is the best by default... does not change when interacting.

What is the expected output?
using scroll bars should set the isInteracting flag on the canvas.

I'm using trunk 

I've tried to add the following code in teh PScrollPane construction. It
works but I believe there are far better ways to do this...
Indeed, if one uses setVerticalScrollBar on the PScrollPane patched with
the code below, it would lead to a memory leak as the old scrollbar would
still be linked to the PScrollPane through the notification/callback
mechanism...

I can try to propose other patches if someone guides me to a better idea !

verticalScrollBar.addAdjustmentListener(new AdjustmentListener() {
  private boolean lastAdjustingState = verticalScrollBar.getValueIsAdjusting();

  public void adjustmentValueChanged(AdjustmentEvent e) {
    final boolean isAdjusting = verticalScrollBar.getValueIsAdjusting();

    if (isAdjusting != lastAdjustingState) {
      Component c = getViewport().getView();
      if (c instanceof PCanvas) {
        final PCanvas canvas = (PCanvas)c;
        canvas.setInteracting(isAdjusting);
        final boolean isInteracting = canvas.getInteracting();
      }
      lastAdjustingState = isAdjusting;
    }
  }
});

Original issue reported on code.google.com by lionel.v...@gmail.com on 10 Oct 2009 at 6:07

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r877.

Original comment by allain.lalonde on 30 Oct 2009 at 9:10

GoogleCodeExporter commented 9 years ago
I like this approach a lot. 

I've implemented it with a couple changes in  r877:
- I've modified the adjustment listener to be an instance field of the PViewport
- It doesn't hold a reference to its scrollbar
- I've made setVerticalScrollbar and setHorizontalScrollbar install and 
uninstall the
listener appropriately.

Thank you for pointing this out lionel. :)

Original comment by allain.lalonde on 30 Oct 2009 at 9:11

GoogleCodeExporter commented 9 years ago
The ScrollingExample looks good to me on several platforms.

Original comment by heue...@gmail.com on 4 Nov 2009 at 7:25