[Lazarus] Toolbar divider issues

Giuliano Colla giuliano.colla at fastwebnet.it
Sun Nov 9 17:39:59 CET 2014


Il 09/11/2014 15:04, Vojtěch Čihák ha scritto:
>
> Hi,
>
> with this code:
>
> procedure TToolButton.SetStyle(Value: TToolButtonStyle);
> begin
>   if FStyle = Value then exit;
>   FStyle := Value;
>   if Value = tbsSeparator then Width := 10;
>   if Value = tbsDivider then Width := 5;
>   InvalidatePreferredSize;
>   if IsControlVisible then
>   UpdateVisibleToolbar;
> end;
>
> It now does deault 10px separators - both design-time and code
>
> and 5px dividers from code but still 3px dividers at design-time.
>
> EditorToolBar looks better now. I'll find solution and I'll send a 
> patch to bugtracker.
>

If you look into the matter, please do not forget that a toolbar can be 
either horizontal or vertical.

 From TToolbutton.CalculatePreferredSize:

...
     if Style = tbsDivider then
       if FToolBar.IsVertical then
         PreferredHeight := 5
       else
         PreferredWidth := 5
     else
     if Style = tbsSeparator then
       if FToolBar.IsVertical then
         PreferredHeight := 10
       else
         PreferredWidth := 10;
   end;

In an ideal world, if the user doesn't set a different width or height, 
the preferred values should go into effect, in any configuration, for 
any visual component.
But in a toolbar there's another constraint: if it's horizontal all 
buttons must share the same height, it it's vertical all buttons must 
share the same width, overriding some of the user settings.
That's what makes it a little bit tricky.

Giuliano

-- 
Giuliano Colla

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





More information about the Lazarus mailing list