| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.h" | 5 #include "ash/shelf/shelf.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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 const char Shelf::kNativeViewName[] = "ShelfView"; | 43 const char Shelf::kNativeViewName[] = "ShelfView"; |
| 44 | 44 |
| 45 Shelf::Shelf(ShelfModel* shelf_model, | 45 Shelf::Shelf(ShelfModel* shelf_model, |
| 46 ShelfDelegate* shelf_delegate, | 46 ShelfDelegate* shelf_delegate, |
| 47 ShelfWidget* shelf_widget) | 47 ShelfWidget* shelf_widget) |
| 48 : shelf_view_(NULL), | 48 : shelf_view_(NULL), |
| 49 alignment_(shelf_widget->GetAlignment()), | 49 alignment_(shelf_widget->GetAlignment()), |
| 50 delegate_(shelf_delegate), | 50 delegate_(shelf_delegate), |
| 51 shelf_widget_(shelf_widget) { | 51 shelf_widget_(shelf_widget) { |
| 52 shelf_view_ = new internal::ShelfView( | 52 shelf_view_ = new ShelfView( |
| 53 shelf_model, delegate_, shelf_widget_->shelf_layout_manager()); | 53 shelf_model, delegate_, shelf_widget_->shelf_layout_manager()); |
| 54 shelf_view_->Init(); | 54 shelf_view_->Init(); |
| 55 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 55 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); |
| 56 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | 56 shelf_widget_->GetNativeView()->SetName(kNativeViewName); |
| 57 delegate_->OnShelfCreated(this); | 57 delegate_->OnShelfCreated(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 Shelf::~Shelf() { | 60 Shelf::~Shelf() { |
| 61 delegate_->OnShelfDestroyed(this); | 61 delegate_->OnShelfDestroyed(this); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 Shelf* Shelf::ForPrimaryDisplay() { | 65 Shelf* Shelf::ForPrimaryDisplay() { |
| 66 ShelfWidget* shelf_widget = internal::RootWindowController::ForShelf( | 66 ShelfWidget* shelf_widget = |
| 67 Shell::GetPrimaryRootWindow())->shelf(); | 67 RootWindowController::ForShelf(Shell::GetPrimaryRootWindow())->shelf(); |
| 68 return shelf_widget ? shelf_widget->shelf() : NULL; | 68 return shelf_widget ? shelf_widget->shelf() : NULL; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 Shelf* Shelf::ForWindow(aura::Window* window) { | 72 Shelf* Shelf::ForWindow(aura::Window* window) { |
| 73 ShelfWidget* shelf_widget = | 73 ShelfWidget* shelf_widget = RootWindowController::ForShelf(window)->shelf(); |
| 74 internal::RootWindowController::ForShelf(window)->shelf(); | |
| 75 return shelf_widget ? shelf_widget->shelf() : NULL; | 74 return shelf_widget ? shelf_widget->shelf() : NULL; |
| 76 } | 75 } |
| 77 | 76 |
| 78 void Shelf::SetAlignment(ShelfAlignment alignment) { | 77 void Shelf::SetAlignment(ShelfAlignment alignment) { |
| 79 alignment_ = alignment; | 78 alignment_ = alignment; |
| 80 shelf_view_->OnShelfAlignmentChanged(); | 79 shelf_view_->OnShelfAlignmentChanged(); |
| 81 // ShelfLayoutManager will resize the shelf. | 80 // ShelfLayoutManager will resize the shelf. |
| 82 } | 81 } |
| 83 | 82 |
| 84 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { | 83 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 188 |
| 190 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { | 189 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { |
| 191 return shelf_view_->GetVisibleItemsBoundsInScreen(); | 190 return shelf_view_->GetVisibleItemsBoundsInScreen(); |
| 192 } | 191 } |
| 193 | 192 |
| 194 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 193 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
| 195 return shelf_view_; | 194 return shelf_view_; |
| 196 } | 195 } |
| 197 | 196 |
| 198 } // namespace ash | 197 } // namespace ash |
| OLD | NEW |