Index: ash/autoclick/autoclick_controller.cc |
diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc |
index 058d2f5609da64795ccdc600d99426a15147c65f..558be95e93a05aa47c9ab4e7f3f1a9d0f5dc4195 100644 |
--- a/ash/autoclick/autoclick_controller.cc |
+++ b/ash/autoclick/autoclick_controller.cc |
@@ -49,6 +49,10 @@ class AutoclickControllerImpl : public AutoclickController, |
AutoclickControllerImpl(); |
~AutoclickControllerImpl() override; |
+ // AutoclickController overrides. |
+ void SetAutoclickgestureDelegate(std::unique_ptr<AutoclickgestureDelegate> |
jdufault
2016/06/03 22:02:44
This doesn't look like normal formatting. Did you
sammiequon
2016/06/07 18:06:16
Done.
|
+ autoclickgesture_delegate) override; |
+ |
private: |
// AutoclickController overrides: |
void SetEnabled(bool enabled) override; |
@@ -63,6 +67,10 @@ class AutoclickControllerImpl : public AutoclickController, |
void OnGestureEvent(ui::GestureEvent* event) override; |
void OnScrollEvent(ui::ScrollEvent* event) override; |
+ void StartRingDisplay(); |
+ void StopRingDisplay(); |
+ void ChangeRingDisplayCenter(); |
+ |
void InitClickTimer(); |
void DoAutoclick(); |
@@ -71,6 +79,7 @@ class AutoclickControllerImpl : public AutoclickController, |
int delay_ms_; |
int mouse_event_flags_; |
std::unique_ptr<base::Timer> autoclick_timer_; |
+ std::unique_ptr<AutoclickgestureDelegate> autoclick_gesture_delegate_; |
// The position in screen coordinates used to determine |
// the distance the mouse has moved. |
gfx::Point anchor_location_; |
@@ -78,11 +87,11 @@ class AutoclickControllerImpl : public AutoclickController, |
DISALLOW_COPY_AND_ASSIGN(AutoclickControllerImpl); |
}; |
- |
AutoclickControllerImpl::AutoclickControllerImpl() |
: enabled_(false), |
delay_ms_(kDefaultAutoclickDelayMs), |
mouse_event_flags_(ui::EF_NONE), |
+ autoclick_gesture_delegate_(nullptr), |
anchor_location_(-kMovementThreshold, -kMovementThreshold) { |
InitClickTimer(); |
} |
@@ -90,6 +99,11 @@ AutoclickControllerImpl::AutoclickControllerImpl() |
AutoclickControllerImpl::~AutoclickControllerImpl() { |
} |
+void AutoclickControllerImpl::SetAutoclickgestureDelegate( |
+ std::unique_ptr<AutoclickgestureDelegate> autoclickgesture_delegate) { |
+ autoclick_gesture_delegate_ = std::move(autoclickgesture_delegate); |
+} |
+ |
void AutoclickControllerImpl::SetEnabled(bool enabled) { |
if (enabled_ == enabled) |
return; |
@@ -116,6 +130,24 @@ int AutoclickControllerImpl::GetAutoclickDelay() const { |
return delay_ms_; |
} |
+void AutoclickControllerImpl::StartRingDisplay() { |
+ if (nullptr != autoclick_gesture_delegate_) { |
jdufault
2016/06/03 22:02:44
Yoda-style conditions are unusual in the Chrome co
sammiequon
2016/06/07 18:06:16
Done.
|
+ autoclick_gesture_delegate_->StartGesture(delay_ms_, anchor_location_); |
+ } |
+} |
+ |
+void AutoclickControllerImpl::StopRingDisplay() { |
+ if (nullptr != autoclick_gesture_delegate_) { |
+ autoclick_gesture_delegate_->StopGesture(); |
+ } |
+} |
+ |
+void AutoclickControllerImpl::ChangeRingDisplayCenter() { |
+ if (nullptr != autoclick_gesture_delegate_) { |
+ autoclick_gesture_delegate_->SetGestureCenter(anchor_location_); |
+ } |
+} |
+ |
void AutoclickControllerImpl::InitClickTimer() { |
autoclick_timer_.reset(new base::Timer( |
FROM_HERE, |
@@ -144,12 +176,18 @@ void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) { |
if (delta.LengthSquared() >= kMovementThreshold * kMovementThreshold) { |
anchor_location_ = mouse_location; |
autoclick_timer_->Reset(); |
+ StartRingDisplay(); |
+ } else if (autoclick_timer_->IsRunning()) { |
+ anchor_location_ = mouse_location; |
+ ChangeRingDisplayCenter(); |
} |
} else if (event->type() == ui::ET_MOUSE_PRESSED) { |
autoclick_timer_->Stop(); |
+ StopRingDisplay(); |
} else if (event->type() == ui::ET_MOUSEWHEEL && |
autoclick_timer_->IsRunning()) { |
autoclick_timer_->Reset(); |
+ StartRingDisplay(); |
} |
} |
@@ -160,20 +198,25 @@ void AutoclickControllerImpl::OnKeyEvent(ui::KeyEvent* event) { |
int new_modifiers = event->flags() & modifier_mask; |
mouse_event_flags_ = (mouse_event_flags_ & ~modifier_mask) | new_modifiers; |
- if (!IsModifierKey(event->key_code())) |
+ if (!IsModifierKey(event->key_code())) { |
autoclick_timer_->Stop(); |
+ StopRingDisplay(); |
+ } |
} |
void AutoclickControllerImpl::OnTouchEvent(ui::TouchEvent* event) { |
autoclick_timer_->Stop(); |
+ StopRingDisplay(); |
} |
void AutoclickControllerImpl::OnGestureEvent(ui::GestureEvent* event) { |
autoclick_timer_->Stop(); |
+ StopRingDisplay(); |
} |
void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { |
autoclick_timer_->Stop(); |
+ StopRingDisplay(); |
} |
void AutoclickControllerImpl::DoAutoclick() { |