Merge pull request #27284 from brave/adjust_separator_between_pinned_unpinned_vertical_tab

Show separator between pinned and unpinned when both are not empty
This commit is contained in:
Simon Hong
2025-01-22 08:48:19 +09:00
committed by GitHub
2 changed files with 37 additions and 13 deletions
@@ -330,9 +330,28 @@ Tab* BraveCompoundTabContainer::AddTab(std::unique_ptr<Tab> tab,
ScrollTabToBeVisible(model_index);
}
UpdatePinnedTabContainerBorder();
return new_tab;
}
void BraveCompoundTabContainer::MoveTab(int from_model_index,
int to_model_index) {
CompoundTabContainer::MoveTab(from_model_index, to_model_index);
UpdatePinnedTabContainerBorder();
}
void BraveCompoundTabContainer::RemoveTab(int index, bool was_active) {
CompoundTabContainer::RemoveTab(index, was_active);
UpdatePinnedTabContainerBorder();
}
void BraveCompoundTabContainer::SetTabPinned(int model_index,
TabPinned pinned) {
CompoundTabContainer::SetTabPinned(model_index, pinned);
UpdatePinnedTabContainerBorder();
}
int BraveCompoundTabContainer::GetUnpinnedContainerIdealLeadingX() const {
if (!ShouldShowVerticalTabs()) {
return CompoundTabContainer::GetUnpinnedContainerIdealLeadingX();
@@ -394,18 +413,6 @@ BrowserRootView::DropTarget* BraveCompoundTabContainer::GetDropTarget(
return nullptr;
}
void BraveCompoundTabContainer::OnThemeChanged() {
CompoundTabContainer::OnThemeChanged();
if (ShouldShowVerticalTabs()) {
pinned_tab_container_->SetBorder(views::CreateSolidSidedBorder(
gfx::Insets().set_bottom(1),
GetColorProvider()->GetColor(kColorBraveVerticalTabSeparator)));
} else {
pinned_tab_container_->SetBorder(nullptr);
}
}
void BraveCompoundTabContainer::PaintChildren(const views::PaintInfo& info) {
if (ShouldShowVerticalTabs()) {
// Bypass CompoundTabContainer::PaintChildren() implementation.
@@ -493,6 +500,20 @@ bool BraveCompoundTabContainer::ShouldShowVerticalTabs() const {
tab_slot_controller_->GetBrowser());
}
void BraveCompoundTabContainer::UpdatePinnedTabContainerBorder() {
// We're using pinned tab container's bottom border as a separator from
// unpinned tab container. It should be drawn when only both are not empty.
const bool should_have_separator_between_pinned_and_unpinned =
ShouldShowVerticalTabs() && pinned_tab_container_->GetTabCount() != 0 &&
unpinned_tab_container_->GetTabCount() != 0;
if (should_have_separator_between_pinned_and_unpinned) {
pinned_tab_container_->SetBorder(views::CreateThemedSolidSidedBorder(
gfx::Insets().set_bottom(1), kColorBraveVerticalTabSeparator));
} else {
pinned_tab_container_->SetBorder(nullptr);
}
}
void BraveCompoundTabContainer::UpdateUnpinnedContainerSize() {
DCHECK(scroll_view_);
@@ -45,12 +45,14 @@ class BraveCompoundTabContainer : public CompoundTabContainer {
Tab* AddTab(std::unique_ptr<Tab> tab,
int model_index,
TabPinned pinned) override;
void MoveTab(int from_model_index, int to_model_index) override;
void RemoveTab(int index, bool was_active) override;
void SetTabPinned(int model_index, TabPinned pinned) override;
int GetUnpinnedContainerIdealLeadingX() const override;
TabContainer* GetTabContainerAt(
gfx::Point point_in_local_coords) const override;
gfx::Rect ConvertUnpinnedContainerIdealBoundsToLocal(
gfx::Rect ideal_bounds) const override;
void OnThemeChanged() override;
void PaintChildren(const views::PaintInfo& info) override;
void ChildPreferredSizeChanged(views::View* child) override;
void SetActiveTab(std::optional<size_t> prev_active_index,
@@ -68,6 +70,7 @@ class BraveCompoundTabContainer : public CompoundTabContainer {
bool ShouldShowVerticalTabs() const;
void UpdatePinnedTabContainerBorder();
void UpdateUnpinnedContainerSize();
void ScrollTabToBeVisible(int model_index);