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

Side by Side Diff: ash/launcher/launcher_button.cc

Issue 10449077: Set "Hover" status during focus for accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 6 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 | « ash/launcher/launcher_button.h ('k') | no next file » | 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 "ash/launcher/launcher_button.h" 5 #include "ash/launcher/launcher_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/launcher/launcher_button_host.h" 10 #include "ash/launcher/launcher_button_host.h"
(...skipping 24 matching lines...) Expand all
35 const int kIconSize = 32; 35 const int kIconSize = 32;
36 const int kHopSpacing = 2; 36 const int kHopSpacing = 2;
37 const int kActiveBarColor = 0xe6ffffff; 37 const int kActiveBarColor = 0xe6ffffff;
38 const int kInactiveBarColor = 0x80ffffff; 38 const int kInactiveBarColor = 0x80ffffff;
39 const int kHopUpMS = 200; 39 const int kHopUpMS = 200;
40 const int kHopDownMS = 200; 40 const int kHopDownMS = 200;
41 const int kAttentionThrobDurationMS = 2000; 41 const int kAttentionThrobDurationMS = 2000;
42 42
43 bool ShouldHop(int state) { 43 bool ShouldHop(int state) {
44 return state & ash::internal::LauncherButton::STATE_HOVERED || 44 return state & ash::internal::LauncherButton::STATE_HOVERED ||
45 state & ash::internal::LauncherButton::STATE_ACTIVE; 45 state & ash::internal::LauncherButton::STATE_ACTIVE ||
46 state & ash::internal::LauncherButton::STATE_FOCUSED;
46 } 47 }
47 48
48 } // namespace 49 } // namespace
49 50
50 namespace ash { 51 namespace ash {
51 52
52 namespace internal { 53 namespace internal {
53 54
54 //////////////////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////////////////
55 // LauncherButton::BarView 56 // LauncherButton::BarView
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 bar_->SetBoundsRect(rect); 391 bar_->SetBoundsRect(rect);
391 } 392 }
392 393
393 bool LauncherButton::GetTooltipText( 394 bool LauncherButton::GetTooltipText(
394 const gfx::Point& p, string16* tooltip) const { 395 const gfx::Point& p, string16* tooltip) const {
395 DCHECK(tooltip); 396 DCHECK(tooltip);
396 tooltip->assign(host_->GetAccessibleName(this)); 397 tooltip->assign(host_->GetAccessibleName(this));
397 return true; 398 return true;
398 } 399 }
399 400
401 void LauncherButton::OnFocus() {
402 AddState(STATE_FOCUSED);
403 }
404
405 void LauncherButton::OnBlur() {
406 ClearState(STATE_FOCUSED);
407 }
408
400 void LauncherButton::Init() { 409 void LauncherButton::Init() {
401 icon_view_ = CreateIconView(); 410 icon_view_ = CreateIconView();
402 // TODO: refactor the layers so each button doesn't require 2. 411 // TODO: refactor the layers so each button doesn't require 2.
403 icon_view_->SetPaintToLayer(true); 412 icon_view_->SetPaintToLayer(true);
404 icon_view_->SetFillsBoundsOpaquely(false); 413 icon_view_->SetFillsBoundsOpaquely(false);
405 icon_view_->SetSize(gfx::Size(kIconSize, kIconSize)); 414 icon_view_->SetSize(gfx::Size(kIconSize, kIconSize));
406 icon_view_->SetHorizontalAlignment(views::ImageView::CENTER); 415 icon_view_->SetHorizontalAlignment(views::ImageView::CENTER);
407 icon_view_->SetVerticalAlignment(views::ImageView::CENTER); 416 icon_view_->SetVerticalAlignment(views::ImageView::CENTER);
408 AddChildView(icon_view_); 417 AddChildView(icon_view_);
409 } 418 }
(...skipping 10 matching lines...) Expand all
420 if (state_ == STATE_NORMAL || state_ & STATE_PENDING) { 429 if (state_ == STATE_NORMAL || state_ & STATE_PENDING) {
421 bar_->SetVisible(false); 430 bar_->SetVisible(false);
422 } else { 431 } else {
423 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 432 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
424 int bar_id; 433 int bar_id;
425 bar_->SetVisible(true); 434 bar_->SetVisible(true);
426 435
427 if (state_ & STATE_ACTIVE || state_ & STATE_ATTENTION) { 436 if (state_ & STATE_ACTIVE || state_ & STATE_ATTENTION) {
428 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_ACTIVE : 437 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_ACTIVE :
429 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_ACTIVE; 438 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_ACTIVE;
430 } else if (state_ & STATE_HOVERED) { 439 } else if (state_ & STATE_HOVERED || state_ & STATE_FOCUSED) {
431 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_HOVER : 440 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_HOVER :
432 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_HOVER; 441 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_HOVER;
433 } else { 442 } else {
434 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_RUNNING : 443 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_RUNNING :
435 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_RUNNING; 444 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_RUNNING;
436 } 445 }
437 446
438 bar_->SetImage(rb.GetImageNamed(bar_id).ToImageSkia()); 447 bar_->SetImage(rb.GetImageNamed(bar_id).ToImageSkia());
439 } 448 }
440 449
(...skipping 15 matching lines...) Expand all
456 bar_->SetVerticalAlignment(views::ImageView::CENTER); 465 bar_->SetVerticalAlignment(views::ImageView::CENTER);
457 break; 466 break;
458 } 467 }
459 468
460 Layout(); 469 Layout();
461 SchedulePaint(); 470 SchedulePaint();
462 } 471 }
463 472
464 } // namespace internal 473 } // namespace internal
465 } // namespace ash 474 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698