| 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 24 matching lines...) Expand all Loading... |
| 35 #include "ui/views/widget/widget_delegate.h" | 35 #include "ui/views/widget/widget_delegate.h" |
| 36 #include "ui/wm/public/activation_client.h" | 36 #include "ui/wm/public/activation_client.h" |
| 37 | 37 |
| 38 namespace ash { | 38 namespace ash { |
| 39 | 39 |
| 40 const char Shelf::kNativeViewName[] = "ShelfView"; | 40 const char Shelf::kNativeViewName[] = "ShelfView"; |
| 41 | 41 |
| 42 Shelf::Shelf(ShelfModel* shelf_model, | 42 Shelf::Shelf(ShelfModel* shelf_model, |
| 43 ShelfDelegate* shelf_delegate, | 43 ShelfDelegate* shelf_delegate, |
| 44 ShelfWidget* shelf_widget) | 44 ShelfWidget* shelf_widget) |
| 45 : shelf_view_(nullptr), | 45 : delegate_(shelf_delegate), |
| 46 alignment_(SHELF_ALIGNMENT_BOTTOM), | 46 shelf_widget_(shelf_widget), |
| 47 auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER), | 47 shelf_view_(new ShelfView(shelf_model, delegate_, this)), |
| 48 delegate_(shelf_delegate), | 48 shelf_locking_manager_(this) { |
| 49 shelf_widget_(shelf_widget) { | |
| 50 shelf_view_ = new ShelfView(shelf_model, delegate_, this); | |
| 51 shelf_view_->Init(); | 49 shelf_view_->Init(); |
| 52 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 50 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); |
| 53 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | 51 shelf_widget_->GetNativeView()->SetName(kNativeViewName); |
| 54 } | 52 } |
| 55 | 53 |
| 56 Shelf::~Shelf() { | 54 Shelf::~Shelf() { |
| 57 delegate_->OnShelfDestroyed(this); | 55 delegate_->OnShelfDestroyed(this); |
| 58 } | 56 } |
| 59 | 57 |
| 60 // static | 58 // static |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 | 72 |
| 75 alignment_ = alignment; | 73 alignment_ = alignment; |
| 76 shelf_view_->OnShelfAlignmentChanged(); | 74 shelf_view_->OnShelfAlignmentChanged(); |
| 77 shelf_widget_->OnShelfAlignmentChanged(); | 75 shelf_widget_->OnShelfAlignmentChanged(); |
| 78 delegate_->OnShelfAlignmentChanged(this); | 76 delegate_->OnShelfAlignmentChanged(this); |
| 79 Shell::GetInstance()->OnShelfAlignmentChanged( | 77 Shell::GetInstance()->OnShelfAlignmentChanged( |
| 80 shelf_widget_->GetNativeWindow()->GetRootWindow()); | 78 shelf_widget_->GetNativeWindow()->GetRootWindow()); |
| 81 // ShelfLayoutManager will resize the shelf. | 79 // ShelfLayoutManager will resize the shelf. |
| 82 } | 80 } |
| 83 | 81 |
| 84 ShelfAlignment Shelf::GetAlignment() const { | |
| 85 // Bottom alignment is forced when the screen is locked or a user gets added. | |
| 86 bool locked = shelf_widget_->shelf_layout_manager()->IsAlignmentLocked(); | |
| 87 return locked ? SHELF_ALIGNMENT_BOTTOM : alignment_; | |
| 88 } | |
| 89 | |
| 90 bool Shelf::IsHorizontalAlignment() const { | 82 bool Shelf::IsHorizontalAlignment() const { |
| 91 return alignment_ == SHELF_ALIGNMENT_BOTTOM; | 83 return ash::IsHorizontalAlignment(alignment_); |
| 92 } | 84 } |
| 93 | 85 |
| 94 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { | 86 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { |
| 95 if (auto_hide_behavior_ == auto_hide_behavior) | 87 if (auto_hide_behavior_ == auto_hide_behavior) |
| 96 return; | 88 return; |
| 97 | 89 |
| 98 auto_hide_behavior_ = auto_hide_behavior; | 90 auto_hide_behavior_ = auto_hide_behavior; |
| 99 delegate_->OnShelfAutoHideBehaviorChanged(this); | 91 delegate_->OnShelfAutoHideBehaviorChanged(this); |
| 100 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( | 92 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( |
| 101 shelf_widget_->GetNativeWindow()->GetRootWindow()); | 93 shelf_widget_->GetNativeWindow()->GetRootWindow()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 197 |
| 206 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { | 198 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { |
| 207 return shelf_view_->GetVisibleItemsBoundsInScreen(); | 199 return shelf_view_->GetVisibleItemsBoundsInScreen(); |
| 208 } | 200 } |
| 209 | 201 |
| 210 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 202 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
| 211 return shelf_view_; | 203 return shelf_view_; |
| 212 } | 204 } |
| 213 | 205 |
| 214 } // namespace ash | 206 } // namespace ash |
| OLD | NEW |