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

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

Issue 3337006: Revert 58388 - Revert 58215 - Revert 58186 - Move the keyboard files from bas... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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/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 "app/throb_animation.h" 7 #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() == app::VKEY_SPACE) { 195 if (e.GetKeyCode() == base::VKEY_SPACE) {
196 SetState(BS_PUSHED); 196 SetState(BS_PUSHED);
197 } else if (e.GetKeyCode() == app::VKEY_RETURN) { 197 } else if (e.GetKeyCode() == base::VKEY_RETURN) {
198 SetState(BS_NORMAL); 198 SetState(BS_NORMAL);
199 NotifyClick(e); 199 NotifyClick(e);
200 } else { 200 } else {
201 return false; 201 return false;
202 } 202 }
203 return true; 203 return true;
204 } 204 }
205 205
206 bool CustomButton::OnKeyReleased(const KeyEvent& e) { 206 bool CustomButton::OnKeyReleased(const KeyEvent& e) {
207 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != app::VKEY_SPACE)) 207 if ((state_ == BS_DISABLED) || (e.GetKeyCode() != base::VKEY_SPACE))
208 return false; 208 return false;
209 209
210 SetState(BS_NORMAL); 210 SetState(BS_NORMAL);
211 NotifyClick(e); 211 NotifyClick(e);
212 return true; 212 return true;
213 } 213 }
214 214
215 void CustomButton::OnDragDone() { 215 void CustomButton::OnDragDone() {
216 SetState(BS_NORMAL); 216 SetState(BS_NORMAL);
217 } 217 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 void CustomButton::AnimationProgressed(const Animation* animation) { 256 void CustomButton::AnimationProgressed(const Animation* animation) {
257 SchedulePaint(); 257 SchedulePaint();
258 } 258 }
259 259
260 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { 260 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) {
261 return IsTriggerableEvent(e); 261 return IsTriggerableEvent(e);
262 } 262 }
263 263
264 } // namespace views 264 } // 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