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

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

Issue 140323010: Ash:Shelf - Cleanup of Alternate Shelf (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + remove AlternateShelf from variable names Created 6 years, 11 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 | Annotate | Revision Log
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // static 94 // static
95 const int ShelfLayoutManager::kAutoHideSize = 3; 95 const int ShelfLayoutManager::kAutoHideSize = 3;
96 96
97 // static 97 // static
98 const int ShelfLayoutManager::kShelfSize = 47; 98 const int ShelfLayoutManager::kShelfSize = 47;
99 99
100 // static 100 // static
101 const int ShelfLayoutManager::kShelfItemInset = 3; 101 const int ShelfLayoutManager::kShelfItemInset = 3;
102 102
103 int ShelfLayoutManager::GetPreferredShelfSize() { 103 int ShelfLayoutManager::GetPreferredShelfSize() {
104 return ash::switches::UseAlternateShelfLayout() ? 104 return ShelfLayoutManager::kShelfSize;
105 ShelfLayoutManager::kShelfSize : kShelfPreferredSize;
Mr4D (OOO till 08-26) 2014/01/23 19:25:08 Just checking - is kShelfPreferredSize still neede
Harry McCleave 2014/01/24 22:48:47 I have removed this function but left GetButtonSiz
106 } 105 }
107 106
108 // ShelfLayoutManager::AutoHideEventFilter ------------------------------------- 107 // ShelfLayoutManager::AutoHideEventFilter -------------------------------------
109 108
110 // Notifies ShelfLayoutManager any time the mouse moves. 109 // Notifies ShelfLayoutManager any time the mouse moves.
111 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler { 110 class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler {
112 public: 111 public:
113 explicit AutoHideEventFilter(ShelfLayoutManager* shelf); 112 explicit AutoHideEventFilter(ShelfLayoutManager* shelf);
114 virtual ~AutoHideEventFilter(); 113 virtual ~AutoHideEventFilter();
115 114
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 target_bounds->shelf_bounds_in_root = SelectValueForShelfAlignment( 752 target_bounds->shelf_bounds_in_root = SelectValueForShelfAlignment(
754 gfx::Rect(available_bounds.x(), available_bounds.bottom() - shelf_height, 753 gfx::Rect(available_bounds.x(), available_bounds.bottom() - shelf_height,
755 available_bounds.width(), shelf_height), 754 available_bounds.width(), shelf_height),
756 gfx::Rect(available_bounds.x(), available_bounds.y(), 755 gfx::Rect(available_bounds.x(), available_bounds.y(),
757 shelf_width, available_bounds.height()), 756 shelf_width, available_bounds.height()),
758 gfx::Rect(available_bounds.right() - shelf_width, available_bounds.y(), 757 gfx::Rect(available_bounds.right() - shelf_width, available_bounds.y(),
759 shelf_width, available_bounds.height()), 758 shelf_width, available_bounds.height()),
760 gfx::Rect(available_bounds.x(), available_bounds.y(), 759 gfx::Rect(available_bounds.x(), available_bounds.y(),
761 available_bounds.width(), shelf_height)); 760 available_bounds.width(), shelf_height));
762 761
763 int status_inset = std::max(0, GetPreferredShelfSize() - 762 int status_inset = 0;
764 PrimaryAxisValue(status_size.height(), status_size.width())); 763 if (IsHorizontalAlignment())
765 764 status_size.set_height(kShelfSize);
766 if (ash::switches::UseAlternateShelfLayout()) { 765 else
767 status_inset = 0; 766 status_size.set_width(kShelfSize);
768 if (IsHorizontalAlignment())
769 status_size.set_height(kShelfSize);
770 else
771 status_size.set_width(kShelfSize);
772 }
773 767
774 target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment( 768 target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment(
775 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), 769 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(),
776 status_inset, status_size.width(), status_size.height()), 770 status_inset, status_size.width(), status_size.height()),
777 gfx::Rect(shelf_width - (status_size.width() + status_inset), 771 gfx::Rect(shelf_width - (status_size.width() + status_inset),
778 shelf_height - status_size.height(), status_size.width(), 772 shelf_height - status_size.height(), status_size.width(),
779 status_size.height()), 773 status_size.height()),
780 gfx::Rect(status_inset, shelf_height - status_size.height(), 774 gfx::Rect(status_inset, shelf_height - status_size.height(),
781 status_size.width(), status_size.height()), 775 status_size.width(), status_size.height()),
782 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), 776 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 if (horizontal) { 867 if (horizontal) {
874 // Move and size the shelf with the gesture. 868 // Move and size the shelf with the gesture.
875 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate; 869 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate;
876 shelf_height = std::max(shelf_height, kAutoHideSize); 870 shelf_height = std::max(shelf_height, kAutoHideSize);
877 target_bounds->shelf_bounds_in_root.set_height(shelf_height); 871 target_bounds->shelf_bounds_in_root.set_height(shelf_height);
878 if (GetAlignment() == SHELF_ALIGNMENT_BOTTOM) { 872 if (GetAlignment() == SHELF_ALIGNMENT_BOTTOM) {
879 target_bounds->shelf_bounds_in_root.set_y( 873 target_bounds->shelf_bounds_in_root.set_y(
880 available_bounds.bottom() - shelf_height); 874 available_bounds.bottom() - shelf_height);
881 } 875 }
882 876
883 if (ash::switches::UseAlternateShelfLayout()) { 877 target_bounds->status_bounds_in_shelf.set_y(0);
884 target_bounds->status_bounds_in_shelf.set_y(0);
885 } else {
886 // The statusbar should be in the center of the shelf.
887 gfx::Rect status_y = target_bounds->shelf_bounds_in_root;
888 status_y.set_y(0);
889 status_y.ClampToCenteredSize(
890 target_bounds->status_bounds_in_shelf.size());
891 target_bounds->status_bounds_in_shelf.set_y(status_y.y());
892 }
893 } else { 878 } else {
894 // Move and size the shelf with the gesture. 879 // Move and size the shelf with the gesture.
895 int shelf_width = target_bounds->shelf_bounds_in_root.width(); 880 int shelf_width = target_bounds->shelf_bounds_in_root.width();
896 bool right_aligned = GetAlignment() == SHELF_ALIGNMENT_RIGHT; 881 bool right_aligned = GetAlignment() == SHELF_ALIGNMENT_RIGHT;
897 if (right_aligned) 882 if (right_aligned)
898 shelf_width -= translate; 883 shelf_width -= translate;
899 else 884 else
900 shelf_width += translate; 885 shelf_width += translate;
901 shelf_width = std::max(shelf_width, kAutoHideSize); 886 shelf_width = std::max(shelf_width, kAutoHideSize);
902 target_bounds->shelf_bounds_in_root.set_width(shelf_width); 887 target_bounds->shelf_bounds_in_root.set_width(shelf_width);
903 if (right_aligned) { 888 if (right_aligned) {
904 target_bounds->shelf_bounds_in_root.set_x( 889 target_bounds->shelf_bounds_in_root.set_x(
905 available_bounds.right() - shelf_width); 890 available_bounds.right() - shelf_width);
906 } 891 }
907 892
908 if (ash::switches::UseAlternateShelfLayout()) { 893 if (right_aligned)
909 if (right_aligned) 894 target_bounds->status_bounds_in_shelf.set_x(0);
910 target_bounds->status_bounds_in_shelf.set_x(0); 895 else
911 else 896 target_bounds->status_bounds_in_shelf.set_x(
912 target_bounds->status_bounds_in_shelf.set_x( 897 target_bounds->shelf_bounds_in_root.width() -
913 target_bounds->shelf_bounds_in_root.width() - 898 kShelfSize);
914 kShelfSize);
915 } else {
916 // The statusbar should be in the center of the shelf.
917 gfx::Rect status_x = target_bounds->shelf_bounds_in_root;
918 status_x.set_x(0);
919 status_x.ClampToCenteredSize(
920 target_bounds->status_bounds_in_shelf.size());
921 target_bounds->status_bounds_in_shelf.set_x(status_x.x());
922 }
923 } 899 }
924 } 900 }
925 901
926 void ShelfLayoutManager::UpdateShelfBackground( 902 void ShelfLayoutManager::UpdateShelfBackground(
927 BackgroundAnimatorChangeType type) { 903 BackgroundAnimatorChangeType type) {
928 const ShelfBackgroundType background_type(GetShelfBackgroundType()); 904 const ShelfBackgroundType background_type(GetShelfBackgroundType());
929 shelf_->SetPaintsBackground(background_type, type); 905 shelf_->SetPaintsBackground(background_type, type);
930 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 906 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
931 OnBackgroundUpdated(background_type, type)); 907 OnBackgroundUpdated(background_type, type));
932 } 908 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 return gfx::Insets(0, distance, 0, 0); 1133 return gfx::Insets(0, distance, 0, 0);
1158 case SHELF_ALIGNMENT_TOP: 1134 case SHELF_ALIGNMENT_TOP:
1159 return gfx::Insets(0, 0, distance, 0); 1135 return gfx::Insets(0, 0, distance, 0);
1160 } 1136 }
1161 NOTREACHED(); 1137 NOTREACHED();
1162 return gfx::Insets(); 1138 return gfx::Insets();
1163 } 1139 }
1164 1140
1165 } // namespace internal 1141 } // namespace internal
1166 } // namespace ash 1142 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698