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

Side by Side Diff: chrome/browser/ui/views/frame/contents_container.cc

Issue 4932001: Makes the current page dim out when transitioning to instant preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 10 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/views/frame/contents_container.h ('k') | chrome/test/test_browser_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/skia/include/core/SkColor.h"
9 #include "views/background.h"
10 #include "views/widget/root_view.h"
11 #include "views/widget/widget.h"
12
13 // Min/max opacity of the overlay.
14 static const int kMinOpacity = 0;
15 static const int kMaxOpacity = 192;
16
7 ContentsContainer::ContentsContainer(views::View* active) 17 ContentsContainer::ContentsContainer(views::View* active)
8 : active_(active), 18 : active_(active),
9 preview_(NULL), 19 preview_(NULL),
10 preview_tab_contents_(NULL), 20 preview_tab_contents_(NULL),
21 active_overlay_(NULL),
11 active_top_margin_(0) { 22 active_top_margin_(0) {
12 AddChildView(active_); 23 AddChildView(active_);
13 } 24 }
14 25
15 ContentsContainer::~ContentsContainer() { 26 ContentsContainer::~ContentsContainer() {
27 // We don't need to explicitly delete active_overlay_ as it'll be deleted by
28 // virtue of being a child window.
16 } 29 }
17 30
18 void ContentsContainer::MakePreviewContentsActiveContents() { 31 void ContentsContainer::MakePreviewContentsActiveContents() {
32 RemoveFade();
33
19 active_ = preview_; 34 active_ = preview_;
20 preview_ = NULL; 35 preview_ = NULL;
21 Layout(); 36 Layout();
22 } 37 }
23 38
24 void ContentsContainer::SetPreview(views::View* preview, 39 void ContentsContainer::SetPreview(views::View* preview,
25 TabContents* preview_tab_contents) { 40 TabContents* preview_tab_contents) {
26 if (preview == preview_) 41 if (preview == preview_)
27 return; 42 return;
28 43
(...skipping 16 matching lines...) Expand all
45 // haven't changed. 60 // haven't changed.
46 InvalidateLayout(); 61 InvalidateLayout();
47 } 62 }
48 63
49 gfx::Rect ContentsContainer::GetPreviewBounds() { 64 gfx::Rect ContentsContainer::GetPreviewBounds() {
50 gfx::Point screen_loc; 65 gfx::Point screen_loc;
51 ConvertPointToScreen(this, &screen_loc); 66 ConvertPointToScreen(this, &screen_loc);
52 return gfx::Rect(screen_loc, size()); 67 return gfx::Rect(screen_loc, size());
53 } 68 }
54 69
70 void ContentsContainer::FadeActiveContents() {
71 if (active_overlay_)
72 return;
73
74 #if !defined(OS_WIN)
75 // TODO: fix this. I'm disabling as z-order isn't right on linux so that
76 // overlay ends up obscuring the omnibox.
77 return;
78 #endif
79
80 overlay_animation_.reset(new SlideAnimation(this));
81 overlay_animation_->SetDuration(300);
82 overlay_animation_->SetSlideDuration(300);
83 overlay_animation_->Show();
84
85 active_overlay_ = views::Widget::CreatePopupWidget(views::Widget::Transparent,
86 views::Widget::NotAcceptEvents,
87 views::Widget::DeleteOnDestroy,
88 views::Widget::MirrorOriginInRTL);
89 active_overlay_->SetOpacity(0);
90 gfx::Point screen_origin;
91 views::View::ConvertPointToScreen(active_, &screen_origin);
92 gfx::Rect overlay_bounds(screen_origin, active_->size());
93 active_overlay_->Init(active_->GetWidget()->GetNativeView(), overlay_bounds);
94 views::View* content_view = new views::View();
95 content_view->set_background(
96 views::Background::CreateSolidBackground(SK_ColorWHITE));
97 active_overlay_->SetContentsView(content_view);
98 active_overlay_->Show();
99 active_overlay_->MoveAbove(active_->GetWidget());
100 }
101
102 void ContentsContainer::RemoveFade() {
103 overlay_animation_.reset();
104 if (active_overlay_) {
105 active_overlay_->Close();
106 active_overlay_ = NULL;
107 }
108 }
109
110 void ContentsContainer::AnimationProgressed(const Animation* animation) {
111 active_overlay_->SetOpacity(
112 Tween::ValueBetween(animation->GetCurrentValue(), kMinOpacity,
113 kMaxOpacity));
114 active_overlay_->GetRootView()->SchedulePaint();
115 }
116
55 void ContentsContainer::Layout() { 117 void ContentsContainer::Layout() {
56 // The active view always gets the full bounds. 118 // The active view always gets the full bounds.
57 active_->SetBounds(0, active_top_margin_, width(), 119 active_->SetBounds(0, active_top_margin_, width(),
58 std::max(0, height() - active_top_margin_)); 120 std::max(0, height() - active_top_margin_));
59 121
60 if (preview_) 122 if (preview_)
61 preview_->SetBounds(0, 0, width(), height()); 123 preview_->SetBounds(0, 0, width(), height());
62 124
63 // Need to invoke views::View in case any views whose bounds didn't change 125 // Need to invoke views::View in case any views whose bounds didn't change
64 // still need a layout. 126 // still need a layout.
65 views::View::Layout(); 127 views::View::Layout();
66 } 128 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/contents_container.h ('k') | chrome/test/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698