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/launcher.h" | 5 #include "ash/launcher/launcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/focus_cycler.h" | 10 #include "ash/focus_cycler.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 launcher_view->SetBounds(0, 0, w, height()); | 160 launcher_view->SetBounds(0, 0, w, height()); |
161 } else { | 161 } else { |
162 int h = std::max(0, height() - launcher_->status_size_.height()); | 162 int h = std::max(0, height() - launcher_->status_size_.height()); |
163 launcher_view->SetBounds(0, 0, width(), h); | 163 launcher_view->SetBounds(0, 0, width(), h); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void Launcher::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { | 167 void Launcher::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { |
168 if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 168 if (launcher_->alignment_ == SHELF_ALIGNMENT_BOTTOM) { |
169 SkPaint paint; | 169 SkPaint paint; |
170 static const gfx::ImageSkia* launcher_background = NULL; | 170 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
171 if (!launcher_background) { | 171 const gfx::ImageSkia* launcher_background = rb.GetImageSkiaNamed( |
172 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 172 internal::ShelfLayoutManager::ForLauncher( |
173 launcher_background = | 173 launcher_->widget()->GetNativeView())-> |
174 rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND_BOTTOM).ToImageSkia(); | 174 SelectValueForShelfAlignment(IDR_AURA_LAUNCHER_BACKGROUND_BOTTOM, |
175 } | 175 IDR_AURA_LAUNCHER_BACKGROUND_LEFT, |
| 176 IDR_AURA_LAUNCHER_BACKGROUND_RIGHT)); |
176 paint.setAlpha(alpha_); | 177 paint.setAlpha(alpha_); |
177 canvas->DrawImageInt( | 178 canvas->DrawImageInt( |
178 *launcher_background, | 179 *launcher_background, |
179 0, 0, launcher_background->width(), launcher_background->height(), | 180 0, 0, launcher_background->width(), launcher_background->height(), |
180 0, 0, width(), height(), | 181 0, 0, width(), height(), |
181 false, | 182 false, |
182 paint); | 183 paint); |
183 canvas->FillRect( | 184 canvas->FillRect( |
184 gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels), | 185 gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels), |
185 SK_ColorBLACK); | 186 SK_ColorBLACK); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 delegate_view_->AddChildView(launcher_view_); | 224 delegate_view_->AddChildView(launcher_view_); |
224 params.delegate = delegate_view_; | 225 params.delegate = delegate_view_; |
225 widget_->Init(params); | 226 widget_->Init(params); |
226 widget_->GetNativeWindow()->SetName("LauncherWindow"); | 227 widget_->GetNativeWindow()->SetName("LauncherWindow"); |
227 // The launcher should not take focus when it is initially shown. | 228 // The launcher should not take focus when it is initially shown. |
228 widget_->set_focus_on_creation(false); | 229 widget_->set_focus_on_creation(false); |
229 widget_->SetContentsView(delegate_view_); | 230 widget_->SetContentsView(delegate_view_); |
230 widget_->GetNativeView()->SetName("LauncherView"); | 231 widget_->GetNativeView()->SetName("LauncherView"); |
231 widget_->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, | 232 widget_->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, |
232 true); | 233 true); |
| 234 |
233 // SetBounds() has to be called after kStayInSameRootWindowKey is set. | 235 // SetBounds() has to be called after kStayInSameRootWindowKey is set. |
234 gfx::Size pref = | 236 gfx::Size pref = |
235 static_cast<views::View*>(launcher_view_)->GetPreferredSize(); | 237 static_cast<views::View*>(launcher_view_)->GetPreferredSize(); |
236 widget_->SetBounds(gfx::Rect(pref)); | 238 widget_->SetBounds(gfx::Rect(pref)); |
237 } | 239 } |
238 | 240 |
239 Launcher::~Launcher() { | 241 Launcher::~Launcher() { |
240 } | 242 } |
241 | 243 |
242 // static | 244 // static |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 widget_->SetBounds(bounds); | 375 widget_->SetBounds(bounds); |
374 if (dimmer_.get()) | 376 if (dimmer_.get()) |
375 dimmer_->SetBounds(bounds); | 377 dimmer_->SetBounds(bounds); |
376 } | 378 } |
377 | 379 |
378 internal::LauncherView* Launcher::GetLauncherViewForTest() { | 380 internal::LauncherView* Launcher::GetLauncherViewForTest() { |
379 return launcher_view_; | 381 return launcher_view_; |
380 } | 382 } |
381 | 383 |
382 } // namespace ash | 384 } // namespace ash |
OLD | NEW |