| 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_window_aura.h" | 10 #include "ash/aura/wm_window_aura.h" |
| 11 #include "ash/common/shelf/shelf_delegate.h" | 11 #include "ash/common/shelf/shelf_delegate.h" |
| 12 #include "ash/common/shelf/shelf_item_delegate.h" | 12 #include "ash/common/shelf/shelf_item_delegate.h" |
| 13 #include "ash/common/shelf/shelf_model.h" | 13 #include "ash/common/shelf/shelf_model.h" |
| 14 #include "ash/common/shelf/shelf_navigator.h" | 14 #include "ash/common/shelf/shelf_navigator.h" |
| 15 #include "ash/common/shelf/wm_shelf_util.h" | 15 #include "ash/common/shelf/shelf_view.h" |
| 16 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
| 17 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 18 #include "ash/root_window_controller.h" | 18 #include "ash/root_window_controller.h" |
| 19 #include "ash/screen_util.h" | 19 #include "ash/screen_util.h" |
| 20 #include "ash/shelf/shelf_layout_manager.h" | 20 #include "ash/shelf/shelf_layout_manager.h" |
| 21 #include "ash/shelf/shelf_util.h" | 21 #include "ash/shelf/shelf_util.h" |
| 22 #include "ash/shelf/shelf_view.h" | |
| 23 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 24 #include "ash/wm/window_properties.h" | 23 #include "ash/wm/window_properties.h" |
| 25 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_event_dispatcher.h" | 25 #include "ui/aura/window_event_dispatcher.h" |
| 27 #include "ui/aura/window_observer.h" | 26 #include "ui/aura/window_observer.h" |
| 28 #include "ui/compositor/layer.h" | 27 #include "ui/compositor/layer.h" |
| 29 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 30 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 31 #include "ui/gfx/image/image_skia_operations.h" | 30 #include "ui/gfx/image/image_skia_operations.h" |
| 32 #include "ui/gfx/skbitmap_operations.h" | 31 #include "ui/gfx/skbitmap_operations.h" |
| 33 #include "ui/views/accessible_pane_view.h" | 32 #include "ui/views/accessible_pane_view.h" |
| 34 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 35 #include "ui/views/widget/widget_delegate.h" | 34 #include "ui/views/widget/widget_delegate.h" |
| 36 #include "ui/wm/public/activation_client.h" | 35 #include "ui/wm/public/activation_client.h" |
| 37 | 36 |
| 38 namespace ash { | 37 namespace ash { |
| 39 | 38 |
| 40 const char Shelf::kNativeViewName[] = "ShelfView"; | 39 const char Shelf::kNativeViewName[] = "ShelfView"; |
| 41 | 40 |
| 42 Shelf::Shelf(ShelfModel* shelf_model, | 41 Shelf::Shelf(ShelfModel* shelf_model, |
| 43 WmShelf* wm_shelf, | 42 WmShelf* wm_shelf, |
| 44 ShelfWidget* shelf_widget) | 43 ShelfWidget* shelf_widget) |
| 45 : wm_shelf_(wm_shelf), | 44 : wm_shelf_(wm_shelf), |
| 46 shelf_widget_(shelf_widget), | 45 shelf_widget_(shelf_widget), |
| 47 shelf_view_(new ShelfView(shelf_model, | 46 shelf_view_(new ShelfView(shelf_model, |
| 48 WmShell::Get()->shelf_delegate(), | 47 WmShell::Get()->shelf_delegate(), |
| 49 wm_shelf, | 48 wm_shelf, |
| 50 this)), | 49 shelf_widget)), |
| 51 shelf_locking_manager_(wm_shelf) { | 50 shelf_locking_manager_(wm_shelf) { |
| 52 DCHECK(wm_shelf_); | 51 DCHECK(wm_shelf_); |
| 53 shelf_view_->Init(); | 52 shelf_view_->Init(); |
| 54 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 53 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); |
| 55 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | 54 shelf_widget_->GetNativeView()->SetName(kNativeViewName); |
| 56 } | 55 } |
| 57 | 56 |
| 58 Shelf::~Shelf() { | 57 Shelf::~Shelf() { |
| 59 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); | 58 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); |
| 60 } | 59 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 | 82 |
| 84 alignment_ = alignment; | 83 alignment_ = alignment; |
| 85 shelf_view_->OnShelfAlignmentChanged(); | 84 shelf_view_->OnShelfAlignmentChanged(); |
| 86 shelf_widget_->OnShelfAlignmentChanged(); | 85 shelf_widget_->OnShelfAlignmentChanged(); |
| 87 WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this); | 86 WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this); |
| 88 Shell::GetInstance()->OnShelfAlignmentChanged( | 87 Shell::GetInstance()->OnShelfAlignmentChanged( |
| 89 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); | 88 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); |
| 90 // ShelfLayoutManager will resize the shelf. | 89 // ShelfLayoutManager will resize the shelf. |
| 91 } | 90 } |
| 92 | 91 |
| 93 bool Shelf::IsHorizontalAlignment() const { | |
| 94 return ::ash::IsHorizontalAlignment(alignment_); | |
| 95 } | |
| 96 | |
| 97 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { | 92 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { |
| 98 if (auto_hide_behavior_ == auto_hide_behavior) | 93 if (auto_hide_behavior_ == auto_hide_behavior) |
| 99 return; | 94 return; |
| 100 | 95 |
| 101 auto_hide_behavior_ = auto_hide_behavior; | 96 auto_hide_behavior_ = auto_hide_behavior; |
| 102 WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this); | 97 WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this); |
| 103 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( | 98 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( |
| 104 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); | 99 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); |
| 105 } | 100 } |
| 106 | 101 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 209 |
| 215 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 210 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
| 216 return shelf_view_; | 211 return shelf_view_; |
| 217 } | 212 } |
| 218 | 213 |
| 219 void Shelf::UpdateShelfItemBackground(int alpha) { | 214 void Shelf::UpdateShelfItemBackground(int alpha) { |
| 220 shelf_view_->UpdateShelfItemBackground(alpha); | 215 shelf_view_->UpdateShelfItemBackground(alpha); |
| 221 } | 216 } |
| 222 | 217 |
| 223 } // namespace ash | 218 } // namespace ash |
| OLD | NEW |