Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ui/views/controls/slider.cc

Issue 2297833002: Fix controlling volume slider with keyboard (Closed)
Patch Set: improve tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/slider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/slider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698