From c198ebe0fbced89fc9885e7a7e5b45e9f6dc8a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 13:43:19 +0100 Subject: [PATCH 1/9] Allow to set `BackgroundColor` of `DocumentControl` --- .../ThemedDocumentControlHandler.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 2625e265c6..71462f7118 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -21,6 +21,7 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler + public override Color BackgroundColor + { + get => backgroundColor; + set + { + backgroundColor = value; + tabDrawable.Invalidate(); + } + } + /// /// Gets or sets the disabled foreground color. /// @@ -229,6 +241,7 @@ public ThemedDocumentControlHandler() nextPrevWidth = 0; startx = 0; font = SystemFonts.Default(); + backgroundColor = SystemColors.Control; disabledForegroundColor = SystemColors.DisabledText; closeBackgroundColor = SystemColors.Control; closeHighlightBackgroundColor = SystemColors.Highlight; @@ -596,7 +609,7 @@ void Drawable_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; - g.Clear(SystemColors.Control); + g.Clear(BackgroundColor); var posx = nextPrevWidth + startx; From e8ec49ea5b367b67938907571ea191c3cbe497cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 13:54:26 +0100 Subject: [PATCH 2/9] Prevent applying hardcoded opacity to background color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- .../ThemedDocumentControlHandler.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 71462f7118..891de6b2fd 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -29,6 +29,7 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler - /// Gets or sets the highlight background color for the highlighted tab. + /// Gets or sets the highlight background color for the highlighted (or active) tab. /// - /// The highlight background color for the close highlighted tab. + /// The highlight background color for the highlighted (or active) tab. public Color TabHighlightBackgroundColor { get { return tabHighlightBackgroundColor; } @@ -185,6 +186,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. /// @@ -249,6 +264,7 @@ public ThemedDocumentControlHandler() closeHighlightForegroundColor = SystemColors.HighlightText; tabBackgroundColor = SystemColors.Control; tabHighlightBackgroundColor = SystemColors.Highlight; + tabHoverBackgroundColor = new Color(SystemColors.Highlight, 0.8f); tabForegroundColor = SystemColors.ControlText; tabHighlightForegroundColor = SystemColors.HighlightText; @@ -684,13 +700,12 @@ 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) { textcolor = TabHighlightForegroundColor; - backcolor = TabHighlightBackgroundColor; + backcolor = TabHoverBackgroundColor; } g.FillRectangle(backcolor, tabRect); From 8b546eba1a703d521c12359f93d00eeaba2cba9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 14:16:19 +0100 Subject: [PATCH 3/9] Apply code formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- .../Forms/ThemedControls/ThemedDocumentControlHandler.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 891de6b2fd..57641bf61b 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -523,7 +523,7 @@ void Drawable_MouseDown(object sender, MouseEventArgs e) } else SelectedIndex = i; - + break; } } @@ -691,8 +691,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 / 3; var textcolor = Enabled ? TabForegroundColor : DisabledForegroundColor; var backcolor = TabBackgroundColor; @@ -725,7 +724,6 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) 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); } - } /// From d73664ec7aa7842843c925c266fcd593df4bad63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 14:28:08 +0100 Subject: [PATCH 4/9] Allow to specify foreground color for the tab in hover state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- .../ThemedDocumentControlHandler.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 57641bf61b..8397199d46 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -32,6 +32,7 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler - /// Gets or sets the highlight foreground color for the close button. + /// Gets or sets the highlight foreground color for the highlighted (or active) tab. /// - /// The highlight foreground color for the close button. + /// The foreground color for the highlighted (or active) tab. public Color TabHighlightForegroundColor { get { return tabHighlightForegroundColor; } @@ -228,6 +229,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. @@ -267,6 +281,7 @@ public ThemedDocumentControlHandler() tabHoverBackgroundColor = new Color(SystemColors.Highlight, 0.8f); tabForegroundColor = SystemColors.ControlText; tabHighlightForegroundColor = SystemColors.HighlightText; + tabHoverForegroundColor = SystemColors.HighlightText; tabDrawable = new Drawable(); @@ -703,7 +718,7 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) if (draggingLocation == null && tabRect.Contains(mousePos) && prevnextsel && !closeSelected && Enabled) { - textcolor = TabHighlightForegroundColor; + textcolor = TabHoverForegroundColor; backcolor = TabHoverBackgroundColor; } From b427261663b813a406eb60e222aaa38a50664500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 16:17:16 +0100 Subject: [PATCH 5/9] Make Highlighted tab colors winning vs Hover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 8397199d46..bd1a0c2611 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -715,8 +715,7 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) textcolor = Enabled ? TabHighlightForegroundColor : DisabledForegroundColor; backcolor = TabHighlightBackgroundColor; } - - if (draggingLocation == null && tabRect.Contains(mousePos) && prevnextsel && !closeSelected && Enabled) + else if (draggingLocation == null && tabRect.Contains(mousePos) && prevnextsel && Enabled) { textcolor = TabHoverForegroundColor; backcolor = TabHoverBackgroundColor; From f4f5aeb9e285bf29271bc2761f37f4c36c057149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 16:57:04 +0100 Subject: [PATCH 6/9] Adjust the size of the close button when using `UseFixedTabHeight` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index bd1a0c2611..05aaff8d87 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -677,7 +677,7 @@ void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx) size.Width += textoffset; } - var closesize = tabDrawable.Height / 2; + var closesize = UseFixedTabHeight ? minImageSquareSide : tabDrawable.Height / 2; var tabRect = new RectangleF(posx, 0, size.Width + (tab.Closable ? closesize + tabPadding.Horizontal + tabPadding.Right : tabPadding.Horizontal), tabDrawable.Height); if (i == selectedIndex && draggingLocation != null) @@ -706,7 +706,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 closemargin = UseFixedTabHeight ? 3 : closerect.Height / 3; var textcolor = Enabled ? TabForegroundColor : DisabledForegroundColor; var backcolor = TabBackgroundColor; From 7bb13420e78b8b832dbc376e6c16f2292ccba2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Fri, 5 Jan 2024 21:50:00 +0100 Subject: [PATCH 7/9] Support rounded corners of certain radius for Close button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- .../ThemedDocumentControlHandler.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 05aaff8d87..a6762f5826 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -34,10 +34,12 @@ public class ThemedDocumentControlHandler : ThemedContainerHandler /// Gets or sets the padding inside each tab around the text. @@ -131,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. /// @@ -733,7 +749,12 @@ 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); From eebc0e07c8a20070d15a003ed775da6a7df8d1d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0evgen=20Baida?= Date: Mon, 15 Jan 2024 14:08:05 +0100 Subject: [PATCH 8/9] Update XML documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: İevgen Baida --- .../Forms/ThemedControls/ThemedDocumentControlHandler.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index a6762f5826..67db272076 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -190,9 +190,9 @@ public Color TabBackgroundColor } /// - /// Gets or sets the highlight background color for the highlighted (or active) tab. + /// Gets or sets the highlight background color for the highlighted or selected tab. /// - /// The highlight background color for the highlighted (or active) tab. + /// The highlight background color for the highlighted or selected tab. public Color TabHighlightBackgroundColor { get { return tabHighlightBackgroundColor; } @@ -232,9 +232,9 @@ public Color TabForegroundColor } /// - /// Gets or sets the highlight foreground color for the highlighted (or active) tab. + /// Gets or sets the highlight foreground color for the highlighted or selected tab. /// - /// The foreground color for the highlighted (or active) tab. + /// The foreground color for the highlighted or selected tab. public Color TabHighlightForegroundColor { get { return tabHighlightForegroundColor; } From 2d64d72ae0b8420fa5d112812b0adfc96dc46a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=CC=87evgen=20Baida?= Date: Mon, 19 Feb 2024 21:55:21 +0100 Subject: [PATCH 9/9] Calculate `closeSize` and `closeMargin` unconditionally --- .../Forms/ThemedControls/ThemedDocumentControlHandler.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs index 67db272076..b4ba694bd8 100644 --- a/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs +++ b/src/Eto/Forms/ThemedControls/ThemedDocumentControlHandler.cs @@ -693,7 +693,7 @@ void CalculateTab(ThemedDocumentPageHandler tab, int i, ref float posx) size.Width += textoffset; } - var closesize = UseFixedTabHeight ? minImageSquareSide : 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) @@ -703,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; @@ -722,7 +722,7 @@ void DrawTab(Graphics g, ThemedDocumentPageHandler tab, int i) var tabRect = tab.Rect; var textRect = tab.TextRect; var closerect = tab.CloseRect; - var closemargin = UseFixedTabHeight ? 3 : closerect.Height / 3; + var closemargin = closerect.Height / 4; var textcolor = Enabled ? TabForegroundColor : DisabledForegroundColor; var backcolor = TabBackgroundColor;