Sign in Join

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

Mailing lists / lazarus / 2015-03

GroupBox AutoSize issues

9 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Henry Vermaak

Hi

A while ago we managed to fix the GroupBox auto sizing not taking the length of the caption into account. I've been using the fixes_1_2 branch and that's working OK.

I switched to fixes_1_4 and started seeing some strange behaviour. Initially it appears that the auto sizing works correctly (see groupbox1.png) but when you resize the window it changes and cuts the caption off (see groupbox2.png). It doesn't resize again after that. This only happens when you've got some anchors set.

Does anyone know what could have caused this? If not I'll have to bisect, which I'd rather avoid!

Henry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: groupbox1.png
Type: image/png
Size: 4514 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150317/fec3a532/attachment-0002.png> -------------- next part --------------
A non-text attachment was scrubbed...
Name: groupbox2.png
Type: image/png
Size: 4198 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150317/fec3a532/attachment-0003.png>

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 14 lines
Hi A while ago we managed to fix the GroupBox auto sizing not taking the length of the caption into account. I've been using the fixes_1_2 branch and that's working OK. I switched to fixes_1_4 and started seeing some strange behaviour. Initially it appears that the auto sizing works correctly (see groupbox1.png) but when you resize the window it changes and cuts the caption off (see groupbox2.png). It doesn't resize again after that. This only happens when you've got some anchors set. Does anyone know what could have caused this? If not I'll have to bisect, which I'd rather avoid!

The LCL gtk2 interface computed the preferred size of a groupbox including the child controls, which lead to a loop. We need another way to compute the size of a groupbox without the child controls.

Mattias

Reply by email

Henry Vermaak
to Mattias Gaertner
Mattias Gaertner wrote 22 lines
On Tue, 17 Mar 2015 16:12:30 +0000 Henry Vermaak wrote: > Hi > > A while ago we managed to fix the GroupBox auto sizing not taking the > length of the caption into account. I've been using the fixes_1_2 > branch and that's working OK. > > I switched to fixes_1_4 and started seeing some strange behaviour. > Initially it appears that the auto sizing works correctly (see > groupbox1.png) but when you resize the window it changes and cuts the > caption off (see groupbox2.png). It doesn't resize again after that. > This only happens when you've got some anchors set. > > Does anyone know what could have caused this? If not I'll have to > bisect, which I'd rather avoid! The LCL gtk2 interface computed the preferred size of a groupbox including the child controls, which lead to a loop. We need another way to compute the size of a groupbox without the child controls.

I don't understand, how can you know the size of the groupbox if you don't know the size of the children? How does, e.g., a panel do this? Sorry if this is a stupid question, the auto size mechanics confuse me a bit.

Henry

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 10 lines
[...] > The LCL gtk2 interface computed the preferred size of a groupbox > including the child controls, which lead to a loop. > We need another way to compute the size of a groupbox without the child > controls. I don't understand, how can you know the size of the groupbox if you don't know the size of the children? How does, e.g., a panel do this? Sorry if this is a stupid question, the auto size mechanics confuse me a bit.

The gtk2 interface only knows the current size of the child control(s). It does not know the preferred size of the child control(s).

Mattias

Reply by email

Henry Vermaak
to Mattias Gaertner
Mattias Gaertner wrote 16 lines
On Tue, 17 Mar 2015 17:05:30 +0000 Henry Vermaak wrote: >[...] > > The LCL gtk2 interface computed the preferred size of a groupbox > > including the child controls, which lead to a loop. > > We need another way to compute the size of a groupbox without the child > > controls. > > I don't understand, how can you know the size of the groupbox if you > don't know the size of the children? How does, e.g., a panel do this? > Sorry if this is a stupid question, the auto size mechanics confuse me a > bit. The gtk2 interface only knows the current size of the child control(s). It does not know the preferred size of the child control(s).

So how do we fix this? If the groupbox code is changed so that it only evaluates its own minimum size, will the autosize code do the rest, i.e. loop over the children and take the maximum width/height?

Henry

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 7 lines
[...] > The gtk2 interface only knows the current size of the child > control(s). It does not know the preferred size of the child control(s). So how do we fix this? If the groupbox code is changed so that it only evaluates its own minimum size, will the autosize code do the rest, i.e. loop over the children and take the maximum width/height?

The LCL takes care of the child sizes.
The gtk2 interfaces needs to add the size of the gtk_frame caption and other theme specials.
I hope I find the time to implement that soon.

Mattias

Reply by email

Henry Vermaak
to Mattias Gaertner
Mattias Gaertner wrote 12 lines
On Fri, 20 Mar 2015 11:31:07 +0000 Henry Vermaak wrote: >[...] > > The gtk2 interface only knows the current size of the child > > control(s). It does not know the preferred size of the child control(s). > > So how do we fix this? If the groupbox code is changed so that it only > evaluates its own minimum size, will the autosize code do the rest, i.e. > loop over the children and take the maximum width/height? The LCL takes care of the child sizes.

OK, so then the use of GetGTKDefaultWidgetSize() in the groupbox is wrong, since that's what is looping through all the child controls. I've attached a patch that works for me, it's basically cribbed from GetGTKDefaultWidgetSize(), so maybe that needs a NoChildren parameter so that we don't duplicate the gtk2 size request code.

Henry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gb-prefsize-nochildren.patch
Type: text/x-diff
Size: 1504 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150320/c2c61030/attachment-0001.bin>

Reply by email

Mattias Gaertner
to Henry Vermaak
Show quoted text 19 lines
On Fri, Mar 20, 2015 at 12:57:47PM +0100, Mattias Gaertner wrote: > On Fri, 20 Mar 2015 11:31:07 +0000 > Henry Vermaak wrote: > > >[...] > > > The gtk2 interface only knows the current size of the child > > > control(s). It does not know the preferred size of the child control(s). > > > > So how do we fix this? If the groupbox code is changed so that it only > > evaluates its own minimum size, will the autosize code do the rest, i.e. > > loop over the children and take the maximum width/height? > > The LCL takes care of the child sizes. OK, so then the use of GetGTKDefaultWidgetSize() in the groupbox is wrong, since that's what is looping through all the child controls. I've attached a patch that works for me, it's basically cribbed from GetGTKDefaultWidgetSize(), so maybe that needs a NoChildren parameter so that we don't duplicate the gtk2 size request code.

gtk_widget_set_size_request computes the gtk2 idea of the size of the widget including all child widgets. This includes widgets of the LCL child controls.

TGtk2WSCustomGroupBox.GetPreferredSize should ignore the LCL child controls. It should return the size, as if there are no LCL child controls.
The LCL computes the needed client area and adds the frame. The final preferred size is the maximum of these two sizes.

I added a comment to TGtk2WSCustomGroupBox.GetPreferredSize.

Mattias

Reply by email

Henry Vermaak
to Mattias Gaertner
Mattias Gaertner wrote 15 lines
On Fri, 20 Mar 2015 12:21:57 +0000 Henry Vermaak wrote: > OK, so then the use of GetGTKDefaultWidgetSize() in the groupbox is > wrong, since that's what is looping through all the child controls. > I've attached a patch that works for me, it's basically cribbed from > GetGTKDefaultWidgetSize(), so maybe that needs a NoChildren parameter so > that we don't duplicate the gtk2 size request code. gtk_widget_set_size_request computes the gtk2 idea of the size of the widget including all child widgets. This includes widgets of the LCL child controls. TGtk2WSCustomGroupBox.GetPreferredSize should ignore the LCL child controls. It should return the size, as if there are no LCL child controls. The LCL computes the needed client area and adds the frame. The final preferred size is the maximum of these two sizes.

OK, I understand. Thanks for fixing the clip region stuff, it's looking much better now!

Henry

Reply by email