| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 176 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 177 gfx::ImageSkia shelf_background = | 177 gfx::ImageSkia shelf_background = |
| 178 *rb->GetImageNamed(IDR_ASH_SHELF_DIMMING).ToImageSkia(); | 178 *rb->GetImageNamed(IDR_ASH_SHELF_DIMMING).ToImageSkia(); |
| 179 | 179 |
| 180 if (shelf_->GetAlignment() != ash::SHELF_ALIGNMENT_BOTTOM) { | 180 if (shelf_->GetAlignment() != ash::SHELF_ALIGNMENT_BOTTOM) { |
| 181 shelf_background = gfx::ImageSkiaOperations::CreateRotatedImage( | 181 shelf_background = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 182 shelf_background, | 182 shelf_background, |
| 183 shelf_->shelf_layout_manager()->SelectValueForShelfAlignment( | 183 shelf_->shelf_layout_manager()->SelectValueForShelfAlignment( |
| 184 SkBitmapOperations::ROTATION_90_CW, | 184 SkBitmapOperations::ROTATION_90_CW, |
| 185 SkBitmapOperations::ROTATION_90_CW, | 185 SkBitmapOperations::ROTATION_90_CW, |
| 186 SkBitmapOperations::ROTATION_270_CW, | 186 SkBitmapOperations::ROTATION_270_CW)); |
| 187 SkBitmapOperations::ROTATION_180_CW)); | |
| 188 } | 187 } |
| 189 paint.setAlpha(alpha_); | 188 paint.setAlpha(alpha_); |
| 190 canvas->DrawImageInt(shelf_background, | 189 canvas->DrawImageInt(shelf_background, |
| 191 0, | 190 0, |
| 192 0, | 191 0, |
| 193 shelf_background.width(), | 192 shelf_background.width(), |
| 194 shelf_background.height(), | 193 shelf_background.height(), |
| 195 0, | 194 0, |
| 196 0, | 195 0, |
| 197 width(), | 196 width(), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 private: | 264 private: |
| 266 gfx::Insets GetInsetsForAlignment(int distance, | 265 gfx::Insets GetInsetsForAlignment(int distance, |
| 267 ash::ShelfAlignment alignment) { | 266 ash::ShelfAlignment alignment) { |
| 268 switch (alignment) { | 267 switch (alignment) { |
| 269 case ash::SHELF_ALIGNMENT_BOTTOM: | 268 case ash::SHELF_ALIGNMENT_BOTTOM: |
| 270 return gfx::Insets(distance, 0, 0, 0); | 269 return gfx::Insets(distance, 0, 0, 0); |
| 271 case ash::SHELF_ALIGNMENT_LEFT: | 270 case ash::SHELF_ALIGNMENT_LEFT: |
| 272 return gfx::Insets(0, 0, 0, distance); | 271 return gfx::Insets(0, 0, 0, distance); |
| 273 case ash::SHELF_ALIGNMENT_RIGHT: | 272 case ash::SHELF_ALIGNMENT_RIGHT: |
| 274 return gfx::Insets(0, distance, 0, 0); | 273 return gfx::Insets(0, distance, 0, 0); |
| 275 case ash::SHELF_ALIGNMENT_TOP: | |
| 276 return gfx::Insets(0, 0, distance, 0); | |
| 277 } | 274 } |
| 278 NOTREACHED(); | 275 NOTREACHED(); |
| 279 return gfx::Insets(); | 276 return gfx::Insets(); |
| 280 } | 277 } |
| 281 | 278 |
| 282 // ash::ShelfLayoutManagerObserver: | 279 // ash::ShelfLayoutManagerObserver: |
| 283 void WillDeleteShelf() override { | 280 void WillDeleteShelf() override { |
| 284 shelf_->RemoveObserver(this); | 281 shelf_->RemoveObserver(this); |
| 285 shelf_ = NULL; | 282 shelf_ = NULL; |
| 286 } | 283 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { | 466 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { |
| 470 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 467 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 471 gfx::ImageSkia shelf_background = | 468 gfx::ImageSkia shelf_background = |
| 472 *rb->GetImageSkiaNamed(IDR_ASH_SHELF_BACKGROUND); | 469 *rb->GetImageSkiaNamed(IDR_ASH_SHELF_BACKGROUND); |
| 473 if (SHELF_ALIGNMENT_BOTTOM != shelf_->GetAlignment()) | 470 if (SHELF_ALIGNMENT_BOTTOM != shelf_->GetAlignment()) |
| 474 shelf_background = gfx::ImageSkiaOperations::CreateRotatedImage( | 471 shelf_background = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 475 shelf_background, | 472 shelf_background, |
| 476 shelf_->shelf_layout_manager()->SelectValueForShelfAlignment( | 473 shelf_->shelf_layout_manager()->SelectValueForShelfAlignment( |
| 477 SkBitmapOperations::ROTATION_90_CW, | 474 SkBitmapOperations::ROTATION_90_CW, |
| 478 SkBitmapOperations::ROTATION_90_CW, | 475 SkBitmapOperations::ROTATION_90_CW, |
| 479 SkBitmapOperations::ROTATION_270_CW, | 476 SkBitmapOperations::ROTATION_270_CW)); |
| 480 SkBitmapOperations::ROTATION_180_CW)); | |
| 481 const gfx::Rect dock_bounds(shelf_->shelf_layout_manager()->dock_bounds()); | 477 const gfx::Rect dock_bounds(shelf_->shelf_layout_manager()->dock_bounds()); |
| 482 SkPaint paint; | 478 SkPaint paint; |
| 483 paint.setAlpha(alpha_); | 479 paint.setAlpha(alpha_); |
| 484 canvas->DrawImageInt(shelf_background, | 480 canvas->DrawImageInt(shelf_background, |
| 485 0, | 481 0, |
| 486 0, | 482 0, |
| 487 shelf_background.width(), | 483 shelf_background.width(), |
| 488 shelf_background.height(), | 484 shelf_background.height(), |
| 489 (SHELF_ALIGNMENT_BOTTOM == shelf_->GetAlignment() && | 485 (SHELF_ALIGNMENT_BOTTOM == shelf_->GetAlignment() && |
| 490 dock_bounds.x() == 0 && dock_bounds.width() > 0) | 486 dock_bounds.x() == 0 && dock_bounds.width() > 0) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 0, | 527 0, |
| 532 dock_bounds.width() - height(), | 528 dock_bounds.width() - height(), |
| 533 height(), | 529 height(), |
| 534 false, | 530 false, |
| 535 paint); | 531 paint); |
| 536 } | 532 } |
| 537 gfx::Rect black_rect = | 533 gfx::Rect black_rect = |
| 538 shelf_->shelf_layout_manager()->SelectValueForShelfAlignment( | 534 shelf_->shelf_layout_manager()->SelectValueForShelfAlignment( |
| 539 gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels), | 535 gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels), |
| 540 gfx::Rect(0, 0, kNumBlackPixels, height()), | 536 gfx::Rect(0, 0, kNumBlackPixels, height()), |
| 541 gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height()), | 537 gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height())); |
| 542 gfx::Rect(0, 0, width(), kNumBlackPixels)); | |
| 543 canvas->FillRect(black_rect, SK_ColorBLACK); | 538 canvas->FillRect(black_rect, SK_ColorBLACK); |
| 544 } | 539 } |
| 545 | 540 |
| 546 bool ShelfWidget::DelegateView::CanActivate() const { | 541 bool ShelfWidget::DelegateView::CanActivate() const { |
| 547 // Allow to activate as fallback. | 542 // Allow to activate as fallback. |
| 548 if (shelf_->activating_as_fallback_) | 543 if (shelf_->activating_as_fallback_) |
| 549 return true; | 544 return true; |
| 550 // Allow to activate from the focus cycler. | 545 // Allow to activate from the focus cycler. |
| 551 if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget()) | 546 if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget()) |
| 552 return true; | 547 return true; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 DCHECK(delegate_view_); | 830 DCHECK(delegate_view_); |
| 836 return delegate_view_->disable_dimming_animations_for_test(); | 831 return delegate_view_->disable_dimming_animations_for_test(); |
| 837 } | 832 } |
| 838 | 833 |
| 839 void ShelfWidget::WillDeleteShelf() { | 834 void ShelfWidget::WillDeleteShelf() { |
| 840 shelf_layout_manager_->RemoveObserver(this); | 835 shelf_layout_manager_->RemoveObserver(this); |
| 841 shelf_layout_manager_ = NULL; | 836 shelf_layout_manager_ = NULL; |
| 842 } | 837 } |
| 843 | 838 |
| 844 } // namespace ash | 839 } // namespace ash |
| OLD | NEW |