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

Side by Side Diff: chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.cc

Issue 6250141: Sidebar mini tabs UI (views version).... Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/sidebar/sidebar_tab_strip_host.h"
6
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "chrome/browser/ui/views/sidebar/sidebar_base_tab.h"
11 #include "chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h"
12 #include "gfx/path.h"
13 #include "gfx/rect.h"
14 #include "gfx/size.h"
15 #include "views/widget/widget.h"
16
17 #if defined(OS_WIN)
18 #include "base/win/scoped_gdi_object.h"
19 #elif defined(OS_LINUX)
20 #include "ui/base/gtk/scoped_handle_gtk.h"
21 #endif
22
23 namespace {
24 #if defined(OS_WIN)
25 typedef base::win::ScopedRegion ScopedPlatformRegion;
26 #elif defined(OS_LINUX)
27 typedef ui::ScopedRegion ScopedPlatformRegion;
28 #else
29 #error Need OS specific ScopedRegion implementation
30 #endif
31 } // namespace
32
33 SidebarTabStripHost::SidebarTabStripHost(BrowserView* browser_view)
34 : browser_view_(browser_view) {
35 }
36
37 void SidebarTabStripHost::Init(SidebarBaseTabStrip* view) {
38 view_ = view;
39
40 // Initialize the host.
41 host_.reset(CreateHost());
42 host_->InitWithWidget(browser_view_->GetWidget(), gfx::Rect());
43 host_->SetContentsView(view_);
44 }
45
46 SidebarTabStripHost::~SidebarTabStripHost() {
47 }
48
49 void SidebarTabStripHost::SetPosition(const gfx::Rect& new_pos) {
50 if (new_pos.IsEmpty()) {
51 host_->Hide();
52 return;
53 }
54
55 SetWidgetPositionNative(new_pos, false);
56
57 if (!host_->IsVisible())
58 host_->Show();
59 }
60
61 // The host widget needs its shape to match the tab strip, so we create
62 // a polygon that corresponds to the tab strip shape. The polygon is then
63 // given to SetWindowRgn which changes the window from being a rectangle
64 // in shape, to match the current shape of the sidebar tab strip.
65 void SidebarTabStripHost::UpdateWindowEdges() {
66 // Update window shape to match the view shape.
67 ScopedPlatformRegion region;
68 for (int i = 0; i < view()->tab_count(); ++i) {
69 gfx::Path tab_shape;
70 SidebarBaseTab* tab = view()->base_tab_at_tab_index(i);
71 tab->GetShape(&tab_shape);
72
73 tab_shape.offset(SkIntToScalar(tab->x()), SkIntToScalar(tab->y()));
74
75 if (!region.Get()) {
76 region.Set(tab_shape.CreateNativeRegion());
77 } else {
78 ScopedPlatformRegion tab_region(tab_shape.CreateNativeRegion());
79 region.Set(gfx::Path::CombineRegions(tab_region.Get(), region.Get()));
80 }
81 }
82 host_->SetShape(region.release());
83 }
84
85 gfx::Size SidebarTabStripHost::GetContentsSize() const {
86 return view_->size();
87 }
88
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698