Problems with Containers

Post

Posted
Rating:
#1 (In Topic #1101)
Regular
JumpyVB is in the usergroup ‘Regular’
What I struggle most in Gambas is probably the arrangement of gui elements. I find the Containers such as Panel cumbersome to works with. What I need to achieve (and am unable to currently) is placing two TextLabels on top of each other, aligned right on the main panel, and aligned left in regards of each other.

So far I am pretty close with this:
Image

(Click to enlarge)

Where:

Code (gambas)

  1. 'FMain
  2. ' .Arrangement = Arrange.Vertical
  3. ' .Autoresize = True
  4. 'GreenPanel
  5. ' .Arrangement = Arrange.Horizontal
  6. '   Spring
  7. '   OrangePanel
  8. '    .Arrangement = Arrange.Vertical
  9. '    .Autoresize = True
  10. '    .Centered = True
  11. '      BlueTextLabel_XXX
  12. '       .Alignment = Left
  13. '       .Autoresize = True
  14. '       .Wrap = False
  15. '      GreenishTextLabel_O
  16. '       .Alignment = Left
  17. '       .Autoresize = True
  18. '       .Wrap = False
  19.  

What do I need to change to make XXX and O drawn on top of each other? I'm thinking of a customized version of the Panel class with the stacking feature removed, but don't know how to do this.
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
 How do you mean "on top of eachother" ?

Do you mean overlapping so it looks like one label?

If yes then it would be better to put them in a Horizontal aligned panel with a border and no spacing then remove the borders from the labels.

Then the panel border acts like the label border and the labels will look like one and can be aligned accordingly.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
There is definitely an art to getting the GUI items the way you want, but it's worth the effort. Have a look at ExpandingForms on the Farm or available here. It will give you the basics.

Regarding your present issue, I think what you are looking for is below. Be careful with the use of AutoResize. In your image it has reduced the size of the TextLables to next to nothing as there is next to nothing in them!

If I have incorrectly interpreted what you are looking for, then let me know and I will try again. If you want the TextLables at the bottom, remove the top Spring. If you want the TextLables at the top, remove both of the Springs.

<IMG src="https://www.cogier.com/gambas/GambasExpands.png"> </IMG>

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
JumpyVB is in the usergroup ‘Regular’

BruceSteers said

Do you mean overlapping so it looks like one label?
I want O to be draw over X; Not above or below.
Image

(Click to enlarge)

And the width of the element should be exactly the length of Xxx no more or less. Eventually I will hide Xxx. I want Xxx to reserve the space and not be visible. O should be aligned left.

PS: I try to make my app work consistently on both GTK and QT with different display scalings on each platform. I noticed that margin, padding and width are not reliable in QT with display scaling.

PSS: I also noticed that leading white space and consecutive white space is trimmed off from Gambas Text elements. This poses yet another problem I try to circumvent.

Maybe I have to investigate creation of a CustomContainer https://gambaswiki.org/wiki/dev/gambas?l=ru

Here's am example where this is going to be used:
Image

(Click to enlarge)

The keyboard shortcuts on the right side may vary depending on user settings and could be as long as "Ctrl+Shift+U" or as short as one letter; But I don't want to hard code the space for this. I want the reserved space to be only as wide as it needs to be. This involves extra steps I can code myself. Currently I just need a way to draw 2 text labels over each other and have the element to autoresize according to the longer label.
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
thatbruce is in the usergroup ‘Regular’

Code

Public Sub Form_Open()

  Dim L1 As New Label(Me)
  Dim L2 As New Label(Me)
  
  L1.X = 1
  L1.Y = 1
  
  L2.X = 1
  L2.Y = 1
  
  L1.AutoResize = True
  L2.AutoResize = True
  
  L1.Text = "Xxxxx"
  L2.Text = "O"

  Me.W = L1.Width
  Me.H = L1.H
  
End

That is the entire code for the project, just an empty form with this proc. No containers.

Online now: No Back to the top
1 guest and 0 members have just viewed this.