Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-06

Anchoring problem with ScrollBox and Panels

9 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gabor Boros

Hi All,

The attached example contains a form with a ScrollBox on it with three Panels in it. Height of Panel1 is static, height of Panel2 depend on the size of Form/ScrollBox, height of Panel3 can be modifiable by the user. In the example a simple OnClick emulate the variable height feature of Panel3. So, start the example, modify (or not) size of the form, then click on Panel3. I got a "Position range overflow..." error. What I doing wrong or is this a bug?

Gabor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: position_range_overflow.png
Type: image/png
Size: 28336 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170606/c8a6c8e3/attachment-0001.png> -------------- next part --------------
A non-text attachment was scrubbed...
Name: ScrollBox_position_range_overflow.tar.gz
Type: application/gzip
Size: 1694 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170606/c8a6c8e3/attachment-0001.gz>

Reply by email

Michael W. Vogel
to Gabor Boros
Gabor Boros wrote 8 lines
The attached example contains a form with a ScrollBox on it with three Panels in it. Height of Panel1 is static, height of Panel2 depend on the size of Form/ScrollBox, height of Panel3 can be modifiable by the user. In the example a simple OnClick emulate the variable height feature of Panel3. So, start the example, modify (or not) size of the form, then click on Panel3. I got a "Position range overflow..." error. What I doing wrong or is this a bug?

I can tell you here the same as in the related bug report https://bugs.freepascal.org/view.php?id=30617, this isn't a bug it is not happy design. You want that the scrollbox height is increased, but then the Panel2 height is increased too. Simple remove anchored bottom of Panel2 and the loop is gone.

As you wrote in bug report: "Thank you for the example but do not do what I want.", please explain better, what you exactly want (step by step, when a user change the height of Panel3, what should happen).

Kind regards

Michl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170606/c25b3374/attachment.html>

Reply by email

Gabor Boros
to Michael W. Vogel

2017. 06. 06. 19:54 keltezéssel, Michael W. Vogel via Lazarus írta:

Simple remove anchored bottom of Panel2 and the loop is gone.

Yes, but Panel2 not follow the size of form/scrollbox.

As you wrote in bug report: "Thank you for the example but do not do what I want.", please explain better, what you exactly want (step by step, when a user change the height of Panel3, what should happen).

Just "remove anchored bottom of Panel2" then start the example and click on Panel3 and will see what I want. The vertical scrollbox showed up and the user can scroll the panels. It's good but the Panel2 not resized with the form/scrollbox without the bottom anchor. So if bottom anchor of Panel2 exists the resizing of Panel2 work as expected, if removed the anchor resizing (by the user) of Panel3 work as expected. But I need the two features coexist.

Gabor

Reply by email

Michael W. Vogel
to Gabor Boros
Gabor Boros wrote
2017. 06. 06. 19:54 keltezéssel, Michael W. Vogel via Lazarus írta: > Simple remove anchored bottom of Panel2 and the loop is gone. Yes, but Panel2 not follow the size of form/scrollbox.

Please try added example. It is nearly the same as in the bugtracker but with aligned scrollbox and a scrollbar to switch the height of Panel3. Is it so as you want?

Michl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/x-zip-compressed
Size: 2162 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170606/6ee7276d/attachment.bin>

Reply by email

Gabor Boros
to Michael W. Vogel

2017. 06. 06. 20:58 keltezéssel, Michael W. Vogel via Lazarus írta:

Please try added example. It is nearly the same as in the bugtracker but with aligned scrollbox and a scrollbar to switch the height of Panel3. Is it so as you want?

No. Attached (I hope ) a better example. The user can resize Panel2 with the Form and can resize Panel3 with the TrackBar. But want higher Panel3 than the available space. For solve this the whole thing sit in a ScrollBox. And the "InvalidatePreferredSize loop detected" problem breaks this solution. I completely don't understand why Panel3 not resizable to lower than border of the ScrollBox. Panel3 not have a bottom anchor. From my POV (and brain) the anchors are correct. Panel2 anchored to bottom of Panel1, Panel3 anchored to bottom of Panel2 and bottom of Panel3 not anchored.

Why got different error message with the TrackBar and OnClick resize of Panel3?

Gabor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScrollBox_position_range_overflow.tar.gz
Type: application/gzip
Size: 1861 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170606/78849c6f/attachment.gz>

Reply by email

Gabor Boros
to Michael W. Vogel: I can tell you here the same as in the related bug report…

2017. 06. 06. 19:54 keltezéssel, Michael W. Vogel via Lazarus írta:

Show quoted text 5 lines
I can tell you here the same as in the related bug report https://bugs.freepascal.org/view.php?id=30617, this isn't a bug it is not happy design. You want that the scrollbox height is increased, but then the Panel2 height is increased too. Simple remove anchored bottom of Panel2 and the loop is gone.

You wrote on the tracker:

"You have anchored Panel2.Bottom to no sibling and Panel3.Top to Panel2.Bottom. When you now change the height of Panel3, that it doesn't fit in the scrollbox anymore, the scrollbox is resized. With resizing of the scrollbox, Panel2 is also resized (because its Bottom is anchored). Now Panel3.Top is moved too and Panel3 doesn't fit in the scrollbox anymore. And repeat."

I understand you(r description) except one thing. "Panel2 is also resized (because its Bottom is anchored)" Why you think Panel2 is resized? When height of Panel3 increased and the vertical scrollbox showed up, height of scrollbox not changed nor top of Panel3.

Attached two pictures. One before resized Panel3 and one after (pressed Continue on the loop error message). You see top, bottom and height of Panel1 and Panel2 is same as before.

So top, bottom, height of Panel1, Panel2 and ScrollBox1 not changed. Why got the loop error? Only height of Panel3 changed. Width of Panel1,2,3 changed, okay but why this block the work of vertical anchoring?

Gabor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before_Panel3_resize.png
Type: image/png
Size: 12347 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170607/36cfa0e2/attachment-0002.png> -------------- next part --------------
A non-text attachment was scrubbed...
Name: after_Panel3_resize.png
Type: image/png
Size: 14299 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170607/36cfa0e2/attachment-0003.png>

Reply by email

Michael W. Vogel
to Gabor Boros
Gabor Boros wrote
I understand you(r description) except one thing. "Panel2 is also resized (because its Bottom is anchored)" Why you think Panel2 is resized? When height of Panel3 increased and the vertical scrollbox showed up, height of scrollbox not changed nor top of Panel3.

You can set a DebugLn in control.inc:

procedure TControl.SetBoundsKeepBase(aLeft, aTop, aWidth, aHeight: integer);
begin
   DebugLn('TControl.SetBoundsKeepBase ', Name, ' ', DbgS(Height));
   ChangeBounds(aLeft, aTop, aWidth, aHeight, true);
end;

You will see, the resizing problem comes from Panel2.

Show quoted text 8 lines
Attached two pictures. One before resized Panel3 and one after (pressed Continue on the loop error message). You see top, bottom and height of Panel1 and Panel2 is same as before. So top, bottom, height of Panel1, Panel2 and ScrollBox1 not changed. Why got the loop error? Only height of Panel3 changed. Width of Panel1,2,3 changed, okay but why this block the work of vertical anchoring?

No, Panel2 height is changed to a invalid value, as sayed before. Panel2 is just not visible updatet, as the height get a invalid value.

To demonstrate what happen take the added example or create a new app, put a panel on it and anchor Left, Top, Right to the form sides and anchor Bottom to nil. Start the app and change the bounds of it.

Michl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/x-zip-compressed
Size: 1759 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170607/26b1b987/attachment.bin>

Reply by email

Gabor Boros
to Michael W. Vogel

2017. 06. 07. 8:37 keltezéssel, Michael W. Vogel via Lazarus írta:

You will see, the resizing problem comes from Panel2.

I see. But don't understand. :D

To demonstrate what happen take the added example or create a new app, put a panel on it and anchor Left, Top, Right to the form sides and anchor Bottom to nil. Start the app and change the bounds of it.

Your example work as expected. If resize the form panel resized properly.

I tried to accomplish the task in a different way. Attached a new example. Bottom of Panel2 anchored to bottom of ScrollBox. This works. Top of Panel2 anchored to bottom of Panel1. When resize the form top of Panel2 is moving Why? Top of Panel2 why not stay with bottom of Panel1?

Gabor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScrollBox_position_range_overflow.tar.gz
Type: application/gzip
Size: 1901 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170607/56b543b1/attachment.gz>

Reply by email

Michael W. Vogel
to Gabor Boros
Gabor Boros wrote
Your example work as expected. If resize the form panel resized properly.

As it should. I simply wanted to show you, what happen when you anchor the bottom of a panel: Sizing of form, sizes the panel. The same, as in all your test projects before: Sizing of ScrollBox1, sizes Panel2.

Show quoted text 5 lines
I tried to accomplish the task in a different way. Attached a new example. Bottom of Panel2 anchored to bottom of ScrollBox. This works. Top of Panel2 anchored to bottom of Panel1. When resize the form top of Panel2 is moving Why? Top of Panel2 why not stay with bottom of Panel1?

You have anchored it to center. The center of Panel2 is now the center of ScrollBox1. See http://wiki.lazarus.freepascal.org/Anchor_Sides#Example_3

Reply by email