Index: chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.cc |
=================================================================== |
--- chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.cc (revision 0) |
+++ chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.cc (revision 0) |
@@ -0,0 +1,88 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.h" |
+ |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/view_ids.h" |
+#include "chrome/browser/ui/views/frame/browser_view.h" |
+#include "chrome/browser/ui/views/sidebar/sidebar_base_tab.h" |
+#include "chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h" |
+#include "gfx/path.h" |
+#include "gfx/rect.h" |
+#include "gfx/size.h" |
+#include "views/widget/widget.h" |
+ |
+#if defined(OS_WIN) |
+#include "base/win/scoped_gdi_object.h" |
+#elif defined(OS_LINUX) |
+#include "ui/base/gtk/scoped_handle_gtk.h" |
+#endif |
+ |
+namespace { |
+#if defined(OS_WIN) |
+typedef base::win::ScopedRegion ScopedPlatformRegion; |
+#elif defined(OS_LINUX) |
+typedef ui::ScopedRegion ScopedPlatformRegion; |
+#else |
+#error Need OS specific ScopedRegion implementation |
+#endif |
+} // namespace |
+ |
+SidebarTabStripHost::SidebarTabStripHost(BrowserView* browser_view) |
+ : browser_view_(browser_view) { |
+} |
+ |
+void SidebarTabStripHost::Init(SidebarBaseTabStrip* view) { |
+ view_ = view; |
+ |
+ // Initialize the host. |
+ host_.reset(CreateHost()); |
+ host_->InitWithWidget(browser_view_->GetWidget(), gfx::Rect()); |
+ host_->SetContentsView(view_); |
+} |
+ |
+SidebarTabStripHost::~SidebarTabStripHost() { |
+} |
+ |
+void SidebarTabStripHost::SetPosition(const gfx::Rect& new_pos) { |
+ if (new_pos.IsEmpty()) { |
+ host_->Hide(); |
+ return; |
+ } |
+ |
+ SetWidgetPositionNative(new_pos, false); |
+ |
+ if (!host_->IsVisible()) |
+ host_->Show(); |
+} |
+ |
+// The host widget needs its shape to match the tab strip, so we create |
+// a polygon that corresponds to the tab strip shape. The polygon is then |
+// given to SetWindowRgn which changes the window from being a rectangle |
+// in shape, to match the current shape of the sidebar tab strip. |
+void SidebarTabStripHost::UpdateWindowEdges() { |
+ // Update window shape to match the view shape. |
+ ScopedPlatformRegion region; |
+ for (int i = 0; i < view()->tab_count(); ++i) { |
+ gfx::Path tab_shape; |
+ SidebarBaseTab* tab = view()->base_tab_at_tab_index(i); |
+ tab->GetShape(&tab_shape); |
+ |
+ tab_shape.offset(SkIntToScalar(tab->x()), SkIntToScalar(tab->y())); |
+ |
+ if (!region.Get()) { |
+ region.Set(tab_shape.CreateNativeRegion()); |
+ } else { |
+ ScopedPlatformRegion tab_region(tab_shape.CreateNativeRegion()); |
+ region.Set(gfx::Path::CombineRegions(tab_region.Get(), region.Get())); |
+ } |
+ } |
+ host_->SetShape(region.release()); |
+} |
+ |
+gfx::Size SidebarTabStripHost::GetContentsSize() const { |
+ return view_->size(); |
+} |
+ |
Property changes on: chrome\browser\ui\views\sidebar\sidebar_tab_strip_host.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |