Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2122)

Unified Diff: ash/common/shelf/shelf.cc

Issue 2274333002: ash: Move more code from Shelf to WmShelf (Closed)
Patch Set: review comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/shelf.h ('k') | ash/common/shelf/shelf_navigator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/shelf.cc
diff --git a/ash/common/shelf/shelf.cc b/ash/common/shelf/shelf.cc
index 6678eb60eddb1707961194c6660e1ddfb1dce511..ca8fba3bb858dafcfce5ddf213133055f3dc6545 100644
--- a/ash/common/shelf/shelf.cc
+++ b/ash/common/shelf/shelf.cc
@@ -5,18 +5,11 @@
#include "ash/common/shelf/shelf.h"
#include "ash/common/shelf/shelf_delegate.h"
-#include "ash/common/shelf/shelf_item_delegate.h"
-#include "ash/common/shelf/shelf_model.h"
-#include "ash/common/shelf/shelf_navigator.h"
#include "ash/common/shelf/shelf_view.h"
#include "ash/common/shelf/wm_shelf.h"
-#include "ash/common/wm_lookup.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
-#include "ash/common/wm_window_property.h"
-#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/rect.h"
namespace ash {
@@ -45,83 +38,12 @@ Shelf* Shelf::ForWindow(WmWindow* window) {
return window->GetRootWindowController()->GetShelf()->shelf();
}
-gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(WmWindow* window) {
- ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID);
- gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id));
- gfx::Point screen_origin;
- views::View::ConvertPointToScreen(shelf_view_, &screen_origin);
- return gfx::Rect(screen_origin.x() + bounds.x(),
- screen_origin.y() + bounds.y(), bounds.width(),
- bounds.height());
-}
-
-void Shelf::UpdateIconPositionForWindow(WmWindow* window) {
- WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_);
- shelf_view_->UpdatePanelIconPosition(
- window->GetIntProperty(WmWindowProperty::SHELF_ID),
- shelf_window->ConvertRectFromScreen(window->GetBoundsInScreen())
- .CenterPoint());
-}
-
-void Shelf::ActivateShelfItem(int index) {
- // We pass in a keyboard event which will then trigger a switch to the
- // next item if the current one is already active.
- ui::KeyEvent event(ui::ET_KEY_RELEASED,
- ui::VKEY_UNKNOWN, // The actual key gets ignored.
- ui::EF_NONE);
-
- ShelfModel* shelf_model = WmShell::Get()->shelf_model();
- const ShelfItem& item = shelf_model->items()[index];
- ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id);
- item_delegate->ItemSelected(event);
-}
-
-void Shelf::CycleWindowLinear(CycleDirection direction) {
- int item_index =
- GetNextActivatedItemIndex(*WmShell::Get()->shelf_model(), direction);
- if (item_index >= 0)
- ActivateShelfItem(item_index);
-}
-
AppListButton* Shelf::GetAppListButton() const {
return shelf_view_->GetAppListButton();
}
-void Shelf::LaunchAppIndexAt(int item_index) {
- ShelfModel* shelf_model = WmShell::Get()->shelf_model();
- const ShelfItems& items = shelf_model->items();
- int item_count = shelf_model->item_count();
- int indexes_left = item_index >= 0 ? item_index : item_count;
- int found_index = -1;
-
- // Iterating until we have hit the index we are interested in which
- // is true once indexes_left becomes negative.
- for (int i = 0; i < item_count && indexes_left >= 0; i++) {
- if (items[i].type != TYPE_APP_LIST) {
- found_index = i;
- indexes_left--;
- }
- }
-
- // There are two ways how found_index can be valid: a.) the nth item was
- // found (which is true when indexes_left is -1) or b.) the last item was
- // requested (which is true when index was passed in as a negative number).
- if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) {
- // Then set this one as active (or advance to the next item of its kind).
- ActivateShelfItem(found_index);
- }
-}
-
-gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const {
- return shelf_view_->GetVisibleItemsBoundsInScreen();
-}
-
app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() {
return shelf_view_;
}
-void Shelf::UpdateShelfItemBackground(int alpha) {
- shelf_view_->UpdateShelfItemBackground(alpha);
-}
-
} // namespace ash
« no previous file with comments | « ash/common/shelf/shelf.h ('k') | ash/common/shelf/shelf_navigator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698