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

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

Issue 2036353002: mash: Move ash/common/wm/shelf to ash/common/shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 4 years, 6 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/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_observer.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 (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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "ash/accelerators/accelerator_commands.h" 13 #include "ash/accelerators/accelerator_commands.h"
14 #include "ash/ash_switches.h" 14 #include "ash/ash_switches.h"
15 #include "ash/aura/wm_window_aura.h" 15 #include "ash/aura/wm_window_aura.h"
16 #include "ash/common/shelf/shelf_constants.h"
17 #include "ash/common/shelf/wm_shelf_util.h"
16 #include "ash/common/shell_window_ids.h" 18 #include "ash/common/shell_window_ids.h"
17 #include "ash/common/wm/shelf/wm_shelf_util.h"
18 #include "ash/common/wm/window_state.h" 19 #include "ash/common/wm/window_state.h"
19 #include "ash/common/wm_root_window_controller.h" 20 #include "ash/common/wm_root_window_controller.h"
20 #include "ash/common/wm_root_window_controller_observer.h" 21 #include "ash/common/wm_root_window_controller_observer.h"
21 #include "ash/root_window_controller.h" 22 #include "ash/root_window_controller.h"
22 #include "ash/screen_util.h" 23 #include "ash/screen_util.h"
23 #include "ash/session/session_state_delegate.h" 24 #include "ash/session/session_state_delegate.h"
24 #include "ash/shelf/shelf.h" 25 #include "ash/shelf/shelf.h"
25 #include "ash/shelf/shelf_bezel_event_filter.h" 26 #include "ash/shelf/shelf_bezel_event_filter.h"
26 #include "ash/shelf/shelf_constants.h"
27 #include "ash/shelf/shelf_delegate.h" 27 #include "ash/shelf/shelf_delegate.h"
28 #include "ash/shelf/shelf_layout_manager_observer.h" 28 #include "ash/shelf/shelf_layout_manager_observer.h"
29 #include "ash/shelf/shelf_util.h" 29 #include "ash/shelf/shelf_util.h"
30 #include "ash/shelf/shelf_widget.h" 30 #include "ash/shelf/shelf_widget.h"
31 #include "ash/shell.h" 31 #include "ash/shell.h"
32 #include "ash/system/status_area_widget.h" 32 #include "ash/system/status_area_widget.h"
33 #include "ash/wm/gestures/shelf_gesture_handler.h" 33 #include "ash/wm/gestures/shelf_gesture_handler.h"
34 #include "ash/wm/lock_state_controller.h" 34 #include "ash/wm/lock_state_controller.h"
35 #include "ash/wm/mru_window_tracker.h" 35 #include "ash/wm/mru_window_tracker.h"
36 #include "ash/wm/window_animations.h" 36 #include "ash/wm/window_animations.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // direction of the drag does not matter. 454 // direction of the drag does not matter.
455 const float kDragHideThreshold = 0.4f; 455 const float kDragHideThreshold = 0.4f;
456 gfx::Rect bounds = GetIdealBounds(); 456 gfx::Rect bounds = GetIdealBounds();
457 float drag_ratio = fabs(gesture_drag_amount_) / 457 float drag_ratio = fabs(gesture_drag_amount_) /
458 (horizontal ? bounds.height() : bounds.width()); 458 (horizontal ? bounds.height() : bounds.width());
459 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { 459 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) {
460 should_change = drag_ratio > kDragHideThreshold; 460 should_change = drag_ratio > kDragHideThreshold;
461 } else { 461 } else {
462 bool correct_direction = false; 462 bool correct_direction = false;
463 switch (GetAlignment()) { 463 switch (GetAlignment()) {
464 case wm::SHELF_ALIGNMENT_BOTTOM: 464 case SHELF_ALIGNMENT_BOTTOM:
465 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: 465 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
466 case wm::SHELF_ALIGNMENT_RIGHT: 466 case SHELF_ALIGNMENT_RIGHT:
467 correct_direction = gesture_drag_amount_ < 0; 467 correct_direction = gesture_drag_amount_ < 0;
468 break; 468 break;
469 case wm::SHELF_ALIGNMENT_LEFT: 469 case SHELF_ALIGNMENT_LEFT:
470 correct_direction = gesture_drag_amount_ > 0; 470 correct_direction = gesture_drag_amount_ > 0;
471 break; 471 break;
472 } 472 }
473 should_change = correct_direction && drag_ratio > kDragHideThreshold; 473 should_change = correct_direction && drag_ratio > kDragHideThreshold;
474 } 474 }
475 } else if (gesture.type() == ui::ET_SCROLL_FLING_START) { 475 } else if (gesture.type() == ui::ET_SCROLL_FLING_START) {
476 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) { 476 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN) {
477 should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 : 477 should_change = horizontal ? fabs(gesture.details().velocity_y()) > 0 :
478 fabs(gesture.details().velocity_x()) > 0; 478 fabs(gesture.details().velocity_x()) > 0;
479 } else { 479 } else {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 562 }
563 563
564 void ShelfLayoutManager::OnWindowActivated( 564 void ShelfLayoutManager::OnWindowActivated(
565 aura::client::ActivationChangeObserver::ActivationReason reason, 565 aura::client::ActivationChangeObserver::ActivationReason reason,
566 aura::Window* gained_active, 566 aura::Window* gained_active,
567 aura::Window* lost_active) { 567 aura::Window* lost_active) {
568 UpdateAutoHideStateNow(); 568 UpdateAutoHideStateNow();
569 } 569 }
570 570
571 bool ShelfLayoutManager::IsHorizontalAlignment() const { 571 bool ShelfLayoutManager::IsHorizontalAlignment() const {
572 return wm::IsHorizontalAlignment(GetAlignment()); 572 return ::ash::IsHorizontalAlignment(GetAlignment());
573 } 573 }
574 574
575 void ShelfLayoutManager::SetChromeVoxPanelHeight(int height) { 575 void ShelfLayoutManager::SetChromeVoxPanelHeight(int height) {
576 chromevox_panel_height_ = height; 576 chromevox_panel_height_ = height;
577 LayoutShelf(); 577 LayoutShelf();
578 } 578 }
579 579
580 //////////////////////////////////////////////////////////////////////////////// 580 ////////////////////////////////////////////////////////////////////////////////
581 // ShelfLayoutManager, private: 581 // ShelfLayoutManager, private:
582 582
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 target_bounds->shelf_bounds_in_root.set_height(shelf_height); 925 target_bounds->shelf_bounds_in_root.set_height(shelf_height);
926 if (IsHorizontalAlignment()) { 926 if (IsHorizontalAlignment()) {
927 target_bounds->shelf_bounds_in_root.set_y( 927 target_bounds->shelf_bounds_in_root.set_y(
928 available_bounds.bottom() - shelf_height); 928 available_bounds.bottom() - shelf_height);
929 } 929 }
930 930
931 target_bounds->status_bounds_in_shelf.set_y(0); 931 target_bounds->status_bounds_in_shelf.set_y(0);
932 } else { 932 } else {
933 // Move and size the shelf with the gesture. 933 // Move and size the shelf with the gesture.
934 int shelf_width = target_bounds->shelf_bounds_in_root.width(); 934 int shelf_width = target_bounds->shelf_bounds_in_root.width();
935 bool right_aligned = GetAlignment() == wm::SHELF_ALIGNMENT_RIGHT; 935 bool right_aligned = GetAlignment() == SHELF_ALIGNMENT_RIGHT;
936 if (right_aligned) 936 if (right_aligned)
937 shelf_width -= translate; 937 shelf_width -= translate;
938 else 938 else
939 shelf_width += translate; 939 shelf_width += translate;
940 shelf_width = std::max(shelf_width, kAutoHideSize); 940 shelf_width = std::max(shelf_width, kAutoHideSize);
941 target_bounds->shelf_bounds_in_root.set_width(shelf_width); 941 target_bounds->shelf_bounds_in_root.set_width(shelf_width);
942 if (right_aligned) { 942 if (right_aligned) {
943 target_bounds->shelf_bounds_in_root.set_x( 943 target_bounds->shelf_bounds_in_root.set_x(
944 available_bounds.right() - shelf_width); 944 available_bounds.right() - shelf_width);
945 } 945 }
946 946
947 if (right_aligned) 947 if (right_aligned)
948 target_bounds->status_bounds_in_shelf.set_x(0); 948 target_bounds->status_bounds_in_shelf.set_x(0);
949 else 949 else
950 target_bounds->status_bounds_in_shelf.set_x( 950 target_bounds->status_bounds_in_shelf.set_x(
951 target_bounds->shelf_bounds_in_root.width() - 951 target_bounds->shelf_bounds_in_root.width() -
952 kShelfSize); 952 kShelfSize);
953 } 953 }
954 } 954 }
955 955
956 void ShelfLayoutManager::UpdateShelfBackground( 956 void ShelfLayoutManager::UpdateShelfBackground(
957 BackgroundAnimatorChangeType type) { 957 BackgroundAnimatorChangeType type) {
958 const wm::ShelfBackgroundType background_type(GetShelfBackgroundType()); 958 const ShelfBackgroundType background_type(GetShelfBackgroundType());
959 shelf_widget_->SetPaintsBackground(background_type, type); 959 shelf_widget_->SetPaintsBackground(background_type, type);
960 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 960 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
961 OnBackgroundUpdated(background_type, type)); 961 OnBackgroundUpdated(background_type, type));
962 } 962 }
963 963
964 wm::ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { 964 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
965 if (state_.visibility_state != SHELF_AUTO_HIDE && 965 if (state_.visibility_state != SHELF_AUTO_HIDE &&
966 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { 966 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) {
967 return wm::SHELF_BACKGROUND_MAXIMIZED; 967 return SHELF_BACKGROUND_MAXIMIZED;
968 } 968 }
969 969
970 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || 970 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
971 (!state_.is_screen_locked && !state_.is_adding_user_screen && 971 (!state_.is_screen_locked && !state_.is_adding_user_screen &&
972 window_overlaps_shelf_) || 972 window_overlaps_shelf_) ||
973 (state_.visibility_state == SHELF_AUTO_HIDE)) { 973 (state_.visibility_state == SHELF_AUTO_HIDE)) {
974 return wm::SHELF_BACKGROUND_OVERLAP; 974 return SHELF_BACKGROUND_OVERLAP;
975 } 975 }
976 976
977 return wm::SHELF_BACKGROUND_DEFAULT; 977 return SHELF_BACKGROUND_DEFAULT;
978 } 978 }
979 979
980 void ShelfLayoutManager::UpdateAutoHideStateNow() { 980 void ShelfLayoutManager::UpdateAutoHideStateNow() {
981 SetState(state_.visibility_state); 981 SetState(state_.visibility_state);
982 982
983 // If the state did not change, the auto hide timer may still be running. 983 // If the state did not change, the auto hide timer may still be running.
984 StopAutoHideTimer(); 984 StopAutoHideTimer();
985 } 985 }
986 986
987 void ShelfLayoutManager::StopAutoHideTimer() { 987 void ShelfLayoutManager::StopAutoHideTimer() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 shelf_widget_->GetNativeWindow()->GetRootWindow()); 1074 shelf_widget_->GetNativeWindow()->GetRootWindow());
1075 if (!cursor_client->IsMouseEventsEnabled()) 1075 if (!cursor_client->IsMouseEventsEnabled())
1076 return SHELF_AUTO_HIDE_HIDDEN; 1076 return SHELF_AUTO_HIDE_HIDDEN;
1077 1077
1078 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen(); 1078 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen();
1079 if (shelf_widget_->status_area_widget() && 1079 if (shelf_widget_->status_area_widget() &&
1080 shelf_widget_->status_area_widget()->IsMessageBubbleShown() && 1080 shelf_widget_->status_area_widget()->IsMessageBubbleShown() &&
1081 IsVisible()) { 1081 IsVisible()) {
1082 // Increase the the hit test area to prevent the shelf from disappearing 1082 // Increase the the hit test area to prevent the shelf from disappearing
1083 // when the mouse is over the bubble gap. 1083 // when the mouse is over the bubble gap.
1084 wm::ShelfAlignment alignment = GetAlignment(); 1084 ShelfAlignment alignment = GetAlignment();
1085 shelf_region.Inset( 1085 shelf_region.Inset(
1086 alignment == wm::SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight 1086 alignment == SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight : 0,
1087 : 0,
1088 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0, 1087 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0,
1089 alignment == wm::SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight 1088 alignment == SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight : 0,
1090 : 0,
1091 0); 1089 0);
1092 } 1090 }
1093 1091
1094 gfx::Point cursor_position_in_screen = 1092 gfx::Point cursor_position_in_screen =
1095 display::Screen::GetScreen()->GetCursorScreenPoint(); 1093 display::Screen::GetScreen()->GetCursorScreenPoint();
1096 if (shelf_region.Contains(cursor_position_in_screen)) 1094 if (shelf_region.Contains(cursor_position_in_screen))
1097 return SHELF_AUTO_HIDE_SHOWN; 1095 return SHELF_AUTO_HIDE_SHOWN;
1098 1096
1099 // When the shelf is auto hidden and the shelf is on the boundary between two 1097 // When the shelf is auto hidden and the shelf is on the boundary between two
1100 // displays, it is hard to trigger showing the shelf. For instance, if a 1098 // displays, it is hard to trigger showing the shelf. For instance, if a
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 UpdateBoundsAndOpacity(target_bounds, true, NULL); 1192 UpdateBoundsAndOpacity(target_bounds, true, NULL);
1195 UpdateVisibilityState(); 1193 UpdateVisibilityState();
1196 } 1194 }
1197 1195
1198 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { 1196 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
1199 UpdateVisibilityState(); 1197 UpdateVisibilityState();
1200 LayoutShelf(); 1198 LayoutShelf();
1201 } 1199 }
1202 1200
1203 } // namespace ash 1201 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698