Hi,
 
CalcPreferredSize is called only when Autosize is True, it's not this case.
 
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.
 
About changing orientation from horizontal to vertical:
I will look at it, frankly, I never used vert. toolbars so I didn't test it.
 
Thanks for pointing it,
 
Vojtěch 
______________________________________________________________
Od: Giuliano Colla <[email protected]>
Komu: Lazarus mailing list <[email protected]>
Datum: 09.11.2014 17:41
Předmět: Re: [Lazarus] Toolbar divider issues


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?


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus 
<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to