Skip to content

Commit

Permalink
Merge pull request #21729 from brave/brave_actions_highlight
Browse files Browse the repository at this point in the history
Fixed to have proper inkdrop size for browser actions
  • Loading branch information
simonhong committed Jan 26, 2024
1 parent 72dc488 commit 3e6cb70
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion browser/ui/brave_layout_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ absl::optional<int> 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;
}
Expand Down
15 changes: 7 additions & 8 deletions browser/ui/views/brave_actions/brave_actions_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down Expand Up @@ -84,14 +78,14 @@ void BraveActionsContainer::AddActionViewForShields() {
AddChildViewAt(std::make_unique<BraveShieldsActionView>(
*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<BraveRewardsActionView>(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();
}
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions browser/ui/views/brave_actions/brave_actions_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions browser/ui/views/brave_actions/brave_rewards_action_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
}
Expand Down

0 comments on commit 3e6cb70

Please sign in to comment.