Chromium Code Reviews| Index: ash/autoclick/autoclick_controller.cc |
| diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc |
| index 4692f759f8d26aa828817a318b71df091f649032..6163ff4bf933add7093c33fb08b91744e262eb63 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. |
|
jdufault
2016/06/08 17:50:19
Move this into the other AutoclickController overr
sammiequon
2016/06/09 04:03:46
Done.
|
| + void SetDelegate( |
| + std::unique_ptr<Delegate> autoclickgesture_delegate) override; |
|
jdufault
2016/06/08 17:50:19
Just delegate
sammiequon
2016/06/09 04:03:46
Done.
|
| + |
| 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<Delegate> autoclick_gesture_delegate_; |
|
jdufault
2016/06/08 17:50:19
Just delegate_
sammiequon
2016/06/09 04:03:46
Done.
|
| // 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() |
|
jdufault
2016/06/08 17:50:19
Restore newline
sammiequon
2016/06/09 04:03:46
Done.
|
| : 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::SetDelegate( |
| + std::unique_ptr<Delegate> autoclickgesture_delegate) { |
| + autoclick_gesture_delegate_ = std::move(autoclickgesture_delegate); |
| +} |
| + |
| void AutoclickControllerImpl::SetEnabled(bool enabled) { |
| if (enabled_ == enabled) |
| return; |
| @@ -116,6 +130,21 @@ int AutoclickControllerImpl::GetAutoclickDelay() const { |
| return delay_ms_; |
| } |
| +void AutoclickControllerImpl::StartRingDisplay() { |
| + if (autoclick_gesture_delegate_) |
| + autoclick_gesture_delegate_->StartGesture(delay_ms_, anchor_location_); |
| +} |
| + |
| +void AutoclickControllerImpl::StopRingDisplay() { |
| + if (autoclick_gesture_delegate_) |
| + autoclick_gesture_delegate_->StopGesture(); |
| +} |
| + |
| +void AutoclickControllerImpl::ChangeRingDisplayCenter() { |
| + if (autoclick_gesture_delegate_) |
| + autoclick_gesture_delegate_->SetGestureCenter(anchor_location_); |
| +} |
| + |
| void AutoclickControllerImpl::InitClickTimer() { |
| autoclick_timer_.reset(new base::Timer( |
| FROM_HERE, |
| @@ -144,12 +173,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 +195,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() { |