Recent

Author Topic: Recommend way to layout controls?  (Read 547 times)

Hi im Pascal

  • New member
  • *
  • Posts: 24
Recommend way to layout controls?
« on: January 05, 2019, 05:41:19 pm »
Hello,

coming from QtCreator I'm used to Vertical/Horizontal Layout, which basically lets you select some controls and then aligns them, creating a new group (e.g. I could put two horizontal layouts into a vertical layout).

I think the anchor mechanism isn't too bad, but if I want to align 5 Labels with 5 Edit Boxes, it seems pretty painful (mentally) to anchor all 10 controls by hand, instead of just selecting them as a group and clicking on a layout button. (although I could inspect the labels and then group all boxes to the longest label simultaneously, but that wont work if label widths change).

Can you recommend any methods for creating responsive layouts, or do you basically just fall back to bsSingle and disable the maximize button?

P.S.: I've tried putting controls into a panel group box and using child sizing, but the panel didn't even really do anything to them somehow the group box thinks it's a good idea to make the button as wide as the edit box (like 200px).

Any tips? Thanks in advance.
« Last Edit: January 05, 2019, 05:50:22 pm by Hi im Pascal »

Bart

  • Hero Member
  • *****
  • Posts: 3247
    • Bart en Mariska's Webstek
Re: Recommend way to layout controls?
« Reply #1 on: January 05, 2019, 06:08:13 pm »
In the form editor, you can select multiple controls (shigt+click) and then right-click on one and schoose "Align"?

Bart

Hi im Pascal

  • New member
  • *
  • Posts: 24
Re: Recommend way to layout controls?
« Reply #2 on: January 05, 2019, 06:17:21 pm »
@Bart,

The problem with Align is, that it's intended for when the user never can resize the application window. E. g. if I align "center of window" and then resize the window, the controls stay in place.

Additionally, things like labels, edit boxes and buttons have different heights on different platforms so I also need to add a center anchor for all controls on the same line (if I want it to look good).

lucamar

  • Hero Member
  • *****
  • Posts: 734
Re: Recommend way to layout controls?
« Reply #3 on: January 05, 2019, 06:26:13 pm »
Anchors, ChildSizing (for containers like TPanel) and Constraints are the Lazarus way of making responsive layouts but you're right in that it's not always easy or convenient.

There is some info about this in the wiki that may be of some help. Let me check a moment ... Done! Here are some of them:

HTH!
« Last Edit: January 05, 2019, 06:34:49 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 12..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

creaothceann

  • Jr. Member
  • **
  • Posts: 94
Re: Recommend way to layout controls?
« Reply #4 on: January 06, 2019, 11:40:44 am »
You can select several components and set their properties (e.g. anchors) simultaneously.

jamie

  • Hero Member
  • *****
  • Posts: 1123
Re: Recommend way to layout controls?
« Reply #5 on: January 06, 2019, 02:51:13 pm »
The TFlowPanel comes to mind when talking about this.

Handoko

  • Hero Member
  • *****
  • Posts: 2766
  • My goal: build my own game engine using Lazarus
Re: Recommend way to layout controls?
« Reply #6 on: January 06, 2019, 03:04:36 pm »
I never heard TFlowPanel before. It seems interesting.

Thanks for letting us know about it.

dsiders

  • Full Member
  • ***
  • Posts: 112
Re: Recommend way to layout controls?
« Reply #7 on: January 06, 2019, 04:20:59 pm »
The TFlowPanel comes to mind when talking about this.

TFlowPanel is definitely a step in the right direction.

It would have been very useful if TFlowPanelControlList had a BorderSpacing property that was applied to controls in the list. At present, you're forced to set the properties on every control added to the panel. It would have saved a little time during layout.
Lazarus 1.8.2 / FPC 3.0.4 / Windows 8.1 64-bit

jamie

  • Hero Member
  • *****
  • Posts: 1123
Re: Recommend way to layout controls?
« Reply #8 on: January 06, 2019, 08:48:34 pm »
I think that was added recently but I could be wrong. I did see some blur about it.