I load a "flat" single-variant layout with five nodes on it. Nothing fancy: just 4 buttons and a text field.
I count the number of nodes using GetAllViewsRecursive:
# before loading the layout: 0 nodes - no worries
# after loading the layout: 5 nodes - no worries
# after MainForm.Show: 10 nodes - huh?
# after another MainForm.Show: 10 nodes - well, at least it's stable
What are the extra nodes for? I could imagine they are created during window (re)sizing, but... why are they not deleted? Should they be? Can I ignore them? Are they always -1 width and height?
produces log:
I count the number of nodes using GetAllViewsRecursive:
# before loading the layout: 0 nodes - no worries
# after loading the layout: 5 nodes - no worries
# after MainForm.Show: 10 nodes - huh?
# after another MainForm.Show: 10 nodes - well, at least it's stable
What are the extra nodes for? I could imagine they are created during window (re)sizing, but... why are they not deleted? Should they be? Can I ignore them? Are they always -1 width and height?
B4X:
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
Dim NumNodes0 As Int = 0
For Each N As Node In MainForm.RootPane.GetAllViewsRecursive
NumNodes0 = NumNodes0 + 1
Next
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
Dim NumNodes1 As Int = 0
For Each N As Node In MainForm.RootPane.GetAllViewsRecursive
NumNodes1 = NumNodes1 + 1
Next
MainForm.Show
Dim NumNodes2 As Int = 0
For Each N As Node In MainForm.RootPane.GetAllViewsRecursive
NumNodes2 = NumNodes2 + 1
Next
MainForm.Show
Dim NumNodes3 As Int = 0
For Each N As Node In MainForm.RootPane.GetAllViewsRecursive
NumNodes3 = NumNodes3 + 1
Next
Log("NumNodes = " & NumNodes0 & " " & NumNodes1 & " " & NumNodes2 & " " & NumNodes3)
For Each N As Node In MainForm.RootPane.GetAllViewsRecursive
Log(N.Left & " " & N.Top & " " & N.PrefWidth & " " & N.PrefHeight)
Next
End Sub
B4X:
Waiting for debugger to connect...
Program started.
NumNodes = 0 5 10 10
10 10 100 30
37 5 -1 -1
370 10 100 30
37 5 -1 -1
10 320 100 30
37 5 -1 -1
380 330 100 30
37 5 -1 -1
20 50 440 260
206 120 -1 -1