| OLD | NEW |
| 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_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 int available_size = shelf_->PrimaryAxisValue(width(), height()); | 805 int available_size = shelf_->PrimaryAxisValue(width(), height()); |
| 806 DCHECK(model_->item_count() == view_model_->view_size()); | 806 DCHECK(model_->item_count() == view_model_->view_size()); |
| 807 if (!available_size) | 807 if (!available_size) |
| 808 return; | 808 return; |
| 809 | 809 |
| 810 int first_panel_index = model_->FirstPanelIndex(); | 810 int first_panel_index = model_->FirstPanelIndex(); |
| 811 int last_button_index = first_panel_index - 1; | 811 int last_button_index = first_panel_index - 1; |
| 812 | 812 |
| 813 int x = 0; | 813 int x = 0; |
| 814 int y = 0; | 814 int y = 0; |
| 815 int button_size = kShelfButtonSize; | 815 int button_size = GetShelfLayoutConstant(SHELF_BUTTON_SIZE); |
| 816 int button_spacing = kShelfButtonSpacing; | 816 int button_spacing = GetShelfLayoutConstant(SHELF_BUTTON_SPACING); |
| 817 | 817 |
| 818 int w = shelf_->PrimaryAxisValue(button_size, width()); | 818 int w = shelf_->PrimaryAxisValue(button_size, width()); |
| 819 int h = shelf_->PrimaryAxisValue(height(), button_size); | 819 int h = shelf_->PrimaryAxisValue(height(), button_size); |
| 820 for (int i = 0; i < view_model_->view_size(); ++i) { | 820 for (int i = 0; i < view_model_->view_size(); ++i) { |
| 821 if (i < first_visible_index_) { | 821 if (i < first_visible_index_) { |
| 822 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0)); | 822 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, 0, 0)); |
| 823 continue; | 823 continue; |
| 824 } | 824 } |
| 825 | 825 |
| 826 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); | 826 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 view_model_->view_at(last_button_index)->bounds(); | 1405 view_model_->view_at(last_button_index)->bounds(); |
| 1406 if (overflow_button_->visible() && | 1406 if (overflow_button_->visible() && |
| 1407 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) { | 1407 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) { |
| 1408 // When overflow button is visible and shelf has no panel items, | 1408 // When overflow button is visible and shelf has no panel items, |
| 1409 // last_button_bounds should be overflow button's bounds. | 1409 // last_button_bounds should be overflow button's bounds. |
| 1410 last_button_bounds = overflow_button_->bounds(); | 1410 last_button_bounds = overflow_button_->bounds(); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 if (shelf_->IsHorizontalAlignment()) { | 1413 if (shelf_->IsHorizontalAlignment()) { |
| 1414 preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_, | 1414 preferred_size = gfx::Size(last_button_bounds.right() + leading_inset_, |
| 1415 kShelfSize); | 1415 GetShelfLayoutConstant(SHELF_SIZE)); |
| 1416 } else { | 1416 } else { |
| 1417 preferred_size = gfx::Size(kShelfSize, | 1417 preferred_size = gfx::Size(GetShelfLayoutConstant(SHELF_SIZE), |
| 1418 last_button_bounds.bottom() + leading_inset_); | 1418 last_button_bounds.bottom() + leading_inset_); |
| 1419 } | 1419 } |
| 1420 } | 1420 } |
| 1421 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); | 1421 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); |
| 1422 | 1422 |
| 1423 // In overflow mode, we should use OverflowBubbleView as a source for | 1423 // In overflow mode, we should use OverflowBubbleView as a source for |
| 1424 // converting |origin| to screen coordinates. When a scroll operation is | 1424 // converting |origin| to screen coordinates. When a scroll operation is |
| 1425 // occurred in OverflowBubble, the bounds of ShelfView in OverflowBubble can | 1425 // occurred in OverflowBubble, the bounds of ShelfView in OverflowBubble can |
| 1426 // be changed. | 1426 // be changed. |
| 1427 if (is_overflow_mode()) | 1427 if (is_overflow_mode()) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 // shrunk to fit only for visible items. | 1473 // shrunk to fit only for visible items. |
| 1474 // If |dragged_off_from_overflow_to_shelf_| is set, there will be no invisible | 1474 // If |dragged_off_from_overflow_to_shelf_| is set, there will be no invisible |
| 1475 // items in the shelf. | 1475 // items in the shelf. |
| 1476 if (is_overflow_mode() && | 1476 if (is_overflow_mode() && |
| 1477 dragged_off_shelf_ && | 1477 dragged_off_shelf_ && |
| 1478 !dragged_off_from_overflow_to_shelf_ && | 1478 !dragged_off_from_overflow_to_shelf_ && |
| 1479 RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE) | 1479 RemovableByRipOff(view_model_->GetIndexOfView(drag_view_)) == REMOVABLE) |
| 1480 last_button_index--; | 1480 last_button_index--; |
| 1481 | 1481 |
| 1482 const gfx::Rect last_button_bounds = | 1482 const gfx::Rect last_button_bounds = |
| 1483 last_button_index >= first_visible_index_ ? | 1483 last_button_index >= first_visible_index_ |
| 1484 view_model_->ideal_bounds(last_button_index) : | 1484 ? view_model_->ideal_bounds(last_button_index) |
| 1485 gfx::Rect(gfx::Size(kShelfSize, kShelfSize)); | 1485 : gfx::Rect(gfx::Size(GetShelfLayoutConstant(SHELF_SIZE), |
| 1486 GetShelfLayoutConstant(SHELF_SIZE))); |
| 1486 | 1487 |
| 1487 if (shelf_->IsHorizontalAlignment()) | 1488 if (shelf_->IsHorizontalAlignment()) |
| 1488 return gfx::Size(last_button_bounds.right() + leading_inset_, kShelfSize); | 1489 return gfx::Size(last_button_bounds.right() + leading_inset_, |
| 1490 GetShelfLayoutConstant(SHELF_SIZE)); |
| 1489 | 1491 |
| 1490 return gfx::Size(kShelfSize, last_button_bounds.bottom() + leading_inset_); | 1492 return gfx::Size(GetShelfLayoutConstant(SHELF_SIZE), |
| 1493 last_button_bounds.bottom() + leading_inset_); |
| 1491 } | 1494 } |
| 1492 | 1495 |
| 1493 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1496 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1494 // This bounds change is produced by the shelf movement and all content has | 1497 // This bounds change is produced by the shelf movement and all content has |
| 1495 // to follow. Using an animation at that time would produce a time lag since | 1498 // to follow. Using an animation at that time would produce a time lag since |
| 1496 // the animation of the BoundsAnimator has itself a delay before it arrives | 1499 // the animation of the BoundsAnimator has itself a delay before it arrives |
| 1497 // at the required location. As such we tell the animator to go there | 1500 // at the required location. As such we tell the animator to go there |
| 1498 // immediately. | 1501 // immediately. |
| 1499 BoundsAnimatorDisabler disabler(bounds_animator_.get()); | 1502 BoundsAnimatorDisabler disabler(bounds_animator_.get()); |
| 1500 LayoutToIdealBounds(); | 1503 LayoutToIdealBounds(); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 | 1890 |
| 1888 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1891 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1889 const gfx::Rect bounds = GetBoundsInScreen(); | 1892 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1890 int distance = shelf_->SelectValueForShelfAlignment( | 1893 int distance = shelf_->SelectValueForShelfAlignment( |
| 1891 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1894 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1892 bounds.x() - coordinate.x()); | 1895 bounds.x() - coordinate.x()); |
| 1893 return distance > 0 ? distance : 0; | 1896 return distance > 0 ? distance : 0; |
| 1894 } | 1897 } |
| 1895 | 1898 |
| 1896 } // namespace ash | 1899 } // namespace ash |
| OLD | NEW |