Wish Designer - code generator

LucaMs

Expert
Licensed User
Longtime User
Because I'm too stupid to get from Designer what I want, I wish there was a Designer function which generates the code to set at runtime the dimensions of all views as percentages compared to the screen (layout).

Something like:

Button1.Width = 25%x
Button1.Height = 10%y
Button1.Left = ...%x
Button1.Top = ...%y
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
I actually wish that's what the layout files were. Something like yours but like this:

B4X:
Dim MyButton As Button
MyButton.Initialize("Event")
MyButton.Text = "MyButton"
MyButton.Width = 100
MyButton.Height = 100
MyButton.Top = 10
MyButton.Left = 20
'Any other designer properties.

So instead of a bal or bil file being binary gibberish, it would be like a Visual Studio ".designer" file. (Would also be good for version control.)

@Erel - Your opinions?
 
Last edited:

NJDude

Expert
Licensed User
Longtime User
B4X:
Dim MyButton As Button
MyButton.Initialize("Event")
MyButton.Text = "MyButton"
MyButton.Width = 100
MyButton.Height = 100
MyButton.Top = 10
MyButton.Left = 20
'Any other designer properties.

Note that you MUST use DIP or your layouts will not scale properly on all devices.

For example:
B4X:
MyButton.Width = 100dip
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
Note that you MUST use DIP or your layouts will not scale properly on all devices.

For example:
B4X:
MyButton.Width = 100dip

I was actually talking about the Bal/Bil files becoming like the displayed code. (Like Visual Studio's ".designer" files.)
 

ArminKH

Well-Known Member
+1
how ever this can be done by converting layouts to json or xml format and then write a good b4j desktop app for calculate all dimentions and then convert back to .bal format
this is just a suggestion
 

LucaMs

Expert
Licensed User
Longtime User
Why do you want to use percentage for your layout? In most cases this is not the correct way to implement a flexible layout.

You should instead use anchors with auto scale all.

Because, as you can see below, if I use anchors and autoscaleall only I don't get what I "need".
Why in that case I don't obtain a bigger or smaller panel (depending on difference between the layout dimensions and the device dimensions) and proportionate edge distances despite I used Autoscaleall?

I think: you use dips, so If you have 100dip, you get same misure on any device (misure in cm) but if you add autoscaleall this 100dip will be ... scaled.

upload_2015-7-5_9-28-27.png
 

Attachments

  • lay2.bal
    4.3 KB · Views: 350
Last edited:

LucaMs

Expert
Licensed User
Longtime User
+1
how ever this can be done by converting layouts to json or xml format and then write a good b4j desktop app for calculate all dimentions and then convert back to .bal format
this is just a suggestion

I tried but it is very difficult to "trace" all views (and names!) with all of their relationships using this method.

[Furthermore, the .bal structure could change in the future]
 

LucaMs

Expert
Licensed User
Longtime User
It's too hot; I should sleep 25 hours/day, perhaps.

While I was trying (see previous post)...

upload_2015-7-5_16-42-55.png


As you can see, the panel is 170 Height, the layout 320... (320-170) / 2 = 75 and Top is 75 but the panel is not vertical centered.

Maybe after several attempts with anchors it has happened and then it is a bug... or it's too hot and I'm wrong these measures :D
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
... but checking/unchecking rechecking :D those parameters (Full Screen and Show Title) now with Top = 75 and Height = 170 (not changed) the panel is centered.

It is just a little bug (like "refresh" or reset some variable).
 
Top