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

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

Issue 6246001: Move app/key* to ui/base/keycodes/* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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/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"
8 #include "ui/base/animation/throb_animation.h" 7 #include "ui/base/animation/throb_animation.h"
8 #include "ui/base/keycodes/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 // static 16 // static
17 const char CustomButton::kViewClassName[] = "views/CustomButton"; 17 const char CustomButton::kViewClassName[] = "views/CustomButton";
18 18
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 SetState(BS_NORMAL); 196 SetState(BS_NORMAL);
197 } 197 }
198 198
199 bool CustomButton::OnKeyPressed(const KeyEvent& e) { 199 bool CustomButton::OnKeyPressed(const KeyEvent& e) {
200 if (state_ == BS_DISABLED) 200 if (state_ == BS_DISABLED)
201 return false; 201 return false;
202 202
203 // Space sets button state to pushed. Enter clicks the button. This matches 203 // Space sets button state to pushed. Enter clicks the button. This matches
204 // the Windows native behavior of buttons, where Space clicks the button on 204 // the Windows native behavior of buttons, where Space clicks the button on
205 // KeyRelease and Enter clicks the button on KeyPressed. 205 // KeyRelease and Enter clicks the button on KeyPressed.
206 if (e.GetKeyCode() == app::VKEY_SPACE) { 206 if (e.GetKeyCode() == ui::VKEY_SPACE) {
207 SetState(BS_PUSHED); 207 SetState(BS_PUSHED);
208 } else if (e.GetKeyCode() == app::VKEY_RETURN) { 208 } else if (e.GetKeyCode() == ui::VKEY_RETURN) {
209 SetState(BS_NORMAL); 209 SetState(BS_NORMAL);
210 NotifyClick(e); 210 NotifyClick(e);
211 } else { 211 } else {
212 return false; 212 return false;
213 } 213 }
214 return true; 214 return true;
215 } 215 }
216 216
217 bool CustomButton::OnKeyReleased(const KeyEvent& e) { 217 bool CustomButton::OnKeyReleased(const KeyEvent& e) {
218 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != app::VKEY_SPACE)) 218 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != ui::VKEY_SPACE))
219 return false; 219 return false;
220 220
221 SetState(BS_NORMAL); 221 SetState(BS_NORMAL);
222 NotifyClick(e); 222 NotifyClick(e);
223 return true; 223 return true;
224 } 224 }
225 225
226 void CustomButton::OnDragDone() { 226 void CustomButton::OnDragDone() {
227 SetState(BS_NORMAL); 227 SetState(BS_NORMAL);
228 } 228 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 void CustomButton::AnimationProgressed(const ui::Animation* animation) { 267 void CustomButton::AnimationProgressed(const ui::Animation* animation) {
268 SchedulePaint(); 268 SchedulePaint();
269 } 269 }
270 270
271 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { 271 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) {
272 return IsTriggerableEvent(e); 272 return IsTriggerableEvent(e);
273 } 273 }
274 274
275 } // namespace views 275 } // 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