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

Side by Side Diff: ash/common/shelf/shelf_layout_manager.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_layout_manager.h ('k') | ash/common/shelf/shelf_widget.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/common/material_design/material_design_controller.h" 11 #include "ash/common/material_design/material_design_controller.h"
12 #include "ash/common/session/session_state_delegate.h" 12 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shelf/shelf.h"
14 #include "ash/common/shelf/shelf_constants.h" 13 #include "ash/common/shelf/shelf_constants.h"
15 #include "ash/common/shelf/shelf_delegate.h" 14 #include "ash/common/shelf/shelf_delegate.h"
16 #include "ash/common/shelf/shelf_layout_manager_observer.h" 15 #include "ash/common/shelf/shelf_layout_manager_observer.h"
16 #include "ash/common/shelf/wm_shelf.h"
17 #include "ash/common/shelf/wm_shelf_util.h" 17 #include "ash/common/shelf/wm_shelf_util.h"
18 #include "ash/common/shell_window_ids.h" 18 #include "ash/common/shell_window_ids.h"
19 #include "ash/common/system/status_area_widget.h" 19 #include "ash/common/system/status_area_widget.h"
20 #include "ash/common/wm/fullscreen_window_finder.h" 20 #include "ash/common/wm/fullscreen_window_finder.h"
21 #include "ash/common/wm/mru_window_tracker.h" 21 #include "ash/common/wm/mru_window_tracker.h"
22 #include "ash/common/wm/window_state.h" 22 #include "ash/common/wm/window_state.h"
23 #include "ash/common/wm/wm_screen_util.h" 23 #include "ash/common/wm/wm_screen_util.h"
24 #include "ash/common/wm_lookup.h" 24 #include "ash/common/wm_lookup.h"
25 #include "ash/common/wm_root_window_controller.h" 25 #include "ash/common/wm_root_window_controller.h"
26 #include "ash/common/wm_root_window_controller_observer.h" 26 #include "ash/common/wm_root_window_controller_observer.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 private: 138 private:
139 ShelfLayoutManager* shelf_layout_manager_; 139 ShelfLayoutManager* shelf_layout_manager_;
140 WmRootWindowController* root_window_controller_; 140 WmRootWindowController* root_window_controller_;
141 141
142 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl); 142 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl);
143 }; 143 };
144 144
145 // ShelfLayoutManager ---------------------------------------------------------- 145 // ShelfLayoutManager ----------------------------------------------------------
146 146
147 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget) 147 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget,
148 WmShelf* wm_shelf)
148 : updating_bounds_(false), 149 : updating_bounds_(false),
149 shelf_widget_(shelf_widget), 150 shelf_widget_(shelf_widget),
151 wm_shelf_(wm_shelf),
150 window_overlaps_shelf_(false), 152 window_overlaps_shelf_(false),
151 mouse_over_shelf_when_auto_hide_timer_started_(false), 153 mouse_over_shelf_when_auto_hide_timer_started_(false),
152 gesture_drag_status_(GESTURE_DRAG_NONE), 154 gesture_drag_status_(GESTURE_DRAG_NONE),
153 gesture_drag_amount_(0.f), 155 gesture_drag_amount_(0.f),
154 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), 156 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
155 update_shelf_observer_(NULL), 157 update_shelf_observer_(NULL),
156 chromevox_panel_height_(0), 158 chromevox_panel_height_(0),
157 duration_override_in_ms_(0), 159 duration_override_in_ms_(0),
158 root_window_controller_observer_( 160 root_window_controller_observer_(
159 new RootWindowControllerObserverImpl(this)) { 161 new RootWindowControllerObserverImpl(this)) {
160 DCHECK(shelf_widget_); 162 DCHECK(shelf_widget_);
163 DCHECK(wm_shelf_);
161 WmShell::Get()->AddShellObserver(this); 164 WmShell::Get()->AddShellObserver(this);
162 WmShell::Get()->AddLockStateObserver(this); 165 WmShell::Get()->AddLockStateObserver(this);
163 WmShell::Get()->AddActivationObserver(this); 166 WmShell::Get()->AddActivationObserver(this);
164 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 167 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
165 } 168 }
166 169
167 ShelfLayoutManager::~ShelfLayoutManager() { 170 ShelfLayoutManager::~ShelfLayoutManager() {
168 if (update_shelf_observer_) 171 if (update_shelf_observer_)
169 update_shelf_observer_->Detach(); 172 update_shelf_observer_->Detach();
170 173
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // Update insets in ShelfWindowTargeter when shelf bounds change. 218 // Update insets in ShelfWindowTargeter when shelf bounds change.
216 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 219 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
217 WillChangeVisibilityState(visibility_state())); 220 WillChangeVisibilityState(visibility_state()));
218 } 221 }
219 222
220 void ShelfLayoutManager::LayoutShelf() { 223 void ShelfLayoutManager::LayoutShelf() {
221 LayoutShelfAndUpdateBounds(true); 224 LayoutShelfAndUpdateBounds(true);
222 } 225 }
223 226
224 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { 227 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() {
225 switch (shelf_widget_->shelf()->auto_hide_behavior()) { 228 switch (wm_shelf_->auto_hide_behavior()) {
226 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: 229 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
227 return SHELF_AUTO_HIDE; 230 return SHELF_AUTO_HIDE;
228 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: 231 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
229 return SHELF_VISIBLE; 232 return SHELF_VISIBLE;
230 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: 233 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN:
231 return SHELF_HIDDEN; 234 return SHELF_HIDDEN;
232 } 235 }
233 return SHELF_VISIBLE; 236 return SHELF_VISIBLE;
234 } 237 }
235 238
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 ShelfAutoHideBehavior new_auto_hide_behavior = 1158 ShelfAutoHideBehavior new_auto_hide_behavior =
1156 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN 1159 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN
1157 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER 1160 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER
1158 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; 1161 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
1159 1162
1160 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide 1163 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide
1161 // behavior affects neither the visibility state nor the auto hide state. Set 1164 // behavior affects neither the visibility state nor the auto hide state. Set
1162 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto 1165 // |gesture_drag_status_| to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto
1163 // hide state to |gesture_drag_auto_hide_state_|. 1166 // hide state to |gesture_drag_auto_hide_state_|.
1164 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; 1167 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS;
1165 Shelf* shelf = shelf_widget_->shelf(); 1168 if (wm_shelf_->auto_hide_behavior() != new_auto_hide_behavior)
1166 if (shelf->auto_hide_behavior() != new_auto_hide_behavior) 1169 wm_shelf_->SetAutoHideBehavior(new_auto_hide_behavior);
1167 shelf->SetAutoHideBehavior(new_auto_hide_behavior);
1168 else 1170 else
1169 UpdateVisibilityState(); 1171 UpdateVisibilityState();
1170 gesture_drag_status_ = GESTURE_DRAG_NONE; 1172 gesture_drag_status_ = GESTURE_DRAG_NONE;
1171 } 1173 }
1172 1174
1173 void ShelfLayoutManager::CancelGestureDrag() { 1175 void ShelfLayoutManager::CancelGestureDrag() {
1174 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1176 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1175 UpdateVisibilityState(); 1177 UpdateVisibilityState();
1176 gesture_drag_status_ = GESTURE_DRAG_NONE; 1178 gesture_drag_status_ = GESTURE_DRAG_NONE;
1177 } 1179 }
1178 1180
1179 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { 1181 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const {
1180 if (invisible_auto_hide_shelf_) 1182 if (invisible_auto_hide_shelf_)
1181 return 0; 1183 return 0;
1182 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); 1184 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE);
1183 } 1185 }
1184 1186
1185 } // namespace ash 1187 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_layout_manager.h ('k') | ash/common/shelf/shelf_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698