Skip to content

Commit

Permalink
Merge pull request #73 from stephenfewer/master
Browse files Browse the repository at this point in the history
[bugfix] Scale the tab, add, close and scroll controls as expected on…
  • Loading branch information
landrix authored Feb 27, 2019
2 parents 3a21882 + 1fa7d0f commit b5c7445
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 82 deletions.
76 changes: 38 additions & 38 deletions Lib/ChromeTabs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4086,48 +4086,48 @@ procedure TCustomChromeTabs.DrawBackGroundTo(Targets: Array of TGPGraphics);

procedure TCustomChromeTabs.SetDefaultOptions;
begin
FOptions.Display.CloseButton.Offsets.Vertical := 6;
FOptions.Display.CloseButton.Offsets.Horizontal := 2;
FOptions.Display.CloseButton.Height := 14;
FOptions.Display.CloseButton.Width := 14;
FOptions.Display.CloseButton.Offsets.Vertical := MulDiv( 6, Screen.PixelsPerInch, 96 );
FOptions.Display.CloseButton.Offsets.Horizontal := MulDiv( 2, Screen.PixelsPerInch, 96 );
FOptions.Display.CloseButton.Height := MulDiv( 14, Screen.PixelsPerInch, 96 );
FOptions.Display.CloseButton.Width := MulDiv( 14, Screen.PixelsPerInch, 96 );
FOptions.Display.CloseButton.AutoHide := True;
FOptions.Display.CloseButton.Visibility := bvAll;
FOptions.Display.CloseButton.AutoHideWidth := 20;
FOptions.Display.CloseButton.CrossRadialOffset := 4;
FOptions.Display.AddButton.Offsets.Vertical := 10;
FOptions.Display.AddButton.Offsets.Horizontal := 2;
FOptions.Display.AddButton.HorizontalOffsetFloating := -3;
FOptions.Display.AddButton.Height := 14;
FOptions.Display.AddButton.Width := 31;
FOptions.Display.CloseButton.AutoHideWidth := MulDiv( 20, Screen.PixelsPerInch, 96 );
FOptions.Display.CloseButton.CrossRadialOffset := MulDiv( 4, Screen.PixelsPerInch, 96 );
FOptions.Display.AddButton.Offsets.Vertical := MulDiv( 10, Screen.PixelsPerInch, 96 );
FOptions.Display.AddButton.Offsets.Horizontal := MulDiv( 2, Screen.PixelsPerInch, 96 );
FOptions.Display.AddButton.HorizontalOffsetFloating := MulDiv( -3, Screen.PixelsPerInch, 96 );
FOptions.Display.AddButton.Height := MulDiv( 14, Screen.PixelsPerInch, 96 );
FOptions.Display.AddButton.Width := MulDiv( 31, Screen.PixelsPerInch, 96 );
FOptions.Display.AddButton.ShowPlusSign := False;
FOptions.Display.AddButton.Visibility := avRightFloating;
FOptions.Display.ScrollButtonLeft.Offsets.Vertical := 10;
FOptions.Display.ScrollButtonLeft.Offsets.Horizontal := 1;
FOptions.Display.ScrollButtonLeft.Height := 15;
FOptions.Display.ScrollButtonLeft.Width := 15;
FOptions.Display.ScrollButtonRight.Offsets.Vertical := 10;
FOptions.Display.ScrollButtonRight.Offsets.Horizontal := 1;
FOptions.Display.ScrollButtonRight.Height := 15;
FOptions.Display.ScrollButtonRight.Width := 15;
FOptions.Display.ScrollButtonLeft.Offsets.Vertical := MulDiv( 10, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonLeft.Offsets.Horizontal := MulDiv( 1, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonLeft.Height := MulDiv( 15, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonLeft.Width := MulDiv( 15, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonRight.Offsets.Vertical := MulDiv( 10, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonRight.Offsets.Horizontal := MulDiv( 1, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonRight.Height := MulDiv( 15, Screen.PixelsPerInch, 96 );
FOptions.Display.ScrollButtonRight.Width := MulDiv( 15, Screen.PixelsPerInch, 96 );
FOptions.Display.TabModifiedGlow.Style := msRightToLeft;
FOptions.Display.TabModifiedGlow.VerticalOffset := -6;
FOptions.Display.TabModifiedGlow.Height := 30;
FOptions.Display.TabModifiedGlow.Width := 100;
FOptions.Display.TabModifiedGlow.VerticalOffset := MulDiv( -6, Screen.PixelsPerInch, 96 );
FOptions.Display.TabModifiedGlow.Height := MulDiv( 30, Screen.PixelsPerInch, 96 );
FOptions.Display.TabModifiedGlow.Width := MulDiv( 100, Screen.PixelsPerInch, 96 );
FOptions.Display.TabModifiedGlow.AnimationPeriodMS := 4000;
FOptions.Display.TabModifiedGlow.EaseType := ttEaseInOutQuad;
FOptions.Display.TabModifiedGlow.AnimationUpdateMS := 50;
FOptions.Display.Tabs.SeeThroughTabs := False;
FOptions.Display.Tabs.TabOverlap := 15;
FOptions.Display.Tabs.ContentOffsetLeft := 18;
FOptions.Display.Tabs.ContentOffsetRight := 16;
FOptions.Display.Tabs.TabOverlap := MulDiv( 15, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.ContentOffsetLeft := MulDiv( 18, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.ContentOffsetRight := MulDiv( 16, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.OffsetLeft := 0;
FOptions.Display.Tabs.OffsetTop := 4;
FOptions.Display.Tabs.OffsetTop := MulDiv( 4, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.OffsetRight := 0;
FOptions.Display.Tabs.OffsetBottom := 0;
FOptions.Display.Tabs.MinWidth := 25;
FOptions.Display.Tabs.MaxWidth := 200;
FOptions.Display.Tabs.PinnedWidth := 39;
FOptions.Display.Tabs.ImageOffsetLeft := 13;
FOptions.Display.Tabs.MinWidth := MulDiv( 25, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.MaxWidth := MulDiv( 200, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.PinnedWidth := MulDiv( 39, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.ImageOffsetLeft := MulDiv( 13, Screen.PixelsPerInch, 96 );
FOptions.Display.Tabs.TextTrimType := tttFade;
FOptions.Display.Tabs.Orientation := toTop;
FOptions.Display.Tabs.BaseLineTabRegionOnly := False;
Expand All @@ -4141,22 +4141,22 @@ procedure TCustomChromeTabs.SetDefaultOptions;
FOptions.Display.TabContainer.PaddingRight := 0;
FOptions.Display.TabMouseGlow.Offsets.Vertical := 0;
FOptions.Display.TabMouseGlow.Offsets.Horizontal := 0;
FOptions.Display.TabMouseGlow.Height := 200;
FOptions.Display.TabMouseGlow.Width := 200;
FOptions.Display.TabMouseGlow.Height := MulDiv( 200, Screen.PixelsPerInch, 96 );
FOptions.Display.TabMouseGlow.Width := MulDiv( 200, Screen.PixelsPerInch, 96 );
FOptions.Display.TabMouseGlow.Visible := True;
FOptions.DragDrop.DragType := dtBetweenContainers;
FOptions.DragDrop.DragOutsideImageAlpha := 220;
FOptions.DragDrop.DragOutsideDistancePixels := 30;
FOptions.DragDrop.DragStartPixels := 2;
FOptions.DragDrop.DragOutsideDistancePixels := MulDiv( 30, Screen.PixelsPerInch, 96 );
FOptions.DragDrop.DragStartPixels := MulDiv( 20, Screen.PixelsPerInch, 96 );
FOptions.DragDrop.DragControlImageResizeFactor := 0.5;
FOptions.DragDrop.DragCursor := crDefault;
FOptions.DragDrop.DragDisplay := ddTabAndControl;
FOptions.DragDrop.DragFormBorderWidth := 2;
FOptions.DragDrop.DragFormBorderWidth := MulDiv( 2, Screen.PixelsPerInch, 96 );
FOptions.DragDrop.DragFormBorderColor := 8421504;
FOptions.Animation.DefaultMovementAnimationTimeMS := 100;
FOptions.Animation.DefaultStyleAnimationTimeMS := 300;
FOptions.Animation.AnimationTimerInterval := 15;
FOptions.Animation.MinimumTabAnimationWidth := 40;
FOptions.Animation.MinimumTabAnimationWidth := MulDiv( 40, Screen.PixelsPerInch, 96 );
FOptions.Animation.DefaultMovementEaseType := ttLinearTween;
FOptions.Animation.DefaultStyleEaseType := ttLinearTween;
FOptions.Animation.MovementAnimations.TabAdd.UseDefaultEaseType := True;
Expand All @@ -4182,11 +4182,11 @@ procedure TCustomChromeTabs.SetDefaultOptions;
FOptions.Behaviour.IgnoreDoubleClicksWhileAnimatingMovement := True;
FOptions.Scrolling.Enabled := True;
FOptions.Scrolling.ScrollButtons := csbRight;
FOptions.Scrolling.ScrollStep := 20;
FOptions.Scrolling.ScrollStep := MulDiv( 20, Screen.PixelsPerInch, 96 );
FOptions.Scrolling.ScrollRepeatDelay := 20;
FOptions.Scrolling.AutoHideButtons := False;
FOptions.Scrolling.DragScroll := True;
FOptions.Scrolling.DragScrollOffset := 50;
FOptions.Scrolling.DragScrollOffset := MulDiv( 50, Screen.PixelsPerInch, 96 );
FOptions.Scrolling.MouseWheelScroll := True;
end;

Expand Down
87 changes: 43 additions & 44 deletions Lib/ChromeTabsControls.pas
Original file line number Diff line number Diff line change
Expand Up @@ -491,41 +491,41 @@ function TAddButtonControl.GetPolygons: IChromeTabPolygons;
Result := TChromeTabPolygons.Create;

Result.AddPolygon(BidiPolygon(
NewPolygon(BidiControlRect, [Point(7, RectHeight(BidiControlRect)),
Point(4, RectHeight(BidiControlRect) - 2),
Point(0, 2),
Point(1, 0),
Point(RectWidth(BidiControlRect) - 7, 0),
Point(RectWidth(BidiControlRect) - 4, 2),
Point(RectWidth(BidiControlRect), RectHeight(BidiControlRect) - 2),
NewPolygon(BidiControlRect, [Point(MulDiv(7,Screen.PixelsPerInch,96), RectHeight(BidiControlRect)),
Point(MulDiv(4,Screen.PixelsPerInch,96), RectHeight(BidiControlRect) - MulDiv(2,Screen.PixelsPerInch,96)),
Point(0, MulDiv(2,Screen.PixelsPerInch,96)),
Point(MulDiv(1,Screen.PixelsPerInch,96), 0),
Point(RectWidth(BidiControlRect) - MulDiv(7,Screen.PixelsPerInch,96), 0),
Point(RectWidth(BidiControlRect) - MulDiv(4,Screen.PixelsPerInch,96), MulDiv(2,Screen.PixelsPerInch,96)),
Point(RectWidth(BidiControlRect), RectHeight(BidiControlRect) - MulDiv(2,Screen.PixelsPerInch,96)),
Point(RectWidth(BidiControlRect), RectHeight(BidiControlRect))],
ChromeTabs.GetOptions.Display.Tabs.Orientation)),
GetButtonBrush,
GetButtonPen);

if ChromeTabs.GetOptions.Display.AddButton.ShowPlusSign then
begin
LeftOffset := (ChromeTabs.GetOptions.Display.AddButton.Width div 2) - 4;
TopOffset := (ChromeTabs.GetOptions.Display.AddButton.Height div 2) - 4;
LeftOffset := (ChromeTabs.GetOptions.Display.AddButton.Width div 2) - MulDiv(4,Screen.PixelsPerInch,96);
TopOffset := (ChromeTabs.GetOptions.Display.AddButton.Height div 2) - MulDiv(4,Screen.PixelsPerInch,96);

Result.AddPolygon(BidiPolygon(
NewPolygon(Rect(BidiControlRect.Left + LeftOffset,
BidiControlRect.Top + TopOffset,
BidiControlRect.Right - LeftOffset,
BidiControlRect.Bottom - TopOffset),
[Point(0, 3),
Point(3, 3),
Point(3, 0),
Point(6, 0),
Point(6, 3),
Point(9, 3),
Point(9, 6),
Point(6, 6),
Point(6, 9),
Point(3, 9),
Point(3, 6),
Point(0, 6),
Point(0, 3)],
[Point(0, MulDiv(3,Screen.PixelsPerInch,96)),
Point(MulDiv(3,Screen.PixelsPerInch,96), MulDiv(3,Screen.PixelsPerInch,96)),
Point(MulDiv(3,Screen.PixelsPerInch,96), 0),
Point(MulDiv(6,Screen.PixelsPerInch,96), 0),
Point(MulDiv(6,Screen.PixelsPerInch,96), MulDiv(3,Screen.PixelsPerInch,96)),
Point(MulDiv(9,Screen.PixelsPerInch,96), MulDiv(3,Screen.PixelsPerInch,96)),
Point(MulDiv(9,Screen.PixelsPerInch,96), MulDiv(6,Screen.PixelsPerInch,96)),
Point(MulDiv(6,Screen.PixelsPerInch,96), MulDiv(6,Screen.PixelsPerInch,96)),
Point(MulDiv(6,Screen.PixelsPerInch,96), MulDiv(9,Screen.PixelsPerInch,96)),
Point(MulDiv(3,Screen.PixelsPerInch,96), MulDiv(9,Screen.PixelsPerInch,96)),
Point(MulDiv(3,Screen.PixelsPerInch,96), MulDiv(6,Screen.PixelsPerInch,96)),
Point(0, MulDiv(6,Screen.PixelsPerInch,96)),
Point(0, MulDiv(3,Screen.PixelsPerInch,96))],
ChromeTabs.GetOptions.Display.Tabs.Orientation)),
GetSymbolBrush,
GetSymbolPen);
Expand Down Expand Up @@ -558,7 +558,6 @@ procedure TAddButtonControl.SetStylePropertyClasses;
constructor TAddButtonControl.Create(ChromeTabs: IChromeTabs);
begin
inherited Create(ChromeTabs);

FControlType := itAddButton;

FButtonStyle := ChromeTabs.GetLookAndFeel.AddButton.Button.Normal;
Expand Down Expand Up @@ -813,16 +812,16 @@ function TChromeTabControl.GetPolygons: IChromeTabPolygons;
Result := TChromeTabPolygons.Create;

Result.AddPolygon(NewPolygon(BidiControlRect, [Point(0, RectHeight(ControlRect)),
Point(4, RectHeight(ControlRect) - 3),
Point(12, 3),
Point(13, 2),
Point(14, 1),
Point(16, 0),
Point(RectWidth(ControlRect) - 16, 0),
Point(RectWidth(ControlRect) - 14, 1),
Point(RectWidth(ControlRect) - 13, 2),
Point(RectWidth(ControlRect) - 12, 3),
Point(RectWidth(ControlRect) - 4, RectHeight(ControlRect) - 3),
Point(MulDiv( 4, Screen.PixelsPerInch, 96 ), RectHeight(ControlRect) - MulDiv( 3, Screen.PixelsPerInch, 96 )),
Point(MulDiv( 12, Screen.PixelsPerInch, 96 ), MulDiv( 3, Screen.PixelsPerInch, 96 )),
Point(MulDiv( 13, Screen.PixelsPerInch, 96 ), MulDiv( 2, Screen.PixelsPerInch, 96 )),
Point(MulDiv( 14, Screen.PixelsPerInch, 96 ), MulDiv( 1, Screen.PixelsPerInch, 96 )),
Point(MulDiv( 16, Screen.PixelsPerInch, 96 ), 0),
Point(RectWidth(ControlRect) - MulDiv( 16, Screen.PixelsPerInch, 96 ), 0),
Point(RectWidth(ControlRect) - MulDiv( 14, Screen.PixelsPerInch, 96 ), MulDiv( 1, Screen.PixelsPerInch, 96 )),
Point(RectWidth(ControlRect) - MulDiv( 13, Screen.PixelsPerInch, 96 ), MulDiv( 2, Screen.PixelsPerInch, 96 )),
Point(RectWidth(ControlRect) - MulDiv( 12, Screen.PixelsPerInch, 96 ), MulDiv( 3, Screen.PixelsPerInch, 96 )),
Point(RectWidth(ControlRect) - MulDiv( 4, Screen.PixelsPerInch, 96 ), RectHeight(ControlRect) - MulDiv( 3, Screen.PixelsPerInch, 96 )),
Point(RectWidth(ControlRect), RectHeight(ControlRect))],
ChromeTabs.GetOptions.Display.Tabs.Orientation),
GetTabBrush,
Expand Down Expand Up @@ -958,7 +957,7 @@ procedure TChromeTabControl.CalculateRects(var ImageRect, TextRect,

if CloseButtonVisible then
begin
RightOffset := CloseButtonRect.Left - 1
RightOffset := CloseButtonRect.Left - MulDiv(1,Screen.PixelsPerInch,96)
end
else
begin
Expand Down Expand Up @@ -1034,14 +1033,14 @@ procedure TChromeTabControl.CalculateRects(var ImageRect, TextRect,
LeftOffset + ImageWidth,
(ControlRect.Top + (RectHeight(ControlRect) div 2) - (ImageHeight div 2)) + ImageHeight);

LeftOffset := LeftOffset + ImageWidth + 1;
LeftOffset := LeftOffset + ImageWidth + MulDiv(1,Screen.PixelsPerInch,96);
end;
end;

// Does the Text fit?
TextVisible := ((not ChromeTab.GetPinned) or
(ChromeTabs.GetOptions.Display.Tabs.ShowPinnedTabText)) and
(RightOffset - LeftOffset >= 5);
(RightOffset - LeftOffset >= MulDiv(5,Screen.PixelsPerInch,96));

if TextVisible then
begin
Expand Down Expand Up @@ -1619,10 +1618,10 @@ function TScrollButtonControl.GetArrowPolygons(
drLeft:
begin
Result.AddPolygon(BidiPolygon(
NewPolygon(BidiControlRect, [Point(3, RectHeight(ControlRect) div 2),
Point(RectWidth(ControlRect) - 3, 2),
Point(RectWidth(ControlRect) - 3, RectHeight(ControlRect) - 2),
Point(3, RectHeight(ControlRect) div 2)],
NewPolygon(BidiControlRect, [Point(MulDiv(3,Screen.PixelsPerInch,96), RectHeight(ControlRect) div 2),
Point(RectWidth(ControlRect) - MulDiv(3,Screen.PixelsPerInch,96), MulDiv(2,Screen.PixelsPerInch,96)),
Point(RectWidth(ControlRect) - MulDiv(3,Screen.PixelsPerInch,96), RectHeight(ControlRect) - MulDiv(2,Screen.PixelsPerInch,96)),
Point(MulDiv(3,Screen.PixelsPerInch,96), RectHeight(ControlRect) div 2)],
ChromeTabs.GetOptions.Display.Tabs.Orientation)),
GetSymbolBrush,
GetSymbolPen);
Expand All @@ -1631,10 +1630,10 @@ function TScrollButtonControl.GetArrowPolygons(
drRight:
begin
Result.AddPolygon(BidiPolygon(
NewPolygon(BidiControlRect, [Point(RectWidth(ControlRect) - 3, RectHeight(ControlRect) div 2),
Point(3, 2),
Point(3, RectHeight(ControlRect) - 2),
Point(RectWidth(ControlRect) - 3, RectHeight(ControlRect) div 2)],
NewPolygon(BidiControlRect, [Point(RectWidth(ControlRect) - MulDiv(3,Screen.PixelsPerInch,96), RectHeight(ControlRect) div 2),
Point(MulDiv(3,Screen.PixelsPerInch,96), MulDiv(2,Screen.PixelsPerInch,96)),
Point(MulDiv(3,Screen.PixelsPerInch,96), RectHeight(ControlRect) - MulDiv(2,Screen.PixelsPerInch,96)),
Point(RectWidth(ControlRect) - MulDiv(3,Screen.PixelsPerInch,96), RectHeight(ControlRect) div 2)],
ChromeTabs.GetOptions.Display.Tabs.Orientation)),
GetSymbolBrush,
GetSymbolPen);
Expand Down

0 comments on commit b5c7445

Please sign in to comment.