[Lazarus] Toolbar divider issues

Giuliano Colla giuliano.colla at fastwebnet.it
Mon Nov 10 00:53:29 CET 2014


Il 09/11/2014 19:01, Vojtěch Čihák ha scritto:
>
> Hi,
>
> CalcPreferredSize is called only when Autosize is True, it's not this 
> case.
>

No, it's called always, also when Autosize is false. It gets called 
starting from TToolButton.GetPreferredSize. In a minimal test program 
with a toolbar and Autosize false, setting a breakpoint on it, that's 
the resulting call stack:

#0 TTOOLBUTTON__CALCULATEPREFERREDSIZE(0, 0, true, <error reading variable>) at ./include/toolbutton.inc:963
#1 TCONTROL__GETPREFERREDSIZE(0, 0, false, true, <error reading variable>) at ./include/control.inc:5220
#2 TTOOLBUTTON__GETPREFERREDSIZE(0, 0, false, true, <error reading variable>) at ./include/toolbutton.inc:738
#3 CALCULATEPOSITION(0xbffff150) at ./include/toolbar.inc:566
#4 TTOOLBAR__WRAPBUTTONS(531, 0, 0, false, <error reading variable>) at ./include/toolbar.inc:818
#5 TTOOLBAR__CONTROLSALIGNED(<error reading variable>) at ./include/toolbar.inc:160
#6 TWINCONTROL__ALIGNCONTROLS(0x0, {LEFT = 1, TOP = 2, RIGHT = 531, BOTTOM = 23, TOPLEFT = {X = 1, Y = 2}, BOTTOMRIGHT = {X = 531, Y = 23}}, <error reading variable>) at ./include/wincontrol.inc:3212
#7 TWINCONTROL__ALIGNCONTROL(0x0, <error reading variable>) at ./include/wincontrol.inc:6289
#8 AUTOSIZECONTROL(0xb7fcce60, 0xbffff3f4) at ./include/control.inc:2846
#9 AUTOSIZECONTROL(0xb7fcafa0, 0xbffff3f4) at ./include/control.inc:2848
#10 TCONTROL__DOALLAUTOSIZE(<error reading variable>) at ./include/control.inc:2896
#11 TWINCONTROL__DOALLAUTOSIZE(<error reading variable>) at ./include/wincontrol.inc:3504
#12 TCONTROL__ENABLEAUTOSIZING(<error reading variable>) at ./include/control.inc:5450
#13 TCONTROL__SETVISIBLE(true, <error reading variable>) at ./include/control.inc:4290
#14 TCUSTOMFORM__SETVISIBLE(true, <error reading variable>) at ./include/customform.inc:486
#15 TCUSTOMFORM__SHOW(<error reading variable>) at ./include/customform.inc:2196
#16 TAPPLICATION__RUN(<error reading variable>) at ./include/application.inc:1387
#17 main at toolbutton.lpr:19


> Furthermore, I found this code in Componenteditors.pas in
>
> procedure TToolBarComponentEditor.ExecuteVerb(Index: Integer);
>
> around line 1255:
>
> if NewStyle = tbsDivider then
>   NewToolButton.Width := 3;
>
> IMO if default with of divider was 5 before that patch then there is 
> something wrong elsewhere.
>

No need to search elsewhere. This just explains why after the patch the 
Divider width has become 3 pixels. Before the patch, the line you 
mention had no effect, because it was overridden by the PreferredSize 
settings of the component. But the side effect is that now also an 
horizontal divider in a vertical toolbar has become 3 pixels wide, which 
is not what was intended.
And it also explains why a Separator which was 10 pixels wide now has 
the same size of a button, because the style tbsSeparator is not 
considered in this portion of code.


> About changing orientation from horizontal to vertical:
>
> I will look at it, frankly, I never used vert. toolbars so I didn't 
> test it.
>

Never did I in the past, but it's been requested for the editortoolbar, 
so I've been forced to look into it.

Giuliano

-- 
Giuliano Colla

Project planning question: when it's 90% done, are we halfway or not yet?





More information about the Lazarus mailing list