Recent

Author Topic: Distribute form size change between multiple GUI elements  (Read 1242 times)

ArminLinder

  • Sr. Member
  • ****
  • Posts: 314
  • Keep it simple.
Distribute form size change between multiple GUI elements
« on: August 22, 2021, 07:38:26 pm »
Hi, please look at the attached layout, I have a form with two memos and buttons belonging to each memo. The challenge is, if the form is resized by the user by dragging the edge, to give the size gain or loss not only to one memo, but distribute it between the two memos. And the buttons should stay at the same position relative to the memo they belong to.

I am aware of the possibility to hook into the form's onResize event and recalculate the positions of all the elements myself, but I wonder whether there isn't a graphical element allowing me to define this behaviour via the form editor.

I thought that I could put each memo along with it's buttons on a panel, and anchor the memo to all four panel sides. This would make the memo size follow the panel size, and the buttons to stay at the right places, and thus simplify the problem to distribute the size change between the two panels. But still I'd have to hook onResize and recalculate the panel coordinates.

Is there any GUI element, a TSplitter maybe, which allows me to achieve the desired behaviour via the forms editor?

Thnx, Armin.
Lazarus 3.3.2 on Windows 7,10,11, Debian 10.8 "Buster", macOS Catalina, macOS BigSur, VMWare Workstation 15, Raspberry Pi

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: Distribute form size change between multiple GUI elements
« Reply #1 on: August 22, 2021, 07:52:15 pm »
I could be wrong but as far as I know there is no such feature so far.

Not exactly what you want, but you may be interested to try this:
https://forum.lazarus.freepascal.org/index.php/topic,55171.msg410088.html#msg410088

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Distribute form size change between multiple GUI elements
« Reply #2 on: August 22, 2021, 08:31:50 pm »
Hi!

Use the anchors this way:

Put two panels in the upper and lower half.
Anchor them on all 4 side.

Put 2 x 3 Buttons on the top of the panels.
Anchor them on three side but not at the bottom.

Put the 2 memos on the panels. A nchor them at 4 sides.

There you are.

Winni


 

TinyPortal © 2005-2018