Skip to content

Commit

Permalink
Use 4px between tab tile border and tab horizontal gap
Browse files Browse the repository at this point in the history
Also give 4px gap between split view tile and others
  • Loading branch information
simonhong committed Dec 19, 2024
1 parent 5124a7d commit e4b5445
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
5 changes: 0 additions & 5 deletions browser/ui/views/tabs/brave_tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion browser/ui/views/tabs/brave_tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 16 additions & 11 deletions browser/ui/views/tabs/brave_tab_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
18 changes: 11 additions & 7 deletions browser/ui/views/tabs/brave_tab_style_views.inc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,25 @@ 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
: tab_bottom -= scale * kPaddingForVerticalTabInTile;
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;
}
}

Expand Down
1 change: 0 additions & 1 deletion chromium_src/chrome/browser/ui/views/tabs/tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class BraveTab;
kMinimumContentsWidthForCloseButtons = 55; \
friend class ::BraveTabTest; \
friend class ::BraveTab; \
virtual void UpdateBorder() {} \
static constexpr int kMinimumContentsWidthForCloseButtons_UnUsed

#define GetWidthOfLargestSelectableRegion \
Expand Down

0 comments on commit e4b5445

Please sign in to comment.