-
Notifications
You must be signed in to change notification settings - Fork 867
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 #6900 from brave/tab_contrast
Increase contrast between active and inactive tabs
- Loading branch information
Showing
7 changed files
with
162 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/ui/views/tabs/brave_tab_strip.h" | ||
|
||
#include "brave/browser/profiles/profile_util.h" | ||
#include "brave/browser/themes/brave_dark_mode_utils.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/themes/theme_service.h" | ||
#include "chrome/browser/themes/theme_service_factory.h" | ||
#include "chrome/browser/ui/views/tabs/tab.h" | ||
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h" | ||
#include "third_party/skia/include/core/SkColor.h" | ||
|
||
BraveTabStrip::~BraveTabStrip() = default; | ||
|
||
bool BraveTabStrip::ShouldHideCloseButtonForTab(Tab* tab) const { | ||
bool should_hide = TabStrip::ShouldHideCloseButtonForTab(tab); | ||
|
||
// If upstream logic want to hide, follow it. | ||
if (should_hide) | ||
return should_hide; | ||
|
||
if (tab->IsActive()) | ||
return false; | ||
|
||
// Only shows close button on tab when mouse is hovered on tab. | ||
return !tab->mouse_hovered(); | ||
} | ||
|
||
SkColor BraveTabStrip::GetTabSeparatorColor() const { | ||
Profile* profile = controller()->GetProfile(); | ||
if (!brave::IsRegularProfile(profile)) | ||
return TabStrip::GetTabSeparatorColor(); | ||
|
||
// If custom theme is used, follow upstream separator color. | ||
auto* theme_service = ThemeServiceFactory::GetForProfile(profile); | ||
if (theme_service->GetThemeSupplier()) | ||
return TabStrip::GetTabSeparatorColor(); | ||
|
||
bool dark_mode = dark_mode::GetActiveBraveDarkModeType() == | ||
dark_mode::BraveDarkModeType::BRAVE_DARK_MODE_TYPE_DARK; | ||
return dark_mode ? SkColorSetRGB(0x39, 0x38, 0x38) | ||
: SkColorSetRGB(0xBE, 0xBF, 0xBF); | ||
} |
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,24 @@ | ||
/* Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_TAB_STRIP_H_ | ||
#define BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_TAB_STRIP_H_ | ||
|
||
#include "chrome/browser/ui/views/tabs/tab_strip.h" | ||
|
||
class BraveTabStrip : public TabStrip { | ||
public: | ||
using TabStrip::TabStrip; | ||
~BraveTabStrip() override; | ||
BraveTabStrip(const BraveTabStrip&) = delete; | ||
BraveTabStrip& operator=(const BraveTabStrip&) = delete; | ||
|
||
private: | ||
// TabStrip overrides: | ||
bool ShouldHideCloseButtonForTab(Tab* tab) const override; | ||
SkColor GetTabSeparatorColor() const override; | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_TAB_STRIP_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
58 changes: 58 additions & 0 deletions
58
chromium_src/chrome/browser/ui/views/tabs/tab_style_views.cc
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,58 @@ | ||
/* Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "chrome/browser/ui/views/tabs/tab_style_views.h" | ||
|
||
#define BRAVE_GM2_TAB_STYLE_H protected: | ||
#define CreateForTab CreateForTab_ChromiumImpl | ||
#include "../../../../../../../chrome/browser/ui/views/tabs/tab_style_views.cc" | ||
#undef CreateForTab | ||
#undef BRAVE_GM2_TAB_STYLE_H | ||
|
||
namespace { | ||
|
||
class BraveGM2TabStyle : public GM2TabStyle { | ||
public: | ||
explicit BraveGM2TabStyle(Tab* tab); | ||
BraveGM2TabStyle(const BraveGM2TabStyle&) = delete; | ||
BraveGM2TabStyle& operator=(const BraveGM2TabStyle&) = delete; | ||
|
||
protected: | ||
TabStyle::TabColors CalculateColors() const override; | ||
const gfx::FontList& GetFontList() const override; | ||
|
||
private: | ||
gfx::FontList semibold_font_; | ||
}; | ||
|
||
BraveGM2TabStyle::BraveGM2TabStyle(Tab* tab) | ||
: GM2TabStyle(tab), | ||
semibold_font_( | ||
normal_font_.DeriveWithWeight(gfx::Font::Weight::SEMIBOLD)) {} | ||
|
||
TabStyle::TabColors BraveGM2TabStyle::CalculateColors() const { | ||
auto colors = GM2TabStyle::CalculateColors(); | ||
const SkColor inactive_non_hovered_fg_color = SkColorSetA( | ||
colors.foreground_color, | ||
gfx::Tween::IntValueBetween(0.7, SK_AlphaTRANSPARENT, SK_AlphaOPAQUE)); | ||
const SkColor final_fg_color = (tab_->IsActive() || tab_->mouse_hovered()) | ||
? colors.foreground_color | ||
: inactive_non_hovered_fg_color; | ||
return {final_fg_color, colors.background_color}; | ||
} | ||
|
||
const gfx::FontList& BraveGM2TabStyle::GetFontList() const { | ||
const auto& font_list = GM2TabStyle::GetFontList(); | ||
if (&font_list == &normal_font_ && tab_->IsActive()) { | ||
return semibold_font_; | ||
} | ||
return font_list; | ||
} | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<TabStyleViews> TabStyleViews::CreateForTab(Tab* tab) { | ||
return std::make_unique<BraveGM2TabStyle>(tab); | ||
} |
15 changes: 15 additions & 0 deletions
15
chromium_src/chrome/browser/ui/views/tabs/tab_style_views.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,15 @@ | ||
/* Copyright (c) 2020 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TABS_TAB_STYLE_VIEWS_H_ | ||
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TABS_TAB_STYLE_VIEWS_H_ | ||
|
||
#define CreateForTab CreateForTab_ChromiumImpl(Tab* tab); \ | ||
static std::unique_ptr<TabStyleViews> CreateForTab | ||
|
||
#include "../../../../../../../chrome/browser/ui/views/tabs/tab_style_views.h" | ||
#undef CreateForTab | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_TABS_TAB_STYLE_VIEWS_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