| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "third_party/skia/include/core/SkPaint.h" | 15 #include "third_party/skia/include/core/SkPaint.h" |
| 16 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_node_data.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 19 #include "ui/gfx/animation/slide_animation.h" | 19 #include "ui/gfx/animation/slide_animation.h" |
| 20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/geometry/point.h" | 21 #include "ui/gfx/geometry/point.h" |
| 22 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 23 #include "ui/resources/grit/ui_resources.h" | 23 #include "ui/resources/grit/ui_resources.h" |
| 24 #include "ui/views/controls/md_slider.h" | 24 #include "ui/views/controls/md_slider.h" |
| 25 #include "ui/views/controls/non_md_slider.h" | 25 #include "ui/views/controls/non_md_slider.h" |
| 26 #include "ui/views/resources/grit/views_resources.h" | 26 #include "ui/views/resources/grit/views_resources.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (event.key_code() == ui::VKEY_LEFT) | 222 if (event.key_code() == ui::VKEY_LEFT) |
| 223 new_value -= keyboard_increment_; | 223 new_value -= keyboard_increment_; |
| 224 else if (event.key_code() == ui::VKEY_RIGHT) | 224 else if (event.key_code() == ui::VKEY_RIGHT) |
| 225 new_value += keyboard_increment_; | 225 new_value += keyboard_increment_; |
| 226 else | 226 else |
| 227 return false; | 227 return false; |
| 228 SetValueInternal(new_value, VALUE_CHANGED_BY_USER); | 228 SetValueInternal(new_value, VALUE_CHANGED_BY_USER); |
| 229 return true; | 229 return true; |
| 230 } | 230 } |
| 231 | 231 |
| 232 void Slider::GetAccessibleState(ui::AXViewState* state) { | 232 void Slider::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 233 state->role = ui::AX_ROLE_SLIDER; | 233 node_data->role = ui::AX_ROLE_SLIDER; |
| 234 state->name = accessible_name_; | 234 node_data->SetName(accessible_name_); |
| 235 state->value = base::UTF8ToUTF16( | 235 node_data->SetValue(base::UTF8ToUTF16( |
| 236 base::StringPrintf("%d%%", static_cast<int>(value_ * 100 + 0.5))); | 236 base::StringPrintf("%d%%", static_cast<int>(value_ * 100 + 0.5)))); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void Slider::OnFocus() { | 239 void Slider::OnFocus() { |
| 240 View::OnFocus(); | 240 View::OnFocus(); |
| 241 SchedulePaint(); | 241 SchedulePaint(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void Slider::OnBlur() { | 244 void Slider::OnBlur() { |
| 245 View::OnBlur(); | 245 View::OnBlur(); |
| 246 SchedulePaint(); | 246 SchedulePaint(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 264 event->SetHandled(); | 264 event->SetHandled(); |
| 265 if (event->details().touch_points() <= 1) | 265 if (event->details().touch_points() <= 1) |
| 266 OnSliderDragEnded(); | 266 OnSliderDragEnded(); |
| 267 break; | 267 break; |
| 268 default: | 268 default: |
| 269 break; | 269 break; |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace views | 273 } // namespace views |
| OLD | NEW |