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

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

Issue 16900002: Added flag for alternate launcher settings (remaining changes to come). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ui::Layer* GetLayer(views::Widget* widget) { 63 ui::Layer* GetLayer(views::Widget* widget) {
64 return widget->GetNativeView()->layer(); 64 return widget->GetNativeView()->layer();
65 } 65 }
66 66
67 bool IsDraggingTrayEnabled() { 67 bool IsDraggingTrayEnabled() {
68 static bool dragging_tray_allowed = CommandLine::ForCurrentProcess()-> 68 static bool dragging_tray_allowed = CommandLine::ForCurrentProcess()->
69 HasSwitch(ash::switches::kAshEnableTrayDragging); 69 HasSwitch(ash::switches::kAshEnableTrayDragging);
70 return dragging_tray_allowed; 70 return dragging_tray_allowed;
71 } 71 }
72 72
73 int GetPreferredShelfSize() {
74 return ash::switches::UseAlternateShelfLayout() ?
75 ShelfLayoutManager::kShelfSize : kLauncherPreferredSize;
76 }
77
73 } // namespace 78 } // namespace
74 79
75 // static 80 // static
76 const int ShelfLayoutManager::kWorkspaceAreaVisibleInset = 2; 81 const int ShelfLayoutManager::kWorkspaceAreaVisibleInset = 2;
77 82
78 // static 83 // static
79 const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5; 84 const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5;
80 85
81 // static 86 // static
82 const int ShelfLayoutManager::kAutoHideSize = 3; 87 const int ShelfLayoutManager::kAutoHideSize = 3;
83 88
89 // static
90 const int ShelfLayoutManager::kShelfSize = 47;
91
84 // ShelfLayoutManager::AutoHideEventFilter ------------------------------------- 92 // ShelfLayoutManager::AutoHideEventFilter -------------------------------------
85 93
86 // Notifies ShelfLayoutManager any time the mouse moves. 94 // Notifies ShelfLayoutManager any time the mouse moves.
87 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler { 95 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler {
88 public: 96 public:
89 explicit AutoHideEventFilter(ShelfLayoutManager* shelf); 97 explicit AutoHideEventFilter(ShelfLayoutManager* shelf);
90 virtual ~AutoHideEventFilter(); 98 virtual ~AutoHideEventFilter();
91 99
92 // Returns true if the last mouse event was a mouse drag. 100 // Returns true if the last mouse event was a mouse drag.
93 bool in_mouse_drag() const { return in_mouse_drag_; } 101 bool in_mouse_drag() const { return in_mouse_drag_; }
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 void ShelfLayoutManager::StopAnimating() { 660 void ShelfLayoutManager::StopAnimating() {
653 GetLayer(shelf_)->GetAnimator()->StopAnimating(); 661 GetLayer(shelf_)->GetAnimator()->StopAnimating();
654 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); 662 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating();
655 } 663 }
656 664
657 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { 665 void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
658 *width = *height = 0; 666 *width = *height = 0;
659 gfx::Size status_size( 667 gfx::Size status_size(
660 shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); 668 shelf_->status_area_widget()->GetWindowBoundsInScreen().size());
661 if (IsHorizontalAlignment()) 669 if (IsHorizontalAlignment())
662 *height = kLauncherPreferredSize; 670 *height = GetPreferredShelfSize();
663 else 671 else
664 *width = kLauncherPreferredSize; 672 *width = GetPreferredShelfSize();
665 } 673 }
666 674
667 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset, 675 void ShelfLayoutManager::AdjustBoundsBasedOnAlignment(int inset,
668 gfx::Rect* bounds) const { 676 gfx::Rect* bounds) const {
669 bounds->Inset(SelectValueForShelfAlignment( 677 bounds->Inset(SelectValueForShelfAlignment(
670 gfx::Insets(0, 0, inset, 0), 678 gfx::Insets(0, 0, inset, 0),
671 gfx::Insets(0, inset, 0, 0), 679 gfx::Insets(0, inset, 0, 0),
672 gfx::Insets(0, 0, 0, inset), 680 gfx::Insets(0, 0, 0, inset),
673 gfx::Insets(inset, 0, 0, 0))); 681 gfx::Insets(inset, 0, 0, 0)));
674 } 682 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 target_bounds->shelf_bounds_in_root = SelectValueForShelfAlignment( 714 target_bounds->shelf_bounds_in_root = SelectValueForShelfAlignment(
707 gfx::Rect(available_bounds.x(), available_bounds.bottom() - shelf_height, 715 gfx::Rect(available_bounds.x(), available_bounds.bottom() - shelf_height,
708 available_bounds.width(), shelf_height), 716 available_bounds.width(), shelf_height),
709 gfx::Rect(available_bounds.x(), available_bounds.y(), 717 gfx::Rect(available_bounds.x(), available_bounds.y(),
710 shelf_width, available_bounds.height()), 718 shelf_width, available_bounds.height()),
711 gfx::Rect(available_bounds.right() - shelf_width, available_bounds.y(), 719 gfx::Rect(available_bounds.right() - shelf_width, available_bounds.y(),
712 shelf_width, available_bounds.height()), 720 shelf_width, available_bounds.height()),
713 gfx::Rect(available_bounds.x(), available_bounds.y(), 721 gfx::Rect(available_bounds.x(), available_bounds.y(),
714 available_bounds.width(), shelf_height)); 722 available_bounds.width(), shelf_height));
715 723
716 int status_inset = std::max(0, kLauncherPreferredSize - 724 int status_inset = std::max(0, GetPreferredShelfSize() -
717 PrimaryAxisValue(status_size.height(), status_size.width())); 725 PrimaryAxisValue(status_size.height(), status_size.width()));
718 726
719 target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment( 727 target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment(
720 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), 728 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(),
721 status_inset, status_size.width(), status_size.height()), 729 status_inset, status_size.width(), status_size.height()),
722 gfx::Rect(shelf_width - (status_size.width() + status_inset), 730 gfx::Rect(shelf_width - (status_size.width() + status_inset),
723 shelf_height - status_size.height(), status_size.width(), 731 shelf_height - status_size.height(), status_size.width(),
724 status_size.height()), 732 status_size.height()),
725 gfx::Rect(status_inset, shelf_height - status_size.height(), 733 gfx::Rect(status_inset, shelf_height - status_size.height(),
726 status_size.width(), status_size.height()), 734 status_size.width(), status_size.height()),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 const gfx::Rect& available_bounds(root_window_->bounds()); 781 const gfx::Rect& available_bounds(root_window_->bounds());
774 int resistance_free_region = 0; 782 int resistance_free_region = 0;
775 783
776 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN && 784 if (gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_HIDDEN &&
777 visibility_state() == SHELF_AUTO_HIDE && 785 visibility_state() == SHELF_AUTO_HIDE &&
778 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) { 786 auto_hide_state() != SHELF_AUTO_HIDE_SHOWN) {
779 // If the shelf was hidden when the drag started (and the state hasn't 787 // If the shelf was hidden when the drag started (and the state hasn't
780 // changed since then, e.g. because the tray-menu was shown because of the 788 // changed since then, e.g. because the tray-menu was shown because of the
781 // drag), then allow the drag some resistance-free region at first to make 789 // drag), then allow the drag some resistance-free region at first to make
782 // sure the shelf sticks with the finger until the shelf is visible. 790 // sure the shelf sticks with the finger until the shelf is visible.
783 resistance_free_region = kLauncherPreferredSize - kAutoHideSize; 791 resistance_free_region = GetPreferredShelfSize() - kAutoHideSize;
784 } 792 }
785 793
786 bool resist = SelectValueForShelfAlignment( 794 bool resist = SelectValueForShelfAlignment(
787 gesture_drag_amount_ < -resistance_free_region, 795 gesture_drag_amount_ < -resistance_free_region,
788 gesture_drag_amount_ > resistance_free_region, 796 gesture_drag_amount_ > resistance_free_region,
789 gesture_drag_amount_ < -resistance_free_region, 797 gesture_drag_amount_ < -resistance_free_region,
790 gesture_drag_amount_ > resistance_free_region); 798 gesture_drag_amount_ > resistance_free_region);
791 799
792 float translate = 0.f; 800 float translate = 0.f;
793 if (resist) { 801 if (resist) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 return gfx::Insets(0, distance, 0, 0); 985 return gfx::Insets(0, distance, 0, 0);
978 case SHELF_ALIGNMENT_TOP: 986 case SHELF_ALIGNMENT_TOP:
979 return gfx::Insets(0, 0, distance, 0); 987 return gfx::Insets(0, 0, distance, 0);
980 } 988 }
981 NOTREACHED(); 989 NOTREACHED();
982 return gfx::Insets(); 990 return gfx::Insets();
983 } 991 }
984 992
985 } // namespace internal 993 } // namespace internal
986 } // namespace ash 994 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698