| OLD | NEW |
| 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 <cstring> | 9 #include <cstring> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // |kMaxAutoHideShowShelfRegionSize| refers to the maximum size of the region | 70 // |kMaxAutoHideShowShelfRegionSize| refers to the maximum size of the region |
| 71 // from the right edge of the primary display which can trigger showing the | 71 // from the right edge of the primary display which can trigger showing the |
| 72 // auto hidden shelf. The region is used to make it easier to trigger showing | 72 // auto hidden shelf. The region is used to make it easier to trigger showing |
| 73 // the auto hidden shelf when the shelf is on the boundary between displays. | 73 // the auto hidden shelf when the shelf is on the boundary between displays. |
| 74 const int kMaxAutoHideShowShelfRegionSize = 10; | 74 const int kMaxAutoHideShowShelfRegionSize = 10; |
| 75 | 75 |
| 76 ui::Layer* GetLayer(views::Widget* widget) { | 76 ui::Layer* GetLayer(views::Widget* widget) { |
| 77 return widget->GetNativeView()->layer(); | 77 return widget->GetNativeView()->layer(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool IsDraggingTrayEnabled() { | |
| 81 static bool dragging_tray_allowed = base::CommandLine::ForCurrentProcess()-> | |
| 82 HasSwitch(ash::switches::kAshEnableTrayDragging); | |
| 83 return dragging_tray_allowed; | |
| 84 } | |
| 85 | |
| 86 } // namespace | 80 } // namespace |
| 87 | 81 |
| 88 // static | 82 // static |
| 89 const int ShelfLayoutManager::kWorkspaceAreaVisibleInset = 2; | 83 const int ShelfLayoutManager::kWorkspaceAreaVisibleInset = 2; |
| 90 | 84 |
| 91 // static | 85 // static |
| 92 const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5; | 86 const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5; |
| 93 | 87 |
| 94 // static | 88 // static |
| 95 const int ShelfLayoutManager::kAutoHideSize = 3; | 89 const int ShelfLayoutManager::kAutoHideSize = 3; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 400 } |
| 407 | 401 |
| 408 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { | 402 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { |
| 409 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; | 403 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; |
| 410 gesture_drag_amount_ = 0.f; | 404 gesture_drag_amount_ = 0.f; |
| 411 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ? | 405 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ? |
| 412 auto_hide_state() : SHELF_AUTO_HIDE_SHOWN; | 406 auto_hide_state() : SHELF_AUTO_HIDE_SHOWN; |
| 413 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE); | 407 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE); |
| 414 } | 408 } |
| 415 | 409 |
| 416 ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag( | 410 void ShelfLayoutManager::UpdateGestureDrag( |
| 417 const ui::GestureEvent& gesture) { | 411 const ui::GestureEvent& gesture) { |
| 418 bool horizontal = IsHorizontalAlignment(); | 412 bool horizontal = IsHorizontalAlignment(); |
| 419 gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() : | 413 gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() : |
| 420 gesture.details().scroll_x(); | 414 gesture.details().scroll_x(); |
| 421 LayoutShelf(); | 415 LayoutShelf(); |
| 422 | |
| 423 // Start reveling the status menu when: | |
| 424 // - dragging up on an already visible shelf | |
| 425 // - dragging up on a hidden shelf, but it is currently completely visible. | |
| 426 if (horizontal && gesture.details().scroll_y() < 0) { | |
| 427 int min_height = 0; | |
| 428 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && shelf_) | |
| 429 min_height = shelf_->GetContentsView()->GetPreferredSize().height(); | |
| 430 | |
| 431 if (min_height < shelf_->GetWindowBoundsInScreen().height() && | |
| 432 gesture.root_location().x() >= | |
| 433 shelf_->status_area_widget()->GetWindowBoundsInScreen().x() && | |
| 434 IsDraggingTrayEnabled()) | |
| 435 return DRAG_TRAY; | |
| 436 } | |
| 437 | |
| 438 return DRAG_SHELF; | |
| 439 } | 416 } |
| 440 | 417 |
| 441 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { | 418 void ShelfLayoutManager::CompleteGestureDrag(const ui::GestureEvent& gesture) { |
| 442 bool horizontal = IsHorizontalAlignment(); | 419 bool horizontal = IsHorizontalAlignment(); |
| 443 bool should_change = false; | 420 bool should_change = false; |
| 444 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { | 421 if (gesture.type() == ui::ET_GESTURE_SCROLL_END) { |
| 445 // The visibility of the shelf changes only if the shelf was dragged X% | 422 // The visibility of the shelf changes only if the shelf was dragged X% |
| 446 // along the correct axis. If the shelf was already visible, then the | 423 // along the correct axis. If the shelf was already visible, then the |
| 447 // direction of the drag does not matter. | 424 // direction of the drag does not matter. |
| 448 const float kDragHideThreshold = 0.4f; | 425 const float kDragHideThreshold = 0.4f; |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 } | 1157 } |
| 1181 | 1158 |
| 1182 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1159 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
| 1183 shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ? | 1160 shelf_->SetAlignment(state_.is_adding_user_screen || state_.is_screen_locked ? |
| 1184 SHELF_ALIGNMENT_BOTTOM : alignment_); | 1161 SHELF_ALIGNMENT_BOTTOM : alignment_); |
| 1185 UpdateVisibilityState(); | 1162 UpdateVisibilityState(); |
| 1186 LayoutShelf(); | 1163 LayoutShelf(); |
| 1187 } | 1164 } |
| 1188 | 1165 |
| 1189 } // namespace ash | 1166 } // namespace ash |
| OLD | NEW |