Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase contrast between active and inactive tabs #6900

Merged
merged 5 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ source_set("ui") {
"views/tabs/brave_browser_tab_strip_controller.h",
"views/tabs/brave_tab_context_menu_contents.cc",
"views/tabs/brave_tab_context_menu_contents.h",
"views/tabs/brave_tab_strip.cc",
"views/tabs/brave_tab_strip.h",
"views/toolbar/bookmark_button.cc",
"views/toolbar/bookmark_button.h",
]
Expand Down
47 changes: 47 additions & 0 deletions browser/ui/views/tabs/brave_tab_strip.cc
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);
}
24 changes: 24 additions & 0 deletions browser/ui/views/tabs/brave_tab_strip.h
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_
4 changes: 4 additions & 0 deletions chromium_src/chrome/browser/ui/views/frame/browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/ui/views/tabs/brave_browser_tab_strip_controller.h"
#include "brave/browser/ui/views/tabs/brave_tab_strip.h"
#include "brave/browser/ui/views/toolbar/brave_toolbar_view.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
mkarolin marked this conversation as resolved.
Show resolved Hide resolved

#define ToolbarView BraveToolbarView
#define BrowserTabStripController BraveBrowserTabStripController
#define TabStrip BraveTabStrip
#include "../../../../../../../chrome/browser/ui/views/frame/browser_view.cc" // NOLINT
#undef ToolbarView
#undef BrowserTabStripController
#undef TabStrip
32 changes: 32 additions & 0 deletions chromium_src/chrome/browser/ui/views/tabs/tab_style_views.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* 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/. */

#define BRAVE_GM2_TAB_STYLE_H \
private: \
gfx::FontList semibold_font_;

#define BRAVE_GM2_TAB_STYLE \
semibold_font_ = normal_font_.DeriveWithWeight(gfx::Font::Weight::SEMIBOLD);

#define BRAVE_CALCULATE_COLORS \
const SkColor inactive_non_hovered_fg_color = \
SkColorSetA(foreground_color, \
gfx::Tween::IntValueBetween(0.7, \
SK_AlphaTRANSPARENT, \
SK_AlphaOPAQUE)); \
const SkColor final_fg_color = \
(tab_->IsActive() || tab_->mouse_hovered()) ? \
foreground_color : inactive_non_hovered_fg_color; \
return { final_fg_color, background_color};

#define BRAVE_GET_FONT_LIST \
return tab_->IsActive() ? semibold_font_ : normal_font_;

#include "../../../../../../../chrome/browser/ui/views/tabs/tab_style_views.cc"

#undef BRAVE_GM2_TAB_STYLE_H
#undef BRAVE_GM2_TAB_STYLE
#undef BRAVE_CALCULATE_COLORS
#undef BRAVE_GET_FONT_LIST
40 changes: 36 additions & 4 deletions patches/chrome-browser-ui-views-tabs-tab_style_views.cc.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
diff --git a/chrome/browser/ui/views/tabs/tab_style_views.cc b/chrome/browser/ui/views/tabs/tab_style_views.cc
index 950c967b5f87a6e3f531e3155a420002a7510d3a..a9b5b74a1a5c345727c1deb631fce7fcbb2762dc 100644
index 950c967b5f87a6e3f531e3155a420002a7510d3a..d488846079f3d0521bd9d1bbe6ffeae158c3393b 100644
--- a/chrome/browser/ui/views/tabs/tab_style_views.cc
+++ b/chrome/browser/ui/views/tabs/tab_style_views.cc
@@ -280,6 +280,7 @@ SkPath GM2TabStyle::GetPath(PathType path_type,
@@ -65,6 +65,7 @@ class GM2TabStyle : public TabStyleViews {
void ShowHover(ShowHoverStyle style) override;
void HideHover(HideHoverStyle style) override;

+ BRAVE_GM2_TAB_STYLE_H
private:
// Gets the bounds for the leading and trailing separators for a tab.
SeparatorBounds GetSeparatorBounds(float scale) const;
@@ -191,6 +192,7 @@ GM2TabStyle::GM2TabStyle(Tab* tab)
views::style::STYLE_PRIMARY)),
heavy_font_(views::style::GetFont(views::style::CONTEXT_BUTTON_MD,
views::style::STYLE_PRIMARY)) {
+ BRAVE_GM2_TAB_STYLE
// TODO(dfried): create a new STYLE_PROMINENT or similar to use instead of
// repurposing CONTEXT_BUTTON_MD.
}
@@ -280,6 +282,7 @@ SkPath GM2TabStyle::GetPath(PathType path_type,
const ShapeModifier shape_modifier = GetShapeModifier(path_type);
const bool extend_left_to_bottom = shape_modifier & kNoLowerLeftArc;
const bool extend_right_to_bottom = shape_modifier & kNoLowerRightArc;
+ bottom_radius = 0;

SkPath path;

@@ -533,7 +534,7 @@ TabStyle::SeparatorBounds GM2TabStyle::GetSeparatorBounds(float scale) const {
@@ -459,6 +462,7 @@ TabStyle::TabColors GM2TabStyle::CalculateColors() const {
expected_opacity > 0.5f ? TabActive::kActive : TabActive::kInactive,
background_color);

+ BRAVE_CALCULATE_COLORS
return {foreground_color, background_color};
}

@@ -472,6 +476,7 @@ const gfx::FontList& GM2TabStyle::GetFontList() const {
return heavy_font_;
}

+ BRAVE_GET_FONT_LIST
return normal_font_;
}

@@ -533,7 +538,7 @@ TabStyle::SeparatorBounds GM2TabStyle::GetSeparatorBounds(float scale) const {
separator_bounds.leading =
gfx::RectF(aligned_bounds.x() + corner_radius,
aligned_bounds.y() +
Expand All @@ -19,7 +51,7 @@ index 950c967b5f87a6e3f531e3155a420002a7510d3a..a9b5b74a1a5c345727c1deb631fce7fc
separator_size.width(), separator_size.height());

separator_bounds.trailing = separator_bounds.leading;
@@ -888,12 +889,16 @@ void GM2TabStyle::PaintSeparators(gfx::Canvas* canvas) const {
@@ -888,12 +893,16 @@ void GM2TabStyle::PaintSeparators(gfx::Canvas* canvas) const {
SK_AlphaOPAQUE));
};

Expand Down