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

Side by Side Diff: ash/launcher/launcher_model.cc

Issue 11348201: Align panel icons on the right / end. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO for panel overflow. Created 8 years 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
« no previous file with comments | « ash/launcher/launcher_model.h ('k') | ash/launcher/launcher_model_unittest.cc » ('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/launcher/launcher_model.h" 5 #include "ash/launcher/launcher_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/launcher/launcher_model_observer.h" 9 #include "ash/launcher/launcher_model_observer.h"
10 10
11 namespace ash { 11 namespace ash {
12 12
13 namespace { 13 namespace {
14 14
15 int LauncherItemTypeToWeight(LauncherItemType type) { 15 int LauncherItemTypeToWeight(LauncherItemType type) {
16 switch (type) { 16 switch (type) {
17 case TYPE_BROWSER_SHORTCUT: 17 case TYPE_BROWSER_SHORTCUT:
18 return 0; 18 return 0;
19 case TYPE_APP_SHORTCUT: 19 case TYPE_APP_SHORTCUT:
20 return 1; 20 return 1;
21 case TYPE_TABBED: 21 case TYPE_TABBED:
22 case TYPE_APP_PANEL:
23 case TYPE_PLATFORM_APP: 22 case TYPE_PLATFORM_APP:
24 return 2; 23 return 2;
25 case TYPE_APP_LIST: 24 case TYPE_APP_LIST:
26 return 3; 25 return 3;
26 case TYPE_APP_PANEL:
27 return 4;
27 } 28 }
28 29
29 NOTREACHED() << "Invalid type " << type; 30 NOTREACHED() << "Invalid type " << type;
30 return 2; 31 return 2;
31 } 32 }
32 33
33 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { 34 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) {
34 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type); 35 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type);
35 } 36 }
36 37
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 LauncherItems::const_iterator LauncherModel::ItemByID(int id) const { 112 LauncherItems::const_iterator LauncherModel::ItemByID(int id) const {
112 for (LauncherItems::const_iterator i = items_.begin(); 113 for (LauncherItems::const_iterator i = items_.begin();
113 i != items_.end(); ++i) { 114 i != items_.end(); ++i) {
114 if (i->id == id) 115 if (i->id == id)
115 return i; 116 return i;
116 } 117 }
117 return items_.end(); 118 return items_.end();
118 } 119 }
119 120
121 int LauncherModel::FirstPanelIndex() const {
122 LauncherItem weight_dummy;
123 weight_dummy.type = TYPE_APP_PANEL;
124 return std::lower_bound(items_.begin(), items_.end(), weight_dummy,
125 CompareByWeight) - items_.begin();
126 }
127
120 void LauncherModel::SetStatus(Status status) { 128 void LauncherModel::SetStatus(Status status) {
121 if (status_ == status) 129 if (status_ == status)
122 return; 130 return;
123 131
124 status_ = status; 132 status_ = status;
125 FOR_EACH_OBSERVER(LauncherModelObserver, observers_, 133 FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
126 LauncherStatusChanged()); 134 LauncherStatusChanged());
127 } 135 }
128 136
129 void LauncherModel::AddObserver(LauncherModelObserver* observer) { 137 void LauncherModel::AddObserver(LauncherModelObserver* observer) {
(...skipping 15 matching lines...) Expand all
145 CompareByWeight) - items_.begin(), 153 CompareByWeight) - items_.begin(),
146 static_cast<LauncherItems::difference_type>(index)); 154 static_cast<LauncherItems::difference_type>(index));
147 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, 155 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy,
148 CompareByWeight) - items_.begin(), 156 CompareByWeight) - items_.begin(),
149 static_cast<LauncherItems::difference_type>(index)); 157 static_cast<LauncherItems::difference_type>(index));
150 158
151 return index; 159 return index;
152 } 160 }
153 161
154 } // namespace ash 162 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_model.h ('k') | ash/launcher/launcher_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698