| 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/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
| 11 #include "ash/common/ash_switches.h" | 11 #include "ash/common/ash_switches.h" |
| 12 #include "ash/common/drag_drop/drag_image_view.h" | 12 #include "ash/common/drag_drop/drag_image_view.h" |
| 13 #include "ash/common/scoped_root_window_for_new_windows.h" | 13 #include "ash/common/scoped_root_window_for_new_windows.h" |
| 14 #include "ash/common/shelf/app_list_button.h" | 14 #include "ash/common/shelf/app_list_button.h" |
| 15 #include "ash/common/shelf/overflow_bubble.h" | 15 #include "ash/common/shelf/overflow_bubble.h" |
| 16 #include "ash/common/shelf/overflow_bubble_view.h" | 16 #include "ash/common/shelf/overflow_bubble_view.h" |
| 17 #include "ash/common/shelf/overflow_button.h" | 17 #include "ash/common/shelf/overflow_button.h" |
| 18 #include "ash/common/shelf/shelf_button.h" | 18 #include "ash/common/shelf/shelf_button.h" |
| 19 #include "ash/common/shelf/shelf_constants.h" | 19 #include "ash/common/shelf/shelf_constants.h" |
| 20 #include "ash/common/shelf/shelf_delegate.h" | 20 #include "ash/common/shelf/shelf_delegate.h" |
| 21 #include "ash/common/shelf/shelf_icon_observer.h" | |
| 22 #include "ash/common/shelf/shelf_menu_model.h" | 21 #include "ash/common/shelf/shelf_menu_model.h" |
| 23 #include "ash/common/shelf/shelf_model.h" | 22 #include "ash/common/shelf/shelf_model.h" |
| 24 #include "ash/common/shelf/wm_shelf.h" | 23 #include "ash/common/shelf/wm_shelf.h" |
| 25 #include "ash/common/shell_delegate.h" | 24 #include "ash/common/shell_delegate.h" |
| 26 #include "ash/common/wm/root_window_finder.h" | 25 #include "ash/common/wm/root_window_finder.h" |
| 27 #include "ash/common/wm_lookup.h" | 26 #include "ash/common/wm_lookup.h" |
| 28 #include "ash/common/wm_shell.h" | 27 #include "ash/common/wm_shell.h" |
| 29 #include "ash/common/wm_window.h" | 28 #include "ash/common/wm_window.h" |
| 30 #include "ash/shelf/shelf_widget.h" | 29 #include "ash/shelf/shelf_widget.h" |
| 31 #include "base/auto_reset.h" | 30 #include "base/auto_reset.h" |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 int index = model_->FirstPanelIndex(); | 1045 int index = model_->FirstPanelIndex(); |
| 1047 while (index < view_model_->view_size() && | 1046 while (index < view_model_->view_size() && |
| 1048 wm_shelf_->PrimaryAxisValue( | 1047 wm_shelf_->PrimaryAxisValue( |
| 1049 view_model_->ideal_bounds(index).right(), | 1048 view_model_->ideal_bounds(index).right(), |
| 1050 view_model_->ideal_bounds(index).bottom()) < min_value) { | 1049 view_model_->ideal_bounds(index).bottom()) < min_value) { |
| 1051 ++index; | 1050 ++index; |
| 1052 } | 1051 } |
| 1053 return index; | 1052 return index; |
| 1054 } | 1053 } |
| 1055 | 1054 |
| 1056 void ShelfView::AddIconObserver(ShelfIconObserver* observer) { | |
| 1057 observers_.AddObserver(observer); | |
| 1058 } | |
| 1059 | |
| 1060 void ShelfView::RemoveIconObserver(ShelfIconObserver* observer) { | |
| 1061 observers_.RemoveObserver(observer); | |
| 1062 } | |
| 1063 | |
| 1064 void ShelfView::AnimateToIdealBounds() { | 1055 void ShelfView::AnimateToIdealBounds() { |
| 1065 IdealBounds ideal_bounds; | 1056 IdealBounds ideal_bounds; |
| 1066 CalculateIdealBounds(&ideal_bounds); | 1057 CalculateIdealBounds(&ideal_bounds); |
| 1067 for (int i = 0; i < view_model_->view_size(); ++i) { | 1058 for (int i = 0; i < view_model_->view_size(); ++i) { |
| 1068 View* view = view_model_->view_at(i); | 1059 View* view = view_model_->view_at(i); |
| 1069 bounds_animator_->AnimateViewTo(view, view_model_->ideal_bounds(i)); | 1060 bounds_animator_->AnimateViewTo(view, view_model_->ideal_bounds(i)); |
| 1070 // Now that the item animation starts, we have to make sure that the | 1061 // Now that the item animation starts, we have to make sure that the |
| 1071 // padding of the first gets properly transferred to the new first item. | 1062 // padding of the first gets properly transferred to the new first item. |
| 1072 if (i && view->border()) | 1063 if (i && view->border()) |
| 1073 view->SetBorder(views::Border::NullBorder()); | 1064 view->SetBorder(views::Border::NullBorder()); |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 } | 1582 } |
| 1592 | 1583 |
| 1593 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1584 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1594 // This bounds change is produced by the shelf movement and all content has | 1585 // This bounds change is produced by the shelf movement and all content has |
| 1595 // to follow. Using an animation at that time would produce a time lag since | 1586 // to follow. Using an animation at that time would produce a time lag since |
| 1596 // the animation of the BoundsAnimator has itself a delay before it arrives | 1587 // the animation of the BoundsAnimator has itself a delay before it arrives |
| 1597 // at the required location. As such we tell the animator to go there | 1588 // at the required location. As such we tell the animator to go there |
| 1598 // immediately. | 1589 // immediately. |
| 1599 BoundsAnimatorDisabler disabler(bounds_animator_.get()); | 1590 BoundsAnimatorDisabler disabler(bounds_animator_.get()); |
| 1600 LayoutToIdealBounds(); | 1591 LayoutToIdealBounds(); |
| 1601 FOR_EACH_OBSERVER(ShelfIconObserver, observers_, | 1592 wm_shelf_->NotifyShelfIconPositionsChanged(); |
| 1602 OnShelfIconPositionsChanged()); | |
| 1603 | 1593 |
| 1604 if (IsShowingOverflowBubble()) | 1594 if (IsShowingOverflowBubble()) |
| 1605 overflow_bubble_->Hide(); | 1595 overflow_bubble_->Hide(); |
| 1606 } | 1596 } |
| 1607 | 1597 |
| 1608 views::FocusTraversable* ShelfView::GetPaneFocusTraversable() { | 1598 views::FocusTraversable* ShelfView::GetPaneFocusTraversable() { |
| 1609 return this; | 1599 return this; |
| 1610 } | 1600 } |
| 1611 | 1601 |
| 1612 void ShelfView::GetAccessibleState(ui::AXViewState* state) { | 1602 void ShelfView::GetAccessibleState(ui::AXViewState* state) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 launcher_menu_runner_.reset(); | 1865 launcher_menu_runner_.reset(); |
| 1876 menu_model_adapter_.reset(); | 1866 menu_model_adapter_.reset(); |
| 1877 menu_model_.reset(); | 1867 menu_model_.reset(); |
| 1878 scoped_root_window_for_new_windows_.reset(); | 1868 scoped_root_window_for_new_windows_.reset(); |
| 1879 | 1869 |
| 1880 // Auto-hide or alignment might have changed, but only for this shelf. | 1870 // Auto-hide or alignment might have changed, but only for this shelf. |
| 1881 wm_shelf_->UpdateVisibilityState(); | 1871 wm_shelf_->UpdateVisibilityState(); |
| 1882 } | 1872 } |
| 1883 | 1873 |
| 1884 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { | 1874 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { |
| 1885 FOR_EACH_OBSERVER(ShelfIconObserver, observers_, | 1875 wm_shelf_->NotifyShelfIconPositionsChanged(); |
| 1886 OnShelfIconPositionsChanged()); | |
| 1887 PreferredSizeChanged(); | 1876 PreferredSizeChanged(); |
| 1888 } | 1877 } |
| 1889 | 1878 |
| 1890 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 1879 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
| 1891 if (snap_back_from_rip_off_view_ && animator == bounds_animator_.get()) { | 1880 if (snap_back_from_rip_off_view_ && animator == bounds_animator_.get()) { |
| 1892 if (!animator->IsAnimating(snap_back_from_rip_off_view_)) { | 1881 if (!animator->IsAnimating(snap_back_from_rip_off_view_)) { |
| 1893 // Coming here the animation of the ShelfButton is finished and the | 1882 // Coming here the animation of the ShelfButton is finished and the |
| 1894 // previously hidden status can be shown again. Since the button itself | 1883 // previously hidden status can be shown again. Since the button itself |
| 1895 // might have gone away or changed locations we check that the button | 1884 // might have gone away or changed locations we check that the button |
| 1896 // is still in the shelf and show its status again. | 1885 // is still in the shelf and show its status again. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1924 | 1913 |
| 1925 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1914 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1926 const gfx::Rect bounds = GetBoundsInScreen(); | 1915 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1927 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1916 int distance = wm_shelf_->SelectValueForShelfAlignment( |
| 1928 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1917 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1929 bounds.x() - coordinate.x()); | 1918 bounds.x() - coordinate.x()); |
| 1930 return distance > 0 ? distance : 0; | 1919 return distance > 0 ? distance : 0; |
| 1931 } | 1920 } |
| 1932 | 1921 |
| 1933 } // namespace ash | 1922 } // namespace ash |
| OLD | NEW |