OLD | NEW |
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/tabbed_launcher_button.h" | 5 #include "ash/launcher/tabbed_launcher_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher_button_host.h" | 9 #include "ash/launcher/launcher_button_host.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 const ui::Animation* animation) { | 38 const ui::Animation* animation) { |
39 if (host_->animation_->current_part_index() == 1) | 39 if (host_->animation_->current_part_index() == 1) |
40 host_->SchedulePaint(); | 40 host_->SchedulePaint(); |
41 } | 41 } |
42 | 42 |
43 // static | 43 // static |
44 TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_1_ = NULL; | 44 TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_1_ = NULL; |
45 TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_2_ = NULL; | 45 TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_2_ = NULL; |
46 TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_3_ = NULL; | 46 TabbedLauncherButton::ImageSet* TabbedLauncherButton::bg_image_3_ = NULL; |
47 | 47 |
| 48 TabbedLauncherButton::ImageSet* |
| 49 TabbedLauncherButton::bg_private_image_1_ = NULL; |
| 50 TabbedLauncherButton::ImageSet* |
| 51 TabbedLauncherButton::bg_private_image_2_ = NULL; |
| 52 TabbedLauncherButton::ImageSet* |
| 53 TabbedLauncherButton::bg_private_image_3_ = NULL; |
| 54 |
48 TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener, | 55 TabbedLauncherButton::TabbedLauncherButton(views::ButtonListener* listener, |
49 LauncherButtonHost* host) | 56 LauncherButtonHost* host) |
50 : views::ImageButton(listener), | 57 : views::ImageButton(listener), |
51 host_(host), | 58 host_(host), |
52 ALLOW_THIS_IN_INITIALIZER_LIST(animation_delegate_(this)), | 59 ALLOW_THIS_IN_INITIALIZER_LIST(animation_delegate_(this)), |
53 show_image_(true), | 60 show_image_(true), |
54 ALLOW_THIS_IN_INITIALIZER_LIST(hover_controller_(this)) { | 61 ALLOW_THIS_IN_INITIALIZER_LIST(hover_controller_(this)) { |
55 if (!bg_image_1_) { | 62 if (!bg_image_1_) { |
56 bg_image_1_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_1, | 63 bg_image_1_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_1, |
57 IDR_AURA_LAUNCHER_TABBED_BROWSER_1_PUSHED, | 64 IDR_AURA_LAUNCHER_TABBED_BROWSER_1_PUSHED, |
58 IDR_AURA_LAUNCHER_TABBED_BROWSER_1_HOT); | 65 IDR_AURA_LAUNCHER_TABBED_BROWSER_1_HOT); |
59 bg_image_2_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_2, | 66 bg_image_2_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_2, |
60 IDR_AURA_LAUNCHER_TABBED_BROWSER_2_PUSHED, | 67 IDR_AURA_LAUNCHER_TABBED_BROWSER_2_PUSHED, |
61 IDR_AURA_LAUNCHER_TABBED_BROWSER_2_HOT); | 68 IDR_AURA_LAUNCHER_TABBED_BROWSER_2_HOT); |
62 bg_image_3_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_3, | 69 bg_image_3_ = CreateImageSet(IDR_AURA_LAUNCHER_TABBED_BROWSER_3, |
63 IDR_AURA_LAUNCHER_TABBED_BROWSER_3_PUSHED, | 70 IDR_AURA_LAUNCHER_TABBED_BROWSER_3_PUSHED, |
64 IDR_AURA_LAUNCHER_TABBED_BROWSER_3_HOT); | 71 IDR_AURA_LAUNCHER_TABBED_BROWSER_3_HOT); |
| 72 |
| 73 bg_private_image_1_ = |
| 74 CreateImageSet(IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_1, |
| 75 IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_1_PUSHED, |
| 76 IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_1_HOT); |
| 77 bg_private_image_2_ = |
| 78 CreateImageSet(IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_2, |
| 79 IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_2_PUSHED, |
| 80 IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_2_HOT); |
| 81 bg_private_image_3_ = |
| 82 CreateImageSet(IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_3, |
| 83 IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_3_PUSHED, |
| 84 IDR_AURA_LAUNCHER_TABBED_PRIVATE_BROWSER_3_HOT); |
65 } | 85 } |
66 SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 86 SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
67 views::ImageButton::ALIGN_MIDDLE); | 87 views::ImageButton::ALIGN_MIDDLE); |
68 set_accessibility_focusable(true); | 88 set_accessibility_focusable(true); |
69 } | 89 } |
70 | 90 |
71 TabbedLauncherButton::~TabbedLauncherButton() { | 91 TabbedLauncherButton::~TabbedLauncherButton() { |
72 } | 92 } |
73 | 93 |
74 void TabbedLauncherButton::PrepareForImageChange() { | 94 void TabbedLauncherButton::PrepareForImageChange() { |
75 if (!show_image_ || (animation_.get() && animation_->is_animating())) | 95 if (!show_image_ || (animation_.get() && animation_->is_animating())) |
76 return; | 96 return; |
77 | 97 |
78 // Pause for 500ms, then ease out for 200ms. | 98 // Pause for 500ms, then ease out for 200ms. |
79 ui::MultiAnimation::Parts animation_parts; | 99 ui::MultiAnimation::Parts animation_parts; |
80 animation_parts.push_back(ui::MultiAnimation::Part(500, ui::Tween::ZERO)); | 100 animation_parts.push_back(ui::MultiAnimation::Part(500, ui::Tween::ZERO)); |
81 animation_parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::EASE_OUT)); | 101 animation_parts.push_back(ui::MultiAnimation::Part(200, ui::Tween::EASE_OUT)); |
82 animation_.reset(new ui::MultiAnimation(animation_parts)); | 102 animation_.reset(new ui::MultiAnimation(animation_parts)); |
83 animation_->set_continuous(false); | 103 animation_->set_continuous(false); |
84 animation_->set_delegate(&animation_delegate_); | 104 animation_->set_delegate(&animation_delegate_); |
85 animation_->Start(); | 105 animation_->Start(); |
86 } | 106 } |
87 | 107 |
88 void TabbedLauncherButton::SetTabImage(const SkBitmap& image, int count) { | 108 void TabbedLauncherButton::SetTabImage(const SkBitmap& image, int count, |
| 109 bool private_tab) { |
89 animation_.reset(); | 110 animation_.reset(); |
90 show_image_ = true; | 111 show_image_ = true; |
91 image_ = image; | 112 image_ = image; |
92 ImageSet* set; | 113 ImageSet* set; |
93 if (count <= 1) | 114 if (private_tab) { |
94 set = bg_image_1_; | 115 if (count <= 1) |
95 else if (count == 2) | 116 set = bg_private_image_1_; |
96 set = bg_image_2_; | 117 else if (count == 2) |
97 else | 118 set = bg_private_image_2_; |
98 set = bg_image_3_; | 119 else |
| 120 set = bg_private_image_3_; |
| 121 } else { |
| 122 if (count <= 1) |
| 123 set = bg_image_1_; |
| 124 else if (count == 2) |
| 125 set = bg_image_2_; |
| 126 else |
| 127 set = bg_image_3_; |
| 128 } |
99 SetImage(BS_NORMAL, set->normal_image); | 129 SetImage(BS_NORMAL, set->normal_image); |
100 SetImage(BS_HOT, set->hot_image); | 130 SetImage(BS_HOT, set->hot_image); |
101 SetImage(BS_PUSHED, set->pushed_image); | 131 SetImage(BS_PUSHED, set->pushed_image); |
102 SchedulePaint(); | 132 SchedulePaint(); |
103 } | 133 } |
104 | 134 |
105 void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) { | 135 void TabbedLauncherButton::OnPaint(gfx::Canvas* canvas) { |
106 ImageButton::OnPaint(canvas); | 136 ImageButton::OnPaint(canvas); |
107 | 137 |
108 hover_controller_.Draw(canvas, *bg_image_1_->normal_image); | 138 hover_controller_.Draw(canvas, *bg_image_1_->normal_image); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 ImageSet* set = new ImageSet; | 206 ImageSet* set = new ImageSet; |
177 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 207 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
178 set->normal_image = new SkBitmap(*rb.GetImageNamed(normal_id).ToSkBitmap()); | 208 set->normal_image = new SkBitmap(*rb.GetImageNamed(normal_id).ToSkBitmap()); |
179 set->pushed_image = new SkBitmap(*rb.GetImageNamed(pushed_id).ToSkBitmap()); | 209 set->pushed_image = new SkBitmap(*rb.GetImageNamed(pushed_id).ToSkBitmap()); |
180 set->hot_image = new SkBitmap(*rb.GetImageNamed(hot_id).ToSkBitmap()); | 210 set->hot_image = new SkBitmap(*rb.GetImageNamed(hot_id).ToSkBitmap()); |
181 return set; | 211 return set; |
182 } | 212 } |
183 | 213 |
184 } // namespace internal | 214 } // namespace internal |
185 } // namespace ash | 215 } // namespace ash |
OLD | NEW |