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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 enum BorderElements { | 44 enum BorderElements { |
45 LEFT, | 45 LEFT, |
46 CENTER_LEFT, | 46 CENTER_LEFT, |
47 CENTER_RIGHT, | 47 CENTER_RIGHT, |
48 RIGHT, | 48 RIGHT, |
49 }; | 49 }; |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 namespace views { | 52 namespace views { |
53 | 53 |
| 54 // static |
| 55 const char Slider::kViewClassName[] = "Slider"; |
| 56 |
54 Slider::Slider(SliderListener* listener, Orientation orientation) | 57 Slider::Slider(SliderListener* listener, Orientation orientation) |
55 : listener_(listener), | 58 : listener_(listener), |
56 orientation_(orientation), | 59 orientation_(orientation), |
57 value_(0.f), | 60 value_(0.f), |
58 keyboard_increment_(0.1f), | 61 keyboard_increment_(0.1f), |
59 animating_value_(0.f), | 62 animating_value_(0.f), |
60 value_is_valid_(false), | 63 value_is_valid_(false), |
61 accessibility_events_enabled_(true), | 64 accessibility_events_enabled_(true), |
62 focus_border_color_(0), | 65 focus_border_color_(0), |
63 bar_active_images_(kBarImagesActive), | 66 bar_active_images_(kBarImagesActive), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 182 |
180 if (!focus_border_color_) { | 183 if (!focus_border_color_) { |
181 canvas->DrawFocusRect(GetLocalBounds()); | 184 canvas->DrawFocusRect(GetLocalBounds()); |
182 } else if (HasFocus()) { | 185 } else if (HasFocus()) { |
183 canvas->DrawSolidFocusRect( | 186 canvas->DrawSolidFocusRect( |
184 gfx::Rect(1, 1, width() - 3, height() - 3), | 187 gfx::Rect(1, 1, width() - 3, height() - 3), |
185 focus_border_color_); | 188 focus_border_color_); |
186 } | 189 } |
187 } | 190 } |
188 | 191 |
| 192 const char* Slider::GetClassName() const { |
| 193 return kViewClassName; |
| 194 } |
| 195 |
189 gfx::Size Slider::GetPreferredSize() const { | 196 gfx::Size Slider::GetPreferredSize() const { |
190 const int kSizeMajor = 200; | 197 const int kSizeMajor = 200; |
191 const int kSizeMinor = 40; | 198 const int kSizeMinor = 40; |
192 | 199 |
193 if (orientation_ == HORIZONTAL) | 200 if (orientation_ == HORIZONTAL) |
194 return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor); | 201 return gfx::Size(std::max(width(), kSizeMajor), kSizeMinor); |
195 return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor)); | 202 return gfx::Size(kSizeMinor, std::max(height(), kSizeMajor)); |
196 } | 203 } |
197 | 204 |
198 void Slider::OnPaint(gfx::Canvas* canvas) { | 205 void Slider::OnPaint(gfx::Canvas* canvas) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (listener_) | 362 if (listener_) |
356 listener_->SliderDragStarted(this); | 363 listener_->SliderDragStarted(this); |
357 } | 364 } |
358 | 365 |
359 void Slider::OnSliderDragEnded() { | 366 void Slider::OnSliderDragEnded() { |
360 if (listener_) | 367 if (listener_) |
361 listener_->SliderDragEnded(this); | 368 listener_->SliderDragEnded(this); |
362 } | 369 } |
363 | 370 |
364 } // namespace views | 371 } // namespace views |
OLD | NEW |