| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 262 } |
| 263 View::OnPaint(canvas); | 263 View::OnPaint(canvas); |
| 264 OnPaintFocus(canvas); | 264 OnPaintFocus(canvas); |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool Slider::OnMousePressed(const ui::MouseEvent& event) { | 267 bool Slider::OnMousePressed(const ui::MouseEvent& event) { |
| 268 if (!event.IsOnlyLeftMouseButton()) | 268 if (!event.IsOnlyLeftMouseButton()) |
| 269 return false; | 269 return false; |
| 270 if (listener_) | 270 if (listener_) |
| 271 listener_->SliderDragStarted(this); | 271 listener_->SliderDragStarted(this); |
| 272 PrepareForMove(event.location()); | 272 PrepareForMove(gfx::ToFlooredPoint(event.location())); |
| 273 MoveButtonTo(event.location()); | 273 MoveButtonTo(gfx::ToFlooredPoint(event.location())); |
| 274 return true; | 274 return true; |
| 275 } | 275 } |
| 276 | 276 |
| 277 bool Slider::OnMouseDragged(const ui::MouseEvent& event) { | 277 bool Slider::OnMouseDragged(const ui::MouseEvent& event) { |
| 278 MoveButtonTo(event.location()); | 278 MoveButtonTo(gfx::ToFlooredPoint(event.location())); |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 | 281 |
| 282 void Slider::OnMouseReleased(const ui::MouseEvent& event) { | 282 void Slider::OnMouseReleased(const ui::MouseEvent& event) { |
| 283 if (listener_) | 283 if (listener_) |
| 284 listener_->SliderDragEnded(this); | 284 listener_->SliderDragEnded(this); |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool Slider::OnKeyPressed(const ui::KeyEvent& event) { | 287 bool Slider::OnKeyPressed(const ui::KeyEvent& event) { |
| 288 if (orientation_ == HORIZONTAL) { | 288 if (orientation_ == HORIZONTAL) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 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 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 319 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 320 event->type() == ui::ET_GESTURE_TAP_DOWN) { | 320 event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 321 PrepareForMove(event->location()); | 321 PrepareForMove(gfx::ToFlooredPoint(event->location())); |
| 322 MoveButtonTo(event->location()); | 322 MoveButtonTo(gfx::ToFlooredPoint(event->location())); |
| 323 event->SetHandled(); | 323 event->SetHandled(); |
| 324 } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 324 } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 325 event->type() == ui::ET_GESTURE_SCROLL_END) { | 325 event->type() == ui::ET_GESTURE_SCROLL_END) { |
| 326 MoveButtonTo(event->location()); | 326 MoveButtonTo(gfx::ToFlooredPoint(event->location())); |
| 327 event->SetHandled(); | 327 event->SetHandled(); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 void Slider::AnimationProgressed(const gfx::Animation* animation) { | 331 void Slider::AnimationProgressed(const gfx::Animation* animation) { |
| 332 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); | 332 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); |
| 333 SchedulePaint(); | 333 SchedulePaint(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void Slider::GetAccessibleState(ui::AXViewState* state) { | 336 void Slider::GetAccessibleState(ui::AXViewState* state) { |
| 337 state->role = ui::AX_ROLE_SLIDER; | 337 state->role = ui::AX_ROLE_SLIDER; |
| 338 state->name = accessible_name_; | 338 state->name = accessible_name_; |
| 339 state->value = base::UTF8ToUTF16( | 339 state->value = base::UTF8ToUTF16( |
| 340 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); | 340 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); |
| 341 } | 341 } |
| 342 | 342 |
| 343 } // namespace views | 343 } // namespace views |
| OLD | NEW |