| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 if (!focus_border_color_) { | 178 if (!focus_border_color_) { |
| 179 canvas->DrawFocusRect(GetLocalBounds()); | 179 canvas->DrawFocusRect(GetLocalBounds()); |
| 180 } else if (HasFocus()) { | 180 } else if (HasFocus()) { |
| 181 canvas->DrawSolidFocusRect( | 181 canvas->DrawSolidFocusRect( |
| 182 gfx::Rect(1, 1, width() - 3, height() - 3), | 182 gfx::Rect(1, 1, width() - 3, height() - 3), |
| 183 focus_border_color_); | 183 focus_border_color_); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 gfx::Size Slider::GetPreferredSize() { | 187 gfx::Size Slider::GetPreferredSize() const { |
| 188 const int kSizeMajor = 200; | 188 const int kSizeMajor = 200; |
| 189 const int kSizeMinor = 40; | 189 const int kSizeMinor = 40; |
| 190 | 190 |
| 191 if (orientation_ == HORIZONTAL) | 191 if (orientation_ == HORIZONTAL) |
| 192 return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor); | 192 return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor); |
| 193 return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor)); | 193 return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void Slider::OnPaint(gfx::Canvas* canvas) { | 196 void Slider::OnPaint(gfx::Canvas* canvas) { |
| 197 gfx::Rect content = GetContentsBounds(); | 197 gfx::Rect content = GetContentsBounds(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |