diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-04 21:39:50 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-04 21:39:50 +0000 |
commit | a310bab6b893a67881660006af0b1abfbad0f94e (patch) | |
tree | 51068df6d6ce9da3e8cbe4611f0984763fdfca91 /chrome/browser | |
parent | 12dd6697d23674001fd4bea4b41bde87e4bb2525 (diff) | |
download | chromium_src-a310bab6b893a67881660006af0b1abfbad0f94e.zip chromium_src-a310bab6b893a67881660006af0b1abfbad0f94e.tar.gz chromium_src-a310bab6b893a67881660006af0b1abfbad0f94e.tar.bz2 |
Add space under the tabstrip when the compact navbar is active.
This was in gtk impl, but missing in toolkit_view impl.
BUG=None
TEST=None
test
Review URL: http://codereview.chromium.org/517024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/chromeos/browser_extenders.cc | 50 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_extender.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 23 | ||||
-rw-r--r-- | chrome/browser/views/frame/standard_extender.cc | 16 |
4 files changed, 76 insertions, 23 deletions
diff --git a/chrome/browser/chromeos/browser_extenders.cc b/chrome/browser/chromeos/browser_extenders.cc index 8a6f13f..3c8479a 100644 --- a/chrome/browser/chromeos/browser_extenders.cc +++ b/chrome/browser/chromeos/browser_extenders.cc @@ -4,6 +4,7 @@ #include <algorithm> +#include "app/gfx/canvas.h" #include "app/menus/simple_menu_model.h" #include "app/theme_provider.h" #include "base/command_line.h" @@ -31,6 +32,17 @@ namespace { const char* kChromeOsWindowManagerName = "chromeos-wm"; +const int kCompactNavbarSpaceHeight = 3; + +class Spacer : public views::View { + SkBitmap* background_; + public: + explicit Spacer(SkBitmap* bitmap) : background_(bitmap) {} + + void Paint(gfx::Canvas* canvas) { + canvas->TileImageInt(*background_, 0, 0, width(), height()); + } +}; // NormalExtender adds ChromeOS specific controls and menus to a BrowserView // created with Browser::TYPE_NORMAL. This extender adds controls to @@ -81,6 +93,10 @@ class NormalExtender : public BrowserExtender, browser_view()->AddChildView(status_area_); status_area_->Init(); + SkBitmap* theme_toolbar = theme_provider->GetBitmapNamed(IDR_THEME_TOOLBAR); + spacer_ = new Spacer(theme_toolbar); + browser_view()->AddChildView(spacer_); + InitSystemMenu(); chromeos::MainMenu::ScheduleCreation(); @@ -105,20 +121,28 @@ class NormalExtender : public BrowserExtender, } } - virtual gfx::Rect Layout(const gfx::Rect& bounds) { + virtual void Layout(const gfx::Rect& bounds, + gfx::Rect* tabstrip_bounds, + int* bottom) { + if (browser_view()->IsTabStripVisible()) { + *bottom = bounds.bottom(); + } else { + *bottom = 0; + } // Skip if there is no space to layout, or if the browser is in // fullscreen mode. if (bounds.IsEmpty() || browser_view()->IsFullscreen()) { main_menu_->SetVisible(false); compact_navigation_bar_->SetVisible(false); status_area_->SetVisible(false); - return bounds; + tabstrip_bounds->SetRect(bounds.x(), bounds.y(), + bounds.width(), bounds.height()); + return; } else { main_menu_->SetVisible(true); compact_navigation_bar_->SetVisible(compact_navigation_bar_enabled_); status_area_->SetVisible(true); } - /* TODO(oshima): * Disabling the ability to update location bar on re-layout bacause * tabstrip state may not be in sync with the browser's state when @@ -157,9 +181,16 @@ class NormalExtender : public BrowserExtender, bounds.height() - 1); curx += cnb_bounds.width(); width -= cnb_bounds.width(); + + spacer_->SetVisible(true); + spacer_->SetBounds(0, *bottom, browser_view()->width(), + kCompactNavbarSpaceHeight); + *bottom += kCompactNavbarSpaceHeight; + } else { + spacer_->SetVisible(false); } width = std::max(0, width); // In case there is no space left. - return gfx::Rect(curx, bounds.y(), width, bounds.height()); + tabstrip_bounds->SetRect(curx, bounds.y(), width, bounds.height()); } virtual bool NonClientHitTest(const gfx::Point& point) { @@ -289,6 +320,10 @@ class NormalExtender : public BrowserExtender, // A flag to specify if the browser window should be maximized. bool force_maximized_window_; + // A spacer under the tap strip used when the compact navigation bar + // is active. + Spacer* spacer_; + DISALLOW_COPY_AND_ASSIGN(NormalExtender); }; @@ -320,8 +355,11 @@ class PopupExtender : public BrowserExtender { gtk_window_resize(native_window, bounds.width(), bounds.height()); } - virtual gfx::Rect Layout(const gfx::Rect& bounds) { - return bounds; + virtual void Layout(const gfx::Rect& bounds, + gfx::Rect* tabstrip_bounds, + int* bottom) { + *bottom = 0; + tabstrip_bounds->SetRect(0, 0, 0, 0); } virtual bool NonClientHitTest(const gfx::Point& point) { diff --git a/chrome/browser/views/frame/browser_extender.h b/chrome/browser/views/frame/browser_extender.h index 1505eff..48c5056 100644 --- a/chrome/browser/views/frame/browser_extender.h +++ b/chrome/browser/views/frame/browser_extender.h @@ -32,9 +32,13 @@ class BrowserExtender { // Initializes the extender. virtual void Init() = 0; - // Layouts controls within the given bounds and returns the remaining - // bounds for tabstip to be layed out. - virtual gfx::Rect Layout(const gfx::Rect& bounds) = 0; + // Layouts controls within the given bounds. The |tabstrip_bounds| will be + // filled with the remaining bounds for tabstip to be layed out and + // the |bottom| will be filled with the y location where toolbar should be + // layed out, in BrowserView cooridnates. + virtual void Layout(const gfx::Rect& bounds, + gfx::Rect* tabstrip_bounds, + int* bottom) = 0; // Tests if the given |point|, which is given in BrowserView coordinates, // hits any of controls. diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 73ce4bd8..d760b3e 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1928,25 +1928,22 @@ void BrowserView::InitSystemMenu() { #endif int BrowserView::LayoutTabStrip() { - gfx::Rect tabstrip_bounds = frame_->GetBoundsForTabStrip(tabstrip_); + gfx::Rect layout_bounds = frame_->GetBoundsForTabStrip(tabstrip_); gfx::Rect toolbar_bounds = GetToolbarBounds(); tabstrip_->SetBackgroundOffset( - gfx::Point(tabstrip_bounds.x() - toolbar_bounds.x(), - tabstrip_bounds.y())); + gfx::Point(layout_bounds.x() - toolbar_bounds.x(), + layout_bounds.y())); - gfx::Point tabstrip_origin = tabstrip_bounds.origin(); + gfx::Point tabstrip_origin = layout_bounds.origin(); ConvertPointToView(GetParent(), this, &tabstrip_origin); - tabstrip_bounds.set_origin(tabstrip_origin); + layout_bounds.set_origin(tabstrip_origin); // Layout extra components. - tabstrip_bounds = browser_extender_->Layout(tabstrip_bounds); - - bool visible = IsTabStripVisible(); - int y = visible ? tabstrip_bounds.y() : 0; - int height = visible ? tabstrip_bounds.height() : 0; - int bottom = y + height; - tabstrip_->SetVisible(visible); - tabstrip_->SetBounds(tabstrip_bounds.x(), y, tabstrip_bounds.width(), height); + int bottom = 0; + gfx::Rect tabstrip_bounds; + browser_extender_->Layout(layout_bounds, &tabstrip_bounds, &bottom); + tabstrip_->SetVisible(IsTabStripVisible()); + tabstrip_->SetBounds(tabstrip_bounds); return bottom; } diff --git a/chrome/browser/views/frame/standard_extender.cc b/chrome/browser/views/frame/standard_extender.cc index 1f2120e..d142b53 100644 --- a/chrome/browser/views/frame/standard_extender.cc +++ b/chrome/browser/views/frame/standard_extender.cc @@ -4,6 +4,9 @@ #include "chrome/browser/views/frame/browser_extender.h" +#include "base/gfx/rect.h" +#include "chrome/browser/views/frame/browser_view.h" + class Tab; namespace { @@ -20,7 +23,18 @@ class StandardExtender : public BrowserExtender { private: // BrowserExtender overrides. virtual void Init() {} - virtual gfx::Rect Layout(const gfx::Rect& bounds) { return bounds; } + virtual void Layout(const gfx::Rect& bounds, + gfx::Rect* tabstrip_bounds, + int* bottom) { + if (browser_view()->IsTabStripVisible()) { + *bottom = bounds.bottom(); + tabstrip_bounds->SetRect( + bounds.x(), bounds.y(), bounds.width(), bounds.height()); + } else { + *bottom = 0; + tabstrip_bounds->SetRect(0, 0, 0, 0); + } + } virtual bool NonClientHitTest(const gfx::Point& point) { return false; } virtual void Show() {} virtual void Close() {} |