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/aura/wm_shelf_aura.h" | 10 #include "ash/aura/wm_shelf_aura.h" |
| 11 #include "ash/common/shelf/wm_shelf_util.h" |
11 #include "ash/common/shell_window_ids.h" | 12 #include "ash/common/shell_window_ids.h" |
12 #include "ash/common/wm/shelf/wm_shelf_util.h" | |
13 #include "ash/focus_cycler.h" | 13 #include "ash/focus_cycler.h" |
14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
15 #include "ash/root_window_settings.h" | 15 #include "ash/root_window_settings.h" |
16 #include "ash/screen_util.h" | 16 #include "ash/screen_util.h" |
17 #include "ash/shelf/shelf_delegate.h" | 17 #include "ash/shelf/shelf_delegate.h" |
18 #include "ash/shelf/shelf_item_delegate.h" | 18 #include "ash/shelf/shelf_item_delegate.h" |
19 #include "ash/shelf/shelf_item_delegate_manager.h" | 19 #include "ash/shelf/shelf_item_delegate_manager.h" |
20 #include "ash/shelf/shelf_layout_manager.h" | 20 #include "ash/shelf/shelf_layout_manager.h" |
21 #include "ash/shelf/shelf_model.h" | 21 #include "ash/shelf/shelf_model.h" |
22 #include "ash/shelf/shelf_navigator.h" | 22 #include "ash/shelf/shelf_navigator.h" |
(...skipping 23 matching lines...) Expand all Loading... |
46 ShelfWidget* shelf_widget) | 46 ShelfWidget* shelf_widget) |
47 : delegate_(shelf_delegate), | 47 : delegate_(shelf_delegate), |
48 shelf_widget_(shelf_widget), | 48 shelf_widget_(shelf_widget), |
49 shelf_view_(new ShelfView(shelf_model, delegate_, this)), | 49 shelf_view_(new ShelfView(shelf_model, delegate_, this)), |
50 shelf_locking_manager_(this) { | 50 shelf_locking_manager_(this) { |
51 shelf_view_->Init(); | 51 shelf_view_->Init(); |
52 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 52 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); |
53 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | 53 shelf_widget_->GetNativeView()->SetName(kNativeViewName); |
54 // This has to be done after the ShelfWidget and ShelfLayoutManager have | 54 // This has to be done after the ShelfWidget and ShelfLayoutManager have |
55 // been created. | 55 // been created. |
56 wm_shelf_.reset(new wm::WmShelfAura(this)); | 56 wm_shelf_.reset(new WmShelfAura(this)); |
57 } | 57 } |
58 | 58 |
59 Shelf::~Shelf() { | 59 Shelf::~Shelf() { |
60 delegate_->OnShelfDestroyed(this); | 60 delegate_->OnShelfDestroyed(this); |
61 } | 61 } |
62 | 62 |
63 // static | 63 // static |
64 Shelf* Shelf::ForPrimaryDisplay() { | 64 Shelf* Shelf::ForPrimaryDisplay() { |
65 return Shelf::ForWindow(Shell::GetPrimaryRootWindow()); | 65 return Shelf::ForWindow(Shell::GetPrimaryRootWindow()); |
66 } | 66 } |
(...skipping 10 matching lines...) Expand all Loading... |
77 for (aura::Window* window : Shell::GetInstance()->GetAllRootWindows()) { | 77 for (aura::Window* window : Shell::GetInstance()->GetAllRootWindows()) { |
78 RootWindowSettings* settings = GetRootWindowSettings(window); | 78 RootWindowSettings* settings = GetRootWindowSettings(window); |
79 if (settings->display_id == display_id && settings->controller) { | 79 if (settings->display_id == display_id && settings->controller) { |
80 ShelfWidget* shelf_widget = settings->controller->shelf_widget(); | 80 ShelfWidget* shelf_widget = settings->controller->shelf_widget(); |
81 return shelf_widget ? shelf_widget->shelf() : nullptr; | 81 return shelf_widget ? shelf_widget->shelf() : nullptr; |
82 } | 82 } |
83 } | 83 } |
84 return nullptr; | 84 return nullptr; |
85 } | 85 } |
86 | 86 |
87 void Shelf::SetAlignment(wm::ShelfAlignment alignment) { | 87 void Shelf::SetAlignment(ShelfAlignment alignment) { |
88 if (alignment_ == alignment) | 88 if (alignment_ == alignment) |
89 return; | 89 return; |
90 | 90 |
91 if (shelf_locking_manager_.is_locked() && | 91 if (shelf_locking_manager_.is_locked() && |
92 alignment != wm::SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 92 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
93 shelf_locking_manager_.set_stored_alignment(alignment); | 93 shelf_locking_manager_.set_stored_alignment(alignment); |
94 return; | 94 return; |
95 } | 95 } |
96 | 96 |
97 alignment_ = alignment; | 97 alignment_ = alignment; |
98 shelf_view_->OnShelfAlignmentChanged(); | 98 shelf_view_->OnShelfAlignmentChanged(); |
99 shelf_widget_->OnShelfAlignmentChanged(); | 99 shelf_widget_->OnShelfAlignmentChanged(); |
100 delegate_->OnShelfAlignmentChanged(this); | 100 delegate_->OnShelfAlignmentChanged(this); |
101 Shell::GetInstance()->OnShelfAlignmentChanged( | 101 Shell::GetInstance()->OnShelfAlignmentChanged( |
102 shelf_widget_->GetNativeWindow()->GetRootWindow()); | 102 shelf_widget_->GetNativeWindow()->GetRootWindow()); |
103 // ShelfLayoutManager will resize the shelf. | 103 // ShelfLayoutManager will resize the shelf. |
104 } | 104 } |
105 | 105 |
106 bool Shelf::IsHorizontalAlignment() const { | 106 bool Shelf::IsHorizontalAlignment() const { |
107 return wm::IsHorizontalAlignment(alignment_); | 107 return ::ash::IsHorizontalAlignment(alignment_); |
108 } | 108 } |
109 | 109 |
110 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { | 110 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { |
111 if (auto_hide_behavior_ == auto_hide_behavior) | 111 if (auto_hide_behavior_ == auto_hide_behavior) |
112 return; | 112 return; |
113 | 113 |
114 auto_hide_behavior_ = auto_hide_behavior; | 114 auto_hide_behavior_ = auto_hide_behavior; |
115 delegate_->OnShelfAutoHideBehaviorChanged(this); | 115 delegate_->OnShelfAutoHideBehaviorChanged(this); |
116 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( | 116 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( |
117 shelf_widget_->GetNativeWindow()->GetRootWindow()); | 117 shelf_widget_->GetNativeWindow()->GetRootWindow()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { | 226 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { |
227 return shelf_view_->GetVisibleItemsBoundsInScreen(); | 227 return shelf_view_->GetVisibleItemsBoundsInScreen(); |
228 } | 228 } |
229 | 229 |
230 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 230 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
231 return shelf_view_; | 231 return shelf_view_; |
232 } | 232 } |
233 | 233 |
234 } // namespace ash | 234 } // namespace ash |
OLD | NEW |