Skip to content

Commit 2a1a8e8

Browse files
committed
add border style for selected tab
1 parent 75b7878 commit 2a1a8e8

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/Config/BrowserTabStyle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal static class BrowserTabStyle {
1818
public static SolidBrush BackColor = new SolidBrush(NormalTabBackColor);
1919

2020
public static Color TabBorderColor = Color.LightGray;
21-
public static int TabBorderThickness = 2;
21+
public static float TabBorderThickness = 2;
2222

2323
// Close tab button (X)
2424

src/Controls/BrowserTabStrip/BrowserTabStrip.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,15 @@ protected override void OnPaint(PaintEventArgs e) {
353353
if (fATabStripItem.Visible || base.DesignMode) {
354354
OnCalcTabPage(e.Graphics, fATabStripItem);
355355
fATabStripItem.IsDrawn = false;
356-
OnDrawTabButton(e.Graphics, fATabStripItem);
356+
DrawSingleTabButton(e.Graphics, fATabStripItem);
357357
}
358358
}
359359

360360
//--------------------------------------------------------
361-
// DRAW BOTTOM LINE to tabButtons, Except Active Tab.
361+
// DRAW BOTTOM LINE on the left/right side of the selected tab
362362

363-
if (Items.DrawnCount == 0 || Items.VisibleCount == 0) {
364-
e.Graphics.DrawLine(Pens.Red, new Point(0, BrowserTabStyle.TabHeight), new Point(base.ClientRectangle.Width, BrowserTabStyle.TabHeight));
365-
}
366-
else if (SelectedTab != null && SelectedTab.IsDrawn) {
367-
var lineColorPen = new Pen(BrowserTabStyle.NormalTabBackColor);
363+
if (SelectedTab != null && SelectedTab.IsDrawn) {
364+
var lineColorPen = new Pen(BrowserTabStyle.TabBorderColor, BrowserTabStyle.TabBorderThickness);
368365

369366
Point point = new Point((int)SelectedTab.StripRect.Left - TabRadius, BrowserTabStyle.TabHeight);
370367
e.Graphics.DrawLine(lineColorPen, new Point(0, BrowserTabStyle.TabHeight), point);
@@ -415,9 +412,9 @@ private void OnCalcTabPage(Graphics g, BrowserTabPage currentItem) {
415412

416413

417414
/// <summary>
418-
/// Draws The Tab Header button
415+
/// Draws a single tab header button.
419416
/// </summary>
420-
private void OnDrawTabButton(Graphics g, BrowserTabPage tab) {
417+
private void DrawSingleTabButton(Graphics g, BrowserTabPage tab) {
421418
Items.IndexOf(tab);
422419
Font font = Font;
423420

@@ -427,7 +424,7 @@ private void OnDrawTabButton(Graphics g, BrowserTabPage tab) {
427424
RectangleF stripRect = tab.StripRect;
428425
var sr = stripRect;
429426
SolidBrush brush = new SolidBrush((tab == SelectedTab) ? BrowserTabStyle.SelectedTabBackColor : BrowserTabStyle.NormalTabBackColor);
430-
Pen pen = new Pen((tab == SelectedTab) ? BrowserTabStyle.SelectedTabBackColor : BrowserTabStyle.NormalTabBackColor);
427+
Pen pen = new Pen((tab == SelectedTab) ? BrowserTabStyle.TabBorderColor : BrowserTabStyle.NormalTabBackColor, BrowserTabStyle.TabBorderThickness);
431428

432429
//--------------------------------------------------------
433430
// Calc Rect for the Tab
@@ -449,18 +446,16 @@ private void OnDrawTabButton(Graphics g, BrowserTabPage tab) {
449446
//g.DrawRoundRectangle(SystemPens.ControlDark, tabDrawnRect, TabRadius);
450447

451448
//--------------------------------------------------------
452-
//// Rounded Chrome Tabs
449+
// Rounded Chrome Tabs
453450
//--------------------------------------------------------
454451
var tabpathNew =
455452
isActiveTab ?
456453
tabDrawnRect.CreateTabPath_Roundtop_RoundBottomOut(TabRadius) :
457454
tabDrawnRect.CreateTabPath_roundAll(TabRadius);
458455

459456
g.FillPath(brush, tabpathNew);
460-
//g.DrawPath(SystemPens.ControlDark, tabpathNew);
461-
//--white color requires more work...
462457
g.DrawPath(pen, tabpathNew);
463-
//--draw ,tab seperator line: | TAB1 | TAB2
458+
// draw tab seperator line: | TAB1 | TAB2
464459
if (!isActiveTab && !is_atRightof_ActiveTab) {
465460
int margin = 14;
466461
sr.Y += 2; //move rect down

0 commit comments

Comments
 (0)