| 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.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 SetValueInternal(value_ - keyboard_increment_, VALUE_CHANGED_BY_USER); | 284 SetValueInternal(value_ - keyboard_increment_, VALUE_CHANGED_BY_USER); |
| 285 return true; | 285 return true; |
| 286 } else if (event.key_code() == ui::VKEY_UP) { | 286 } else if (event.key_code() == ui::VKEY_UP) { |
| 287 SetValueInternal(value_ + keyboard_increment_, VALUE_CHANGED_BY_USER); | 287 SetValueInternal(value_ + keyboard_increment_, VALUE_CHANGED_BY_USER); |
| 288 return true; | 288 return true; |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 return false; | 291 return false; |
| 292 } | 292 } |
| 293 | 293 |
| 294 ui::EventResult Slider::OnGestureEvent(ui::GestureEvent* event) { | 294 void Slider::OnGestureEvent(ui::GestureEvent* event) { |
| 295 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 295 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 296 event->type() == ui::ET_GESTURE_TAP_DOWN) { | 296 event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 297 PrepareForMove(event->location()); | 297 PrepareForMove(event->location()); |
| 298 MoveButtonTo(event->location()); | 298 MoveButtonTo(event->location()); |
| 299 return ui::ER_CONSUMED; | 299 event->SetHandled(); |
| 300 } else | 300 } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 301 if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 301 event->type() == ui::ET_GESTURE_SCROLL_END) { |
| 302 event->type() == ui::ET_GESTURE_SCROLL_END) { | |
| 303 MoveButtonTo(event->location()); | 302 MoveButtonTo(event->location()); |
| 304 return ui::ER_CONSUMED; | 303 event->SetHandled(); |
| 305 } | 304 } |
| 306 return ui::ER_UNHANDLED; | |
| 307 } | 305 } |
| 308 | 306 |
| 309 void Slider::AnimationProgressed(const ui::Animation* animation) { | 307 void Slider::AnimationProgressed(const ui::Animation* animation) { |
| 310 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); | 308 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); |
| 311 SchedulePaint(); | 309 SchedulePaint(); |
| 312 } | 310 } |
| 313 | 311 |
| 314 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { | 312 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { |
| 315 state->role = ui::AccessibilityTypes::ROLE_SLIDER; | 313 state->role = ui::AccessibilityTypes::ROLE_SLIDER; |
| 316 state->name = accessible_name_; | 314 state->name = accessible_name_; |
| 317 state->value = UTF8ToUTF16( | 315 state->value = UTF8ToUTF16( |
| 318 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); | 316 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); |
| 319 } | 317 } |
| 320 | 318 |
| 321 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { | 319 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { |
| 322 if (!focus_border_color_) { | 320 if (!focus_border_color_) { |
| 323 View::OnPaintFocusBorder(canvas); | 321 View::OnPaintFocusBorder(canvas); |
| 324 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { | 322 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { |
| 325 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), | 323 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), |
| 326 focus_border_color_); | 324 focus_border_color_); |
| 327 } | 325 } |
| 328 } | 326 } |
| 329 | 327 |
| 330 } // namespace views | 328 } // namespace views |
| OLD | NEW |