Commit 3d4e47d8 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Use highlight-path generators in CustomShapeButton

Replaces kHighlightPathKey setting for CustomShapeButton child classes.

Bug: chromium:1007546
Change-Id: I5374a57ac2f6ae4963487a34aabca8a7a0613978
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848476
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704292}
parent 71f0e510
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "ui/views/animation/ink_drop_mask.h" #include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/masked_targeter_delegate.h" #include "ui/views/masked_targeter_delegate.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
namespace ash { namespace ash {
...@@ -156,10 +155,6 @@ class AutoclickScrollButton : public CustomShapeButton, ...@@ -156,10 +155,6 @@ class AutoclickScrollButton : public CustomShapeButton,
} }
SetPreferredSize(size_); SetPreferredSize(size_);
auto path = std::make_unique<SkPath>(
CreateCustomShapePath(gfx::Rect(GetPreferredSize())));
SetProperty(views::kHighlightPathKey, path.release());
set_clip_path(CreateCustomShapePath(gfx::Rect(GetPreferredSize()))); set_clip_path(CreateCustomShapePath(gfx::Rect(GetPreferredSize())));
SetEventTargeter(std::make_unique<views::ViewTargeter>(this)); SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/separator.h" #include "ui/views/controls/separator.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/view_class_properties.h"
namespace ash { namespace ash {
...@@ -77,10 +76,6 @@ class BackButton : public CustomShapeButton { ...@@ -77,10 +76,6 @@ class BackButton : public CustomShapeButton {
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU));
SetBorder(views::CreateEmptyBorder( SetBorder(views::CreateEmptyBorder(
gfx::Insets((kTrayItemSize - image.width()) / 2))); gfx::Insets((kTrayItemSize - image.width()) / 2)));
auto path = std::make_unique<SkPath>(
CreateCustomShapePath(gfx::Rect(CalculatePreferredSize())));
SetProperty(views::kHighlightPathKey, path.release());
} }
~BackButton() override = default; ~BackButton() override = default;
......
...@@ -11,16 +11,12 @@ ...@@ -11,16 +11,12 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/scoped_canvas.h" #include "ui/gfx/scoped_canvas.h"
#include "ui/views/view_class_properties.h"
namespace ash { namespace ash {
CollapseButton::CollapseButton(views::ButtonListener* listener) CollapseButton::CollapseButton(views::ButtonListener* listener)
: CustomShapeButton(listener) { : CustomShapeButton(listener) {
OnEnabledChanged(); OnEnabledChanged();
auto path = std::make_unique<SkPath>(
CreateCustomShapePath(gfx::Rect(CalculatePreferredSize())));
SetProperty(views::kHighlightPathKey, path.release());
} }
CollapseButton::~CollapseButton() = default; CollapseButton::~CollapseButton() = default;
......
...@@ -16,12 +16,31 @@ ...@@ -16,12 +16,31 @@
#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/animation/ink_drop_mask.h" #include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/highlight_path_generator.h"
namespace {
class CustomShapeButtonHighlightPathGenerator
: public views::HighlightPathGenerator {
public:
CustomShapeButtonHighlightPathGenerator() = default;
SkPath GetHighlightPath(const views::View* view) override {
return static_cast<const ash::CustomShapeButton*>(view)
->CreateCustomShapePath(view->GetLocalBounds());
}
private:
DISALLOW_COPY_AND_ASSIGN(CustomShapeButtonHighlightPathGenerator);
};
} // namespace
namespace ash { namespace ash {
CustomShapeButton::CustomShapeButton(views::ButtonListener* listener) CustomShapeButton::CustomShapeButton(views::ButtonListener* listener)
: ImageButton(listener) { : ImageButton(listener) {
TrayPopupUtils::ConfigureTrayPopupButton(this); TrayPopupUtils::ConfigureTrayPopupButton(this);
views::HighlightPathGenerator::Install(
this, std::make_unique<CustomShapeButtonHighlightPathGenerator>());
} }
CustomShapeButton::~CustomShapeButton() = default; CustomShapeButton::~CustomShapeButton() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment