Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect tab width when it's calculated from caption length #70

Open
bogdanpolak opened this issue Oct 24, 2018 · 0 comments
Open

Incorrect tab width when it's calculated from caption length #70

bogdanpolak opened this issue Oct 24, 2018 · 0 comments

Comments

@bogdanpolak
Copy link
Collaborator

bogdanpolak commented Oct 24, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant