TChromeTabs
TChromeTabs copied to clipboard
Incorrect tab width when it's calculated from caption length
When property TabWidthFromContent is set, tabs width is calculated incorrectly.
TChromeTabs.Options.Display.Tabs.TabWidthFromContent := true;
On the first render tab widths are calculated incorrectly. Just after mouse cursor goes through area of the control and exits it width is calculated properly and tabs are rendered with correct width, but even then tabs are not well displayed. Only after mouse goes through the control next time everything is displayed correctly.
Try this code:
procedure TForm1.EventSetTabWidth(Sender: TObject;
ATabControl: ChromeTabsControls.TChromeTabControl; var TabWidth: Integer);
begin
TestTabWidth := TabWidth;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Assigned(TestChromeTabs) then
TestChromeTabs.Free;
TestChromeTabs := TChromeTabs.Create(self);
TestChromeTabs.OnSetTabWidth := EventSetTabWidth;
TestChromeTabs.Parent := self;
TestChromeTabs.Left := 8;
TestChromeTabs.Top := 102;
TestChromeTabs.Width := 350;
TestChromeTabs.Options.Display.Tabs.TabWidthFromContent := True;
TestChromeTabs.Tabs.Add.Caption := '1 Tab 1';
TestChromeTabs.Tabs.Add.Caption := '2 Longer tab caption 2';
TestChromeTabs.Tabs.Add.Caption := '3 Tab 3';
(Sender as TButton).Caption := Format('Expected: %d, Actual: %d',
[79, TestTabWidth]);
end;
-
After button click (just type Enter and do not move the mouse) you will see this:
-
After mouse cursor goes through the area of the ChromeTab component you will see:
-
After moving the mouse over again: