From e4b5445b6b47aa41b7d956a76b41dd836556f79f Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Thu, 19 Dec 2024 15:11:37 +0900 Subject: [PATCH] Use 4px between tab tile border and tab horizontal gap Also give 4px gap between split view tile and others --- browser/ui/views/tabs/brave_tab.cc | 5 ---- browser/ui/views/tabs/brave_tab.h | 1 - browser/ui/views/tabs/brave_tab_container.cc | 27 +++++++++++-------- .../views/tabs/brave_tab_style_views.inc.cc | 18 ++++++++----- .../chrome/browser/ui/views/tabs/tab.h | 1 - 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/browser/ui/views/tabs/brave_tab.cc b/browser/ui/views/tabs/brave_tab.cc index 03523f069c47..309682b52b29 100644 --- a/browser/ui/views/tabs/brave_tab.cc +++ b/browser/ui/views/tabs/brave_tab.cc @@ -54,11 +54,6 @@ std::u16string BraveTab::GetTooltipText(const gfx::Point& p) const { return Tab::GetTooltipText(p); } -void BraveTab::UpdateBorder() { - // In vertical tab, different border is used based on split view state. - SetBorder(views::CreateEmptyBorder(tab_style_views()->GetContentsInsets())); -} - int BraveTab::GetWidthOfLargestSelectableRegion() const { // Assume the entire region except the area that alert indicator/close buttons // occupied is available for click-to-select. diff --git a/browser/ui/views/tabs/brave_tab.h b/browser/ui/views/tabs/brave_tab.h index 798e14bfc706..8bd14932d8c3 100644 --- a/browser/ui/views/tabs/brave_tab.h +++ b/browser/ui/views/tabs/brave_tab.h @@ -24,7 +24,6 @@ class BraveTab : public Tab { // Tab: std::u16string GetTooltipText(const gfx::Point& p) const override; - void UpdateBorder() override; // Overridden because we moved alert button to left side in the tab whereas // upstream put it on right side. Need to consider this change for calculating diff --git a/browser/ui/views/tabs/brave_tab_container.cc b/browser/ui/views/tabs/brave_tab_container.cc index fa44f6d4b9f7..f9b652833116 100644 --- a/browser/ui/views/tabs/brave_tab_container.cc +++ b/browser/ui/views/tabs/brave_tab_container.cc @@ -15,6 +15,7 @@ #include "base/containers/flat_map.h" #include "base/feature_list.h" #include "brave/browser/ui/color/brave_color_id.h" +#include "brave/browser/ui/tabs/brave_tab_layout_constants.h" #include "brave/browser/ui/tabs/brave_tab_prefs.h" #include "brave/browser/ui/tabs/features.h" #include "brave/browser/ui/tabs/split_view_browser_data.h" @@ -309,10 +310,8 @@ void BraveTabContainer::PaintBoundingBoxForTile(gfx::Canvas& canvas, // implementations in compound_tab_container.cc implementation. Thus, we need // to add pinned tab count. auto* tab_strip_model = tab_slot_controller_->GetBrowser()->tab_strip_model(); - const bool is_pinned_tab_container = - tabs_view_model_.view_at(0)->data().pinned; const int offset = - is_pinned_tab_container ? 0 : tab_strip_model->IndexOfFirstNonPinnedTab(); + IsPinnedTabContainer() ? 0 : tab_strip_model->IndexOfFirstNonPinnedTab(); auto tab1_index = tab_strip_model->GetIndexOfTab(tile.first) - offset; auto tab2_index = tab_strip_model->GetIndexOfTab(tile.second) - offset; @@ -334,11 +333,11 @@ void BraveTabContainer::PaintBoundingBoxForTile(gfx::Canvas& canvas, // In order to make margin between the bounding box and tab strip. // Need to compensate the amount of overlap because it's hidden by overlap // at bottom. - constexpr int kVerticalMargin = 2; - const int margin_bottom = - kVerticalMargin + GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP); - bounding_rects.Inset( - gfx::Insets::TLBR(kVerticalMargin, 0, margin_bottom, 0)); + int vertical_margin = GetTabAtModelIndex(tab1_index)->data().pinned ? 4 : 2; + bounding_rects.Inset(gfx::Insets::TLBR( + vertical_margin, brave_tabs::kHorizontalTabInset, + vertical_margin + GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP), + brave_tabs::kHorizontalTabInset)); } constexpr auto kRadius = 12.f; // same value with --leo-radius-l @@ -759,7 +758,8 @@ void BraveTabContainer::SetDropArrow( } bool BraveTabContainer::IsPinnedTabContainer() const { - return tabs_view_model_.view_size() > 0 && tabs_view_model_.view_at(0)->data().pinned; + return tabs_view_model_.view_size() > 0 && + tabs_view_model_.view_at(0)->data().pinned; } void BraveTabContainer::UpdateTabsBorderInTile(const TabTile& tile) { @@ -780,8 +780,13 @@ void BraveTabContainer::UpdateTabsBorderInTile(const TabTile& tile) { auto* tab1 = GetTabAtModelIndex(tab1_index); auto* tab2 = GetTabAtModelIndex(tab2_index); - tab1->UpdateBorder(); - tab2->UpdateBorder(); + + // Tab's border varies per split view state. + // See BraveVerticalTabStyle::GetContentsInsets(). + tab1->SetBorder( + views::CreateEmptyBorder(tab1->tab_style_views()->GetContentsInsets())); + tab2->SetBorder( + views::CreateEmptyBorder(tab2->tab_style_views()->GetContentsInsets())); } BEGIN_METADATA(BraveTabContainer) diff --git a/browser/ui/views/tabs/brave_tab_style_views.inc.cc b/browser/ui/views/tabs/brave_tab_style_views.inc.cc index 8e4eea83dadf..f47e25f7d3bc 100644 --- a/browser/ui/views/tabs/brave_tab_style_views.inc.cc +++ b/browser/ui/views/tabs/brave_tab_style_views.inc.cc @@ -217,7 +217,8 @@ SkPath BraveVerticalTabStyle::GetPath( } } - if (!is_pinned && IsTabTiled(tab()) && path_type != TabStyle::PathType::kHitTest) { + if (!is_pinned && IsTabTiled(tab()) && + path_type != TabStyle::PathType::kHitTest) { if (ShouldShowVerticalTabs()) { tab()->controller()->IsFirstTabInTile(tab()) ? tab_top += scale* kPaddingForVerticalTabInTile @@ -225,13 +226,16 @@ SkPath BraveVerticalTabStyle::GetPath( tab_left += scale * kPaddingForVerticalTabInTile; tab_right -= scale * kPaddingForVerticalTabInTile; } else { - // Give 2 dip more padding when tab is in tile. - constexpr auto kPaddingForHorizontalTab = 2; - tab_top += scale * kPaddingForHorizontalTab; - tab_bottom -= scale * kPaddingForHorizontalTab; + constexpr int kTotalVerticalPaddingForHorizontalTab = 6; + constexpr int kAdditionalVerticalPadding = + kTotalVerticalPaddingForHorizontalTab - brave_tabs::kHorizontalTabGap; + tab_top += scale * kAdditionalVerticalPadding; + tab_bottom -= scale * kAdditionalVerticalPadding; + + constexpr int kAdditionalHorizontalPadding = 4; tab()->controller()->IsFirstTabInTile(tab()) - ? tab_left += scale* kPaddingForHorizontalTab - : tab_right -= scale * kPaddingForHorizontalTab; + ? tab_left += scale* kAdditionalHorizontalPadding + : tab_right -= scale * kAdditionalHorizontalPadding; } } diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab.h b/chromium_src/chrome/browser/ui/views/tabs/tab.h index 7d2b89e7ef57..8cc15a690dc0 100644 --- a/chromium_src/chrome/browser/ui/views/tabs/tab.h +++ b/chromium_src/chrome/browser/ui/views/tabs/tab.h @@ -13,7 +13,6 @@ class BraveTab; kMinimumContentsWidthForCloseButtons = 55; \ friend class ::BraveTabTest; \ friend class ::BraveTab; \ - virtual void UpdateBorder() {} \ static constexpr int kMinimumContentsWidthForCloseButtons_UnUsed #define GetWidthOfLargestSelectableRegion \