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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/contents_container.cc
diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc
index c3056f794c1bae32a7fef3a4d53838dd82a89b5b..084c87f7cda3e1f73fb423c599a5c9d027497a95 100644
--- a/chrome/browser/ui/views/frame/contents_container.cc
+++ b/chrome/browser/ui/views/frame/contents_container.cc
@@ -4,18 +4,33 @@
#include "chrome/browser/views/frame/contents_container.h"
+#include "app/slide_animation.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "views/background.h"
+#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
+
+// Min/max opacity of the overlay.
+static const int kMinOpacity = 0;
+static const int kMaxOpacity = 192;
+
ContentsContainer::ContentsContainer(views::View* active)
: active_(active),
preview_(NULL),
preview_tab_contents_(NULL),
+ active_overlay_(NULL),
active_top_margin_(0) {
AddChildView(active_);
}
ContentsContainer::~ContentsContainer() {
+ // We don't need to explicitly delete active_overlay_ as it'll be deleted by
+ // virtue of being a child window.
}
void ContentsContainer::MakePreviewContentsActiveContents() {
+ RemoveFade();
+
active_ = preview_;
preview_ = NULL;
Layout();
@@ -52,6 +67,53 @@ gfx::Rect ContentsContainer::GetPreviewBounds() {
return gfx::Rect(screen_loc, size());
}
+void ContentsContainer::FadeActiveContents() {
+ if (active_overlay_)
+ return;
+
+#if !defined(OS_WIN)
+ // TODO: fix this. I'm disabling as z-order isn't right on linux so that
+ // overlay ends up obscuring the omnibox.
+ return;
+#endif
+
+ overlay_animation_.reset(new SlideAnimation(this));
+ overlay_animation_->SetDuration(300);
+ overlay_animation_->SetSlideDuration(300);
+ overlay_animation_->Show();
+
+ active_overlay_ = views::Widget::CreatePopupWidget(views::Widget::Transparent,
+ views::Widget::NotAcceptEvents,
+ views::Widget::DeleteOnDestroy,
+ views::Widget::MirrorOriginInRTL);
+ active_overlay_->SetOpacity(0);
+ gfx::Point screen_origin;
+ views::View::ConvertPointToScreen(active_, &screen_origin);
+ gfx::Rect overlay_bounds(screen_origin, active_->size());
+ active_overlay_->Init(active_->GetWidget()->GetNativeView(), overlay_bounds);
+ views::View* content_view = new views::View();
+ content_view->set_background(
+ views::Background::CreateSolidBackground(SK_ColorWHITE));
+ active_overlay_->SetContentsView(content_view);
+ active_overlay_->Show();
+ active_overlay_->MoveAbove(active_->GetWidget());
+}
+
+void ContentsContainer::RemoveFade() {
+ overlay_animation_.reset();
+ if (active_overlay_) {
+ active_overlay_->Close();
+ active_overlay_ = NULL;
+ }
+}
+
+void ContentsContainer::AnimationProgressed(const Animation* animation) {
+ active_overlay_->SetOpacity(
+ Tween::ValueBetween(animation->GetCurrentValue(), kMinOpacity,
+ kMaxOpacity));
+ active_overlay_->GetRootView()->SchedulePaint();
+}
+
void ContentsContainer::Layout() {
// The active view always gets the full bounds.
active_->SetBounds(0, active_top_margin_, width(),
« 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