TChromeTabs icon indicating copy to clipboard operation
TChromeTabs copied to clipboard

Incorrect tab width when it's calculated from caption length

Open bogdanpolak opened this issue 6 years ago • 0 comments

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;
  1. After button click (just type Enter and do not move the mouse) you will see this: iss70-image01

  2. After mouse cursor goes through the area of the ChromeTab component you will see: iss70-image02

  3. After moving the mouse over again: iss70-image03

bogdanpolak avatar Oct 24 '18 13:10 bogdanpolak