PiDog ScrollingCanvas - Bug or am I doing it wrong?

  1. 6 months ago

    Markus W

    Jan 8 Pre-Release Testers #JeSuisHuman Germany, Heidelb...
    Edited 6 months ago

    Hi,

    I'm evaluating ScrollingCanvas for a project. I make a simple test: add ScrollingCavas to a project, add a canvas to a window and set its super to ScrollingCanvas, add the PaintScrollingLayer event, then have the following code in PaintScrollingLayer:

    g.ForeColor = &cFF000000
    g.FillOval( 100 - xOffset, 100 - yOffset, 100, 100 )

    This draws a red circle on the canvas.

    At first view scrolling and zooming work fine, but if I enlarge the window so that no scrollbars are necessary then zooming doesn't work at all. Is this a bug or am I doing it wrong?

    Best Regards

    Markus

    P.S. I put the test project and a screen capture movie in my dropbox - see https://www.dropbox.com/s/cjrszydjj1q3j6w/test%20PiDog%20scrolling%20Canvas.zip?dl=0 - when the movie seems as if nothing is happening then I try pinching and zooming but without effect.

    P.P.S. I had tried to send the message to PiDog but only get an error "There was an error trying to send your message. Please try again later."

  2. jim m

    Jan 8 Pre-Release Testers, Xojo Pro piDog.com

    I see what's happening. Give me a minute and I'll get a fix posted.

  3. jim m

    Jan 8 Pre-Release Testers, Xojo Pro piDog.com
    Edited 6 months ago

    Here's a new version that should fix the zoom issue, along with the laggy scrolling.
    DataView_piDogScrollingCanvas_1.13.4.3.zip

    I did hopefully get the contact form fixed on the piDog site also...

  4. Markus W

    Jan 8 Pre-Release Testers #JeSuisHuman Germany, Heidelb...

    Excellent - that works much better. Now I have to see how it integrates into my existing drawing structure …

  5. Markus W

    Jan 9 Pre-Release Testers #JeSuisHuman Germany, Heidelb...
    Edited 5 months ago

    My drawing structure is based on SimpleDraw from xDev 12.5, so my canvas has a simple paint event:

    Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
      
      draw(g)  
      
    End Sub

    when I set the canvas super to ScrollingCanvas then I get the error that ScrollingCanvas has already implemented the paint event.

    Should ScrollingCanvas not perpetuate the paint event? (add an event definition and raise the event)

    I also put draw(g) into the PaintScrollingLayer event but that did not change anything.

    One thing I notice: there does not seem to be a "big picture overview" to help one understand how to work with the ScrollingCanvas …

  6. 5 months ago

    jim m

    Jan 9 Pre-Release Testers, Xojo Pro piDog.com

    The reason for not exposing the Paint event is due to the ambiguity. It wouldn't be clear which layer you're painting.

    The layers are (from back to front)

    Static Layer - painted in PaintStaticLayer (ie for gridlines)
    Scrolling Layer - painted in PaintScrollingLayer (for content)
    Overlay Layer - painted in PaintOverlayLayer (ie for rulers or information display)
    Dragging Layer - painted in PaintDragLayer (only meaningful in raster mode to avoid redrawing the overlay every frame)

    The overview document seems to have been lost when I moved to my new documentation generator. I'm adding that back in now. Thanks for pointing that out!

  7. Markus W

    Jan 9 Pre-Release Testers #JeSuisHuman Germany, Heidelb...
    Edited 5 months ago

    Thanks for the explanation and the fast responses.

    Currently I see no way to integrate ScrollingCanvas. My canvas has a list of objects that know how to draw themselves. My paint event simply calls a draw method that in turn (1) creates a BitMapForCaching to draw on, and (2) calls each objects draw method, and in the end the picture in BitMapForCaching is drawn on the canvas with DrawPicture:

    Private Sub draw(g As Graphics, printing as boolean = false, alternateX as integer = 0, alternateY as integer = 0)
    
      // Create BitMapForCaching
      mCachedContent = Self.TrueWindow.BitmapForCaching( hScroll.Maximum, vScroll.Maximum )
      
      // Draw background and border.
      g.transparency = 0
      g.foreColor = &cFFFFFF // White
      g.fillRect(0, 0, g.width, g.height)
      
      dim x, y as integer
      
      if alternateX < 0 then x = -alternateX
      if alternateY < 0 then y = -alternateY
      
      // MyDrawing is a list of objects that each know how to draw themselves
      // Draw the picture by calling each objects draw method
      if myDrawing <> nil then
        dim objectNum as integer
        for i as integer = 0 to objectList.ubound
          objectNum = objectList(i)
          dim selected as boolean = (selection = objectNum)
          dim drawob as sdObjectType = myDrawing.lookup(objectNum, nil)
          if drawob <> nil then drawob.draw(g, x, y, ZoomFactor, selected)
        next i
      end if // myDrawing = nil
      
      // now draw the picture
      g.DrawPicture(mCachedContent, 0, 0)
      
    End Sub

    I tried to change the mCachedContent reference

    //mCachedContent = Self.TrueWindow.BitmapForCaching( hScroll.Maximum, vScroll.Maximum )
    mCachedContent = pictCanvas.ScrollingImage

    but no luck there.

    I presume ScrollingCanvas does its own BitMapForCaching so that could be a problem, but at the moment I simply don't know, and the documentation is not exactly helpful (I would rate it even less helpful than Monkeybread's documentation). At the moment I would say ScrollingCanvas works very very well for what it does, support is superb, but the documentation is atrocious - as soon as you hit a snag it won't be helpful. But keep in mind that this might be due to my very limited understanding of the product … which of course I blame entirely on the documentation ;-)

  8. jim m

    Jan 9 Pre-Release Testers, Xojo Pro piDog.com

    I'll make some assumptions about your objects here and assume that pictCanvas is the scrollingCanvas...

    First thing you'll need to do is set the pictCanvas.ScrollingLayerWidth and pictCanvas.ScrollingLayerHeight to the dimensions of the content area you need.

    Then, try adding this to the paintScrollingLayer event of pictCanvas:

     if myDrawing <> nil then
        dim objectNum as integer
        for i as integer = 0 to objectList.ubound
          objectNum = objectList(i)
          dim selected as boolean = (selection = objectNum)
          dim drawob as sdObjectType = myDrawing.lookup(objectNum, nil)
          if drawob <> nil then drawob.draw(g, xoffset, yoffset, Zoom, selected)
        next i
      end if

    You may also want to check that renderMode is set to Vector in the inspector.

    This is just a guess based on what I see...

  9. Markus W

    Jan 9 Pre-Release Testers #JeSuisHuman Germany, Heidelb...

    Hi Jim,

    Thanks. I send you a pm.

or Sign Up to reply!