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

Updated toolbar download button style #17769

Merged
merged 2 commits into from
Mar 28, 2023
Merged

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Mar 27, 2023

Normal state -
Screenshot 2023-03-28 at 9 13 57 AM

In-progress -
Screenshot 2023-03-28 at 9 14 10 AM

Completed and user doesn't click the button yet.
Screenshot 2023-03-28 at 9 14 30 AM
fix brave/brave-browser#29324

Resolves

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@simonhong simonhong self-assigned this Mar 27, 2023
@simonhong simonhong force-pushed the update_download_button_style branch from 88c8bb4 to f1b137d Compare March 27, 2023 07:46
namespace {

-constexpr int kProgressRingRadius = 9;
+constexpr int kProgressRingRadius = 12;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made patch here. I think this is the most simplest way.
As this value is used in the middle of PaintButtonContents(),
we need to override that method and copy the most of that method's impls.

} \
\
protected: \
DownloadDisplayController* display_controller() const { \
Copy link
Member Author

@simonhong simonhong Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to call this from the const method (GetIconColor()).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: returning mutable from const is not great, so another option here is to implement this as DownloadDisplayController::IconInfo GetIconInfo() const { return controller_->GetIconInfo(); }.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the return type should be const DownloadDisplayController* based on https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/const.md - The returned member could be changed so this getter doesn't seem to be logically const.


But changing return type like so would make us use const_cast<>, so I think we can remove this getter here and just use const_cast<> from the callsite.

Copy link
Contributor

@sangwoo108 sangwoo108 Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw @goodov right after I'd written the comment above. +1 for @goodov 's suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonhong simonhong marked this pull request as ready for review March 27, 2023 23:55
@simonhong simonhong requested review from a team as code owners March 27, 2023 23:55
@simonhong simonhong requested a review from sangwoo108 March 27, 2023 23:55
} \
\
protected: \
DownloadDisplayController* display_controller() const { \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: returning mutable from const is not great, so another option here is to implement this as DownloadDisplayController::IconInfo GetIconInfo() const { return controller_->GetIconInfo(); }.

Comment on lines 9 to 39

#define DownloadToolbarButtonView DownloadToolbarButtonViewChromium

#include "src/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc"

#undef DownloadToolbarButtonView

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's worth, but can we remove the patch file by overriding gfx::RectFToSkRect() like this?

Suggested change
#define DownloadToolbarButtonView DownloadToolbarButtonViewChromium
#include "src/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc"
#undef DownloadToolbarButtonView
#include "ui/gfx/geometry/skia_conversions.h"
namespace gfx {
SkRect AdjustRingBounds(const gfx::RectF& ring_bounds);
}
#define RectFToSkRect(ring_bounds) AdjustRingBounds(ring_bounds)
#define DownloadToolbarButtonView DownloadToolbarButtonViewChromium
#include "src/chrome/browser/ui/views/download/bubble/download_toolbar_button_view.cc"
#undef DownloadToolbarButtonView
#undef RectFToSkRect
namespace gfx {
SkRect AdjustRingBounds(const gfx::RectF& ring_bounds) {
const int chromium_ring_radius = ui::TouchUiController::Get()->touch_ui()
? kProgressRingRadiusTouchMode
: kProgressRingRadius;
constexpr auto kBraveRingRadius = 12;
const auto delta = kBraveRingRadius - chromium_ring_radius;
gfx::RectF new_bounds(ring_bounds);
new_bounds.Outset(gfx::OutsetsF(delta));
return gfx::RectFToSkRect(new_bounds);
}
} // namespace gfx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, removed patch!

} \
\
protected: \
DownloadDisplayController* display_controller() const { \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the return type should be const DownloadDisplayController* based on https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/const.md - The returned member could be changed so this getter doesn't seem to be logically const.


But changing return type like so would make us use const_cast<>, so I think we can remove this getter here and just use const_cast<> from the callsite.

@simonhong simonhong force-pushed the update_download_button_style branch from f1b137d to 9ba33a2 Compare March 28, 2023 08:32
@simonhong simonhong merged commit 44553a8 into master Mar 28, 2023
@simonhong simonhong deleted the update_download_button_style branch March 28, 2023 12:03
@github-actions github-actions bot added this to the 1.51.x - Nightly milestone Mar 28, 2023
simonhong added a commit that referenced this pull request Mar 29, 2023
@kjozwiak
Copy link
Member

Verification PASSED on Win 11 x64 using the following build(s):

Brave | 1.52.2 Chromium: 112.0.5615.39 (Official Build) nightly (64-bit)
-- | --
Revision | a0e7b9718a92bcd1cf33b7c95316caff3fc20714-refs/branch-heads/5615@{#753}
OS | Windows 11 Version 22H2 (Build 22621.1413)

Using the examples mentioned via #17769 (comment) & brave/brave-browser#29324 (comment), verified the following:

Light Theme

defaultLight
downloadingLight
downloadProgressPanelLight
completedLight
completedIconLight

DarkTheme

defaultDark
image
downloadProgressPanelDark
completedDark
completedIconDark

kjozwiak pushed a commit that referenced this pull request Mar 29, 2023
Merge pull request #17769 from brave/update_download_button_style

Updated toolbar download button style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update toolbar's download button style
4 participants