Recent

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

Hi im Pascal

  • New Member
  • *
  • Posts: 40
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: 5274
    • 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: 40
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: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

creaothceann

  • Full Member
  • ***
  • Posts: 117
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: 6090
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.
The only true wisdom is knowing you know nothing

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • 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

  • Hero Member
  • *****
  • Posts: 1052
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.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

jamie

  • Hero Member
  • *****
  • Posts: 6090
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.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018