B4J Question Canvas "World view" and Movable Window View

maleche

Active Member
Licensed User
Longtime User
When drawing MANY items on a Canvas, I would like to keep the plotted lines and objects that are moving.
The canvas should contain a "World View" having 9000 x 9000. The targets move per speed and course vector every second and encompass the entire World (9000 x 9000).
i would like to only show the "View port" or a window about 100 x 100. as i move the "Window/View Port", it shows the objects.
To clarify, the "World" dimensions are beyond the view and the window only displays the current or previous plotted targets.
Moreover, i have tried to scale the canvas, but rely on redrawing everything using 100dip/100 as i read in this forum.
any chance of a function/method to accomplish this scaling and window?
see attached example
Keep up the outstanding work!
Doyle
 

Attachments

  • WorldWindow.png
    WorldWindow.png
    231.8 KB · Views: 116

drgottjr

Expert
Licensed User
Longtime User
not sure i fully understand what you want, but it sounds like a transparent (movable) pane on top of a fixed base. technically, you could also move the base when the movable pane gets to the edge of the screen. for the demo i chose 4 buttons to move the pane around. obviously there are other ways to handle it
 

Attachments

  • sky2.jpg
    sky2.jpg
    46.1 KB · Views: 86
  • sky1.jpg
    sky1.jpg
    42.6 KB · Views: 94
Upvote 0

maleche

Active Member
Licensed User
Longtime User
Thank your for the quick response.
I think i was unclear in my initial description.
The Portal is the entire screen, while the "World" view is extend beyond the portal. The user can move the world view in range of the view port. the 100x100 is really the screen resolution (view).
sorry if i wasn't clear.

Here is a better example picture
 

Attachments

  • WorldView.PNG
    WorldView.PNG
    73.8 KB · Views: 93
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I would think that a ScrollPane would be the way to go for this.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
@stevel05 is, as usual, perfect in his solution. I wasn't too familiar with ScrollPane, so I made a little test.
Note the handles of the scroll bars. The image generated by a B4XCanvas on a designer layout pane is 9000 x 9000 pixels.
The view screen = the form is 1024 x 768. The complete code (.zip attached):

B4X:
Sub Class_Globals
    Type SortPair(key As Object, value As Object)
    Private Root As B4XView
    Private xui As XUI
    
    Dim cv As B4XCanvas
    Private Pane1 As B4XView
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Dim windowz As ScrollPane
    windowz.Initialize("move")
    windowz.SetHScrollVisibility("ALWAYS")
    windowz.SetVScrollVisibility("ALWAYS")

    Dim windowx As B4XView = windowz
    Root.AddView(windowx, 0, 0, Root.Width, Root.height)
    windowx.ScrollViewInnerPanel.LoadLayout("bigPane")
    
    cv.Initialize(Pane1)
    For r = 4000 To 100 Step -100
        cv.DrawCircle(4500, 4500, r, xui.Color_RGB(Rnd(100, 255), Rnd(100, 255), Rnd(100, 255)), True, 0)
    Next

    windowz.HPosition = .5
    windowz.VPosition = .5
End Sub



Screenshot1.png
Screenshot2.png
 

Attachments

  • viewPort.zip
    9.8 KB · Views: 86
Upvote 0

Magma

Expert
Licensed User
Longtime User
When drawing MANY items on a Canvas, I would like to keep the plotted lines and objects that are moving.
The canvas should contain a "World View" having 9000 x 9000. The targets move per speed and course vector every second and encompass the entire World (9000 x 9000).
i would like to only show the "View port" or a window about 100 x 100. as i move the "Window/View Port", it shows the objects.
To clarify, the "World" dimensions are beyond the view and the window only displays the current or previous plotted targets.
Moreover, i have tried to scale the canvas, but rely on redrawing everything using 100dip/100 as i read in this forum.
any chance of a function/method to accomplish this scaling and window?
see attached example
Keep up the outstanding work!
Doyle
...I think stevel05 was right... my question... is why you need that?...

* if it is for "Game" reason... you may need some limits, IFs, etc (for showing objects moving only if showing in viewport) - or may be use some game library...
* if it is just for drawing - it is great !
 
Upvote 0
Top