diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 2625e265c6..b4ba694bd8 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -21,6 +21,7 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler /// Gets or sets the padding inside each tab around the text. @@ -75,6 +80,17 @@ public Font Font } } + /// + public override Color BackgroundColor + { + get => backgroundColor; + set + { + backgroundColor = value; + tabDrawable.Invalidate(); + } + } + /// /// Gets or sets the disabled foreground color. /// @@ -117,6 +133,20 @@ public Color CloseHighlightBackgroundColor } } + /// + /// Gets or sets the corner radius of the close button. + /// + /// The corner radius of the close button. + public int CloseCornerRadius + { + get { return closeCornerRadius; } + set + { + closeCornerRadius = value; + tabDrawable.Invalidate(); + } + } + /// /// Gets or sets the foreground color for the close button. /// @@ -160,9 +190,9 @@ public Color TabBackgroundColor } /// - /// Gets or sets the highlight background color for the highlighted tab. + /// Gets or sets the highlight background color for the highlighted or selected tab. /// - /// The highlight background color for the close highlighted tab. + /// The highlight background color for the highlighted or selected tab. public Color TabHighlightBackgroundColor { get { return tabHighlightBackgroundColor; } @@ -173,6 +203,20 @@ public Color TabHighlightBackgroundColor } } + /// + /// Gets or sets the background color for the tab under mouse. + /// + /// The background color for the tab under mouse. + public Color TabHoverBackgroundColor + { + get { return tabHoverBackgroundColor; } + set + { + tabHoverBackgroundColor = value; + tabDrawable.Invalidate(); + } + } + /// /// Gets or sets the foreground color for the tab. /// @@ -188,9 +232,9 @@ public Color TabForegroundColor } /// - /// Gets or sets the highlight foreground color for the close button. + /// Gets or sets the highlight foreground color for the highlighted or selected tab. /// - /// The highlight foreground color for the close button. + /// The foreground color for the highlighted or selected tab. public Color TabHighlightForegroundColor { get { return tabHighlightForegroundColor; } @@ -201,6 +245,19 @@ public Color TabHighlightForegroundColor } } + /// + /// Gets or sets the foreground color for the tab under mouse. + /// + /// The foreground color for the tab under mouse. + public Color TabHoverForegroundColor + { + get { return tabHoverForegroundColor; } + set + { + tabHoverForegroundColor = value; + tabDrawable.Invalidate(); + } + } /// /// Gets or sets a value indicating whether to use a fixed tab height. @@ -229,6 +286,7 @@ public ThemedDocumentControlHandler() nextPrevWidth = 0; startx = 0; font = SystemFonts.Default(); + backgroundColor = SystemColors.Control; disabledForegroundColor = SystemColors.DisabledText; closeBackgroundColor = SystemColors.Control; closeHighlightBackgroundColor = SystemColors.Highlight; @@ -236,8 +294,10 @@ public ThemedDocumentControlHandler() closeHighlightForegroundColor = SystemColors.HighlightText; tabBackgroundColor = SystemColors.Control; tabHighlightBackgroundColor = SystemColors.Highlight; + tabHoverBackgroundColor = new Color(SystemColors.Highlight, 0.8f); tabForegroundColor = SystemColors.ControlText; tabHighlightForegroundColor = SystemColors.HighlightText; + tabHoverForegroundColor = SystemColors.HighlightText; tabDrawable = new Drawable(); @@ -494,7 +554,7 @@ void Drawable_MouseDown(object sender, MouseEventArgs e) } else SelectedIndex = i; - + break; } } @@ -596,7 +656,7 @@ void Drawable_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; - g.Clear(SystemColors.Control); + g.Clear(BackgroundColor); var posx = nextPrevWidth + startx; @@ -633,7 +693,7 @@ void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx) size.Width += textoffset; } - var closesize = tabDrawable.Height / 2; + var closesize = (int)Math.Floor(tabDrawable.Height * 0.6); var tabRect = new RectangleF(posx, 0, size.Width + (tab.Closable ? closesize + tabPadding.Horizontal + tabPadding.Right : tabPadding.Horizontal), tabDrawable.Height); if (i == selectedIndex && draggingLocation != null) @@ -643,7 +703,7 @@ void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx) tab.Rect = tabRect; - tab.CloseRect = new RectangleF(tabRect.X + tab.Rect.Width - tabPadding.Right - closesize, tabDrawable.Height / 4, closesize, closesize); + tab.CloseRect = new RectangleF(tabRect.X + tab.Rect.Width - tabPadding.Right - closesize, (tabDrawable.Height - closesize) / 2, closesize, closesize); tab.TextRect = new RectangleF(tabRect.X + tabPadding.Left + textoffset, (tabDrawable.Height - size.Height) / 2, textSize.Width, textSize.Height); posx += tab.Rect.Width; @@ -662,8 +722,7 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) var tabRect = tab.Rect; var textRect = tab.TextRect; var closerect = tab.CloseRect; - var closemargin = closerect.Height / 3; - var size = tabRect.Size; + var closemargin = closerect.Height / 4; var textcolor = Enabled ? TabForegroundColor : DisabledForegroundColor; var backcolor = TabBackgroundColor; @@ -671,13 +730,11 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) { textcolor = Enabled ? TabHighlightForegroundColor : DisabledForegroundColor; backcolor = TabHighlightBackgroundColor; - backcolor.A *= 0.8f; } - - if (draggingLocation == null && tabRect.Contains(mousePos) && prevnextsel && !closeSelected && Enabled) + else if (draggingLocation == null && tabRect.Contains(mousePos) && prevnextsel && Enabled) { - textcolor = TabHighlightForegroundColor; - backcolor = TabHighlightBackgroundColor; + textcolor = TabHoverForegroundColor; + backcolor = TabHoverBackgroundColor; } g.FillRectangle(backcolor, tabRect); @@ -692,12 +749,16 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) if (tab.Closable) { - g.FillRectangle(closeSelected ? CloseHighlightBackgroundColor : CloseBackgroundColor, closerect); + var closeBackground = closeSelected ? CloseHighlightBackgroundColor : CloseBackgroundColor; + if (closeCornerRadius > 0) + g.FillPath(closeBackground, GraphicsPath.GetRoundRect(closerect, closeCornerRadius)); + else + g.FillRectangle(closeBackground, closerect); + var closeForeground = Enabled ? closeSelected ? CloseHighlightForegroundColor : CloseForegroundColor : DisabledForegroundColor; g.DrawLine(closeForeground, closerect.X + closemargin, closerect.Y + closemargin, closerect.X + closerect.Width - 1 - closemargin, closerect.Y + closerect.Height - 1 - closemargin); g.DrawLine(closeForeground, closerect.X + closemargin, closerect.Y + closerect.Height - 1 - closemargin, closerect.X + closerect.Width - 1 - closemargin, closerect.Y + closemargin); } - } ///