Anchor to sides

Post your Gambas programming questions here.
Post Reply
squidink7
Posts: 6
Joined: Saturday 16th January 2021 11:31pm

Anchor to sides

Post by squidink7 » Saturday 16th January 2021 11:39pm

Hey there, I'm relatively new to gambas and am trying to get my applications to resize properly. I've been messing with containers but they can be a real pain sometimes and I was wondering if there was an anchor property I could set to get some objects to follow the bottom right (for example) rather than the top left that they are stuck to now. Thanks in advance!

cage
Posts: 93
Joined: Monday 02nd September 2019 5:47am
Location: Phoenix Arizona

Re: Anchor to sides

Post by cage » Sunday 17th January 2021 1:32am

squidink7 look in project showcase for a program written by Cedron called Resizer. It works pretty good for most things at allowing you to resize the window and it's contents. Cogier is one of the guys that knows the in and outs of what your asking about. I think if you use the search on this website you find all that you are looking for.

squidink7
Posts: 6
Joined: Saturday 16th January 2021 11:31pm

Re: Anchor to sides

Post by squidink7 » Sunday 17th January 2021 11:43am

That's great! I will probably use it in my projects from now on, so thanks for letting me know about it. However it would still be nice to have an anchor option as it serves a different use case; say you wanted all the buttons and text to stay the same size but a frame in the middle to grow in size, sort of like how dolphin handles it (or whatever file manager your desktop comes with) Plus having either that or resizer integrated by default into gambas would make it more discoverable and easy to use.

User avatar
cogier
Site Admin
Posts: 637
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Anchor to sides

Post by cogier » Sunday 17th January 2021 1:11pm

The code that Cedron uses works but in most cases no code, or very little, is required. Have a look at a program I wrote to help people with this. It is on the 'Farm' or available here.

If you post your form here I will look at it and make it expandable for you.

If you are thinking VB then don't. Gambas does this in a very different way but once you get the hang of it you can do a lot.

User avatar
sjsepan
Posts: 62
Joined: Saturday 12th October 2019 10:11pm
Location: Leeper, PA, USA
Contact:

Re: Anchor to sides

Post by sjsepan » Sunday 17th January 2021 7:14pm

squidink7 wrote:
Sunday 17th January 2021 11:43am
That's great! I will probably use it in my projects from now on, so thanks for letting me know about it. However it would still be nice to have an anchor option as it serves a different use case; say you wanted all the buttons and text to stay the same size but a frame in the middle to grow in size, sort of like how dolphin handles it (or whatever file manager your desktop comes with) Plus having either that or resizer integrated by default into gambas would make it more discoverable and easy to use.
Also have a peek at GambasGuiGeneric (https://gambas.one/gambasfarm/?id=675&action=search) and the DockAnchor (https://gambas.one/gambasfarm/?id=658&action=search) library it uses. These are early versions, though, and the most up-to-date copies of the DockAnchor project are on my GitHub (https://github.com/ssepan2?tab=repositories).
Downside is that it does require code, but I tried to emulate WinForms Docking/Anchoring.

To try out (that particular) project, you would need:
1) https://github.com/ssepan2/GambasGuiGeneric
2) https://github.com/ssepan2/DockAnchor
3) https://github.com/ssepan2/GambasGuiAppUtilityLib
4) https://github.com/ssepan2/GambasAppUtilityLib
5) https://github.com/ssepan2/GambasSomeModelLib

However if you just want to read the code and see how I am using DockAnchor in the GUI app, you would only need to grab the 1st two.
To run DockAnchor, you need #2 and #4.

User avatar
cogier
Site Admin
Posts: 637
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Anchor to sides

Post by cogier » Monday 18th January 2021 4:20pm

Let me try again. Here is a video showing a Gambas form expanding. Note that there is no code created to do this, it is all done inside the IDE.

Image

Here is the program: -
ExpandIt-0.0.1.tar.gz
(212.47 KiB) Downloaded 30 times

squidink7
Posts: 6
Joined: Saturday 16th January 2021 11:31pm

Re: Anchor to sides

Post by squidink7 » Friday 29th January 2021 1:02pm

Thanks everyone! Up until now I had no idea about things like springs or using panels as spacers, or even the arrangement property. I guess Gambas just needs some better documentation to help make these things more discoverable and understandable but until then thanks again. :D

Post Reply