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

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

Issue 130983007: Creating multi profile animations for switching users and teleporting of windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const int kRipOffDistance = 48; 114 const int kRipOffDistance = 48;
115 115
116 // The rip off drag and drop proxy image should get scaled by this factor. 116 // The rip off drag and drop proxy image should get scaled by this factor.
117 const float kDragAndDropProxyScale = 1.5f; 117 const float kDragAndDropProxyScale = 1.5f;
118 118
119 // The opacity represents that this partially disappeared item will get removed. 119 // The opacity represents that this partially disappeared item will get removed.
120 const float kDraggedImageOpacity = 0.5f; 120 const float kDraggedImageOpacity = 0.5f;
121 121
122 namespace { 122 namespace {
123 123
124 // A class to temporarily disable a given bounds animator.
125 class BoundsAnimatorDisabler {
126 public:
127 BoundsAnimatorDisabler(views::BoundsAnimator* bounds_animator)
128 : old_duration_(bounds_animator->GetAnimationDuration()),
129 bounds_animator_(bounds_animator) {
130 bounds_animator_->SetAnimationDuration(1);
Harry McCleave 2014/01/25 01:28:02 Is the 1 ms needed here, would it be better to hav
Mr4D (OOO till 08-26) 2014/01/27 15:37:52 Unfortunately a 1 is required, otherwise there wil
131 }
132
133 ~BoundsAnimatorDisabler() {
134 bounds_animator_->SetAnimationDuration(old_duration_);
135 }
136
137 private:
138 // The previous animation duration.
139 int old_duration_;
140 // The bounds animator which gets used.
141 views::BoundsAnimator* bounds_animator_;
142
143 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorDisabler);
144 };
145
124 // The MenuModelAdapter gets slightly changed to adapt the menu appearance to 146 // The MenuModelAdapter gets slightly changed to adapt the menu appearance to
125 // our requirements. 147 // our requirements.
126 class ShelfMenuModelAdapter : public views::MenuModelAdapter { 148 class ShelfMenuModelAdapter : public views::MenuModelAdapter {
127 public: 149 public:
128 explicit ShelfMenuModelAdapter(ShelfMenuModel* menu_model); 150 explicit ShelfMenuModelAdapter(ShelfMenuModel* menu_model);
129 151
130 // views::MenuModelAdapter: 152 // views::MenuModelAdapter:
131 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; 153 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE;
132 virtual bool IsCommandEnabled(int id) const OVERRIDE; 154 virtual bool IsCommandEnabled(int id) const OVERRIDE;
133 virtual void GetHorizontalIconMargins(int id, 155 virtual void GetHorizontalIconMargins(int id,
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 if (layout_manager_->IsHorizontalAlignment()) { 1505 if (layout_manager_->IsHorizontalAlignment()) {
1484 return gfx::Size(last_button_bounds.right() + leading_inset_, 1506 return gfx::Size(last_button_bounds.right() + leading_inset_,
1485 preferred_size); 1507 preferred_size);
1486 } 1508 }
1487 1509
1488 return gfx::Size(preferred_size, 1510 return gfx::Size(preferred_size,
1489 last_button_bounds.bottom() + leading_inset_); 1511 last_button_bounds.bottom() + leading_inset_);
1490 } 1512 }
1491 1513
1492 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1514 void ShelfView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1515 // This bounds change is produced by the shelf movement and all content has
1516 // to follow. Using an animation at that time would produce a time lag since
1517 // the animation of the BoundsAnimator has itself a delay before it arrives
1518 // at the required location. As such we tell the animator to go there
1519 // immediately.
1520 BoundsAnimatorDisabler disabler(bounds_animator_.get());
1493 LayoutToIdealBounds(); 1521 LayoutToIdealBounds();
1494 FOR_EACH_OBSERVER(ShelfIconObserver, observers_, 1522 FOR_EACH_OBSERVER(ShelfIconObserver, observers_,
1495 OnShelfIconPositionsChanged()); 1523 OnShelfIconPositionsChanged());
1496 1524
1497 if (IsShowingOverflowBubble()) 1525 if (IsShowingOverflowBubble())
1498 overflow_bubble_->Hide(); 1526 overflow_bubble_->Hide();
1499 } 1527 }
1500 1528
1501 views::FocusTraversable* ShelfView::GetPaneFocusTraversable() { 1529 views::FocusTraversable* ShelfView::GetPaneFocusTraversable() {
1502 return this; 1530 return this;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 break; 2051 break;
2024 case SHELF_ALIGNMENT_TOP: 2052 case SHELF_ALIGNMENT_TOP:
2025 distance = coordinate.y() - bounds.bottom(); 2053 distance = coordinate.y() - bounds.bottom();
2026 break; 2054 break;
2027 } 2055 }
2028 return distance > 0 ? distance : 0; 2056 return distance > 0 ? distance : 0;
2029 } 2057 }
2030 2058
2031 } // namespace internal 2059 } // namespace internal
2032 } // namespace ash 2060 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698