From 3e6cb7064c130714d7665ef0aca4ca2b27a8071c Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Thu, 25 Jan 2024 08:18:52 +0900 Subject: [PATCH] Merge pull request #21729 from brave/brave_actions_highlight Fixed to have proper inkdrop size for browser actions --- browser/ui/brave_layout_constants.cc | 3 ++- .../brave_actions/brave_actions_container.cc | 15 +++++++-------- .../views/brave_actions/brave_actions_container.h | 1 + .../brave_actions/brave_rewards_action_view.cc | 4 ++-- .../brave_actions/brave_shields_action_view.cc | 2 +- .../ui/views/location_bar/location_bar_view.cc | 4 ++-- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/browser/ui/brave_layout_constants.cc b/browser/ui/brave_layout_constants.cc index 9e56bb28a66c..7554e9cf20d0 100644 --- a/browser/ui/brave_layout_constants.cc +++ b/browser/ui/brave_layout_constants.cc @@ -37,9 +37,10 @@ absl::optional GetBraveLayoutConstant(LayoutConstant constant) { return 24; } case LOCATION_BAR_HEIGHT: + // Consider adjust below element padding also when this height is changed. return 32; case LOCATION_BAR_ELEMENT_PADDING: - return 4; + return 2; default: break; } diff --git a/browser/ui/views/brave_actions/brave_actions_container.cc b/browser/ui/views/brave_actions/brave_actions_container.cc index 66f501b24764..82fc5a9b42ba 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.cc +++ b/browser/ui/views/brave_actions/brave_actions_container.cc @@ -23,12 +23,6 @@ #include "ui/views/layout/box_layout.h" #include "ui/views/view.h" -namespace { - -constexpr gfx::Size kToolbarActionSize(34, 30); - -} // namespace - BraveActionsContainer::BraveActionsContainer(Browser* browser, Profile* profile) : browser_(browser) {} @@ -84,14 +78,14 @@ void BraveActionsContainer::AddActionViewForShields() { AddChildViewAt(std::make_unique( *browser_->profile(), *browser_->tab_strip_model()), 1); - shields_action_btn_->SetPreferredSize(kToolbarActionSize); + shields_action_btn_->SetPreferredSize(GetActionSize()); shields_action_btn_->Init(); } void BraveActionsContainer::AddActionViewForRewards() { auto button = std::make_unique(browser_); rewards_action_btn_ = AddChildViewAt(std::move(button), 2); - rewards_action_btn_->SetPreferredSize(kToolbarActionSize); + rewards_action_btn_->SetPreferredSize(GetActionSize()); rewards_action_btn_->SetVisible(ShouldShowBraveRewardsAction()); rewards_action_btn_->Update(); } @@ -125,6 +119,11 @@ void BraveActionsContainer::UpdateVisibility() { SetVisible(!should_hide_ && can_show); } +gfx::Size BraveActionsContainer::GetActionSize() const { + return {34, GetLayoutConstant(LOCATION_BAR_HEIGHT) - + 2 * GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING)}; +} + void BraveActionsContainer::SetShouldHide(bool should_hide) { should_hide_ = should_hide; Update(); diff --git a/browser/ui/views/brave_actions/brave_actions_container.h b/browser/ui/views/brave_actions/brave_actions_container.h index 49b626658005..3cdd10a3d084 100644 --- a/browser/ui/views/brave_actions/brave_actions_container.h +++ b/browser/ui/views/brave_actions/brave_actions_container.h @@ -61,6 +61,7 @@ class BraveActionsContainer : public views::View { void AddActionViewForShields(); void UpdateVisibility(); + gfx::Size GetActionSize() const; // Brave Rewards preferences change observers callback. void OnBraveRewardsPreferencesChanged(); diff --git a/browser/ui/views/brave_actions/brave_rewards_action_view.cc b/browser/ui/views/brave_actions/brave_rewards_action_view.cc index 925b9e3bf092..d833871b3694 100644 --- a/browser/ui/views/brave_actions/brave_rewards_action_view.cc +++ b/browser/ui/views/brave_actions/brave_rewards_action_view.cc @@ -68,8 +68,8 @@ class ButtonHighlightPathGenerator : public views::HighlightPathGenerator { auto* layout_provider = ChromeLayoutProvider::Get(); DCHECK(layout_provider); - int radius = layout_provider->GetCornerRadiusMetric( - views::Emphasis::kMaximum, rect.size()); + int radius = layout_provider->GetCornerRadiusMetric(views::Emphasis::kHigh, + rect.size()); SkPath path; path.addRoundRect(gfx::RectToSkRect(rect), radius, radius); diff --git a/browser/ui/views/brave_actions/brave_shields_action_view.cc b/browser/ui/views/brave_actions/brave_shields_action_view.cc index 623382c5614d..5576f1109e9c 100644 --- a/browser/ui/views/brave_actions/brave_shields_action_view.cc +++ b/browser/ui/views/brave_actions/brave_shields_action_view.cc @@ -112,7 +112,7 @@ SkPath BraveShieldsActionView::GetHighlightPath() const { gfx::Rect rect(GetPreferredSize()); rect.Inset(highlight_insets); const int radii = ChromeLayoutProvider::Get()->GetCornerRadiusMetric( - views::Emphasis::kMaximum, rect.size()); + views::Emphasis::kHigh, rect.size()); SkPath path; path.addRoundRect(gfx::RectToSkRect(rect), radii, radii); return path; diff --git a/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc index 822d6769074c..65c08048d9b2 100644 --- a/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chromium_src/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -10,13 +10,13 @@ #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" // |icon_left| - Padding between left border of location bar and first -// decoration. Use fixed 4px always. +// decoration. Use element padding. // |text_left| - Padding between omnibox view and last leading decoration. // If last decoration has label, it has sufficient padding inside. // If custom padding is provided(text_left is not null), respect // it. Otherwise, set our design value - 5px. #define BRAVE_LAYOUT_LEADING_DECORATIONS \ - icon_left = 4; \ + icon_left = GetLayoutConstant(LOCATION_BAR_ELEMENT_PADDING); \ if (text_left == 0 && !location_icon_view_->ShouldShowLabel()) { \ text_left = 5; \ }