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

Side by Side Diff: ash/common/shelf/shelf.cc

Issue 2272793005: ash: Move alignment and autohide behavior from Shelf to WmShelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
« no previous file with comments | « ash/common/shelf/shelf.h ('k') | ash/common/shelf/shelf_layout_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/shelf/shelf.h" 5 #include "ash/common/shelf/shelf.h"
6 6
7 #include <algorithm>
8 #include <cmath>
9
10 #include "ash/common/shelf/shelf_delegate.h" 7 #include "ash/common/shelf/shelf_delegate.h"
11 #include "ash/common/shelf/shelf_item_delegate.h" 8 #include "ash/common/shelf/shelf_item_delegate.h"
12 #include "ash/common/shelf/shelf_layout_manager.h"
13 #include "ash/common/shelf/shelf_model.h" 9 #include "ash/common/shelf/shelf_model.h"
14 #include "ash/common/shelf/shelf_navigator.h" 10 #include "ash/common/shelf/shelf_navigator.h"
15 #include "ash/common/shelf/shelf_view.h" 11 #include "ash/common/shelf/shelf_view.h"
16 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
17 #include "ash/common/shell_window_ids.h"
18 #include "ash/common/wm_lookup.h" 13 #include "ash/common/wm_lookup.h"
19 #include "ash/common/wm_root_window_controller.h" 14 #include "ash/common/wm_root_window_controller.h"
20 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
21 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
22 #include "ash/common/wm_window_property.h" 17 #include "ash/common/wm_window_property.h"
23 #include "ui/compositor/layer.h" 18 #include "ui/gfx/geometry/point.h"
24 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gfx/image/image.h"
26 #include "ui/gfx/image/image_skia_operations.h"
27 #include "ui/gfx/skbitmap_operations.h"
28 #include "ui/views/accessible_pane_view.h"
29 #include "ui/views/widget/widget.h"
30 #include "ui/views/widget/widget_delegate.h"
31 #include "ui/wm/public/activation_client.h"
32 20
33 namespace ash { 21 namespace ash {
34 22
35 Shelf::Shelf(WmShelf* wm_shelf, 23 Shelf::Shelf(WmShelf* wm_shelf,
36 ShelfView* shelf_view, 24 ShelfView* shelf_view,
37 ShelfWidget* shelf_widget) 25 ShelfWidget* shelf_widget)
38 : wm_shelf_(wm_shelf), 26 : wm_shelf_(wm_shelf),
39 shelf_widget_(shelf_widget), 27 shelf_widget_(shelf_widget),
40 shelf_view_(shelf_view), 28 shelf_view_(shelf_view) {
41 shelf_locking_manager_(wm_shelf) {
42 DCHECK(wm_shelf_); 29 DCHECK(wm_shelf_);
43 DCHECK(shelf_view_); 30 DCHECK(shelf_view_);
44 DCHECK(shelf_widget_); 31 DCHECK(shelf_widget_);
45 } 32 }
46 33
47 Shelf::~Shelf() { 34 Shelf::~Shelf() {
48 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this); 35 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this);
49 } 36 }
50 37
51 // static 38 // static
52 Shelf* Shelf::ForPrimaryDisplay() { 39 Shelf* Shelf::ForPrimaryDisplay() {
53 return Shelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow()); 40 return Shelf::ForWindow(WmShell::Get()->GetPrimaryRootWindow());
54 } 41 }
55 42
56 // static 43 // static
57 Shelf* Shelf::ForWindow(WmWindow* window) { 44 Shelf* Shelf::ForWindow(WmWindow* window) {
58 return window->GetRootWindowController()->GetShelf()->shelf(); 45 return window->GetRootWindowController()->GetShelf()->shelf();
59 } 46 }
60 47
61 void Shelf::SetAlignment(ShelfAlignment alignment) {
62 if (alignment_ == alignment)
63 return;
64
65 if (shelf_locking_manager_.is_locked() &&
66 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) {
67 shelf_locking_manager_.set_stored_alignment(alignment);
68 return;
69 }
70
71 alignment_ = alignment;
72 shelf_view_->OnShelfAlignmentChanged();
73 shelf_widget_->OnShelfAlignmentChanged();
74 WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this);
75 WmShell::Get()->NotifyShelfAlignmentChanged(
76 WmLookup::Get()->GetWindowForWidget(shelf_widget_)->GetRootWindow());
77 // ShelfLayoutManager will resize the shelf.
78 }
79
80 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) {
81 if (auto_hide_behavior_ == auto_hide_behavior)
82 return;
83
84 auto_hide_behavior_ = auto_hide_behavior;
85 WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this);
86 WmShell::Get()->NotifyShelfAutoHideBehaviorChanged(
87 WmLookup::Get()->GetWindowForWidget(shelf_widget_)->GetRootWindow());
88 }
89
90 ShelfAutoHideState Shelf::GetAutoHideState() const {
91 return shelf_widget_->shelf_layout_manager()->auto_hide_state();
92 }
93
94 ShelfVisibilityState Shelf::GetVisibilityState() const {
95 return shelf_widget_->shelf_layout_manager()->visibility_state();
96 }
97
98 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { 48 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(WmWindow* window) {
99 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID); 49 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID);
100 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); 50 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id));
101 gfx::Point screen_origin; 51 gfx::Point screen_origin;
102 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); 52 views::View::ConvertPointToScreen(shelf_view_, &screen_origin);
103 return gfx::Rect(screen_origin.x() + bounds.x(), 53 return gfx::Rect(screen_origin.x() + bounds.x(),
104 screen_origin.y() + bounds.y(), bounds.width(), 54 screen_origin.y() + bounds.y(), bounds.width(),
105 bounds.height()); 55 bounds.height());
106 } 56 }
107 57
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 118
169 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { 119 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() {
170 return shelf_view_; 120 return shelf_view_;
171 } 121 }
172 122
173 void Shelf::UpdateShelfItemBackground(int alpha) { 123 void Shelf::UpdateShelfItemBackground(int alpha) {
174 shelf_view_->UpdateShelfItemBackground(alpha); 124 shelf_view_->UpdateShelfItemBackground(alpha);
175 } 125 }
176 126
177 } // namespace ash 127 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf.h ('k') | ash/common/shelf/shelf_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698