Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all four corners of the tip panel rounded (uplift to 1.52.x) #18569

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 9 additions & 37 deletions browser/ui/views/brave_rewards/tip_panel_bubble_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,10 @@ namespace brave_rewards {

namespace {

// The tip dialog is anchored to the center of the location bar, and must be
// drawn with rounded bottom borders. We implement these customizations by
// subclassing `WebUIBubbleDialogView`. This implementation is then used by
// `TipPanelBubbleManager` when creating the dialog view.
class TipPanelDialogView : public WebUIBubbleDialogView {
public:
TipPanelDialogView(views::View* anchor_view,
BubbleContentsWrapper* contents_wrapper,
const absl::optional<gfx::Rect>& anchor_rect)
: WebUIBubbleDialogView(anchor_view, contents_wrapper, anchor_rect) {
SetArrow(views::BubbleBorder::TOP_CENTER);
SetPaintClientToLayer(true);
set_use_round_corners(true);
set_corner_radius(16);
}

// views::Widget:
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override {
auto frame = WebUIBubbleDialogView::CreateNonClientFrameView(widget);
auto* bubble_frame = static_cast<views::BubbleFrameView*>(frame.get());
auto* bubble_border = bubble_frame->bubble_border();
DCHECK(bubble_border);
bubble_border->SetRoundedCorners(0, 0, 16, 16);
return frame;
}

// views::View:
void AddedToWidget() override {
WebUIBubbleDialogView::AddedToWidget();
web_view()->holder()->SetCornerRadii(gfx::RoundedCornersF(0, 0, 16, 16));
}
};

// In order to use `TipPanelDialogView` as the dialog view implementation, we
// must override the `CreateWebUIBubbleDialog` of `WebUIBubbleManager`.
// In order to customize the borders and alignment of the bubble panel, we must
// override the `CreateWebUIBubbleDialog` of `WebUIBubbleManager`. Note that
// originally only the bottom borders were rounded but at the time that resulted
// in inconsistent cross-platform rendering.
class TipPanelBubbleManager : public WebUIBubbleManager {
public:
TipPanelBubbleManager(views::View* anchor_view, Profile* profile)
Expand All @@ -82,8 +50,12 @@ class TipPanelBubbleManager : public WebUIBubbleManager {
set_cached_contents_wrapper(std::move(contents_wrapper));
cached_contents_wrapper()->ReloadWebContents();

auto bubble_view = std::make_unique<TipPanelDialogView>(
auto bubble_view = std::make_unique<WebUIBubbleDialogView>(
anchor_view_, cached_contents_wrapper(), anchor);
bubble_view->SetArrow(views::BubbleBorder::TOP_CENTER);
bubble_view->SetPaintClientToLayer(true);
bubble_view->set_use_round_corners(true);
bubble_view->set_corner_radius(16);

auto weak_ptr = bubble_view->GetWeakPtr();
views::BubbleDialogDelegateView::CreateBubble(std::move(bubble_view));
Expand Down
2 changes: 1 addition & 1 deletion components/resources/rewards_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@
Share your support
</message>
<message name="IDS_REWARDS_TIP_SHARE_TEXT" desc="">
I just contributed <ph name="AMOUNT">$1</ph> using the Brave Browser! See how you can support your favorite creators and sites too: https://brave.com/rewards
I just contributed <ph name="AMOUNT">$1</ph> BAT using the Brave Browser! See how you can support your favorite creators and sites too: https://brave.com/rewards
</message>
<message name="IDS_REWARDS_TIP_UNEXPECTED_ERROR_TITLE" desc="">
An unexpected error has occurred
Expand Down