'Panel, max size, min gap
DesignerUtils.SpreadControlsHorizontally(Pane1, 300dip, 20dip)
'Panel, row height
DesignerUtils.HorizontalFlow(Pane2, 60dip)
'Panel, MaxSize, MinGap
Public Sub SpreadControlsHorizontally (DesignerArgs As DesignerArgs)
Dim Panel As B4XView = DesignerArgs.GetViewFromArgs(0)
Dim MaxSize As Int = DesignerArgs.Arguments(1)
Dim MinGap As Int = DesignerArgs.Arguments(2)
Dim AllWidth As Int = Panel.Width
Dim w As Int = Min(AllWidth / Panel.NumberOfViews - MinGap, MaxSize)
Dim gap As Int = (AllWidth - Panel.NumberOfViews * w) / Panel.NumberOfViews
For i = 0 To Panel.NumberOfViews - 1
Dim v As B4XView = Panel.GetView(i)
v.SetLayoutAnimated(0, (i + 0.5) * gap + i * w, v.Top, w, v.Height)
Next
End Sub
'Panel, RowHeight
Public Sub HorizontalFlow (DesignerArgs As DesignerArgs)
Dim panel As B4XView = DesignerArgs.GetViewFromArgs(0)
Dim RowHeight As Int = DesignerArgs.Arguments(1)
Dim gap As Int = 5dip
Dim x As Int = gap
Dim y As Int = gap
For i = 0 To panel.NumberOfViews - 1
Dim v As B4XView = panel.GetView(i)
If x > gap And x + v.Width > panel.Width - gap Then
x = gap
y = y + RowHeight
End If
v.Left = x
v.Top = y
x = x + v.Width + gap
Next
End Sub
So, will it available on all the platforms? Great!This feature will be included in the next version of B4X
Any static module with a sub that matches the expected signature will work.Can you show (or describe) how the Designer will know about our DesignerUtils b4xlib (or even some simple code in one of our modules)?
The easiest solution that comes to my mind is that DesignerUtils will be a "reserved" name and the Designer will look for a module or lib named like that. But a more general MyModule.MySub syntax recognized by the designer parser will work even better.
Yes, the B4X sub can return a simple value.Another question: will the designer script accept a sequence like scriptcode-calltoexternalcode-scriptcode? In other words, will the script be able to make use of values and items produced by the external code? From your demo code it looks there's a one-way only parameters passing (from script to code).
I think you can use it to create a single layout that perfectly adapts on Tablets and Phones without necessarily having the eye view.it says that it is a b4x feature but i only see it being used in b4j since it only makes sense in a desktop app where you can resize the window.
what would be the benefit of calling it from the designer and not from the _resize event?
thanx
This is long throw. Views have changed here, like layout changed.I think you can use it to create a single layout that perfectly adapts on Tablets and Phones without necessarily having the eye view.
Something like this :
View attachment 130393
The example is very indicative: align, correctly space N Views; how many times have you (we) had to do this with the internal script? If the source code was in your own library, you would get it with only one line in the script.it says that it is a b4x feature but i only see it being used in b4j since it only makes sense in a desktop app where you can resize the window.
what would be the benefit of calling it from the designer and not from the _resize event?
thanx
Check the example on the very first post. It is relevant with B4A / B4i exactly as it is relevant with B4J.it says that it is a b4x feature but i only see it being used in b4j since it only makes sense in a desktop app where you can resize the window.
Not really. There are too many small details and different use cases to make it useful without adding many parameters, and making it too complex to use.That said, if that functionality, spacing, were already part of the Designer (as requested in the past) it would be even better.
I am curious ?It will be easier to answer in a few months from now
That new feature is certainly "powerful", very useful and I'm sure we will realize it.Not really. There are too many small details and different use cases to make it useful without adding many parameters, and making it too complex to use.
This is why it was never implemented as an internal feature.
With the external call feature developers can modify the behavior as they need.
This is also the way I see it.Anyway, I think it will be enough to develop an official library (B4XLib), with just these basic functionalities.
i have difficulties seeing how this result can be done more easier with the new feature than using different variants instead or different layout files for different variants.I think you can use it to create a single layout that perfectly adapts on Tablets and Phones without necessarily having the eye view.
Something like this :
View attachment 130393
designer script is very important. i use it in every app. so the resize event will never take the place of the designer script at least not for me.You can ask why use the designer script at all.
A single layout file that you can load in million places and it will "automatically" adopt to the parent size. This is a big thing.
It will be a surprise from Erel.just need to understand how to use effeciently
I'm giving you tools. It is up for the developer to use them in the correct place.i agree but this is also very dangerous. in your example it can ruin the whole app if the views are sent to next row if the screen resized. i know it is just an example of showing the idea but no one would want to have such a layout:
Understanding how to use any feature efficiently requires time. For all of us. Don't worryi am happy for every new feature in b4x just need to understand how to use effeciently
and you are doing it very well. ? like the awesome XLUtils / jPOI 5 and many many other tools.I'm giving you tools. It is up for the developer to use them in the correct place.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
For i = 1 To 100
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Root.Width, 200dip)
p.LoadLayout("Item")
CustomListView1.Add(p, "")
Next
End Sub
DDD.SpreadControlsHorizontally(Pane1, 200dip, 5dip)
DDD.SetText(Button1, "Sunday", "Sun", "Su", "S")
DDD.SetText(Button2, "Monday", "Mon", "Mo", "M")
DDD.SetText(Button3, "Tuesday", "Tue", "Tu", "T")
DDD.SetText(Button4, "Wednesday", "Wed", "We", "W")
DDD.SetText(Button5, "Thurdsay", "Thu", "Th", "T")
DDD.SetText(Button6, "Friday", "Fri", "Fr", "F")
DDD.SetText(Button7, "Saturday", "Sat", "Sa", "S")
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?