diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 01:34:34 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 01:34:34 +0000 |
commit | b608d84596f658c901d2936aee107041ecf5e4cd (patch) | |
tree | 0e07a5426286d80a702b3c6635a6e0ae8b6c5c3f /chrome/browser/views/frame | |
parent | 5fc6a04194611a82da93902458fa2b2a16fa1728 (diff) | |
download | chromium_src-b608d84596f658c901d2936aee107041ecf5e4cd.zip chromium_src-b608d84596f658c901d2936aee107041ecf5e4cd.tar.gz chromium_src-b608d84596f658c901d2936aee107041ecf5e4cd.tar.bz2 |
Make the side tabstrip participate in the layout of the BrowserView.
Turn on the side tabstrip by default when --enable-vertical-tabs is specified, for ease of testing/debugging.
Adjust glass rendering in this mode.
http://crbug.com/34509
TEST=none
Review URL: http://codereview.chromium.org/570029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/frame')
-rw-r--r-- | chrome/browser/views/frame/browser_frame_win.cc | 12 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view_layout.cc | 65 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view_layout.h | 5 | ||||
-rw-r--r-- | chrome/browser/views/frame/glass_browser_frame_view.cc | 15 |
6 files changed, 67 insertions, 46 deletions
diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc index c79c415..ddfe7ba 100644 --- a/chrome/browser/views/frame/browser_frame_win.cc +++ b/chrome/browser/views/frame/browser_frame_win.cc @@ -273,12 +273,20 @@ void BrowserFrameWin::UpdateDWMFrame() { margins.cxLeftWidth = kClientEdgeThickness + 1; margins.cxRightWidth = kClientEdgeThickness + 1; margins.cyBottomHeight = kClientEdgeThickness + 1; + margins.cyTopHeight = kClientEdgeThickness + 1; } // In maximized mode, we only have a titlebar strip of glass, no side/bottom // borders. if (!browser_view_->IsFullscreen()) { - margins.cyTopHeight = - GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); + if (browser_view_->UsingSideTabs()) { + margins.cxLeftWidth += + GetBoundsForTabStrip(browser_view_->tabstrip()).right(); + margins.cyTopHeight += + GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION); + } else { + margins.cyTopHeight = + GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); + } } } else { // For popup and app windows we want to use the default margins. diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index d27990d..caa6224 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -544,6 +544,10 @@ bool BrowserView::IsTabStripVisible() const { return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); } +bool BrowserView::UsingSideTabs() const { + return SideTabStrip::Visible(browser_->profile()); +} + bool BrowserView::IsOffTheRecord() const { return browser_->profile()->IsOffTheRecord(); } @@ -1595,12 +1599,9 @@ views::LayoutManager* BrowserView::CreateLayoutManager() const { } BaseTabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { - BaseTabStrip* tabstrip = NULL; - if (SideTabStrip::Visible(browser_->profile())) - tabstrip = new SideTabStrip; - else - tabstrip = new TabStrip(model); - return tabstrip; + if (UsingSideTabs()) + return new SideTabStrip; + return new TabStrip(model); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index cbd4701..c2f73cc 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -144,6 +144,9 @@ class BrowserView : public BrowserWindow, // Returns true if various window components are visible. bool IsTabStripVisible() const; + // Returns true if the vertical tabstrip is in use. + bool UsingSideTabs() const; + // Returns true if the profile associated with this Browser window is // off the record. bool IsOffTheRecord() const; diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc index 67fdbd2..316b702 100644 --- a/chrome/browser/views/frame/browser_view_layout.cc +++ b/chrome/browser/views/frame/browser_view_layout.cc @@ -245,7 +245,7 @@ void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { } void BrowserViewLayout::Layout(views::View* host) { - LayoutSideTabs(); + vertical_layout_rect_ = browser_view_->GetLocalBounds(true); int top = LayoutTabStrip(); top = LayoutToolbar(top); top = LayoutBookmarkAndInfoBars(top); @@ -274,47 +274,46 @@ gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { ////////////////////////////////////////////////////////////////////////////// // BrowserViewLayout, private: -void BrowserViewLayout::LayoutSideTabs() { - vertical_layout_rect_ = browser_view_->GetLocalBounds(true); - if (SideTabStrip::Visible(browser()->profile())) { - gfx::Size ps = tabstrip_->GetPreferredSize(); - vertical_layout_rect_.Inset(ps.width(), 0, 0, 0); - tabstrip_->SetBounds(0, 0, ps.width(), browser_view_->height()); - } -} - int BrowserViewLayout::LayoutTabStrip() { if (!browser_view_->IsTabStripVisible()) { tabstrip_->SetVisible(false); tabstrip_->SetBounds(0, 0, 0, 0); return 0; + } + gfx::Rect layout_bounds = + browser_view_->frame()->GetBoundsForTabStrip(tabstrip_); + + if (browser_view_->UsingSideTabs()) { + vertical_layout_rect_.Inset(layout_bounds.width(), 0, 0, 0); } else { - gfx::Rect layout_bounds = - browser_view_->frame()->GetBoundsForTabStrip(tabstrip_); gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds(); tabstrip_->SetBackgroundOffset( - gfx::Point(layout_bounds.x() - toolbar_bounds.x(), layout_bounds.y())); + gfx::Point(layout_bounds.x() - toolbar_bounds.x(), + layout_bounds.y())); + } - gfx::Point tabstrip_origin = layout_bounds.origin(); - views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_, + gfx::Point tabstrip_origin = layout_bounds.origin(); + views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_, &tabstrip_origin); - layout_bounds.set_origin(tabstrip_origin); - tabstrip_->SetVisible(true); - tabstrip_->SetBounds(layout_bounds); - return layout_bounds.bottom(); - } + layout_bounds.set_origin(tabstrip_origin); + tabstrip_->SetVisible(true); + tabstrip_->SetBounds(layout_bounds); + return browser_view_->UsingSideTabs() ? 0 : layout_bounds.bottom(); } int BrowserViewLayout::LayoutToolbar(int top) { - int browser_view_width = browser_view_->width(); + int browser_view_width = vertical_layout_rect_.width(); bool visible = browser_view_->IsToolbarVisible(); toolbar_->location_bar()->SetFocusable(visible); - int y = top - + int y = 0; + if (!browser_view_->UsingSideTabs()) { + y = top - ((visible && browser_view_->IsTabStripVisible()) ? kToolbarTabStripVerticalOverlap : 0); + } int height = visible ? toolbar_->GetPreferredSize().height() : 0; toolbar_->SetVisible(visible); - toolbar_->SetBounds(0, y, browser_view_width, height); + toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); return y + height; } @@ -335,7 +334,7 @@ int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { int BrowserViewLayout::LayoutBookmarkBar(int top) { DCHECK(active_bookmark_bar_); - int y = top, x = 0; + int y = top; if (!browser_view_->IsBookmarkBarVisible()) { active_bookmark_bar_->SetVisible(false); active_bookmark_bar_->SetBounds(0, y, browser_view_->width(), 0); @@ -348,8 +347,8 @@ int BrowserViewLayout::LayoutBookmarkBar(int top) { 0 : active_bookmark_bar_->GetToolbarOverlap(false)); active_bookmark_bar_->SetVisible(true); - active_bookmark_bar_->SetBounds(x, y, - browser_view_->width() - x, + active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(), y, + vertical_layout_rect_.width(), bookmark_bar_height); return y + bookmark_bar_height; } @@ -358,14 +357,16 @@ int BrowserViewLayout::LayoutInfoBar(int top) { bool visible = browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR); int height = visible ? infobar_container_->GetPreferredSize().height() : 0; infobar_container_->SetVisible(visible); - infobar_container_->SetBounds(0, top, browser_view_->width(), height); + infobar_container_->SetBounds(vertical_layout_rect_.x(), top, + vertical_layout_rect_.width(), height); return top + height; } // Layout the TabContents container, between the coordinates |top| and // |bottom|. void BrowserViewLayout::LayoutTabContents(int top, int bottom) { - contents_split_->SetBounds(0, top, browser_view_->width(), bottom - top); + contents_split_->SetBounds(vertical_layout_rect_.x(), top, + vertical_layout_rect_.width(), bottom - top); } int BrowserViewLayout::LayoutExtensionAndDownloadShelves() { @@ -396,8 +397,8 @@ int BrowserViewLayout::LayoutDownloadShelf(int bottom) { DCHECK(download_shelf_); int height = visible ? download_shelf_->GetPreferredSize().height() : 0; download_shelf_->SetVisible(visible); - download_shelf_->SetBounds(0, bottom - height, - browser_view_->width(), height); + download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, + vertical_layout_rect_.width(), height); download_shelf_->Layout(); bottom -= height; } @@ -411,8 +412,8 @@ int BrowserViewLayout::LayoutExtensionShelf(int bottom) { int height = visible ? extension_shelf_->GetPreferredSize().height() : 0; extension_shelf_->SetVisible(visible); - extension_shelf_->SetBounds(0, bottom - height, - browser_view_->width(), height); + extension_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, + vertical_layout_rect_.width(), height); extension_shelf_->Layout(); bottom -= height; } diff --git a/chrome/browser/views/frame/browser_view_layout.h b/chrome/browser/views/frame/browser_view_layout.h index 941af52..068d8302 100644 --- a/chrome/browser/views/frame/browser_view_layout.h +++ b/chrome/browser/views/frame/browser_view_layout.h @@ -43,11 +43,6 @@ class BrowserViewLayout : public views::LayoutManager { return browser_view_->browser(); } - // Layout the vertical tabstrip, adjusting |vertical_layout_rect_| for the - // available space for the remainder of the BrowserView contents. This must - // be called before any other element of the BrowserView is laid out. - void LayoutSideTabs(); - // Layout the TabStrip, returns the coordinate of the bottom of the TabStrip, // for laying out subsequent controls. virtual int LayoutTabStrip(); diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index 8510ba8..397a17f 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -10,6 +10,7 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/views/frame/browser_view.h" +#include "chrome/browser/views/tabs/side_tab_strip.h" #include "chrome/browser/views/tabs/tab_strip.h" #include "grit/app_resources.h" #include "grit/theme_resources.h" @@ -81,6 +82,10 @@ GlassBrowserFrameView::~GlassBrowserFrameView() { gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( BaseTabStrip* tabstrip) const { + if (browser_view_->UsingSideTabs()) { + gfx::Size ps = tabstrip->GetPreferredSize(); + return gfx::Rect(0, 0, ps.width(), browser_view_->height()); + } int minimize_button_offset = frame_->GetMinimizeButtonOffset(); int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_avatar_bounds_.right() + kOTRSideSpacing) : @@ -228,8 +233,11 @@ int GlassBrowserFrameView::NonClientTopBorderHeight() const { // We'd like to use FrameBorderThickness() here, but the maximized Aero glass // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). + const int kRestoredHeight = browser_view_->UsingSideTabs() + ? GetSystemMetrics(SM_CYCAPTION) + : kNonClientRestoredExtraThickness; return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? - -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); + -kTabstripTopShadowThickness : kRestoredHeight); } void GlassBrowserFrameView::PaintDistributorLogo(gfx::Canvas* canvas) { @@ -306,6 +314,11 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); + if (browser_view_->UsingSideTabs()) { + client_area_bounds.Inset( + GetBoundsForTabStrip(browser_view_->tabstrip()).width(), 0, 0, 0); + } + int client_area_bottom = std::max(client_area_top, height() - NonClientBorderThickness()); int client_area_height = client_area_bottom - client_area_top; |