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

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

Issue 2248773002: Use MD-ash's auto hide behavior for arc++ windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/shelf/shelf_layout_manager.h" 5 #include "ash/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
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return SHELF_VISIBLE; 232 return SHELF_VISIBLE;
233 } 233 }
234 234
235 void ShelfLayoutManager::UpdateVisibilityState() { 235 void ShelfLayoutManager::UpdateVisibilityState() {
236 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); 236 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_);
237 WmRootWindowController* controller = shelf_window->GetRootWindowController(); 237 WmRootWindowController* controller = shelf_window->GetRootWindowController();
238 // Bail out early before the shelf is initialized or after it is destroyed. 238 // Bail out early before the shelf is initialized or after it is destroyed.
239 if (!controller || !shelf_widget_->shelf() || in_shutdown_) 239 if (!controller || !shelf_widget_->shelf() || in_shutdown_)
240 return; 240 return;
241 241
242 // Always reset to be safe.
243 invisible_auto_hide_shelf_ = false;
242 if (state_.is_screen_locked || state_.is_adding_user_screen) { 244 if (state_.is_screen_locked || state_.is_adding_user_screen) {
243 SetState(SHELF_VISIBLE); 245 SetState(SHELF_VISIBLE);
244 } else if (WmShell::Get()->IsPinned()) { 246 } else if (WmShell::Get()->IsPinned()) {
245 SetState(SHELF_HIDDEN); 247 SetState(SHELF_HIDDEN);
246 } else { 248 } else {
247 // TODO(zelidrag): Verify shelf drag animation still shows on the device 249 // TODO(zelidrag): Verify shelf drag animation still shows on the device
248 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 250 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
249 wm::WorkspaceWindowState window_state( 251 wm::WorkspaceWindowState window_state(
250 controller->GetWorkspaceWindowState()); 252 controller->GetWorkspaceWindowState());
251 switch (window_state) { 253 switch (window_state) {
252 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { 254 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
253 if (IsShelfHiddenForFullscreen()) { 255 switch (GetShelfModeForFullscreen()) {
254 SetState(SHELF_HIDDEN); 256 case wm::WindowState::SHELF_HIDDEN:
255 } else { 257 SetState(SHELF_HIDDEN);
256 // The shelf is sometimes not hidden when in immersive fullscreen. 258 break;
257 // Force the shelf to be auto hidden in this case. 259 case wm::WindowState::SHELF_AUTO_HIDE_VISIBLE:
258 SetState(SHELF_AUTO_HIDE); 260 // A hack to swtich the visibility state correctly
261 // between auto hide visible to auto hide invisible.
262 // TODO(oshima): Remove this once MD ash is launched.
263 if (state_.visibility_state == SHELF_AUTO_HIDE)
264 SetState(SHELF_HIDDEN);
265
266 SetState(SHELF_AUTO_HIDE);
267 break;
268 case wm::WindowState::SHELF_AUTO_HIDE_INVISIBLE:
269 // A hack to swtich the visibility state correctly
270 // between auto hide visible to auto hide invisible.
271 // TODO(oshima): Remove this once MD ash is launched.
272 if (state_.visibility_state == SHELF_AUTO_HIDE)
273 SetState(SHELF_HIDDEN);
274
275 invisible_auto_hide_shelf_ = true;
276 SetState(SHELF_AUTO_HIDE);
277 break;
259 } 278 }
260 break; 279 break;
261 } 280 }
262 281
263 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: 282 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED:
264 SetState(CalculateShelfVisibility()); 283 SetState(CalculateShelfVisibility());
265 break; 284 break;
266 285
267 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: 286 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
268 case wm::WORKSPACE_WINDOW_STATE_DEFAULT: 287 case wm::WORKSPACE_WINDOW_STATE_DEFAULT:
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 if (resist) { 807 if (resist) {
789 float diff = fabsf(gesture_drag_amount_) - resistance_free_region; 808 float diff = fabsf(gesture_drag_amount_) - resistance_free_region;
790 diff = std::min(diff, sqrtf(diff)); 809 diff = std::min(diff, sqrtf(diff));
791 if (gesture_drag_amount_ < 0) 810 if (gesture_drag_amount_ < 0)
792 translate = -resistance_free_region - diff; 811 translate = -resistance_free_region - diff;
793 else 812 else
794 translate = resistance_free_region + diff; 813 translate = resistance_free_region + diff;
795 } else { 814 } else {
796 translate = gesture_drag_amount_; 815 translate = gesture_drag_amount_;
797 } 816 }
798 int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); 817 int shelf_insets = GetShelfInsetsForAutoHide();
799 if (horizontal) { 818 if (horizontal) {
800 // Move and size the shelf with the gesture. 819 // Move and size the shelf with the gesture.
801 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate; 820 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate;
802 shelf_height = std::max(shelf_height, shelf_insets); 821 shelf_height = std::max(shelf_height, shelf_insets);
803 target_bounds->shelf_bounds_in_root.set_height(shelf_height); 822 target_bounds->shelf_bounds_in_root.set_height(shelf_height);
804 if (IsHorizontalAlignment()) { 823 if (IsHorizontalAlignment()) {
805 target_bounds->shelf_bounds_in_root.set_y(available_bounds.bottom() - 824 target_bounds->shelf_bounds_in_root.set_y(available_bounds.bottom() -
806 shelf_height); 825 shelf_height);
807 } 826 }
808 827
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 WmWindow* status_window = 1000 WmWindow* status_window =
982 WmLookup::Get()->GetWindowForWidget(shelf_widget_->status_area_widget()); 1001 WmLookup::Get()->GetWindowForWidget(shelf_widget_->status_area_widget());
983 return (shelf_window && shelf_window->Contains(window)) || 1002 return (shelf_window && shelf_window->Contains(window)) ||
984 (status_window && status_window->Contains(window)); 1003 (status_window && status_window->Contains(window));
985 } 1004 }
986 1005
987 int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const { 1006 int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const {
988 if (state.visibility_state == SHELF_VISIBLE) 1007 if (state.visibility_state == SHELF_VISIBLE)
989 return size; 1008 return size;
990 if (state.visibility_state == SHELF_AUTO_HIDE) 1009 if (state.visibility_state == SHELF_AUTO_HIDE)
991 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); 1010 return GetShelfInsetsForAutoHide();
992 return 0; 1011 return 0;
993 } 1012 }
994 1013
995 void ShelfLayoutManager::OnDockBoundsChanging( 1014 void ShelfLayoutManager::OnDockBoundsChanging(
996 const gfx::Rect& dock_bounds, 1015 const gfx::Rect& dock_bounds,
997 DockedWindowLayoutManagerObserver::Reason reason) { 1016 DockedWindowLayoutManagerObserver::Reason reason) {
998 // Skip shelf layout in case docked notification originates from this class. 1017 // Skip shelf layout in case docked notification originates from this class.
999 if (reason == DISPLAY_INSETS_CHANGED) 1018 if (reason == DISPLAY_INSETS_CHANGED)
1000 return; 1019 return;
1001 if (dock_bounds_ != dock_bounds) { 1020 if (dock_bounds_ != dock_bounds) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 } 1057 }
1039 1058
1040 float ShelfLayoutManager::ComputeTargetOpacity(const State& state) { 1059 float ShelfLayoutManager::ComputeTargetOpacity(const State& state) {
1041 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || 1060 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
1042 state.visibility_state == SHELF_VISIBLE) { 1061 state.visibility_state == SHELF_VISIBLE) {
1043 return 1.0f; 1062 return 1.0f;
1044 } 1063 }
1045 // In Chrome OS Material Design, when shelf is hidden during auto hide state, 1064 // In Chrome OS Material Design, when shelf is hidden during auto hide state,
1046 // target bounds are also hidden. So the window can extend to the edge of 1065 // target bounds are also hidden. So the window can extend to the edge of
1047 // screen. 1066 // screen.
1048 if (ash::MaterialDesignController::IsShelfMaterial()) { 1067 if (ash::MaterialDesignController::IsShelfMaterial() ||
1068 invisible_auto_hide_shelf_) {
1049 return (state.visibility_state == SHELF_AUTO_HIDE && 1069 return (state.visibility_state == SHELF_AUTO_HIDE &&
1050 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN) 1070 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)
1051 ? 1.0f 1071 ? 1.0f
1052 : 0.0f; 1072 : 0.0f;
1053 } 1073 }
1054 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; 1074 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
1055 } 1075 }
1056 1076
1077 ash::wm::WindowState::FullscreenShelfMode
1078 ShelfLayoutManager::GetShelfModeForFullscreen() const {
1079 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode(
1080 WmLookup::Get()->GetWindowForWidget(shelf_widget_));
1081 return fullscreen_window->GetWindowState()->shelf_mode_in_fullscreen();
1082 }
1083
1057 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const { 1084 bool ShelfLayoutManager::IsShelfHiddenForFullscreen() const {
1058 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode( 1085 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode(
1059 WmLookup::Get()->GetWindowForWidget(shelf_widget_)); 1086 WmLookup::Get()->GetWindowForWidget(shelf_widget_));
1060 return fullscreen_window && 1087 return fullscreen_window &&
1061 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen(); 1088 fullscreen_window->GetWindowState()->shelf_mode_in_fullscreen() ==
1089 ash::wm::WindowState::SHELF_HIDDEN;
1062 } 1090 }
1063 1091
1064 //////////////////////////////////////////////////////////////////////////////// 1092 ////////////////////////////////////////////////////////////////////////////////
1065 // ShelfLayoutManager, Gesture functions: 1093 // ShelfLayoutManager, Gesture functions:
1066 1094
1067 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { 1095 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
1068 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; 1096 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
1069 gesture_drag_amount_ = 0.f; 1097 gesture_drag_amount_ = 0.f;
1070 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE 1098 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE
1071 ? auto_hide_state() 1099 ? auto_hide_state()
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 UpdateVisibilityState(); 1177 UpdateVisibilityState();
1150 gesture_drag_status_ = GESTURE_DRAG_NONE; 1178 gesture_drag_status_ = GESTURE_DRAG_NONE;
1151 } 1179 }
1152 1180
1153 void ShelfLayoutManager::CancelGestureDrag() { 1181 void ShelfLayoutManager::CancelGestureDrag() {
1154 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1182 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1155 UpdateVisibilityState(); 1183 UpdateVisibilityState();
1156 gesture_drag_status_ = GESTURE_DRAG_NONE; 1184 gesture_drag_status_ = GESTURE_DRAG_NONE;
1157 } 1185 }
1158 1186
1187 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const {
1188 if (invisible_auto_hide_shelf_)
1189 return 0;
1190 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE);
1191 }
1192
1159 } // namespace ash 1193 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698