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

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: local variable to avoid static_cast 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..dee59919b5509bae52b7878fd3dfc9366bf5c6cb 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
@@ -138,8 +134,11 @@ SpeechView::SpeechView(AppListViewDelegate* delegate)
indicator_->SetVisible(false);
container->AddChildView(indicator_);
- mic_button_ = new MicButton(this);
+ MicButton* mic_button = new MicButton(this);
+ mic_button_ = mic_button;
container->AddChildView(mic_button_);
+ mic_button_->SetEventTargeter(
+ scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(mic_button)));
// 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