OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/views/frame/contents_container.h" | 5 #include "chrome/browser/views/frame/contents_container.h" |
6 | 6 |
7 #include "app/slide_animation.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "ui/base/animation/slide_animation.h" |
10 #include "views/background.h" | 10 #include "views/background.h" |
11 #include "views/widget/root_view.h" | 11 #include "views/widget/root_view.h" |
12 #include "views/widget/widget.h" | 12 #include "views/widget/widget.h" |
13 | 13 |
14 // Min/max opacity of the overlay. | 14 // Min/max opacity of the overlay. |
15 static const int kMinOpacity = 0; | 15 static const int kMinOpacity = 0; |
16 static const int kMaxOpacity = 192; | 16 static const int kMaxOpacity = 192; |
17 | 17 |
18 // View used to track when the overlay widget is destroyed. If the | 18 // View used to track when the overlay widget is destroyed. If the |
19 // ContentsContainer is still valid when the destructor is invoked this invokes | 19 // ContentsContainer is still valid when the destructor is invoked this invokes |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 InvalidateLayout(); | 88 InvalidateLayout(); |
89 } | 89 } |
90 | 90 |
91 gfx::Rect ContentsContainer::GetPreviewBounds() { | 91 gfx::Rect ContentsContainer::GetPreviewBounds() { |
92 gfx::Point screen_loc; | 92 gfx::Point screen_loc; |
93 ConvertPointToScreen(this, &screen_loc); | 93 ConvertPointToScreen(this, &screen_loc); |
94 return gfx::Rect(screen_loc, size()); | 94 return gfx::Rect(screen_loc, size()); |
95 } | 95 } |
96 | 96 |
97 void ContentsContainer::FadeActiveContents() { | 97 void ContentsContainer::FadeActiveContents() { |
98 if (active_overlay_ || !Animation::ShouldRenderRichAnimation()) | 98 if (active_overlay_ || !ui::Animation::ShouldRenderRichAnimation()) |
99 return; | 99 return; |
100 | 100 |
101 #if !defined(OS_WIN) | 101 #if !defined(OS_WIN) |
102 // TODO: fix this. I'm disabling as z-order isn't right on linux so that | 102 // TODO: fix this. I'm disabling as z-order isn't right on linux so that |
103 // overlay ends up obscuring the omnibox. | 103 // overlay ends up obscuring the omnibox. |
104 return; | 104 return; |
105 #endif | 105 #endif |
106 | 106 |
107 overlay_animation_.reset(new SlideAnimation(this)); | 107 overlay_animation_.reset(new ui::SlideAnimation(this)); |
108 overlay_animation_->SetDuration(300); | 108 overlay_animation_->SetDuration(300); |
109 overlay_animation_->SetSlideDuration(300); | 109 overlay_animation_->SetSlideDuration(300); |
110 overlay_animation_->Show(); | 110 overlay_animation_->Show(); |
111 | 111 |
112 CreateOverlay(kMinOpacity); | 112 CreateOverlay(kMinOpacity); |
113 } | 113 } |
114 | 114 |
115 void ContentsContainer::ShowFade() { | 115 void ContentsContainer::ShowFade() { |
116 if (active_overlay_ || !Animation::ShouldRenderRichAnimation()) | 116 if (active_overlay_ || !ui::Animation::ShouldRenderRichAnimation()) |
117 return; | 117 return; |
118 | 118 |
119 CreateOverlay(kMaxOpacity); | 119 CreateOverlay(kMaxOpacity); |
120 } | 120 } |
121 | 121 |
122 void ContentsContainer::RemoveFade() { | 122 void ContentsContainer::RemoveFade() { |
123 overlay_animation_.reset(); | 123 overlay_animation_.reset(); |
124 if (active_overlay_) { | 124 if (active_overlay_) { |
125 overlay_view_->Detach(); | 125 overlay_view_->Detach(); |
126 overlay_view_ = NULL; | 126 overlay_view_ = NULL; |
127 active_overlay_->Close(); | 127 active_overlay_->Close(); |
128 active_overlay_ = NULL; | 128 active_overlay_ = NULL; |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void ContentsContainer::AnimationProgressed(const Animation* animation) { | 132 void ContentsContainer::AnimationProgressed(const ui::Animation* animation) { |
133 active_overlay_->SetOpacity( | 133 active_overlay_->SetOpacity( |
134 Tween::ValueBetween(animation->GetCurrentValue(), kMinOpacity, | 134 ui::Tween::ValueBetween(animation->GetCurrentValue(), kMinOpacity, |
135 kMaxOpacity)); | 135 kMaxOpacity)); |
136 active_overlay_->GetRootView()->SchedulePaint(); | 136 active_overlay_->GetRootView()->SchedulePaint(); |
137 } | 137 } |
138 | 138 |
139 void ContentsContainer::Layout() { | 139 void ContentsContainer::Layout() { |
140 // The active view always gets the full bounds. | 140 // The active view always gets the full bounds. |
141 active_->SetBounds(0, active_top_margin_, width(), | 141 active_->SetBounds(0, active_top_margin_, width(), |
142 std::max(0, height() - active_top_margin_)); | 142 std::max(0, height() - active_top_margin_)); |
143 | 143 |
144 if (preview_) | 144 if (preview_) |
145 preview_->SetBounds(0, 0, width(), height()); | 145 preview_->SetBounds(0, 0, width(), height()); |
(...skipping 19 matching lines...) Expand all Loading... |
165 views::Background::CreateSolidBackground(SK_ColorWHITE)); | 165 views::Background::CreateSolidBackground(SK_ColorWHITE)); |
166 active_overlay_->SetContentsView(overlay_view_); | 166 active_overlay_->SetContentsView(overlay_view_); |
167 active_overlay_->Show(); | 167 active_overlay_->Show(); |
168 active_overlay_->MoveAbove(active_->GetWidget()); | 168 active_overlay_->MoveAbove(active_->GetWidget()); |
169 } | 169 } |
170 | 170 |
171 void ContentsContainer::OverlayViewDestroyed() { | 171 void ContentsContainer::OverlayViewDestroyed() { |
172 active_overlay_ = NULL; | 172 active_overlay_ = NULL; |
173 overlay_view_ = NULL; | 173 overlay_view_ = NULL; |
174 } | 174 } |
OLD | NEW |