| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 SetValueInternal(value_ - keyboard_increment_, VALUE_CHANGED_BY_USER); | 254 SetValueInternal(value_ - keyboard_increment_, VALUE_CHANGED_BY_USER); |
| 255 return true; | 255 return true; |
| 256 } else if (event.key_code() == ui::VKEY_UP) { | 256 } else if (event.key_code() == ui::VKEY_UP) { |
| 257 SetValueInternal(value_ + keyboard_increment_, VALUE_CHANGED_BY_USER); | 257 SetValueInternal(value_ + keyboard_increment_, VALUE_CHANGED_BY_USER); |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 | 263 |
| 264 ui::GestureStatus Slider::OnGestureEvent(const ui::GestureEvent& event) { | 264 ui::EventResult Slider::OnGestureEvent(const ui::GestureEvent& event) { |
| 265 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE || | 265 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 266 event.type() == ui::ET_GESTURE_SCROLL_BEGIN || | 266 event.type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 267 event.type() == ui::ET_GESTURE_SCROLL_END || | 267 event.type() == ui::ET_GESTURE_SCROLL_END || |
| 268 event.type() == ui::ET_GESTURE_TAP_DOWN) { | 268 event.type() == ui::ET_GESTURE_TAP_DOWN) { |
| 269 MoveButtonTo(event.location()); | 269 MoveButtonTo(event.location()); |
| 270 return ui::GESTURE_STATUS_CONSUMED; | 270 return ui::ER_CONSUMED; |
| 271 } | 271 } |
| 272 return ui::GESTURE_STATUS_UNKNOWN; | 272 return ui::ER_UNHANDLED; |
| 273 } | 273 } |
| 274 | 274 |
| 275 void Slider::AnimationProgressed(const ui::Animation* animation) { | 275 void Slider::AnimationProgressed(const ui::Animation* animation) { |
| 276 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); | 276 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); |
| 277 SchedulePaint(); | 277 SchedulePaint(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { | 280 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { |
| 281 state->role = ui::AccessibilityTypes::ROLE_SLIDER; | 281 state->role = ui::AccessibilityTypes::ROLE_SLIDER; |
| 282 state->name = accessible_name_; | 282 state->name = accessible_name_; |
| 283 state->value = UTF8ToUTF16( | 283 state->value = UTF8ToUTF16( |
| 284 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); | 284 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { | 287 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { |
| 288 if (!focus_border_color_) { | 288 if (!focus_border_color_) { |
| 289 View::OnPaintFocusBorder(canvas); | 289 View::OnPaintFocusBorder(canvas); |
| 290 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { | 290 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { |
| 291 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), | 291 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), |
| 292 focus_border_color_); | 292 focus_border_color_); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace views | 296 } // namespace views |
| OLD | NEW |