| 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 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace views { | 25 namespace views { |
| 26 | 26 |
| 27 Slider::Slider(SliderListener* listener, Orientation orientation) | 27 Slider::Slider(SliderListener* listener, Orientation orientation) |
| 28 : listener_(listener), | 28 : listener_(listener), |
| 29 orientation_(orientation), | 29 orientation_(orientation), |
| 30 value_(0.f), | 30 value_(0.f), |
| 31 keyboard_increment_(0.1f), | 31 keyboard_increment_(0.1f), |
| 32 animating_value_(0.f), | 32 animating_value_(0.f), |
| 33 value_is_valid_(false) { | 33 value_is_valid_(false), |
| 34 focus_color_(0) { |
| 34 EnableCanvasFlippingForRTLUI(true); | 35 EnableCanvasFlippingForRTLUI(true); |
| 35 set_focusable(true); | 36 set_focusable(true); |
| 36 } | 37 } |
| 37 | 38 |
| 38 Slider::~Slider() { | 39 Slider::~Slider() { |
| 39 } | 40 } |
| 40 | 41 |
| 41 void Slider::SetValue(float value) { | 42 void Slider::SetValue(float value) { |
| 42 SetValueInternal(value, VALUE_CHANGED_BY_API); | 43 SetValueInternal(value, VALUE_CHANGED_BY_API); |
| 43 } | 44 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 SchedulePaint(); | 194 SchedulePaint(); |
| 194 } | 195 } |
| 195 | 196 |
| 196 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { | 197 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { |
| 197 state->role = ui::AccessibilityTypes::ROLE_SLIDER; | 198 state->role = ui::AccessibilityTypes::ROLE_SLIDER; |
| 198 state->name = accessible_name_; | 199 state->name = accessible_name_; |
| 199 state->value = UTF8ToUTF16( | 200 state->value = UTF8ToUTF16( |
| 200 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); | 201 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); |
| 201 } | 202 } |
| 202 | 203 |
| 204 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { |
| 205 if (!focus_color_) { |
| 206 View::OnPaintFocusBorder(canvas); |
| 207 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { |
| 208 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), |
| 209 focus_color_); |
| 210 } |
| 211 } |
| 212 |
| 203 } // namespace views | 213 } // namespace views |
| OLD | NEW |