| Index: ui/app_list/views/speech_view.cc
|
| diff --git a/ui/app_list/views/speech_view.cc b/ui/app_list/views/speech_view.cc
|
| index ba2e690e2f06d816e31429393ddd9a56787a83fa..ddeb5061441989d763e8699c9551ee35a2d2e717 100644
|
| --- a/ui/app_list/views/speech_view.cc
|
| +++ b/ui/app_list/views/speech_view.cc
|
| @@ -21,6 +21,7 @@
|
| #include "ui/views/controls/image_view.h"
|
| #include "ui/views/controls/label.h"
|
| #include "ui/views/layout/fill_layout.h"
|
| +#include "ui/views/masked_view_targeter.h"
|
| #include "ui/views/shadow_border.h"
|
|
|
| namespace app_list {
|
| @@ -95,18 +96,43 @@ bool MicButton::HasHitTestMask() const {
|
| return true;
|
| }
|
|
|
| +// TODO(tdanderson): Move the implementation into views::View::HitTestRect()
|
| +// and delete this function. See crbug.com/377527.
|
| void MicButton::GetHitTestMask(views::View::HitTestSource source,
|
| gfx::Path* mask) const {
|
| - // The mic button icon is a circle. |source| doesn't matter.
|
| - gfx::Rect local_bounds = GetLocalBounds();
|
| - int radius = local_bounds.width() / 2 + kIndicatorRadiusMinOffset;
|
| - gfx::Point center = local_bounds.CenterPoint();
|
| - center.set_y(center.y() + kIndicatorCenterOffsetY);
|
| - mask->addCircle(SkIntToScalar(center.x()),
|
| - SkIntToScalar(center.y()),
|
| - SkIntToScalar(radius));
|
| + ui::EventTargeter* targeter = GetEventTargeter();
|
| + CHECK(targeter);
|
| +
|
| + MicButton* b = const_cast<MicButton*>(this);
|
| + static_cast<views::MaskedViewTargeter*>(targeter)->GetHitTestMask(b, mask);
|
| }
|
|
|
| +// Used to define the circular hit test region of a MicButton for the
|
| +// purposes of event targeting.
|
| +class MicButtonTargeter : public views::MaskedViewTargeter {
|
| + public:
|
| + explicit MicButtonTargeter(views::View* mic_button)
|
| + : views::MaskedViewTargeter(mic_button) {
|
| + }
|
| + virtual ~MicButtonTargeter() {}
|
| +
|
| + private:
|
| + virtual bool GetHitTestMask(views::View* view,
|
| + gfx::Path* mask) const OVERRIDE {
|
| + // The mic button icon is a circle.
|
| + gfx::Rect local_bounds = view->GetLocalBounds();
|
| + int radius = local_bounds.width() / 2 + kIndicatorRadiusMinOffset;
|
| + gfx::Point center = local_bounds.CenterPoint();
|
| + center.set_y(center.y() + kIndicatorCenterOffsetY);
|
| + mask->addCircle(SkIntToScalar(center.x()),
|
| + SkIntToScalar(center.y()),
|
| + SkIntToScalar(radius));
|
| + return true;
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MicButtonTargeter);
|
| +};
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -140,6 +166,8 @@ SpeechView::SpeechView(AppListViewDelegate* delegate)
|
|
|
| mic_button_ = new MicButton(this);
|
| container->AddChildView(mic_button_);
|
| + mic_button_->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
|
| + new MicButtonTargeter(mic_button_)));
|
|
|
| // TODO(mukai): use BoundedLabel to cap 2 lines.
|
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
|
|