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

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

Issue 1742953002: Simplify ash shelf layout code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore ConvertRectToScreen calls. Created 4 years, 9 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
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/shelf/shelf_view_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/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 last_button_index--; 1407 last_button_index--;
1408 1408
1409 const gfx::Rect last_button_bounds = 1409 const gfx::Rect last_button_bounds =
1410 last_button_index >= first_visible_index_ ? 1410 last_button_index >= first_visible_index_ ?
1411 view_model_->ideal_bounds(last_button_index) : 1411 view_model_->ideal_bounds(last_button_index) :
1412 gfx::Rect(gfx::Size(kShelfSize, kShelfSize)); 1412 gfx::Rect(gfx::Size(kShelfSize, kShelfSize));
1413 1413
1414 if (shelf_->IsHorizontalAlignment()) 1414 if (shelf_->IsHorizontalAlignment())
1415 return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize); 1415 return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize);
1416 1416
1417 return gfx::Size(kShelfSize, 1417 return gfx::Size(kShelfSize, last_button_bounds.bottom() + leading_inset_);
1418 last_button_bounds.bottom() + leading_inset_);
1419 } 1418 }
1420 1419
1421 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1420 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1422 // This bounds change is produced by the shelf movement and all content has 1421 // This bounds change is produced by the shelf movement and all content has
1423 // to follow. Using an animation at that time would produce a time lag since 1422 // to follow. Using an animation at that time would produce a time lag since
1424 // the animation of the BoundsAnimator has itself a delay before it arrives 1423 // the animation of the BoundsAnimator has itself a delay before it arrives
1425 // at the required location. As such we tell the animator to go there 1424 // at the required location. As such we tell the animator to go there
1426 // immediately. 1425 // immediately.
1427 BoundsAnimatorDisabler disabler(bounds_animator_.get()); 1426 BoundsAnimatorDisabler disabler(bounds_animator_.get());
1428 LayoutToIdealBounds(); 1427 LayoutToIdealBounds();
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 1959
1961 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1960 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1962 const gfx::Rect bounds = GetBoundsInScreen(); 1961 const gfx::Rect bounds = GetBoundsInScreen();
1963 int distance = shelf_->SelectValueForShelfAlignment( 1962 int distance = shelf_->SelectValueForShelfAlignment(
1964 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1963 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1965 bounds.x() - coordinate.x(), coordinate.y() - bounds.bottom()); 1964 bounds.x() - coordinate.x(), coordinate.y() - bounds.bottom());
1966 return distance > 0 ? distance : 0; 1965 return distance > 0 ? distance : 0;
1967 } 1966 }
1968 1967
1969 } // namespace ash 1968 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698