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

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

Issue 10823351: Update launcher status images (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: permissions Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/resources/default_100_percent/ash/launcher_browser.png » ('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) 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 16 matching lines...) Expand all
27 #include "ui/views/controls/image_view.h" 27 #include "ui/views/controls/image_view.h"
28 28
29 namespace { 29 namespace {
30 30
31 // Size of the bar. This is along the opposite axis of the shelf. For example, 31 // Size of the bar. This is along the opposite axis of the shelf. For example,
32 // if the shelf is aligned horizontally then this is the height of the bar. 32 // if the shelf is aligned horizontally then this is the height of the bar.
33 const int kBarSize = 3; 33 const int kBarSize = 3;
34 const int kBarSpacing = 5; 34 const int kBarSpacing = 5;
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 kHopUpMS = 0;
38 const int kInactiveBarColor = 0x80ffffff;
39 const int kHopUpMS = 200;
40 const int kHopDownMS = 200; 38 const int kHopDownMS = 200;
41 const int kAttentionThrobDurationMS = 2000; 39 const int kAttentionThrobDurationMS = 1000;
42 40
43 bool ShouldHop(int state) { 41 bool ShouldHop(int state) {
44 return state & ash::internal::LauncherButton::STATE_HOVERED || 42 return state & ash::internal::LauncherButton::STATE_HOVERED ||
45 state & ash::internal::LauncherButton::STATE_ACTIVE || 43 state & ash::internal::LauncherButton::STATE_ACTIVE ||
46 state & ash::internal::LauncherButton::STATE_FOCUSED; 44 state & ash::internal::LauncherButton::STATE_FOCUSED;
47 } 45 }
48 46
49 } // namespace 47 } // namespace
50 48
51 namespace ash { 49 namespace ash {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 457 }
460 458
461 bool LauncherButton::IsShelfHorizontal() const { 459 bool LauncherButton::IsShelfHorizontal() const {
462 return host_->GetShelfAlignment() == SHELF_ALIGNMENT_BOTTOM; 460 return host_->GetShelfAlignment() == SHELF_ALIGNMENT_BOTTOM;
463 } 461 }
464 462
465 void LauncherButton::UpdateState() { 463 void LauncherButton::UpdateState() {
466 if (state_ == STATE_NORMAL || state_ & STATE_PENDING) { 464 if (state_ == STATE_NORMAL || state_ & STATE_PENDING) {
467 bar_->SetVisible(false); 465 bar_->SetVisible(false);
468 } else { 466 } else {
469 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
470 int bar_id; 467 int bar_id;
471 bar_->SetVisible(true); 468 if (IsShelfHorizontal()) {
472 469 if (state_ & (STATE_HOVERED | STATE_FOCUSED | STATE_ATTENTION))
473 if (state_ & STATE_ACTIVE || state_ & STATE_ATTENTION) { 470 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_HOVER;
474 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_ACTIVE : 471 else if (state_ & STATE_ACTIVE)
475 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_ACTIVE; 472 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_ACTIVE;
476 } else if (state_ & STATE_HOVERED || state_ & STATE_FOCUSED) { 473 else
477 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_HOVER : 474 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_RUNNING;
478 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_HOVER;
479 } else { 475 } else {
480 bar_id = IsShelfHorizontal() ? IDR_AURA_LAUNCHER_UNDERLINE_RUNNING : 476 if (state_ & (STATE_HOVERED | STATE_FOCUSED | STATE_ATTENTION))
481 IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_RUNNING; 477 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_HOVER;
478 else if (state_ & STATE_ACTIVE)
479 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_ACTIVE;
480 else
481 bar_id = IDR_AURA_LAUNCHER_UNDERLINE_VERTICAL_RUNNING;
482 } 482 }
483 483
484 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
484 bar_->SetImage(rb.GetImageNamed(bar_id).ToImageSkia()); 485 bar_->SetImage(rb.GetImageNamed(bar_id).ToImageSkia());
486 bar_->SetVisible(true);
485 } 487 }
486 488
487 switch (host_->GetShelfAlignment()) { 489 switch (host_->GetShelfAlignment()) {
488 case SHELF_ALIGNMENT_BOTTOM: 490 case SHELF_ALIGNMENT_BOTTOM:
489 bar_->SetHorizontalAlignment(views::ImageView::CENTER); 491 bar_->SetHorizontalAlignment(views::ImageView::CENTER);
490 bar_->SetVerticalAlignment(views::ImageView::TRAILING); 492 bar_->SetVerticalAlignment(views::ImageView::TRAILING);
491 break; 493 break;
492 case SHELF_ALIGNMENT_LEFT: 494 case SHELF_ALIGNMENT_LEFT:
493 bar_->SetHorizontalAlignment( 495 bar_->SetHorizontalAlignment(
494 base::i18n::IsRTL() ? views::ImageView::TRAILING : 496 base::i18n::IsRTL() ? views::ImageView::TRAILING :
495 views::ImageView::LEADING); 497 views::ImageView::LEADING);
496 bar_->SetVerticalAlignment(views::ImageView::CENTER); 498 bar_->SetVerticalAlignment(views::ImageView::CENTER);
497 break; 499 break;
498 case SHELF_ALIGNMENT_RIGHT: 500 case SHELF_ALIGNMENT_RIGHT:
499 bar_->SetHorizontalAlignment( 501 bar_->SetHorizontalAlignment(
500 base::i18n::IsRTL() ? views::ImageView::LEADING : 502 base::i18n::IsRTL() ? views::ImageView::LEADING :
501 views::ImageView::TRAILING); 503 views::ImageView::TRAILING);
502 bar_->SetVerticalAlignment(views::ImageView::CENTER); 504 bar_->SetVerticalAlignment(views::ImageView::CENTER);
503 break; 505 break;
504 } 506 }
505 507
506 Layout(); 508 Layout();
507 SchedulePaint(); 509 SchedulePaint();
508 } 510 }
509 511
510 } // namespace internal 512 } // namespace internal
511 } // namespace ash 513 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/resources/default_100_percent/ash/launcher_browser.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698