Chromium Code Reviews| 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" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 26 #include "ui/gfx/image/image_skia_operations.h" | 26 #include "ui/gfx/image/image_skia_operations.h" |
| 27 #include "ui/gfx/skbitmap_operations.h" | 27 #include "ui/gfx/skbitmap_operations.h" |
| 28 #include "ui/views/accessible_pane_view.h" | 28 #include "ui/views/accessible_pane_view.h" |
| 29 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 30 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
| 31 #include "ui/wm/public/activation_client.h" | 31 #include "ui/wm/public/activation_client.h" |
| 32 | 32 |
| 33 namespace ash { | 33 namespace ash { |
| 34 | 34 |
| 35 const char Shelf::kNativeViewName[] = "ShelfView"; | 35 Shelf::Shelf(WmShelf* wm_shelf, |
| 36 | 36 ShelfView* shelf_view, |
| 37 Shelf::Shelf(ShelfModel* shelf_model, | |
| 38 WmShelf* wm_shelf, | |
| 39 ShelfWidget* shelf_widget) | 37 ShelfWidget* shelf_widget) |
| 40 : wm_shelf_(wm_shelf), | 38 : wm_shelf_(wm_shelf), |
| 41 shelf_widget_(shelf_widget), | 39 shelf_widget_(shelf_widget), |
| 42 shelf_view_(new ShelfView(shelf_model, | 40 shelf_view_(shelf_view), |
|
James Cook
2016/08/12 22:00:47
I'd like to eliminate this member, but it's a bit
msw
2016/08/12 22:39:53
Acknowledged.
| |
| 43 WmShell::Get()->shelf_delegate(), | |
| 44 wm_shelf, | |
| 45 shelf_widget)), | |
| 46 shelf_locking_manager_(wm_shelf) { | 41 shelf_locking_manager_(wm_shelf) { |
| 47 DCHECK(wm_shelf_); | 42 DCHECK(wm_shelf_); |
| 48 shelf_view_->Init(); | 43 DCHECK(shelf_view_); |
| 49 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 44 DCHECK(shelf_widget_); |
| 50 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | |
| 51 } | 45 } |
| 52 | 46 |
| 53 Shelf::~Shelf() { | 47 Shelf::~Shelf() { |
| 54 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); | 48 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); |
| 55 } | 49 } |
| 56 | 50 |
| 57 // static | 51 // static |
| 58 Shelf* Shelf::ForPrimaryDisplay() { | 52 Shelf* Shelf::ForPrimaryDisplay() { |
| 59 return Shelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()); | 53 return Shelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()); |
| 60 } | 54 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 .CenterPoint()); | 116 .CenterPoint()); |
| 123 } | 117 } |
| 124 | 118 |
| 125 void Shelf::ActivateShelfItem(int index) { | 119 void Shelf::ActivateShelfItem(int index) { |
| 126 // We pass in a keyboard event which will then trigger a switch to the | 120 // We pass in a keyboard event which will then trigger a switch to the |
| 127 // next item if the current one is already active. | 121 // next item if the current one is already active. |
| 128 ui::KeyEvent event(ui::ET_KEY_RELEASED, | 122 ui::KeyEvent event(ui::ET_KEY_RELEASED, |
| 129 ui::VKEY_UNKNOWN, // The actual key gets ignored. | 123 ui::VKEY_UNKNOWN, // The actual key gets ignored. |
| 130 ui::EF_NONE); | 124 ui::EF_NONE); |
| 131 | 125 |
| 132 const ShelfItem& item = shelf_view_->model()->items()[index]; | 126 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); |
| 133 ShelfItemDelegate* item_delegate = | 127 const ShelfItem& item = shelf_model->items()[index]; |
| 134 shelf_view_->model()->GetShelfItemDelegate(item.id); | 128 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); |
| 135 item_delegate->ItemSelected(event); | 129 item_delegate->ItemSelected(event); |
| 136 } | 130 } |
| 137 | 131 |
| 138 void Shelf::CycleWindowLinear(CycleDirection direction) { | 132 void Shelf::CycleWindowLinear(CycleDirection direction) { |
| 139 int item_index = | 133 int item_index = |
| 140 GetNextActivatedItemIndex(*(shelf_view_->model()), direction); | 134 GetNextActivatedItemIndex(*WmShell::Get()->shelf_model(), direction); |
| 141 if (item_index >= 0) | 135 if (item_index >= 0) |
| 142 ActivateShelfItem(item_index); | 136 ActivateShelfItem(item_index); |
| 143 } | 137 } |
| 144 | 138 |
| 145 void Shelf::AddIconObserver(ShelfIconObserver* observer) { | 139 void Shelf::AddIconObserver(ShelfIconObserver* observer) { |
| 146 shelf_view_->AddIconObserver(observer); | 140 shelf_view_->AddIconObserver(observer); |
| 147 } | 141 } |
| 148 | 142 |
| 149 void Shelf::RemoveIconObserver(ShelfIconObserver* observer) { | 143 void Shelf::RemoveIconObserver(ShelfIconObserver* observer) { |
| 150 shelf_view_->RemoveIconObserver(observer); | 144 shelf_view_->RemoveIconObserver(observer); |
| 151 } | 145 } |
| 152 | 146 |
| 153 bool Shelf::IsShowingMenu() const { | 147 bool Shelf::IsShowingMenu() const { |
| 154 return shelf_view_->IsShowingMenu(); | 148 return shelf_view_->IsShowingMenu(); |
| 155 } | 149 } |
| 156 | 150 |
| 157 bool Shelf::IsShowingOverflowBubble() const { | 151 bool Shelf::IsShowingOverflowBubble() const { |
| 158 return shelf_view_->IsShowingOverflowBubble(); | 152 return shelf_view_->IsShowingOverflowBubble(); |
| 159 } | 153 } |
| 160 | 154 |
| 161 void Shelf::SetVisible(bool visible) const { | |
| 162 shelf_view_->SetVisible(visible); | |
| 163 } | |
| 164 | |
| 165 bool Shelf::IsVisible() const { | 155 bool Shelf::IsVisible() const { |
| 166 return shelf_view_->visible(); | 156 return shelf_view_->visible(); |
| 167 } | 157 } |
| 168 | 158 |
| 169 void Shelf::SchedulePaint() { | 159 void Shelf::SchedulePaint() { |
| 170 shelf_view_->SchedulePaintForAllButtons(); | 160 shelf_view_->SchedulePaintForAllButtons(); |
| 171 } | 161 } |
| 172 | 162 |
| 173 AppListButton* Shelf::GetAppListButton() const { | 163 AppListButton* Shelf::GetAppListButton() const { |
| 174 return shelf_view_->GetAppListButton(); | 164 return shelf_view_->GetAppListButton(); |
| 175 } | 165 } |
| 176 | 166 |
| 177 void Shelf::LaunchAppIndexAt(int item_index) { | 167 void Shelf::LaunchAppIndexAt(int item_index) { |
| 178 ShelfModel* shelf_model = shelf_view_->model(); | 168 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); |
| 179 const ShelfItems& items = shelf_model->items(); | 169 const ShelfItems& items = shelf_model->items(); |
| 180 int item_count = shelf_model->item_count(); | 170 int item_count = shelf_model->item_count(); |
| 181 int indexes_left = item_index >= 0 ? item_index : item_count; | 171 int indexes_left = item_index >= 0 ? item_index : item_count; |
| 182 int found_index = -1; | 172 int found_index = -1; |
| 183 | 173 |
| 184 // Iterating until we have hit the index we are interested in which | 174 // Iterating until we have hit the index we are interested in which |
| 185 // is true once indexes_left becomes negative. | 175 // is true once indexes_left becomes negative. |
| 186 for (int i = 0; i < item_count && indexes_left >= 0; i++) { | 176 for (int i = 0; i < item_count && indexes_left >= 0; i++) { |
| 187 if (items[i].type != TYPE_APP_LIST) { | 177 if (items[i].type != TYPE_APP_LIST) { |
| 188 found_index = i; | 178 found_index = i; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 205 | 195 |
| 206 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 196 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
| 207 return shelf_view_; | 197 return shelf_view_; |
| 208 } | 198 } |
| 209 | 199 |
| 210 void Shelf::UpdateShelfItemBackground(int alpha) { | 200 void Shelf::UpdateShelfItemBackground(int alpha) { |
| 211 shelf_view_->UpdateShelfItemBackground(alpha); | 201 shelf_view_->UpdateShelfItemBackground(alpha); |
| 212 } | 202 } |
| 213 | 203 |
| 214 } // namespace ash | 204 } // namespace ash |
| OLD | NEW |