Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/slider.h" | 5 #include "ui/views/controls/slider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 SchedulePaint(); | 310 SchedulePaint(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void Slider::OnBlur() { | 313 void Slider::OnBlur() { |
| 314 View::OnBlur(); | 314 View::OnBlur(); |
| 315 SchedulePaint(); | 315 SchedulePaint(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void Slider::OnGestureEvent(ui::GestureEvent* event) { | 318 void Slider::OnGestureEvent(ui::GestureEvent* event) { |
| 319 switch (event->type()) { | 319 switch (event->type()) { |
| 320 // In a multi point gesture only the touch point will generate | 320 // In a multi point gesture only the (first?) touch point will generate |
|
sadrul
2014/07/24 19:12:13
yes. Looks like someone accidentally the word.
| |
| 321 // an ET_GESTURE_TAP_DOWN event. | 321 // an ET_GESTURE_TAP_DOWN event. |
| 322 case ui::ET_GESTURE_TAP_DOWN: | 322 case ui::ET_GESTURE_TAP_DOWN: |
| 323 OnSliderDragStarted(); | 323 OnSliderDragStarted(); |
| 324 PrepareForMove(event->location()); | 324 PrepareForMove(event->location()); |
| 325 // Intentional fall through to next case. | 325 // Intentional fall through to next case. |
| 326 case ui::ET_GESTURE_SCROLL_BEGIN: | 326 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 327 case ui::ET_GESTURE_SCROLL_UPDATE: | 327 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 328 MoveButtonTo(event->location()); | 328 MoveButtonTo(event->location()); |
| 329 event->SetHandled(); | 329 event->SetHandled(); |
| 330 break; | 330 break; |
| 331 case ui::ET_GESTURE_END: | 331 case ui::ET_GESTURE_SCROLL_END: |
| 332 case ui::ET_SCROLL_FLING_START: | |
| 333 case ui::ET_GESTURE_TAP: | |
| 332 MoveButtonTo(event->location()); | 334 MoveButtonTo(event->location()); |
| 333 event->SetHandled(); | 335 event->SetHandled(); |
| 334 if (event->details().touch_points() <= 1) | 336 if (event->details().touch_points() <= 1) |
| 335 OnSliderDragEnded(); | 337 OnSliderDragEnded(); |
| 336 break; | 338 break; |
| 339 case ui::ET_GESTURE_TWO_FINGER_TAP: | |
| 340 MoveButtonTo(event->location()); | |
| 341 event->SetHandled(); | |
| 342 OnSliderDragEnded(); | |
| 343 break; | |
|
sadrul
2014/07/24 19:12:13
Is this necessary?
| |
| 337 default: | 344 default: |
| 338 break; | 345 break; |
| 339 } | 346 } |
| 340 } | 347 } |
| 341 | 348 |
| 342 void Slider::AnimationProgressed(const gfx::Animation* animation) { | 349 void Slider::AnimationProgressed(const gfx::Animation* animation) { |
| 343 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); | 350 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); |
| 344 SchedulePaint(); | 351 SchedulePaint(); |
| 345 } | 352 } |
| 346 | 353 |
| 347 void Slider::GetAccessibleState(ui::AXViewState* state) { | 354 void Slider::GetAccessibleState(ui::AXViewState* state) { |
| 348 state->role = ui::AX_ROLE_SLIDER; | 355 state->role = ui::AX_ROLE_SLIDER; |
| 349 state->name = accessible_name_; | 356 state->name = accessible_name_; |
| 350 state->value = base::UTF8ToUTF16( | 357 state->value = base::UTF8ToUTF16( |
| 351 base::StringPrintf("%d%%", static_cast<int>(value_ * 100 + 0.5))); | 358 base::StringPrintf("%d%%", static_cast<int>(value_ * 100 + 0.5))); |
| 352 } | 359 } |
| 353 | 360 |
| 354 void Slider::OnSliderDragStarted() { | 361 void Slider::OnSliderDragStarted() { |
| 355 if (listener_) | 362 if (listener_) |
| 356 listener_->SliderDragStarted(this); | 363 listener_->SliderDragStarted(this); |
| 357 } | 364 } |
| 358 | 365 |
| 359 void Slider::OnSliderDragEnded() { | 366 void Slider::OnSliderDragEnded() { |
| 360 if (listener_) | 367 if (listener_) |
| 361 listener_->SliderDragEnded(this); | 368 listener_->SliderDragEnded(this); |
| 362 } | 369 } |
| 363 | 370 |
| 364 } // namespace views | 371 } // namespace views |
| OLD | NEW |