-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20044 from brave/ksmith-h-tabs
Update horizontal tabs styling
- Loading branch information
Showing
36 changed files
with
624 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_TABS_BRAVE_TAB_LAYOUT_CONSTANTS_H_ | ||
#define BRAVE_BROWSER_UI_TABS_BRAVE_TAB_LAYOUT_CONSTANTS_H_ | ||
|
||
namespace brave_tabs { | ||
|
||
// Horizontal tab layout: | ||
// | ||
// The upstream tab implemenation assumes that tab view bounds overlap. In order | ||
// to create a gap between tabs without violating these assumptions, tabs views | ||
// are given a small overlap. Rounded tab rectangles are drawn centered and | ||
// inset horizontally by an amount that will create the required visual gap. | ||
|
||
// The amount of space before the first tab. | ||
constexpr int kHorizontalTabStripLeftMargin = 8; | ||
|
||
// The amount of vertical spacing between the top and bottom of tabs and the | ||
// bounds of the tab strip region. The portion of this space below tabs will be | ||
// occupied by tab group underlines. | ||
constexpr int kHorizontalTabStripVerticalSpacing = 4; | ||
|
||
// The visual gap between tabs. | ||
constexpr int kHorizontalTabGap = 4; | ||
|
||
// The amount of overlap between tabs. Based on upstream assumptions, tab views | ||
// must have a non-negative overlap. Furthermore, tab separators will not render | ||
// correctly if the tab overlap is zero. | ||
constexpr int kHorizontalTabOverlap = 2; | ||
|
||
// The horizontal difference between the edge of the tab view and the visual | ||
// edge of the rendered tab. | ||
constexpr int kHorizontalTabInset = | ||
(kHorizontalTabGap + kHorizontalTabOverlap) / 2; | ||
|
||
// The content padding within a tab. | ||
constexpr int kHorizontalTabPadding = 6; | ||
|
||
// The horizontal difference between the visual edge of a tab group and the | ||
// bounds of the group underline. | ||
constexpr int kHorizontalGroupUnderlineInset = 2; | ||
|
||
// The tab border radius. | ||
constexpr int kTabBorderRadius = 8; | ||
|
||
// The size of the group header slot when the title is empty. | ||
constexpr int kEmptyGroupTitleSize = 22; | ||
|
||
} // namespace brave_tabs | ||
|
||
#endif // BRAVE_BROWSER_UI_TABS_BRAVE_TAB_LAYOUT_CONSTANTS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_TABS_BRAVE_TAB_STYLE_H_ | ||
#define BRAVE_BROWSER_UI_TABS_BRAVE_TAB_STYLE_H_ | ||
|
||
#include "brave/browser/ui/tabs/brave_tab_layout_constants.h" | ||
#include "brave/browser/ui/tabs/features.h" | ||
#include "chrome/browser/ui/layout_constants.h" | ||
#include "ui/gfx/geometry/insets.h" | ||
|
||
// A subclass of TabStyle used to customize tab layout and visuals. It is | ||
// implemented as a template because it must be included in the source file | ||
// override before the base class definition. | ||
template <typename TabStyleBase> | ||
class BraveTabStyle : public TabStyleBase { | ||
public: | ||
int GetTabOverlap() const override { | ||
if (!tabs::features::HorizontalTabsUpdateEnabled()) { | ||
return TabStyleBase::GetTabOverlap(); | ||
} | ||
return brave_tabs::kHorizontalTabOverlap; | ||
} | ||
|
||
int GetTopCornerRadius() const override { | ||
if (!tabs::features::HorizontalTabsUpdateEnabled()) { | ||
return TabStyleBase::GetTopCornerRadius(); | ||
} | ||
return brave_tabs::kTabBorderRadius; | ||
} | ||
|
||
int GetBottomCornerRadius() const override { | ||
if (!tabs::features::HorizontalTabsUpdateEnabled()) { | ||
return TabStyleBase::GetBottomCornerRadius(); | ||
} | ||
return brave_tabs::kTabBorderRadius; | ||
} | ||
|
||
gfx::Insets GetContentsInsets() const override { | ||
if (!tabs::features::HorizontalTabsUpdateEnabled()) { | ||
return TabStyleBase::GetContentsInsets(); | ||
} | ||
return gfx::Insets::VH( | ||
0, brave_tabs::kHorizontalTabPadding + brave_tabs::kHorizontalTabInset); | ||
} | ||
|
||
int GetPinnedWidth() const override { | ||
if (!tabs::features::HorizontalTabsUpdateEnabled()) { | ||
return TabStyleBase::GetPinnedWidth(); | ||
} | ||
return GetLayoutConstant(TAB_HEIGHT) + brave_tabs::kHorizontalTabInset * 2; | ||
} | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_TABS_BRAVE_TAB_STYLE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.