Wish Designer - code generator

Discussion in 'Bugs & wishlist' started by LucaMs, Jul 4, 2015.

  1. LucaMs

    LucaMs Expert Licensed 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: Jul 4, 2015
    walt61 likes this.
  2. jahswani

    jahswani Active Member Licensed User

  3. UFOCoder13

    UFOCoder13 Well-Known Member Licensed User

    I actually wish that's what the layout files were. Something like yours but like this:

    Code:
    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: Jul 4, 2015
    LucaMs likes this.
  4. NJDude

    NJDude Expert Licensed User

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

    For example:
    Code:
    MyButton.Width = 100dip
     
    Last edited: Jul 4, 2015
    UFOCoder13 likes this.
  5. UFOCoder13

    UFOCoder13 Well-Known Member Licensed User

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

    NJDude Expert Licensed User

    Still, I was making a note to use DIP since is a common mistake.
     
    UFOCoder13 likes this.
  7. LucaMs

    LucaMs Expert Licensed User

    MyButton.Width = 25%x works better
     
  8. ArminKH

    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
     
  9. Erel

    Erel Administrator Staff Member Licensed 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.
     
    ArminKH likes this.
  10. LucaMs

    LucaMs Expert Licensed User

    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
     

    Attached Files:

    Last edited: Jul 5, 2015
    ArminKH likes this.
  11. LucaMs

    LucaMs Expert Licensed User

    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]
     
    ArminKH likes this.
  12. LucaMs

    LucaMs Expert Licensed User

    upload_2015-7-5_9-58-45.png
    (I should use this script testing before the screen orientation, if it is landscape, and I should use percentages for all views)

    upload_2015-7-5_10-0-35.png
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    The first step is to comment all the designer script.
    The second step is to set the vertical and horizontal anchors to BOTH.
     
    LucaMs likes this.
  14. LucaMs

    LucaMs Expert Licensed User


    So it is perfect, thank you, Erel.

    Now I have to investigate if I should set all the views in the same way (I fear it would be too simple :D)
     
  15. LucaMs

    LucaMs Expert Licensed 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: Jul 5, 2015
  16. Erel

    Erel Administrator Staff Member Licensed User

    You should have set the anchors to BOTH.
     
  17. klaus

    klaus Expert Licensed User

    You are confusing total height 320 and real height 320 - 50 = 270 !
    (270 - 170) / 2 = 50 !
     
  18. LucaMs

    LucaMs Expert Licensed User


    Yes, I did it and it works (see my post #14) but now, after I reset each view (including panel) to Left-Top (anchors), I get that error.
    [bal attached]
     

    Attached Files:

  19. LucaMs

    LucaMs Expert Licensed User


    No, Klaus, thank you, because I unchecked Show Title and checked Full Screen, then 320 is the full free vertical space

    upload_2015-7-5_17-11-25.png
     
    Last edited: Jul 5, 2015
  20. LucaMs

    LucaMs Expert Licensed 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).
     
Loading...