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

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

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 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
« 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 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 int available_size = shelf_->PrimaryAxisValue(width(), height()); 814 int available_size = shelf_->PrimaryAxisValue(width(), height());
815 DCHECK(model_->item_count() == view_model_->view_size()); 815 DCHECK(model_->item_count() == view_model_->view_size());
816 if (!available_size) 816 if (!available_size)
817 return; 817 return;
818 818
819 int first_panel_index = model_->FirstPanelIndex(); 819 int first_panel_index = model_->FirstPanelIndex();
820 int last_button_index = first_panel_index - 1; 820 int last_button_index = first_panel_index - 1;
821 821
822 int x = 0; 822 int x = 0;
823 int y = 0; 823 int y = 0;
824 int button_size = kShelfButtonSize; 824 int button_size = GetShelfConstant(SHELF_BUTTON_SIZE);
825 int button_spacing = kShelfButtonSpacing; 825 int button_spacing = GetShelfConstant(SHELF_BUTTON_SPACING);
826 826
827 int w = shelf_->PrimaryAxisValue(button_size, width()); 827 int w = shelf_->PrimaryAxisValue(button_size, width());
828 int h = shelf_->PrimaryAxisValue(height(), button_size); 828 int h = shelf_->PrimaryAxisValue(height(), button_size);
829 for (int i = 0; i < view_model_->view_size(); ++i) { 829 for (int i = 0; i < view_model_->view_size(); ++i) {
830 if (i < first_visible_index_) { 830 if (i < first_visible_index_) {
831 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0)); 831 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0));
832 continue; 832 continue;
833 } 833 }
834 834
835 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); 835 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h));
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 view_model_->view_at(last_button_index)->bounds(); 1415 view_model_->view_at(last_button_index)->bounds();
1416 if (overflow_button_->visible() && 1416 if (overflow_button_->visible() &&
1417 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) { 1417 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) {
1418 // When overflow button is visible and shelf has no panel items, 1418 // When overflow button is visible and shelf has no panel items,
1419 // last_button_bounds should be overflow button's bounds. 1419 // last_button_bounds should be overflow button's bounds.
1420 last_button_bounds = overflow_button_->bounds(); 1420 last_button_bounds = overflow_button_->bounds();
1421 } 1421 }
1422 1422
1423 if (shelf_->IsHorizontalAlignment()) { 1423 if (shelf_->IsHorizontalAlignment()) {
1424 preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_, 1424 preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_,
1425 kShelfSize); 1425 GetShelfConstant(SHELF_SIZE));
1426 } else { 1426 } else {
1427 preferred_size = gfx::Size(kShelfSize, 1427 preferred_size = gfx::Size(GetShelfConstant(SHELF_SIZE),
1428 last_button_bounds.bottom() + leading_inset_); 1428 last_button_bounds.bottom() + leading_inset_);
1429 } 1429 }
1430 } 1430 }
1431 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); 1431 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0);
1432 1432
1433 // In overflow mode, we should use OverflowBubbleView as a source for 1433 // In overflow mode, we should use OverflowBubbleView as a source for
1434 // converting |origin| to screen coordinates. When a scroll operation is 1434 // converting |origin| to screen coordinates. When a scroll operation is
1435 // occurred in OverflowBubble, the bounds of ShelfView in OverflowBubble can 1435 // occurred in OverflowBubble, the bounds of ShelfView in OverflowBubble can
1436 // be changed. 1436 // be changed.
1437 if (is_overflow_mode()) 1437 if (is_overflow_mode())
(...skipping 29 matching lines...) Expand all
1467 // If the modified view will be at the end of the list, return the new end of 1467 // If the modified view will be at the end of the list, return the new end of
1468 // the list. 1468 // the list.
1469 if (at_end) 1469 if (at_end)
1470 return view_model_->view_size(); 1470 return view_model_->view_size();
1471 return modified_view ? view_model_->GetIndexOfView(modified_view) : -1; 1471 return modified_view ? view_model_->GetIndexOfView(modified_view) : -1;
1472 } 1472 }
1473 1473
1474 gfx::Size ShelfView::GetPreferredSize() const { 1474 gfx::Size ShelfView::GetPreferredSize() const {
1475 IdealBounds ideal_bounds; 1475 IdealBounds ideal_bounds;
1476 CalculateIdealBounds(&ideal_bounds); 1476 CalculateIdealBounds(&ideal_bounds);
1477 const int shelf_size = GetShelfConstant(SHELF_SIZE);
1477 1478
1478 int last_button_index = is_overflow_mode() ? 1479 int last_button_index = is_overflow_mode() ?
1479 last_visible_index_ : view_model_->view_size() - 1; 1480 last_visible_index_ : view_model_->view_size() - 1;
1480 1481
1481 // When an item is dragged off from the overflow bubble, it is moved to last 1482 // When an item is dragged off from the overflow bubble, it is moved to last
1482 // position and and changed to invisible. Overflow bubble size should be 1483 // position and and changed to invisible. Overflow bubble size should be
1483 // shrunk to fit only for visible items. 1484 // shrunk to fit only for visible items.
1484 // If |dragged_off_from_overflow_to_shelf_| is set, there will be no invisible 1485 // If |dragged_off_from_overflow_to_shelf_| is set, there will be no invisible
1485 // items in the shelf. 1486 // items in the shelf.
1486 if (is_overflow_mode() && 1487 if (is_overflow_mode() &&
1487 dragged_off_shelf_ && 1488 dragged_off_shelf_ &&
1488 !dragged_off_from_overflow_to_shelf_ && 1489 !dragged_off_from_overflow_to_shelf_ &&
1489 RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE) 1490 RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE)
1490 last_button_index--; 1491 last_button_index--;
1491 1492
1492 const gfx::Rect last_button_bounds = 1493 const gfx::Rect last_button_bounds =
1493 last_button_index >= first_visible_index_ ? 1494 last_button_index >= first_visible_index_
1494 view_model_->ideal_bounds(last_button_index) : 1495 ? view_model_->ideal_bounds(last_button_index)
1495 gfx::Rect(gfx::Size(kShelfSize, kShelfSize)); 1496 : gfx::Rect(gfx::Size(shelf_size, shelf_size));
1496 1497
1497 if (shelf_->IsHorizontalAlignment()) 1498 if (shelf_->IsHorizontalAlignment())
1498 return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize); 1499 return gfx::Size(last_button_bounds.right() + leading_inset_, shelf_size);
1499 1500
1500 return gfx::Size(kShelfSize, last_button_bounds.bottom() + leading_inset_); 1501 return gfx::Size(shelf_size, last_button_bounds.bottom() + leading_inset_);
1501 } 1502 }
1502 1503
1503 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1504 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1504 // This bounds change is produced by the shelf movement and all content has 1505 // This bounds change is produced by the shelf movement and all content has
1505 // to follow. Using an animation at that time would produce a time lag since 1506 // to follow. Using an animation at that time would produce a time lag since
1506 // the animation of the BoundsAnimator has itself a delay before it arrives 1507 // the animation of the BoundsAnimator has itself a delay before it arrives
1507 // at the required location. As such we tell the animator to go there 1508 // at the required location. As such we tell the animator to go there
1508 // immediately. 1509 // immediately.
1509 BoundsAnimatorDisabler disabler(bounds_animator_.get()); 1510 BoundsAnimatorDisabler disabler(bounds_animator_.get());
1510 LayoutToIdealBounds(); 1511 LayoutToIdealBounds();
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 1898
1898 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1899 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1899 const gfx::Rect bounds = GetBoundsInScreen(); 1900 const gfx::Rect bounds = GetBoundsInScreen();
1900 int distance = shelf_->SelectValueForShelfAlignment( 1901 int distance = shelf_->SelectValueForShelfAlignment(
1901 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1902 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1902 bounds.x() - coordinate.x()); 1903 bounds.x() - coordinate.x());
1903 return distance > 0 ? distance : 0; 1904 return distance > 0 ? distance : 0;
1904 } 1905 }
1905 1906
1906 } // namespace ash 1907 } // 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