Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: ui/app_list/views/speech_view.cc

Issue 365753002: MicButton should implement MaskedTargeterDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9b92e7e158a621f6fa6d358f34f14a35cddeae52..11b7dcd46721f9d5c56083a758300ceffa05fcbc 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_targeter_delegate.h"
#include "ui/views/shadow_border.h"
namespace app_list {
@@ -69,17 +70,16 @@ void SoundLevelIndicator::OnPaint(gfx::Canvas* canvas) {
canvas->DrawCircle(bounds().CenterPoint(), width() / 2, paint);
}
-// MicButton is an image button with circular hit area.
-class MicButton : public views::ImageButton {
+// MicButton is an image button with a circular hit test mask.
+class MicButton : public views::ImageButton,
+ public views::MaskedTargeterDelegate {
public:
explicit MicButton(views::ButtonListener* listener);
virtual ~MicButton();
private:
- // Overridden from views::View:
- virtual bool HasHitTestMask() const OVERRIDE;
- virtual void GetHitTestMaskDeprecated(views::View::HitTestSource source,
- gfx::Path* mask) const OVERRIDE;
+ // views::MaskedTargeterDelegate:
+ virtual bool GetHitTestMask(gfx::Path* mask) const OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(MicButton);
};
@@ -89,15 +89,10 @@ MicButton::MicButton(views::ButtonListener* listener)
MicButton::~MicButton() {}
-bool MicButton::HasHitTestMask() const {
- return true;
-}
-
-void MicButton::GetHitTestMaskDeprecated(views::View::HitTestSource source,
- gfx::Path* mask) const {
+bool MicButton::GetHitTestMask(gfx::Path* mask) const {
DCHECK(mask);
- // The mic button icon is a circle. |source| doesn't matter.
+ // The mic button icon is a circle.
gfx::Rect local_bounds = GetLocalBounds();
int radius = local_bounds.width() / 2 + kIndicatorRadiusMinOffset;
gfx::Point center = local_bounds.CenterPoint();
@@ -105,6 +100,7 @@ void MicButton::GetHitTestMaskDeprecated(views::View::HitTestSource source,
mask->addCircle(SkIntToScalar(center.x()),
SkIntToScalar(center.y()),
SkIntToScalar(radius));
+ return true;
}
} // namespace
@@ -140,6 +136,8 @@ SpeechView::SpeechView(AppListViewDelegate* delegate)
mic_button_ = new MicButton(this);
container->AddChildView(mic_button_);
+ mic_button_->SetEventTargeter(scoped_ptr<views::ViewTargeter>(
+ new views::ViewTargeter(static_cast<MicButton*>(mic_button_))));
sky 2014/07/10 15:46:00 I'm not a fan of the static_cast here. Could you c
tdanderson 2014/07/10 16:53:45 Done.
// TODO(mukai): use BoundedLabel to cap 2 lines.
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698