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

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

Issue 211002: Add touchpad speed factor setting to Chrome OS touchpad settings page... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « views/controls/slider/slider.h ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "views/controls/slider/slider.h"
6
7 #include <string>
8
9 #include "views/controls/slider/native_slider_wrapper.h"
10 #include "views/widget/widget.h"
11
12 namespace views {
13
14 // static
15 const char Slider::kViewClassName[] = "views/Slider";
16
17 /////////////////////////////////////////////////////////////////////////////
18 // Slider
19
20 Slider::Slider()
21 : native_wrapper_(NULL),
22 listener_(NULL),
23 style_(STYLE_HORIZONTAL) {
24 SetFocusable(true);
25 }
26
27 Slider::Slider(double min, double max, double step, StyleFlags style,
28 SliderListener* listener)
29 : native_wrapper_(NULL),
30 listener_(listener),
31 style_(style),
32 min_(min),
33 max_(max),
34 step_(step) {
35 SetFocusable(true);
36 }
37
38 Slider::~Slider() {
39 }
40
41 void Slider::NotifyValueChanged() {
42 if (native_wrapper_)
43 value_ = native_wrapper_->GetValue();
44 if (listener_)
45 listener_->SliderValueChanged(this);
46 }
47
48 void Slider::SetValue(double value) {
49 value_ = value;
50 if (native_wrapper_)
51 native_wrapper_->SetValue(value);
52 }
53
54 ////////////////////////////////////////////////////////////////////////////////
55 // Slider, View overrides:
56
57 void Slider::Layout() {
58 if (native_wrapper_) {
59 native_wrapper_->GetView()->SetBounds(GetLocalBounds(true));
60 native_wrapper_->GetView()->Layout();
61 }
62 }
63
64 gfx::Size Slider::GetPreferredSize() {
65 if (native_wrapper_)
66 return native_wrapper_->GetPreferredSize();
67 return gfx::Size();
68 }
69
70 bool Slider::IsFocusable() const {
71 return IsEnabled();
72 }
73
74 void Slider::SetEnabled(bool enabled) {
75 View::SetEnabled(enabled);
76 if (native_wrapper_)
77 native_wrapper_->UpdateEnabled();
78 }
79
80 void Slider::Focus() {
81 if (native_wrapper_) {
82 // Forward the focus to the wrapper if it exists.
83 native_wrapper_->SetFocus();
84 } else {
85 // If there is no wrapper, cause the RootView to be focused so that we still
86 // get keyboard messages.
87 View::Focus();
88 }
89 }
90
91 void Slider::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
92 if (is_add && !native_wrapper_ && GetWidget()) {
93 // The native wrapper's lifetime will be managed by the view hierarchy after
94 // we call AddChildView.
95 native_wrapper_ = NativeSliderWrapper::CreateWrapper(this);
96 AddChildView(native_wrapper_->GetView());
97 native_wrapper_->UpdateEnabled();
98 }
99 }
100
101 std::string Slider::GetClassName() const {
102 return kViewClassName;
103 }
104
105 NativeSliderWrapper* Slider::CreateWrapper() {
106 NativeSliderWrapper* native_wrapper =
107 NativeSliderWrapper::CreateWrapper(this);
108
109 native_wrapper->UpdateEnabled();
110
111 return native_wrapper;
112 }
113
114 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/slider/slider.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698