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

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

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock on left or right edge Created 7 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
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 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 728
729 // Also push in the work area inset for the keyboard if it is visible. 729 // Also push in the work area inset for the keyboard if it is visible.
730 if (!keyboard_bounds_.IsEmpty()) { 730 if (!keyboard_bounds_.IsEmpty()) {
731 target_bounds->work_area_insets.Set( 731 target_bounds->work_area_insets.Set(
732 target_bounds->work_area_insets.top(), 732 target_bounds->work_area_insets.top(),
733 target_bounds->work_area_insets.left(), 733 target_bounds->work_area_insets.left(),
734 target_bounds->work_area_insets.bottom() + keyboard_bounds_.height(), 734 target_bounds->work_area_insets.bottom() + keyboard_bounds_.height(),
735 target_bounds->work_area_insets.right()); 735 target_bounds->work_area_insets.right());
736 } 736 }
737 737
738 // Also push in the work area inset for the dock if it is visible.
flackr 2013/05/31 14:23:45 It seems odd that the shelf layout manager is resp
varkha 2013/05/31 23:33:42 Done.
739 if (!dock_bounds_.IsEmpty()) {
740 int left_inset = dock_bounds_.x() > 0 ? dock_bounds_.width() : 0;
741 int right_inset = dock_bounds_.x() > 0 ? 0 : dock_bounds_.width();
742 target_bounds->work_area_insets.Set(
flackr 2013/05/31 14:23:45 the +=(Insets) operator would probably look nicer.
varkha 2013/05/31 23:33:42 Done.
743 target_bounds->work_area_insets.top(),
744 target_bounds->work_area_insets.left() + left_inset,
745 target_bounds->work_area_insets.bottom(),
746 target_bounds->work_area_insets.right() + right_inset);
747 }
748
738 target_bounds->opacity = 749 target_bounds->opacity =
739 (gesture_drag_status_ != GESTURE_DRAG_NONE || 750 (gesture_drag_status_ != GESTURE_DRAG_NONE ||
740 state.visibility_state == SHELF_VISIBLE || 751 state.visibility_state == SHELF_VISIBLE ||
741 state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; 752 state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
742 753
743 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) 754 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS)
744 UpdateTargetBoundsForGesture(target_bounds); 755 UpdateTargetBoundsForGesture(target_bounds);
745 756
746 // This needs to happen after calling UpdateTargetBoundsForGesture(), because 757 // This needs to happen after calling UpdateTargetBoundsForGesture(), because
747 // that can change the size of the shelf. 758 // that can change the size of the shelf.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 bounds.set_height(bounds.height() - keyboard_bounds_.height()); 963 bounds.set_height(bounds.height() - keyboard_bounds_.height());
953 return bounds; 964 return bounds;
954 } 965 }
955 966
956 void ShelfLayoutManager::OnKeyboardBoundsChanging( 967 void ShelfLayoutManager::OnKeyboardBoundsChanging(
957 const gfx::Rect& keyboard_bounds) { 968 const gfx::Rect& keyboard_bounds) {
958 keyboard_bounds_ = keyboard_bounds; 969 keyboard_bounds_ = keyboard_bounds;
959 OnWindowResized(); 970 OnWindowResized();
960 } 971 }
961 972
973 void ShelfLayoutManager::OnDockBoundsChanging(
974 const gfx::Rect& dock_bounds) {
975 LOG(INFO) << "OnDockBoundsChanging - (" <<
976 dock_bounds.x() << "," << dock_bounds.y() << ") (" <<
977 dock_bounds.width() << "x" << dock_bounds.height() << ")";
978 dock_bounds_ = dock_bounds;
979 OnWindowResized();
980 }
981
962 gfx::Insets ShelfLayoutManager::GetInsetsForAlignment(int distance) const { 982 gfx::Insets ShelfLayoutManager::GetInsetsForAlignment(int distance) const {
963 switch (alignment_) { 983 switch (alignment_) {
964 case SHELF_ALIGNMENT_BOTTOM: 984 case SHELF_ALIGNMENT_BOTTOM:
965 return gfx::Insets(distance, 0, 0, 0); 985 return gfx::Insets(distance, 0, 0, 0);
966 case SHELF_ALIGNMENT_LEFT: 986 case SHELF_ALIGNMENT_LEFT:
967 return gfx::Insets(0, 0, 0, distance); 987 return gfx::Insets(0, 0, 0, distance);
968 case SHELF_ALIGNMENT_RIGHT: 988 case SHELF_ALIGNMENT_RIGHT:
969 return gfx::Insets(0, distance, 0, 0); 989 return gfx::Insets(0, distance, 0, 0);
970 case SHELF_ALIGNMENT_TOP: 990 case SHELF_ALIGNMENT_TOP:
971 return gfx::Insets(0, 0, distance, 0); 991 return gfx::Insets(0, 0, distance, 0);
972 } 992 }
973 NOTREACHED(); 993 NOTREACHED();
974 return gfx::Insets(); 994 return gfx::Insets();
975 } 995 }
976 996
977 } // namespace internal 997 } // namespace internal
978 } // namespace ash 998 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698