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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 bool Slider::OnMouseDragged(const ui::MouseEvent& event) { | 235 bool Slider::OnMouseDragged(const ui::MouseEvent& event) { |
236 MoveButtonTo(event.location()); | 236 MoveButtonTo(event.location()); |
237 return true; | 237 return true; |
238 } | 238 } |
239 | 239 |
240 void Slider::OnMouseReleased(const ui::MouseEvent& event) { | 240 void Slider::OnMouseReleased(const ui::MouseEvent& event) { |
241 OnSliderDragEnded(); | 241 OnSliderDragEnded(); |
242 } | 242 } |
243 | 243 |
244 bool Slider::OnKeyPressed(const ui::KeyEvent& event) { | 244 bool Slider::OnKeyPressed(const ui::KeyEvent& event) { |
245 int new_value = value_; | 245 float new_value = value_; |
246 if (event.key_code() == ui::VKEY_LEFT) | 246 if (event.key_code() == ui::VKEY_LEFT) |
247 new_value -= keyboard_increment_; | 247 new_value -= keyboard_increment_; |
248 else if (event.key_code() == ui::VKEY_RIGHT) | 248 else if (event.key_code() == ui::VKEY_RIGHT) |
249 new_value += keyboard_increment_; | 249 new_value += keyboard_increment_; |
250 else | 250 else |
251 return false; | 251 return false; |
252 SetValueInternal(new_value, VALUE_CHANGED_BY_USER); | 252 SetValueInternal(new_value, VALUE_CHANGED_BY_USER); |
253 return true; | 253 return true; |
254 } | 254 } |
255 | 255 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 if (listener_) | 303 if (listener_) |
304 listener_->SliderDragStarted(this); | 304 listener_->SliderDragStarted(this); |
305 } | 305 } |
306 | 306 |
307 void Slider::OnSliderDragEnded() { | 307 void Slider::OnSliderDragEnded() { |
308 if (listener_) | 308 if (listener_) |
309 listener_->SliderDragEnded(this); | 309 listener_->SliderDragEnded(this); |
310 } | 310 } |
311 | 311 |
312 } // namespace views | 312 } // namespace views |
OLD | NEW |