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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 // Removing and re-inserting a view in our view model will strip the ideal | 1612 // Removing and re-inserting a view in our view model will strip the ideal |
1613 // bounds from the item. To avoid recalculation of everything the bounds | 1613 // bounds from the item. To avoid recalculation of everything the bounds |
1614 // get remembered and restored after the insertion to the previous value. | 1614 // get remembered and restored after the insertion to the previous value. |
1615 gfx::Rect old_ideal_bounds = view_model_->ideal_bounds(model_index); | 1615 gfx::Rect old_ideal_bounds = view_model_->ideal_bounds(model_index); |
1616 view_model_->Remove(model_index); | 1616 view_model_->Remove(model_index); |
1617 views::View* new_view = CreateViewForItem(item); | 1617 views::View* new_view = CreateViewForItem(item); |
1618 AddChildView(new_view); | 1618 AddChildView(new_view); |
1619 view_model_->Add(new_view, model_index); | 1619 view_model_->Add(new_view, model_index); |
1620 view_model_->set_ideal_bounds(model_index, old_ideal_bounds); | 1620 view_model_->set_ideal_bounds(model_index, old_ideal_bounds); |
1621 new_view->SetBoundsRect(old_view->bounds()); | 1621 new_view->SetBoundsRect(old_view->bounds()); |
1622 if (overflow_button_ && overflow_button_->visible()) | |
1623 AnimateToIdealBounds(); | |
1624 return; | 1622 return; |
1625 } | 1623 } |
1626 | 1624 |
1627 views::View* view = view_model_->view_at(model_index); | 1625 views::View* view = view_model_->view_at(model_index); |
1628 switch (item.type) { | 1626 switch (item.type) { |
1629 case TYPE_BROWSER_SHORTCUT: | 1627 case TYPE_BROWSER_SHORTCUT: |
1630 // Fallthrough for the new Shelf since it needs to show the activation | 1628 // Fallthrough for the new Shelf since it needs to show the activation |
1631 // change as well. | 1629 // change as well. |
1632 case TYPE_APP_SHORTCUT: | 1630 case TYPE_APP_SHORTCUT: |
1633 case TYPE_WINDOWED_APP: | 1631 case TYPE_WINDOWED_APP: |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 snap_back_from_rip_off_view_ = nullptr; | 1860 snap_back_from_rip_off_view_ = nullptr; |
1863 } | 1861 } |
1864 } | 1862 } |
1865 } | 1863 } |
1866 | 1864 |
1867 bool ShelfView::IsRepostEvent(const ui::Event& event) { | 1865 bool ShelfView::IsRepostEvent(const ui::Event& event) { |
1868 if (closing_event_time_.is_zero()) | 1866 if (closing_event_time_.is_zero()) |
1869 return false; | 1867 return false; |
1870 | 1868 |
1871 base::TimeDelta delta = | 1869 base::TimeDelta delta = |
1872 base::TimeDelta(event.time_stamp() - closing_event_time_); | 1870 (event.time_stamp() - base::TimeTicks()) - closing_event_time_; |
1873 closing_event_time_ = base::TimeDelta(); | 1871 closing_event_time_ = base::TimeDelta(); |
1874 // If the current (press down) event is a repost event, the time stamp of | 1872 // If the current (press down) event is a repost event, the time stamp of |
1875 // these two events should be the same. | 1873 // these two events should be the same. |
1876 return (delta.InMilliseconds() == 0); | 1874 return (delta.InMilliseconds() == 0); |
1877 } | 1875 } |
1878 | 1876 |
1879 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const { | 1877 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const { |
1880 const int view_index = view_model_->GetIndexOfView(view); | 1878 const int view_index = view_model_->GetIndexOfView(view); |
1881 return (view_index < 0) ? nullptr : &(model_->items()[view_index]); | 1879 return (view_index < 0) ? nullptr : &(model_->items()[view_index]); |
1882 } | 1880 } |
1883 | 1881 |
1884 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1882 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
1885 const gfx::Rect bounds = GetBoundsInScreen(); | 1883 const gfx::Rect bounds = GetBoundsInScreen(); |
1886 int distance = shelf_->SelectValueForShelfAlignment( | 1884 int distance = shelf_->SelectValueForShelfAlignment( |
1887 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1885 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
1888 bounds.x() - coordinate.x()); | 1886 bounds.x() - coordinate.x()); |
1889 return distance > 0 ? distance : 0; | 1887 return distance > 0 ? distance : 0; |
1890 } | 1888 } |
1891 | 1889 |
1892 } // namespace ash | 1890 } // namespace ash |
OLD | NEW |