Sign in Join

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

Mailing lists / lazarus / 2014-11

Toolbar divider issues

10 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Giuliano Colla

With rev 46741 (patch from bug 25291) the default width of Toolbar Divider and Separator has become inconsistent.

Before the patch, both from IDE designer and from component created in code, Separator width was 10 pixels, and Divider width 5 pixels.

After the patch, from IDE designer Separator width has become 23 pixels, and Divider width 3 pixels; when created in code both Separator and divider are 23 pixels, as it can be seen in Editortoolbar.

Is that expected, or it must be considered a bug?

Giuliano

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

Reply by email

Vojtěch Čihák
to Giuliano Colla

Hi,
?
@Is that expected, or it must be considered a bug? ?
That depends. Bugreport title is "ToolBar separator can't change width." Now all dividers and separators on TToolBar can have different width. ?
Therefore, saying "when created in code both Separator and divider are 23 pixels,..." is meaningless, because now, what you set is what you get: ?
procedure TForm1.Button2Click(Sender: TObject);
var aTBtn: TToolButton;
begin
aTBtn:=TToolButton.Create(self);
aTBtn.Style:=tbsSeparator;
aTBtn.Width:=10;
aTBtn.Parent:=ToolBar1;
end;

procedure TForm1.Button3Click(Sender: TObject);
var aTBtn: TToolButton;
begin
 aTBtn:=TToolButton.Create(self);
 aTBtn.Style:=tbsDivider;
aTBtn.Width:=5;
 aTBtn.Parent:=ToolBar1;
end;
?
Currently, there's probably nothing like default width of separator or divider.
?
I can look on it, maybe adding code to Style setter would solve it:
?
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; ?
?
I'll test it.?
?
Vojt?ch?

Reply by email

Vojtěch Čihák
to Vojtěch Čihák

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.? ?
Vojt?ch?

Reply by email

Giuliano Colla
to Vojtěch Čihák

Il 09/11/2014 15:04, Vojt?ch ?ih?k ha scritto:

Show quoted text 23 lines
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?

Reply by email

Giuliano Colla
to Giuliano Colla

Il 09/11/2014 17:39, Giuliano Colla ha scritto:

Show quoted text 9 lines
Il 09/11/2014 15:04, Vojt?ch ?ih?k ha scritto: > > [...] If you look into the matter, please do not forget that a toolbar can be either horizontal or vertical. [...]

Another issue: prior to the patch, changing orientation from horizontal to vertical, the previous implementation assigned the proper width and height to separators and dividers. After the patch, they are adjusted for height, but they keep the previous value for width, which is completely wrong.

Giuliano

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

Reply by email

Vojtěch Čihák
to Giuliano Colla: Il 09/11/2014 15:04, Vojt?ch ?ih?k ha scritto: If you look into the matter, please do not…

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?

Reply by email

Giuliano Colla
to Vojtěch Čihák

Il 09/11/2014 19:01, Vojt?ch ?ih?k ha scritto:

Show quoted text 6 lines
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 :19

Show quoted text 12 lines
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.

Show quoted text 5 lines
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?

Reply by email

Giuliano Colla
to Vojtěch Čihák

Il 11/11/2014 23:35, Vojt?ch ?ih?k ha scritto:

Show quoted text 7 lines
Hi, I added patch http://bugs.freepascal.org/view.php?id=27030 It (I hope) solves all issues you pointed here.

It would appear that today bugtracker is more times down than up, at least from here.
I'll test as soon as I manage to reach it. For the moment, no luck :-(

Giuliano

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

Reply by email