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

Side by Side Diff: views/controls/button/custom_button.cc

Issue 3165064: Move the keyboard files from base/ to app/. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: latest merge Created 10 years, 4 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 | « views/accelerator.cc ('k') | views/controls/button/menu_button.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/button/custom_button.h" 5 #include "views/controls/button/custom_button.h"
6 6
7 #include "app/keyboard_codes.h"
7 #include "app/throb_animation.h" 8 #include "app/throb_animation.h"
8 #include "base/keyboard_codes.h"
9 #include "views/screen.h" 9 #include "views/screen.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 // How long the hover animation takes if uninterrupted. 13 // How long the hover animation takes if uninterrupted.
14 static const int kHoverFadeDurationMs = 150; 14 static const int kHoverFadeDurationMs = 150;
15 15
16 //////////////////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////////////////
17 // CustomButton, public: 17 // CustomButton, public:
18 18
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 SetState(BS_NORMAL); 185 SetState(BS_NORMAL);
186 } 186 }
187 187
188 bool CustomButton::OnKeyPressed(const KeyEvent& e) { 188 bool CustomButton::OnKeyPressed(const KeyEvent& e) {
189 if (state_ == BS_DISABLED) 189 if (state_ == BS_DISABLED)
190 return false; 190 return false;
191 191
192 // Space sets button state to pushed. Enter clicks the button. This matches 192 // Space sets button state to pushed. Enter clicks the button. This matches
193 // the Windows native behavior of buttons, where Space clicks the button on 193 // the Windows native behavior of buttons, where Space clicks the button on
194 // KeyRelease and Enter clicks the button on KeyPressed. 194 // KeyRelease and Enter clicks the button on KeyPressed.
195 if (e.GetKeyCode() == base::VKEY_SPACE) { 195 if (e.GetKeyCode() == app::VKEY_SPACE) {
196 SetState(BS_PUSHED); 196 SetState(BS_PUSHED);
197 } else if (e.GetKeyCode() == base::VKEY_RETURN) { 197 } else if (e.GetKeyCode() == app::VKEY_RETURN) {
198 SetState(BS_NORMAL); 198 SetState(BS_NORMAL);
199 NotifyClick(e); 199 NotifyClick(e);
200 } 200 }
201 return true; 201 return true;
202 } 202 }
203 203
204 bool CustomButton::OnKeyReleased(const KeyEvent& e) { 204 bool CustomButton::OnKeyReleased(const KeyEvent& e) {
205 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != base::VKEY_SPACE)) 205 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != app::VKEY_SPACE))
206 return false; 206 return false;
207 207
208 SetState(BS_NORMAL); 208 SetState(BS_NORMAL);
209 NotifyClick(e); 209 NotifyClick(e);
210 return true; 210 return true;
211 } 211 }
212 212
213 void CustomButton::OnDragDone() { 213 void CustomButton::OnDragDone() {
214 SetState(BS_NORMAL); 214 SetState(BS_NORMAL);
215 } 215 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 void CustomButton::AnimationProgressed(const Animation* animation) { 254 void CustomButton::AnimationProgressed(const Animation* animation) {
255 SchedulePaint(); 255 SchedulePaint();
256 } 256 }
257 257
258 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { 258 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) {
259 return IsTriggerableEvent(e); 259 return IsTriggerableEvent(e);
260 } 260 }
261 261
262 } // namespace views 262 } // namespace views
OLDNEW
« no previous file with comments | « views/accelerator.cc ('k') | views/controls/button/menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698