Skip to content

Commit

Permalink
Merge pull request #4076 from brave/speaker_icon_on_pinned_tab
Browse files Browse the repository at this point in the history
Make speaker icon on pinned tab un-clickable
  • Loading branch information
simonhong authored Nov 27, 2019
2 parents 414a894 + 7d576b7 commit 7fe7fe2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 16 additions & 6 deletions browser/ui/views/tabs/brave_alert_indicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class BraveAlertIndicator::BraveAlertBackground : public views::Background {

// views::Background overrides:
void Paint(gfx::Canvas* canvas, views::View* view) const override {
if (!host_view_->IsTabAudioToggleable())
return;

gfx::Point center = host_view_->GetContentsBounds().CenterPoint();
SkPath path;
path.setFillType(SkPath::kEvenOdd_FillType);
Expand All @@ -58,7 +61,7 @@ BraveAlertIndicator::BraveAlertIndicator(Tab* parent_tab)

SkColor BraveAlertIndicator::GetBackgroundColor() const {
TabStyle::TabColors colors = parent_tab_->tab_style()->CalculateColors();
if (!IsAudioState(alert_state_) || !IsMouseHovered())
if (!IsTabAudioToggleable() || !IsMouseHovered())
return colors.background_color;

// Approximating the InkDrop behavior of the close button.
Expand All @@ -70,7 +73,7 @@ bool BraveAlertIndicator::OnMousePressed(const ui::MouseEvent& event) {
mouse_pressed_ = true;
SchedulePaint();

if (!IsAudioState(alert_state_))
if (!IsTabAudioToggleable())
return AlertIndicator::OnMousePressed(event);

return true;
Expand All @@ -80,7 +83,7 @@ void BraveAlertIndicator::OnMouseReleased(const ui::MouseEvent& event) {
mouse_pressed_ = false;
SchedulePaint();

if (!IsAudioState(alert_state_) || !IsMouseHovered())
if (!IsTabAudioToggleable() || !IsMouseHovered())
return AlertIndicator::OnMouseReleased(event);

auto* tab_strip = static_cast<TabStrip*>(parent_tab_->controller());
Expand All @@ -99,19 +102,26 @@ void BraveAlertIndicator::OnMouseReleased(const ui::MouseEvent& event) {
}

void BraveAlertIndicator::OnMouseEntered(const ui::MouseEvent& event) {
if (IsAudioState(alert_state_))
if (IsTabAudioToggleable())
SchedulePaint();
AlertIndicator::OnMouseExited(event);
}

void BraveAlertIndicator::OnMouseExited(const ui::MouseEvent& event) {
if (IsAudioState(alert_state_))
if (IsTabAudioToggleable())
SchedulePaint();
AlertIndicator::OnMouseExited(event);
}

bool BraveAlertIndicator::OnMouseDragged(const ui::MouseEvent& event) {
if (IsAudioState(alert_state_))
if (IsTabAudioToggleable())
SchedulePaint();
return AlertIndicator::OnMouseDragged(event);
}

bool BraveAlertIndicator::IsTabAudioToggleable() const {
if (parent_tab_->controller()->IsTabPinned(parent_tab_))
return false;

return IsAudioState(alert_state_);
}
2 changes: 2 additions & 0 deletions browser/ui/views/tabs/brave_alert_indicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BraveAlertIndicator : public AlertIndicator {

SkColor GetBackgroundColor() const;

bool IsTabAudioToggleable() const;

bool mouse_pressed_ = false;

DISALLOW_COPY_AND_ASSIGN(BraveAlertIndicator);
Expand Down

0 comments on commit 7fe7fe2

Please sign in to comment.