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

Side by Side Diff: ui/views/view_model_utils.cc

Issue 10068027: ash: Fix launcher icon overlaps with status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use last_visible_index_ part from 9808026 and add tests Created 8 years, 8 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
« ash/launcher/launcher_view.cc ('K') | « ui/views/view_model_utils.h ('k') | no next file » | 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 "ui/views/view_model_utils.h" 5 #include "ui/views/view_model_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/views/view_model.h" 9 #include "ui/views/view_model.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
11 11
12 namespace views { 12 namespace views {
13 13
14 // static 14 // static
15 void ViewModelUtils::SetViewBoundsToIdealBounds(const ViewModel& model) { 15 void ViewModelUtils::SetViewBoundsToIdealBounds(const ViewModel& model) {
16 for (int i = 0; i < model.view_size(); ++i) 16 for (int i = 0; i < model.view_size(); ++i)
17 model.view_at(i)->SetBoundsRect(model.ideal_bounds(i)); 17 model.view_at(i)->SetBoundsRect(model.ideal_bounds(i));
18 } 18 }
19 19
20 // static 20 // static
21 void ViewModelUtils::SetViewVisibilityToIdealVisibility(
22 const ViewModel& model) {
23 for (int i = 0; i < model.view_size(); ++i)
24 model.view_at(i)->SetVisible(model.ideal_visibility(i));
25 }
26
27 // static
21 int ViewModelUtils::DetermineMoveIndex(const ViewModel& model, 28 int ViewModelUtils::DetermineMoveIndex(const ViewModel& model,
22 View* view, 29 View* view,
23 int x) { 30 int x) {
24 int current_index = model.GetIndexOfView(view); 31 int current_index = model.GetIndexOfView(view);
25 DCHECK_NE(-1, current_index); 32 DCHECK_NE(-1, current_index);
26 for (int i = 0; i < current_index; ++i) { 33 for (int i = 0; i < current_index; ++i) {
27 int mid_x = model.ideal_bounds(i).x() + model.ideal_bounds(i).width() / 2; 34 int mid_x = model.ideal_bounds(i).x() + model.ideal_bounds(i).width() / 2;
28 if (x < mid_x) 35 if (x < mid_x)
29 return i; 36 return i;
30 } 37 }
31 38
32 if (current_index + 1 == model.view_size()) 39 if (current_index + 1 == model.view_size())
33 return current_index; 40 return current_index;
34 41
35 // For indices after the current index ignore the bounds of the view being 42 // For indices after the current index ignore the bounds of the view being
36 // dragged. This keeps the view from bouncing around as moved. 43 // dragged. This keeps the view from bouncing around as moved.
37 int delta = model.ideal_bounds(current_index + 1).x() - 44 int delta = model.ideal_bounds(current_index + 1).x() -
38 model.ideal_bounds(current_index).x(); 45 model.ideal_bounds(current_index).x();
39 for (int i = current_index + 1; i < model.view_size(); ++i) { 46 for (int i = current_index + 1; i < model.view_size(); ++i) {
40 const gfx::Rect& bounds(model.ideal_bounds(i)); 47 const gfx::Rect& bounds(model.ideal_bounds(i));
41 int mid_x = bounds.x() + bounds.width() / 2 - delta; 48 int mid_x = bounds.x() + bounds.width() / 2 - delta;
42 if (x < mid_x) 49 if (x < mid_x)
43 return i - 1; 50 return i - 1;
44 } 51 }
45 return model.view_size() - 1; 52 return model.view_size() - 1;
46 } 53 }
47 54
48 } // namespace views 55 } // namespace views
OLDNEW
« ash/launcher/launcher_view.cc ('K') | « ui/views/view_model_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698